Closed prmtl closed 5 years ago
Comment by syb...@stuvel.eu, 2012-11-05T06:19:48Z
PS: the unittests on the mentioned Python 3 branch don't run on Python 3, so it's doubtful whether the port is actually compatible.
Comment by sandro.tosi, 2014-03-12T15:01:06Z
This is the patch I'm going to apply to the Debian packaging.
Attached support-py3k.patch
(view on Gist)
Comment by sandro.tosi, 2014-03-12T15:09:53Z
in the above patch there's still a bug in the write* functions, bad playing with bytes/strings
Comment by sandro.tosi, 2014-03-22T07:28:41Z
I've improved the provious patch a bit by replacing file() with open()
Attached support-py3k.patch
(view on Gist)
Comment by sandro.tosi, 2014-04-19T04:47:52Z
here are some crashed with this patch (don't have time to fix them):
When I call pydot.graph_from_dot_data()
with str
, it fails with:
Traceback (most recent call last):
File "routing/graph-reach-simple-add-state.py", line 19, in <module>
graph = pydot.graph_from_dot_data(args.dot.read())
File "/usr/lib/python3/dist-packages/pydot.py", line 220, in graph_from_dot_data
return dot_parser.parse_dot_data(data)
File "/usr/lib/python3/dist-packages/dot_parser.py", line 510, in parse_dot_data
if data.startswith(codecs.BOM_UTF8):
TypeError: startswith first arg must be str or a tuple of str, not bytes
and when I call it with bytes
, it fails with:
Traceback (most recent call last):
File "routing/graph-reach-simple-add-state.py", line 19, in <module>
graph = pydot.graph_from_dot_data(args.dot.read())
File "/usr/lib/python3/dist-packages/pydot.py", line 220, in graph_from_dot_data
return dot_parser.parse_dot_data(data)
File "/usr/lib/python3/dist-packages/dot_parser.py", line 520, in parse_dot_data
tokens = graphparser.parseString(data)
File "/usr/lib/python3/dist-packages/pyparsing.py", line 1031, in parseString
loc, tokens = self._parse( instring, 0 )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 899, in _parseNoCache
preloc = self.preParse( instring, loc )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 856, in preParse
loc = self._skipIgnorables( instring, loc )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 848, in _skipIgnorables
loc,dummy = e._parse( instring, loc )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 905, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 2543, in parseImpl
return self.expr._parse( instring, loc, doActions, callPreParse=False )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 905, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 1758, in parseImpl
result = self.re.match(instring,loc)
TypeError: can't use a string pattern on a bytes-like object
This worked in python2, because it autoconverted between str
and unicode
, but python3 does not. The test in the first failure is inappropriate if the passed object is of type str
.
and
When I call pydot.graph_from_dot_data()
with str
argument, I get:
Traceback (most recent call last):
File "routing/graph-reach-simple-add-state.py", line 19, in <module>
graph = pydot.graph_from_dot_data(args.dot.read())
File "/usr/lib/python3/dist-packages/pydot.py", line 220, in graph_from_dot_data
return dot_parser.parse_dot_data(data)
File "/usr/lib/python3/dist-packages/dot_parser.py", line 510, in parse_dot_data
if data.startswith(codecs.BOM_UTF8):
TypeError: startswith first arg must be str or a tuple of str, not bytes
and when I call it with bytes
argument, I get:
Traceback (most recent call last):
File "routing/graph-reach-simple-add-state.py", line 19, in <module>
graph = pydot.graph_from_dot_data(args.dot.read())
File "/usr/lib/python3/dist-packages/pydot.py", line 220, in graph_from_dot_data
return dot_parser.parse_dot_data(data)
File "/usr/lib/python3/dist-packages/dot_parser.py", line 520, in parse_dot_data
tokens = graphparser.parseString(data)
File "/usr/lib/python3/dist-packages/pyparsing.py", line 1031, in parseString
loc, tokens = self._parse( instring, 0 )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 899, in _parseNoCache
preloc = self.preParse( instring, loc )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 856, in preParse
loc = self._skipIgnorables( instring, loc )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 848, in _skipIgnorables
loc,dummy = e._parse( instring, loc )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 905, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 2543, in parseImpl
return self.expr._parse( instring, loc, doActions, callPreParse=False )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 905, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "/usr/lib/python3/dist-packages/pyparsing.py", line 1758, in parseImpl
result = self.re.match(instring,loc)
TypeError: can't use a string pattern on a bytes-like object
This worked in python2, because it auto-converted between str and unicode, but python3 does not.
Comment by twang...@gmail.com, 2014-06-02T17:50:43Z
Here is another vote. This little package is not Python3-compatible, and the allegedly Py3-compatible branch isn't either, nor is it maintained. I get the same errors ("data.startswith(codecs.BOM_UTF8)" bombs as shown, no matter which quick'n'dirty fix you try).
Comment by mike@chaliy.name, 2014-07-10T09:41:12Z
Any news? There are plenty of python3 compatible forks, but of course none of them in pypi. Is there any chance to get python3 compatible version in pypi?
Comment by trueflyi...@gmail.com, 2014-12-02T11:56:47Z
Please just merge this fork and upload a Python 3 compatible version.
It's almost 2015!
Done. Closing.
Reported by syb...@stuvel.eu, 2012-11-05T14:43:39Z
The Python 3-compatible branch mentioned on the project home page is over a year old, so apparently it's not kept up-to-date with pydot development. The latest tag is for version 1.0.15, whereas 1.0.28 is the current version of pydot.
Python 3 is becoming more and more mainstream, especially for new projects. It would be very nice to be able to use pydot in Python 3.x projects too. From: https://code.google.com/p/pydot/issues/detail?id=76