[Qgis-developer] qgis 2.8.5 / python 2.7.4

Bill Murphy gc2majortom at gmail.com
Fri Jan 8 20:53:54 PST 2016


Hi,
While debugging a qgis plugin written in python, we stumbled on a bug with
Python 274
apps\Lib\zipfile.py extract_member() ~ line 1056 that looks like it was
fixed in Python 275.
As the offending code was patched there, and our bug was fixed when we
patched
apps\Lib\zipfile.py with the code from the python 275 apps\Lib\zipfile.py
library.
See attached diff between the two python versions,side by side diff, and
some example
screen captures from our plugin failing to unzip a file in a 32 bit Windows
7 environment running qgis 2.8.5 LTR.

So with qgis Wien 32bit versions shipping with Python 274, 32 Bit users
can't use a plugin utilizing the
python 'zipfile' library to unzip a file. We can of course just copy
zipfile.py from a 64 bit qgis installation
and copy it to the appropriate location on the Win 7 32 machines...

qgis 32 bit windows version ships with Python 2.7.4 (our plugin breaks).
qgis x86-64 windows version ships with Python 2.7.5 (our plugin works fine).

We really just wanted to take some time to thank you folks for such a
useful gis application and pass along our finding, just in case other end
users might experience the same issue. And ask if there is a path forward
for the qgis 32 bit windows versions to be shipped with Python >=2.7.5?
Please let us know.

Some past history from python development regarding this bug:

https://www.python.org/download/releases/2.7.5/

http://bugs.python.org/issue17656

Thank you again for such a useful gis tool.

Thanks in advance

Bill Murphy

cc:Bill Turczyn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160108/270584b7/attachment.html>
-------------- next part --------------
--- zipfile.py.2.7.4    2016-01-08 20:48:07.643724331 -0500
+++ zipfile.py.2.7.5    2016-01-08 14:51:05.279118804 -0500
@@ -1053,7 +1053,10 @@
         if os.path.sep == '\\':
             # filter illegal characters on Windows
             illegal = ':<>|"?*'
-            table = string.maketrans(illegal, '_' * len(illegal))
+            if isinstance(arcname, unicode):
+                table = {ord(c): ord('_') for c in illegal}
+            else:
+                table = string.maketrans(illegal, '_' * len(illegal))
             arcname = arcname.translate(table)
             # remove trailing dots
             arcname = (x.rstrip('.') for x in arcname.split(os.path.sep))


More information about the Qgis-developer mailing list