Hello community,

here is the log from the commit of package python-polib for openSUSE:Factory 
checked in at 2013-09-14 19:09:27
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-polib (Old)
 and      /work/SRC/openSUSE:Factory/.python-polib.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-polib"

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-polib/python-polib.changes        
2013-02-13 14:39:12.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.python-polib.new/python-polib.changes   
2013-09-14 19:09:29.000000000 +0200
@@ -1,0 +2,6 @@
+Thu Sep 12 14:51:41 UTC 2013 - [email protected]
+
+- Fixed issue #53 (bad magic number written on big endian platforms)
+  endian_magic.patch 
+
+-------------------------------------------------------------------

New:
----
  endian_magic.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-polib.spec ++++++
--- /var/tmp/diff_new_pack.4kuuVP/_old  2013-09-14 19:09:29.000000000 +0200
+++ /var/tmp/diff_new_pack.4kuuVP/_new  2013-09-14 19:09:29.000000000 +0200
@@ -25,6 +25,7 @@
 License:        MIT
 Group:          Development/Languages/Python
 Source0:        
http://bitbucket.org/izi/polib/downloads/polib-%{version}.tar.gz
+Patch0:         endian_magic.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 BuildRequires:  python-Sphinx
 BuildRequires:  python-devel
@@ -63,6 +64,7 @@
 
 %prep
 %setup -q -n polib-%{version}
+%patch0 -p1
 
 %build
 python setup.py build

++++++ endian_magic.patch ++++++
Index: polib-1.0.3/polib.py
===================================================================
--- polib-1.0.3.orig/polib.py
+++ polib-1.0.3/polib.py
@@ -536,16 +536,11 @@ class _BaseFile(list):
             koffsets += [l1, o1 + keystart]
             voffsets += [l2, o2 + valuestart]
         offsets = koffsets + voffsets
-        # check endianness for magic number
-        if struct.pack('@h', 1) == struct.pack('<h', 1):
-            magic_number = MOFile.LITTLE_ENDIAN
-        else:
-            magic_number = MOFile.BIG_ENDIAN
 
         output = struct.pack(
             "Iiiiiii",
             # Magic number
-            magic_number,
+            MOFile.MAGIC,
             # Version
             0,
             # number of entries
@@ -688,8 +683,8 @@ class MOFile(_BaseFile):
     This class inherits the :class:`~polib._BaseFile` class and, by
     extension, the python ``list`` type.
     """
-    BIG_ENDIAN = 0xde120495
-    LITTLE_ENDIAN = 0x950412de
+    MAGIC = 0x950412de
+    MAGIC_SWAPPED = 0xde120495
 
     def __init__(self, *args, **kwargs):
         """
@@ -1432,7 +1427,8 @@ class _POFileParser(object):
         if self.current_state in ['MC', 'MS', 'MX']:
             self.instance.append(self.current_entry)
             self.current_entry = POEntry()
-        self.current_entry.flags += self.current_token[3:].split(', ')
+        self.current_entry.flags += [c.strip() for c in
+                                     self.current_token[3:].split(',')]
         return True
 
     def handle_pp(self):
@@ -1564,9 +1560,9 @@ class _MOFileParser(object):
         """
         # parse magic number
         magic_number = self._readbinary('<I', 4)
-        if magic_number == MOFile.LITTLE_ENDIAN:
+        if magic_number == MOFile.MAGIC:
             ii = '<II'
-        elif magic_number == MOFile.BIG_ENDIAN:
+        elif magic_number == MOFile.MAGIC_SWAPPED:
             ii = '>II'
         else:
             raise IOError('Invalid mo file, magic number is incorrect !')
-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to