コード例 #1
0
ファイル: strbufobject.py プロジェクト: sota/pypy-old
 def force(self):
     if self.w_str is None:
         s = self.builder.build()
         if self.length < len(s):
             s = s[:self.length]
         self.w_str = W_BytesObject(s)
         return s
     else:
         return self.w_str._value
コード例 #2
0
 def _newtext_memo(self, s):
     if s is None:
         return self.w_None  # can happen during annotation
     # try to see whether we exist as an interned string, but don't intern
     # if not
     w_t = self.interned_strings.get(s)
     if w_t is not None:
         return w_t
     return W_BytesObject(s)
コード例 #3
0
 def newfilename(self, s):
     assert isinstance(s, str)  # on pypy3, this decodes the byte string
     return W_BytesObject(s)  # with the filesystem encoding
コード例 #4
0
 def newtext(self, s):
     assert isinstance(s, str)
     return W_BytesObject(s)  # Python3 this is unicode
コード例 #5
0
 def newbytes(self, s):
     assert isinstance(s, str)
     return W_BytesObject(s)
コード例 #6
0
 def newtext(self, s):
     assert isinstance(s, str)
     if is_annotation_constant(s):
         return self._newtext_memo(s)
     return W_BytesObject(s)  # Python3 this is unicode