hefronmedia / pdfsizeopt

Automatically exported from code.google.com/p/pdfsizeopt
0 stars 0 forks source link

pdfsizeopt gets "DeprecationWarning: 'H' format requires 0 <= number <= 65535" [patch] #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. python pdfsizeopt.py concen.pdf

I used the test file from issue 19
http://code.google.com/p/pdfsizeopt/issues/detail?id=19

What is the expected output? What do you see instead?

I get two deprecation warnings.  (The resulting pdf is ok.)

$ python pdfsizeopt.py concen.pdf 
info: This is pdfsizeopt.py rUNKNOWN.
info: loading PDF from: concen.pdf
info: loaded PDF of 294339 bytes
info: separated to 229 objs
info: found 0 Type1 fonts loaded
info: found 23 Type1C fonts loaded
info: writing Type1CParser (67298 font bytes) to: pso.conv.parse.tmp.ps
info: executing Type1CParser with Ghostscript: gs -q -dNOPAUSE -dBATCH
-sDEVICE=nullpage -sDataFile=pso.conv.parsedata.tmp.ps -f pso.conv.parse.tmp.ps
Type1CParser: using interpreter GPL Ghostscript 871 20100210
Type1CParser: all OK
info: parsed 23 Type1C fonts
pdfsizeopt.py:2214: DeprecationWarning: struct integer overflow masking is
deprecated
  output.append(chr(28) + struct.pack('>H', operand))
pdfsizeopt.py:2214: DeprecationWarning: 'H' format requires 0 <= number <=
65535
  output.append(chr(28) + struct.pack('>H', operand))

What version of the product are you using? On what operating system?

Fedora 8 Linux

--- pdfsizeopt/pdfsizeopt.py-   2010-03-24 21:06:15.000000000 +0000
+++ pdfsizeopt/pdfsizeopt.py    2010-03-30 01:55:38.000000000 +0100
@@ -2211,7 +2211,7 @@
                 (((-operand - 108) >> 8) + 251, (-operand - 108) & 255))
             assert 251 <= ord(output[-1][0]) <= 254
           elif -32768 <= operand <= 32767:
-            output.append(chr(28) + struct.pack('>H', operand))
+            output.append(chr(28) + struct.pack('>H', operand & 0xFFFF))
           elif ~0x7fffffff <= operand <= 0x7fffffff:
             output.append(chr(29) + struct.pack('>L', operand))
           else:

Original issue reported on code.google.com by william.bader@gmail.com on 30 Mar 2010 at 1:17

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for the bug report and the patch. Integrated it with a similar patch 
into r147.

Original comment by pts...@gmail.com on 10 Feb 2011 at 10:27