At file:///v/home/vila/src/bzr/experimental/bzr-py26-compat/
------------------------------------------------------------
revno: 3735
revision-id: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: Vincent Ladeuil <[EMAIL PROTECTED]>
branch nick: gzip-changes
timestamp: Thu 2008-09-25 17:17:15 +0200
message:
Fix U32, LOWU32 disapearance in python-2.6.
* bzrlib/tuned_gzip.py:
(U32, LOWU32): These functions are gone in python-2.6, they are
trivial enough to be copied as is.
=== modified file 'bzrlib/tuned_gzip.py'
--- a/bzrlib/tuned_gzip.py 2008-04-24 07:22:53 +0000
+++ b/bzrlib/tuned_gzip.py 2008-09-25 15:17:15 +0000
@@ -21,7 +21,7 @@
# make GzipFile faster:
import gzip
-from gzip import U32, LOWU32, FEXTRA, FCOMMENT, FNAME, FHCRC
+from gzip import FEXTRA, FCOMMENT, FNAME, FHCRC
import sys
import struct
import zlib
@@ -32,6 +32,21 @@
__all__ = ["GzipFile", "bytes_to_gzip"]
+def U32(i):
+ """Return i as an unsigned integer, assuming it fits in 32 bits.
+
+ If it's >= 2GB when viewed as a 32-bit unsigned int, return a long.
+ """
+ if i < 0:
+ i += 1L << 32
+ return i
+
+
+def LOWU32(i):
+ """Return the low-order 32 bits of an int, as a non-negative int."""
+ return i & 0xFFFFFFFFL
+
+
def bytes_to_gzip(bytes, factory=zlib.compressobj,
level=zlib.Z_DEFAULT_COMPRESSION, method=zlib.DEFLATED,
width=-zlib.MAX_WBITS, mem=zlib.DEF_MEM_LEVEL,
--
bazaar-commits mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/bazaar-commits