Support Python 3
Bug #809884 reported by
Andreas Becker
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
JessyInk |
Fix Committed
|
Medium
|
Hannes Hochreiner |
Bug Description
Please change the Python code for the Inkscape plugin to support both Python 2.x and Python 3. It is very easy, because the tool “2to3” can convert the code.
In Python 3, the “u” prefix to strings is not supported, because there, all strings are unicode. A solution is either to remove the prefix, if it also works without it in Python 2.x, or to replace “u” by a function “u(...)” and define this function like the following:
def u(string):
try:
return unicode(string)
except:
return string
Related branches
Changed in jessyink: | |
status: | Confirmed → Fix Committed |
milestone: | none → 1.5.6 |
To post a comment you must log in.
Thanks for pointing this problem out. Adding the "u(...)"-function would not be a big deal and I'll happily do it, since the scripts would then run on python 2 and 3. However, I did some quick tests with the 2to3 tool and there are at least two other constructs that are quite frequently used that would need to be replaced:
- if node.attrib. has_key( "{" + inkex.NSS[ "jessyink" ] + "}view"): "jessyink" ] + "}view" in node.attrib:
+ if "{" + inkex.NSS[
- for id, node in self.selected. items() : selected. items() ):
+ for id, node in list(self.
Do you know whether the suggested changed still work in python 2?