Bug 481786
Summary: | pydot does not support unicode :) | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Pierre-YvesChibon <pingou> |
Component: | pydot | Assignee: | Tom "spot" Callaway <tcallawa> |
Status: | CLOSED DEFERRED | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | medium | Docs Contact: | |
Priority: | low | ||
Version: | 10 | CC: | a.badger, tcallawa |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2009-08-31 16:59:59 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Pierre-YvesChibon
2009-01-27 16:22:18 UTC
Unicode in python gives me a headache. All my attempts to fix this just made it worse. Hopefully upstream will have better luck than I did. Filed upstream here: http://code.google.com/p/pydot/issues/detail?id=24 I've had quite some headache trying to understand it :) Thanks for reporting it. This one looks like it isn't a bug to me. Rather, it's a request for an API change. Right now, pydot accepts str type. It does not accept unicode type. So the user is forced to change the unicode strings that they have into byte strings before sending it into a pydot function. That's why n1.encode('UTF-8') is necessary. This makes some sense as pydot must interact with the world outside of python in the form of the /usr/bin/dot command. pydot communicates with that command by writing the information for /usr/bin/dot to a temporary file and then having /usr/bin/dot operate on that file. In order to create the temporary file, pydot must deal in byte strings (str). In the current code, the user gives pydot byte strings and pydot writes those out directly to the file. The user performs the conversion from unicode type to utf-8 encoded byte string. In order for pydot to handle unicode strings instead of byte strings, it would need to make the conversion that the user is currently doing. That shouldn't be too hard as /usr/bin/dot will accept utf-8 and all unicode strings can be encoded to utf-8. However, for sanity of the pydot upstream, pydot probably should stop accepting byte strings when it makes this switch. So end-user code similar to this will start to fail: g.add_edge(pydot.Edge('Th\xe9r\xe8se Doe')) If pydot upstream chooses to accept both byte strings and unicode type, it will have to take into account what happens when the user provides byte strings that are not valid utf-8 and also unicode strings. If they aren't careful, pydot will get confused about what it needs to do in this situation and either crash or output garbage. Making this sort of API change should only be done by upstream. This is filed upstream, but upstream seems to be gone. :/ http://code.google.com/p/pydot/issues/detail?id=24 Since I agree with Toshio, we won't be doing a one-off fix here, especially since it breaks API, I'm closing this ticket out. |