[Twisted-Python] Re: [Twisted-commits] r16970 - removed a bunch of deprecations but then realized I didn't want to spend the last 30 minutes of the day working on this
Jean-Paul Calderone
exarkun at divmod.com
Tue May 30 07:02:45 MDT 2006
On Mon, 29 May 2006 21:24:29 -0600, Glyph Lefkowitz <glyph at wolfwood.twistedmatrix.com> wrote:
>Author: glyph
>Date: Mon May 29 21:24:28 2006
>New Revision: 16970
>
>Modified:
> [snip]
> branches/killtpc-1636/twisted/spread/banana.py
> branches/killtpc-1636/twisted/test/test_banana.py
> [snip]
>Log:
>removed a bunch of deprecations but then realized I didn't want to spend the last 30 minutes of the day working on this
>
> [snip]
>Modified: branches/killtpc-1636/twisted/spread/banana.py
>==============================================================================
>--- branches/killtpc-1636/twisted/spread/banana.py (original)
>+++ branches/killtpc-1636/twisted/spread/banana.py Mon May 29 21:24:28 2006
>@@ -255,20 +255,21 @@
> write(LIST)
> for elem in obj:
> self._encode(elem, write)
>- elif isinstance(obj, types.IntType):
>- if obj >= 0:
>- int2b128(obj, write)
>- write(INT)
>+ elif isinstance(obj, (types.IntType, types.LongType)):
>+ aobj = abs(obj)
>+ if aobj < (2**32): # this is lame, but it's what the protocol
>+ # spec says.
>+ if obj >= 0:
>+ typebyte = INT
>+ else:
>+ typebyte = NEG
> else:
>- int2b128(-obj, write)
>- write(NEG)
>- elif isinstance(obj, types.LongType):
>- if obj >= 0l:
>- int2b128(obj, write)
>- write(LONGINT)
>- else:
>- int2b128(-obj, write)
>- write(LONGNEG)
>+ if obj >= 0:
>+ typebyte = LONGINT
>+ else:
>+ typebyte = LONGNEG
>+ int2b128(aobj, write)
>+ write(typebyte)
> elif isinstance(obj, types.FloatType):
> write(FLOAT)
> write(struct.pack("!d", obj))
>
> [snip]
>Modified: branches/killtpc-1636/twisted/test/test_banana.py
>==============================================================================
>--- branches/killtpc-1636/twisted/test/test_banana.py (original)
>+++ branches/killtpc-1636/twisted/test/test_banana.py Mon May 29 21:24:28 2006
>@@ -134,7 +134,21 @@
> self.enc.dataReceived(self.io.getvalue())
> assert self.result == -2147483648, "should be -2147483648, got %s" % self.result
>
>-
>+ def _roundtrip(self, value):
>+ self.io.seek(0)
>+ self.io.truncate()
>+ self.enc.sendEncoded(value)
>+ self.enc.dataReceived(self.io.getvalue())
>+ return self.result
>+
>+ def testSizedIntegerTypes(self):
>+ # use int to decode int, long to decode long.
>+ self.assertEquals(type(self._roundtrip(2l)), int)
>+ # this should always come back as a 'long' even on 64-bit platforms,
>+ # because it was encoded that way. Kind of a lame test, but at least
>+ # it makes sure that <64bit numbers won't be encoded as INT...
>+ self.assertEquals(type(self._roundtrip(2**35)), long)
>+
> testCases = [MathTestCase, BananaTestCase]
>
> try:
>
These changes don't look like the others.
More information about the Twisted-Python
mailing list