← Back to team overview

registry team mailing list archive

[Bug 690375] Re: Python 2.7: table checkSum writing "struct.error: integer out of range for 'L' format code"

 

Following kludge was good enough to be able to export successfully:

 --- /usr/share/pyshared/FontTools/fontTools/ttLib/sfnt.py~	2009-10-25 04:39:28.000000000 +0000 
 +++ /usr/share/pyshared/FontTools/fontTools/ttLib/sfnt.py	2010-12-14 22:05:54.283601000 +0000
 @@ -173,5 +173,5 @@
  		# write the checksum to the file
  		self.file.seek(self.tables['head'].offset + 8)
 -		self.file.write(struct.pack(">L", checksumadjustment))
 +		self.file.write(struct.pack(">l", checksumadjustment))
  
  
 @@ -205,5 +205,5 @@
  		> # big endian
  		tag:            4s
 -		checkSum:       L
 +		checkSum:       l
  		offset:         L
  		length:         L


** Description changed:

  Binary package hint: fonttools
  
  The checksum writing code does not bound to the range 0..0xffffffff
- needed for sstruct in Pythong 2.7, resulting int trying to write (32-bit
+ needed for sstruct in Python 2.7, resulting int trying to write (32-bit
  hex values such as) -685515063 for the 'checkSum' field:
  
-   File "/usr/lib/pymodules/python2.7/FontTools/fontTools/ttLib/__init__.py", line 203, in save
-     writer.close()
-   File "/usr/lib/pymodules/python2.7/FontTools/fontTools/ttLib/sfnt.py", line 153, in close
-     directory = directory + entry.toString()
-   File "/usr/lib/pymodules/python2.7/FontTools/fontTools/ttLib/sfnt.py", line 224, in toString
-     return sstruct.pack(sfntDirectoryEntryFormat, self)
-   File "/usr/lib/pymodules/python2.7/FontTools/sstruct.py", line 79, in pack
-     data = apply(struct.pack, (formatstring,) + tuple(elements))
+   File "/usr/lib/pymodules/python2.7/FontTools/fontTools/ttLib/__init__.py", line 203, in save
+     writer.close()
+   File "/usr/lib/pymodules/python2.7/FontTools/fontTools/ttLib/sfnt.py", line 153, in close
+     directory = directory + entry.toString()
+   File "/usr/lib/pymodules/python2.7/FontTools/fontTools/ttLib/sfnt.py", line 224, in toString
+     return sstruct.pack(sfntDirectoryEntryFormat, self)
+   File "/usr/lib/pymodules/python2.7/FontTools/sstruct.py", line 79, in pack
+     data = apply(struct.pack, (formatstring,) + tuple(elements))
  
- The solution is probably to use something like checksum ^ 0xffffffff
+ The solution is probably to use something like checksum & 0xffffffff
  during preparation.

-- 
You received this bug notification because you are a member of Registry
Administrators, which is the registrant for Fedora.
https://bugs.launchpad.net/bugs/690375

Title:
  Python 2.7: table checkSum writing "struct.error: integer out of range for 'L' format code"



References