]> granicus.if.org Git - python/commitdiff
Use %c rather than chr() to turn some ints into chars.
authorGuido van Rossum <guido@python.org>
Wed, 29 Jan 2003 20:14:23 +0000 (20:14 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 29 Jan 2003 20:14:23 +0000 (20:14 +0000)
Lib/pickle.py

index 739c24fb9b35ce71276ed22ac2aca6092974dfe4..9630d33942352974f35986b0a06efe368e5ca881 100644 (file)
@@ -475,7 +475,7 @@ class Pickler:
                     self.write(BININT1 + chr(obj))
                     return
                 if obj <= 0xffff:
-                    self.write(BININT2 + chr(obj&0xff) + chr(obj>>8))
+                    self.write("%c%c%c" % (BININT2, obj&0xff, obj>>8))
                     return
             # Next check for 4-byte signed ints:
             high_bits = obj >> 31  # note that Python shift sign-extends
@@ -747,7 +747,7 @@ class Pickler:
                 if code <= 0xff:
                     write(EXT1 + chr(code))
                 elif code <= 0xffff:
-                    write(EXT2 + chr(code&0xff) + chr(code>>8))
+                    write("%c%c%c" % (EXT2, code&0xff, code>>8))
                 else:
                     write(EXT4 + pack("<i", code))
                 return