Modify

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)

p4trac.diff (7.4 KB) - added by Kenji Nakamura 18 years ago.

Download all attachments as: .zip

Change History (3)

Changed 18 years ago by Kenji Nakamura

Attachment: p4trac.diff added

comment:1 Changed 18 years ago by Björn Swift

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:

19d19
< from types import *
132c131
<         return map(str, result)
---
>         return result
325,327d324
<         if type(value) is UnicodeType:
<             value = str(value)
<

comment:2 Changed 18 years ago by Lewis Baker

Resolution: fixed
Status: newclosed

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain ttressieres.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.