[Python-checkins] python/dist/src/Lib gettext.py,1.14,1.15

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
Wed, 14 Aug 2002 08:09:14 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv5800

Modified Files:
	gettext.py 
Log Message:
Patch by Tim to shut up the compiler's DeprecationWarnings on the
high-bit-set hex constants.


Index: gettext.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/gettext.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** gettext.py	1 Jun 2002 01:29:16 -0000	1.14
--- gettext.py	14 Aug 2002 15:09:12 -0000	1.15
***************
*** 140,151 ****
  class GNUTranslations(NullTranslations):
      # Magic number of .mo files
!     LE_MAGIC = 0x950412de
!     BE_MAGIC = 0xde120495
  
      def _parse(self, fp):
          """Override this method to support alternative .mo formats."""
-         # We need to & all 32 bit unsigned integers with 0xffffffff for
-         # portability to 64 bit machines.
-         MASK = 0xffffffff
          unpack = struct.unpack
          filename = getattr(fp, 'name', '')
--- 140,148 ----
  class GNUTranslations(NullTranslations):
      # Magic number of .mo files
!     LE_MAGIC = 0x950412deL
!     BE_MAGIC = 0xde120495L
  
      def _parse(self, fp):
          """Override this method to support alternative .mo formats."""
          unpack = struct.unpack
          filename = getattr(fp, 'name', '')
***************
*** 156,181 ****
          buflen = len(buf)
          # Are we big endian or little endian?
!         magic = unpack('<i', buf[:4])[0] & MASK
          if magic == self.LE_MAGIC:
!             version, msgcount, masteridx, transidx = unpack('<4i', buf[4:20])
!             ii = '<ii'
          elif magic == self.BE_MAGIC:
!             version, msgcount, masteridx, transidx = unpack('>4i', buf[4:20])
!             ii = '>ii'
          else:
              raise IOError(0, 'Bad magic number', filename)
-         # more unsigned ints
-         msgcount &= MASK
-         masteridx &= MASK
-         transidx &= MASK
          # Now put all messages from the .mo file buffer into the catalog
          # dictionary.
          for i in xrange(0, msgcount):
              mlen, moff = unpack(ii, buf[masteridx:masteridx+8])
!             moff &= MASK
!             mend = moff + (mlen & MASK)
              tlen, toff = unpack(ii, buf[transidx:transidx+8])
!             toff &= MASK
!             tend = toff + (tlen & MASK)
              if mend < buflen and tend < buflen:
                  tmsg = buf[toff:tend]
--- 153,172 ----
          buflen = len(buf)
          # Are we big endian or little endian?
!         magic = unpack('<I', buf[:4])[0]
          if magic == self.LE_MAGIC:
!             version, msgcount, masteridx, transidx = unpack('<4I', buf[4:20])
!             ii = '<II'
          elif magic == self.BE_MAGIC:
!             version, msgcount, masteridx, transidx = unpack('>4I', buf[4:20])
!             ii = '>II'
          else:
              raise IOError(0, 'Bad magic number', filename)
          # Now put all messages from the .mo file buffer into the catalog
          # dictionary.
          for i in xrange(0, msgcount):
              mlen, moff = unpack(ii, buf[masteridx:masteridx+8])
!             mend = moff + mlen
              tlen, toff = unpack(ii, buf[transidx:transidx+8])
!             tend = toff + tlen
              if mend < buflen and tend < buflen:
                  tmsg = buf[toff:tend]