Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ba884f3

Browse files
committed
Use %c rather than chr() to turn some ints into chars.
1 parent c1c2b3e commit ba884f3

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/pickle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def save_int(self, obj, pack=struct.pack):
475475
self.write(BININT1 + chr(obj))
476476
return
477477
if obj <= 0xffff:
478-
self.write(BININT2 + chr(obj&0xff) + chr(obj>>8))
478+
self.write("%c%c%c" % (BININT2, obj&0xff, obj>>8))
479479
return
480480
# Next check for 4-byte signed ints:
481481
high_bits = obj >> 31 # note that Python shift sign-extends
@@ -747,7 +747,7 @@ def save_global(self, obj, name=None, pack=struct.pack):
747747
if code <= 0xff:
748748
write(EXT1 + chr(code))
749749
elif code <= 0xffff:
750-
write(EXT2 + chr(code&0xff) + chr(code>>8))
750+
write("%c%c%c" % (EXT2, code&0xff, code>>8))
751751
else:
752752
write(EXT4 + pack("<i", code))
753753
return

0 commit comments

Comments
 (0)