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
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)
def newfilename(self, s): assert isinstance(s, str) # on pypy3, this decodes the byte string return W_BytesObject(s) # with the filesystem encoding
def newtext(self, s): assert isinstance(s, str) return W_BytesObject(s) # Python3 this is unicode
def newbytes(self, s): assert isinstance(s, str) return W_BytesObject(s)
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