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

Skip to content

Commit 09707e3

Browse files
committed
Patch by Tim to shut up the compiler's DeprecationWarnings on the
high-bit-set hex constants.
1 parent 20f0b36 commit 09707e3

1 file changed

Lines changed: 9 additions & 18 deletions

File tree

Lib/gettext.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,11 @@ def install(self, unicode=0):
139139

140140
class GNUTranslations(NullTranslations):
141141
# Magic number of .mo files
142-
LE_MAGIC = 0x950412de
143-
BE_MAGIC = 0xde120495
142+
LE_MAGIC = 0x950412deL
143+
BE_MAGIC = 0xde120495L
144144

145145
def _parse(self, fp):
146146
"""Override this method to support alternative .mo formats."""
147-
# We need to & all 32 bit unsigned integers with 0xffffffff for
148-
# portability to 64 bit machines.
149-
MASK = 0xffffffff
150147
unpack = struct.unpack
151148
filename = getattr(fp, 'name', '')
152149
# Parse the .mo file header, which consists of 5 little endian 32
@@ -155,28 +152,22 @@ def _parse(self, fp):
155152
buf = fp.read()
156153
buflen = len(buf)
157154
# Are we big endian or little endian?
158-
magic = unpack('<i', buf[:4])[0] & MASK
155+
magic = unpack('<I', buf[:4])[0]
159156
if magic == self.LE_MAGIC:
160-
version, msgcount, masteridx, transidx = unpack('<4i', buf[4:20])
161-
ii = '<ii'
157+
version, msgcount, masteridx, transidx = unpack('<4I', buf[4:20])
158+
ii = '<II'
162159
elif magic == self.BE_MAGIC:
163-
version, msgcount, masteridx, transidx = unpack('>4i', buf[4:20])
164-
ii = '>ii'
160+
version, msgcount, masteridx, transidx = unpack('>4I', buf[4:20])
161+
ii = '>II'
165162
else:
166163
raise IOError(0, 'Bad magic number', filename)
167-
# more unsigned ints
168-
msgcount &= MASK
169-
masteridx &= MASK
170-
transidx &= MASK
171164
# Now put all messages from the .mo file buffer into the catalog
172165
# dictionary.
173166
for i in xrange(0, msgcount):
174167
mlen, moff = unpack(ii, buf[masteridx:masteridx+8])
175-
moff &= MASK
176-
mend = moff + (mlen & MASK)
168+
mend = moff + mlen
177169
tlen, toff = unpack(ii, buf[transidx:transidx+8])
178-
toff &= MASK
179-
tend = toff + (tlen & MASK)
170+
tend = toff + tlen
180171
if mend < buflen and tend < buflen:
181172
tmsg = buf[toff:tend]
182173
catalog[buf[moff:mend]] = tmsg

0 commit comments

Comments
 (0)