我们从Python开源项目中,提取了以下24个代码示例,用于说明如何使用future.utils.text_to_native_str()。
def _reconstruct_header(cls_name, bases, value): return type(text_to_native_str(cls_name), bases, {})._reconstruct(value)
def __getitem__(self, name): cls = self.registry.get(name.lower(), self.default_class) return type(text_to_native_str('_'+cls.__name__), (cls, self.base_class), {})
def to_bytes(self): # TODO: This is a WORKAROUND! # Before Python 2.7.7, struct.pack() only accepts native str. # Uses of unicode will cause TypeError: Struct() argument 1 must be string, not unicode. # This have been fixed by the Python community: # https://hg.python.org/cpython/raw-file/f89216059edf/Misc/NEWS return struct.pack(text_to_native_str(self.FORMAT), self.nlmsg_len, self.nlmsg_type, self.nlmsg_flags, self.nlmsg_seq, self.nlmsg_pid)
def to_bytes(self): # TODO: This is a WORKAROUND! # Before Python 2.7.7, struct.pack() only accepts native str. # Uses of unicode will cause TypeError: Struct() argument 1 must be string, not unicode. # This have been fixed by the Python community: # https://hg.python.org/cpython/raw-file/f89216059edf/Misc/NEWS return struct.pack(text_to_native_str(self.FORMAT), self.version, self.flag, self.length, self.payload_type, self.reserved, self.seq, self.timestamp)