Description of problem: Running this simple lines of code make pydot crash: #!/usr/bin/python #-*- coding: UTF-8 -*- import pydot g = pydot.Dot() g.add_node(pydot.Node("Anne-Cécile")) g.add_edge(pydot.Edge(src='Anne-Cécile', dst='Anne-Marie')) g.write('test.jpg', format='raw') g.write_jpeg('test.jpg') Version-Release number of selected component (if applicable): pydot-1.0.2-1.fc10.noarch How reproducible: Always Steps to Reproduce: 1.Run the code given above 2.Enjoy :) 3. Actual results: >>> g.write_jpeg('test.jpg') Anne-Cécile [195, 169] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/pydot.py", line 1603, in <lambda> lambda path, f=frmt, prog=self.prog : self.write(path, format=f, prog=prog)) File "/usr/lib/python2.5/site-packages/pydot.py", line 1697, in write dot_fd.write(self.create(prog, format)) File "/usr/lib/python2.5/site-packages/pydot.py", line 1797, in create status, stderr_output) ) pydot.InvocationException: Program terminated with status: 6. stderr follows: Error: /tmp/tmpVEABbQ:2: syntax error near line 2 context: >>> Anne- <<< Cécile; Expected results: >>> g.write_jpeg('test.jpg') True Additional info: I managed to solve it by a dirty solution: I commented these lines: line 157 # chars = [ord(c) for c in s if ord(c)>0x7f or ord(c)==0] # if chars: # print s, chars # return False line 162 of the file /usr/lib/python2.5/site-packages/pydot.py It's probably more a bug to report upstream but I have not find place where to do so... Thanks for your help :)
Filed upstream: http://code.google.com/p/pydot/issues/detail?id=23 I poked this for a while and couldn't come up with a fix.
Thanks for reporting it. What do you think of the 4 lines I commented ?
Well, its not a real fix, for sure. I tried all sorts of things in that section of code to fix it properly, but without success.
There's some sort of bug in needs_quotes() and quote_if_necessary() but I haven't unravelled it yet. It almost looks like needs_quotes() is returning the opposite values as it should. ie: Returning False when quotes are needed and True when they aren't. But at least one of the tests (id_re_dbl_quoted.match) is wrong if I just change every True to False and False to True. So I need to understand that section of code a little bit better.
Created attachment 345862 [details] Fix reversed return values from need_quote() I think this is right but if you use this module with any frequency, a bit of testing would be appreciated :-) Some of the return values were reversed in needs_quote() but regex checks were returning the correct value. This patch should fix things up.
My test case was: #!/usr/bin/python #-*- coding: UTF-8 -*- import pydot n1 = u'Th\xe9r\xe8se Doe' n2 = u'Jean-Pierre Tou\xe9' g = pydot.Dot() g.add_node(pydot.Node(n1.encode('utf-8'))) g.add_edge(pydot.Edge(src=n1.encode('utf-8'), dst=n2.encode('utf-8'))) g.write('test.dot', format='raw') g.write_jpeg('test.jpg')
pydot-1.0.2-4.fc10 has been submitted as an update for Fedora 10. http://admin.fedoraproject.org/updates/pydot-1.0.2-4.fc10
pydot-1.0.2-4.fc11 has been submitted as an update for Fedora 11. http://admin.fedoraproject.org/updates/pydot-1.0.2-4.fc11
pydot-1.0.2-4.fc11 has been pushed to the Fedora 11 stable repository. If problems still persist, please make note of it in this bug report.
pydot-1.0.2-4.fc10 has been pushed to the Fedora 10 stable repository. If problems still persist, please make note of it in this bug report.
I just wanted to thank Toshio for the patch and Tom to push it, it works great for me :-)