Am Dienstag, 2. August 2016, 03:39:58 CEST schrieb Glyph Lefkowitz:
> Probably we should up-convert from bytes automatically in the places
> where we know python will be using the values as identifiers, including
> callRemote and the keys in a __dict__.
Attached is some grep for my port showing where I had co convert.
grep -ri -e '\(network\|native\)'
> This is unfortunately very tricky to know though, if we support
> serializing both bytes and strings :-\.
Why? The wire protocol does not change. PY3 bytes are already
compatible, and PY3 strings are serialized as unicode objects.
--
Wolfgang
jelly.py:from twisted.python.compat import nativeString, networkString
jelly.py: classname = nativeString(classname)
jelly.py: sxp.extend([networkString(qual(inst.__class__)),
jellier.jelly(state)])
jelly.py: networkString(qual(self.__class__)),
jelly.py: return [function_atom,
networkString(pickle.whichmodule(obj, obj.__name__))
jelly.py: return [datetime_atom, networkString('%s %s %s %s %s
%s %s' % (
jelly.py: return [time_atom, networkString('%s %s %s %s' %
(obj.hour, obj.minute,
jelly.py: return [date_atom, networkString('%s %s %s' %
(obj.year, obj.month, obj.day))]
jelly.py: return [timedelta_atom, networkString('%s %s %s' %
(obj.days, obj.seconds,
jelly.py: jelType = nativeString(obj[0])
jelly.py: moduleName = nativeString(moduleName)
jelly.py: qualName = nativeString(rest[0])
jelly.py: im_name = nativeString(rest[0])
jelly.py: typeName = nativeString(typeName)
flavors.py:from twisted.python.compat import _PY3, nativeString, networkString
flavors.py: kw = nativeStringDict(broker.unserialize(kw))
flavors.py: method = getattr(self, "remote_%s" % nativeString(message),
None)
flavors.py: raise NoSuchMethod("No such method: remote_%s" %
(nativeString(message),))
flavors.py: method = getattr(self.object, "view_%s" %
nativeString(message))
flavors.py: t = networkString(self.getTypeToCopyFor(p))
flavors.py: l.extend([networkString(type_), luid, jstate])
flavors.py:def nativeStringDict(networkDict, encoding='ascii'):
flavors.py: Convert them to the native string type.
flavors.py: @param networkDict: Any C{dict}. Keys must be C{bytes} or
C{unicode}.
flavors.py: @return: The passed dict, but all keys converted with
nativeString().
flavors.py: return dict((nativeString(key, encoding), value)
flavors.py: for key, value in networkDict.items())
flavors.py: self.__dict__ = nativeStringDict(state)
flavors.py: method = getattr(self, "observe_%s" % nativeString(message))
banana.py:from twisted.python.compat import _PY3, networkChar
banana.py: stream(networkChar(0))
banana.py: stream(networkChar(integer & 0x7f))
banana.py:LIST = networkChar(0x80)
banana.py:INT = networkChar(0x81)
banana.py:STRING = networkChar(0x82)
banana.py:NEG = networkChar(0x83)
banana.py:FLOAT = networkChar(0x84)
banana.py:LONGINT = networkChar(0x85)
banana.py:LONGNEG = networkChar(0x86)
banana.py:VOCAB = networkChar(0x87)
banana.py: typebyte = networkChar(buffer[pos])
pb.py:from twisted.python.compat import xrange, networkString, nativeString
pb.py:from twisted.python.compat import nativeString, _PY3
pb.py:from twisted.python.compat import unicode, networkChar
pb.py: This method is called when a network message is received.
pb.py: This method is called when a network message is received.
pb.py: method = getattr(self, "perspective_%s" % nativeString(message))
pb.py: state['value'] = nativeString(self.value, encoding='utf-8') #
Exception instance
pb.py: file.write(nativeString(self.traceback, encoding='utf-8'))
pb.py: nativeString(str(self.type)),
pb.py: nativeString(self.value, encoding='utf-8'))
pb.py: methodName = "proto_%s" % nativeString(command)
pb.py: objectID = networkString(objectID)
pb.py: self.sendCall(prefix+message_atom, requestID, objectID,
networkString(message), answerRequired, netArgs, netKw)
pb.py: message = nativeString(message)
pb.py: objectID = nativeString(objectID)
pb.py:# unserFail.value =
unserFail.type((nativeString(unserFail.value, encoding='utf-8')))
pb.py: crap = crap + networkChar(random.randint(65,90))
pb.py: Alternatively, any object providing or adaptable to L{IPBRoot} can be
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python