Opened 18 years ago
Closed 18 years ago
#379 closed defect (fixed)
P4Python doesn't accept unicode type as the parameters
Reported by: | Kenji Nakamura | Owned by: | ttressieres |
---|---|---|---|
Priority: | normal | Component: | PerforcePlugin |
Severity: | blocker | Keywords: | |
Cc: | Trac Release: | 0.10 |
Description
I installed sandbox/vc-refactoring 0.10dev code (as of 5/18/06) from svn, and P4Python 0.6 on Fedora Core 4. I followed the installation guide, but got errors telling P4Python.run() method doesn't accept unicode type as the parameter. I whipped up a patch, which simply added a method to encode to ASCII, and the problem is fixed. The patch is not suitable to apply the real code, but it should give a hint for the fix. (For example, I could localize the encoding in a method and simply invoke it. ) I'm not sure why other users don't encounter the problem, but I guess it may be related to the fact that Fedora Core uses UTF-8 as the character encoding.
Attachments (1)
Change History (3)
Changed 18 years ago by
Attachment: | p4trac.diff added |
---|
comment:1 Changed 18 years ago by
comment:2 Changed 18 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
The latest version, 0.4.1, uses PyPerforce which supports unicode
strings natively and automatically encodes strings using the current P4CHARSET
.
However, the plugin still needs to choose an encoding to use to convert between unicode
and str
strings when the Perforce server isn't running in Unicode mode so that it can handle any extended characters (the default encoding of ASCII causes errors for such characters).
Version 0.4.1 assumes the encoding is ISO-8859-1 if the Perforce server isn't running in Unicode mode.
The plugin now uses unicode
strings throughout and only performs any encoding of the string at the boundary to Perforce.
In my opinion, this is not a bug within Trac's Perforce plugin but with the Python Perforce bindings. The plugin should use Unicode internally and be able to pass them onto P4. This however, is open for debate.
I patched p4.py some time ago, and sent them to P4Python's maintainer some days back. The changes are here, for those who are interested: