summaryrefslogtreecommitdiffstats
path: root/Lib/pickletools.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-01-27 23:51:11 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-01-27 23:51:11 (GMT)
commit217e571a19c9d643005d8c8d88abab16f88735a2 (patch)
treef3fee1822931143b8d8ff28470ecff960dffac25 /Lib/pickletools.py
parentf29d3d6011e41b40282994375454f2020a429d79 (diff)
downloadcpython-217e571a19c9d643005d8c8d88abab16f88735a2.zip
cpython-217e571a19c9d643005d8c8d88abab16f88735a2.tar.gz
cpython-217e571a19c9d643005d8c8d88abab16f88735a2.tar.bz2
decode_long(): Simplified the "is it negative?" test.
Diffstat (limited to 'Lib/pickletools.py')
-rw-r--r--Lib/pickletools.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/pickletools.py b/Lib/pickletools.py
index 5c0367b..dec533d 100644
--- a/Lib/pickletools.py
+++ b/Lib/pickletools.py
@@ -590,14 +590,17 @@ def decode_long(data):
-256L
>>> decode_long("\x00\x80")
-32768L
- >>>
+ >>> decode_long("\x80")
+ -128L
+ >>> decode_long("\x7f")
+ 127L
"""
x = 0L
i = 0L
for c in data:
x |= long(ord(c)) << i
i += 8L
- if i and (x & (1L << (i-1L))):
+ if data and ord(c) >= 0x80:
x -= 1L << i
return x