After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 703979 - in libxml2-2.9.1, python/drv_libxml2.py is incompatible with python3
in libxml2-2.9.1, python/drv_libxml2.py is incompatible with python3
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
: 734005 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-07-11 03:05 UTC by Alexandre Rostovtsev
Modified: 2014-10-06 11:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (1.30 KB, patch)
2013-07-11 03:07 UTC, Alexandre Rostovtsev
none Details | Review
Patch (1.36 KB, patch)
2013-07-11 12:42 UTC, Arfrever Frehtes Taifersar Arahesis
none Details | Review

Description Alexandre Rostovtsev 2013-07-11 03:05:32 UTC
libxml2-2.9.1 is supposed to be compatible with python3, but:

*** Error compiling '/var/tmp/portage/dev-libs/libxml2-2.9.1/image//usr/lib64/python3.2/site-packages/drv_libxml2.py'...
  • File "/usr/lib64/python3.2/site-packages/drv_libxml2.py", line 37
    __author__  = u"Stéphane Bidoul <sbi@skynet.be>"
SyntaxError: invalid syntax

*** Error compiling '/var/tmp/portage/dev-libs/libxml2-2.9.1/image//usr/lib64/python3.3/site-packages/drv_libxml2.py'...
  File "/usr/lib64/python3.3/site-packages/drv_libxml2.py", line 68
    except ImportError, e:
                      ^
SyntaxError: invalid syntax
Comment 1 Alexandre Rostovtsev 2013-07-11 03:07:25 UTC
Created attachment 248904 [details] [review]
proposed patch
Comment 2 Daniel Veillard 2013-07-11 07:27:09 UTC
Looks fine, okay, pushed to git !

https://git.gnome.org/browse/libxml2/commit/?id=6c9c611beed57f001ca3ae6b964518d9c7336a69

  thanks !

Daniel
Comment 3 Arfrever Frehtes Taifersar Arahesis 2013-07-11 09:20:04 UTC
What is minimal supported version of Python?

Some other files use sys.exc_info instead of 'except ${exception_class} as ${exception_variable}:' to support Python <2.6, but commit mentioned in comment #2 adds syntax incompatible with Python <2.6. (Personally I do not need support for Python <2.6.)

Since Python 2.2, types.StringType and types.UnicodeType are not needed, and 'StringTypes = (str, unicode)' could be used.
Comment 4 Arfrever Frehtes Taifersar Arahesis 2013-07-11 09:23:41 UTC
By the way, parentheses are not needed in 'StringTypes = (str)'.
Comment 5 Arfrever Frehtes Taifersar Arahesis 2013-07-11 09:34:40 UTC
StringTypes is used only in the following line:
            if type(source) in StringTypes:

This line causes TypeError with Python 3.

Solution with support for Python <2.2:
-    StringTypes = (str)
+    StringTypes = (str,)

Solution without support for Python <2.2:
-    StringTypes = (str)
+    StringTypes = str
...
-            if type(source) in StringTypes:
+            if isinstance(source, StringTypes):
Comment 6 Daniel Veillard 2013-07-11 09:47:01 UTC
Ouch right, we need 2.6 support IMHO, I didn't realized that
thi broke it. I have tried until not to allow 2.6 and later
to be used.
would you mind providing a fixup ?

  thanks !

Daniel
Comment 7 Arfrever Frehtes Taifersar Arahesis 2013-07-11 11:16:32 UTC
New syntax of 'except' statements was introduced in Python 2.6. That commit broke support for Python older than 2.6 (and did not really fix support for Python 3).

I can create a patch. What minimal Python version should I assume?
Comment 8 Daniel Veillard 2013-07-11 12:02:52 UTC
Cool, ideally I would prefer to still be able to build on RHEL-5/CentOS-5
and they ship with python 2.4, so >= 2.4 would be ideal !

  thanks !

Daniel
Comment 9 Arfrever Frehtes Taifersar Arahesis 2013-07-11 12:42:45 UTC
Created attachment 248922 [details] [review]
Patch
Comment 10 Alexandre Rostovtsev 2013-07-11 12:51:41 UTC
(In reply to comment #5)

I must apologize for the brain error. I had intended "StringTypes = (str,)"
Comment 11 Daniel Veillard 2013-07-12 03:23:11 UTC
No need to apologize :-) contributions gratefully received !

Latest patch pushed, hopefully this is okay now !

https://git.gnome.org/browse/libxml2/commit/?id=6dd7775f3506741093890d99f09c242e0b34b55f

  thanks !

Daniel
Comment 12 Daniel Veillard 2014-10-06 11:48:48 UTC
*** Bug 734005 has been marked as a duplicate of this bug. ***