189: Unicode problem in Repository info.

richb*****@gmai***** (Google Code) (Is this you? Claim this profile.)
david
david
Aug. 10, 2007
What's the URL of the page containing the problem?
http://127.0.0.1:8000/r/new/

What steps will reproduce the problem?
1. Click on "New Review Request"

What is the expected output? What do you see instead?
You expect to see the "New Review Request" page. Instead you get a Python
error dump.

What operating system are you using? What browser?
Ubuntu 7.04 - Firefox 2.0.0.6

Please provide any additional information below.
-----------------------------------------------------------

I believe this issue is similar to Issue #171, but I wasn't positive they
are the same.
Here is the error log:
TypeError at /r/new/
P4Client attribute values must be strings
Request Method: 	GET
Request URL: 	http://127.0.0.1:8000/r/new/
Exception Type: 	TypeError
Exception Value: 	P4Client attribute values must be strings
Exception Location: 	/usr/lib/python2.5/site-packages/p4.py in __setattr__,
line 72
Python Executable: 	/usr/bin/python
Python Version: 	2.5.1

Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in
get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/home/rbutler/reviewboard/reviewboard/djblets/auth/util.py" in
_checklogin
  45. return view_func(request, *args, **kwargs)
File
"/home/rbutler/reviewboard/reviewboard/../reviewboard/reviews/views.py" in
new_review_request
  87. fields[repo.id] = repo.get_scmtool().get_fields()
File
"/home/rbutler/reviewboard/reviewboard/../reviewboard/scmtools/models.py"
in get_scmtool
  42. return cls(self)
File
"/home/rbutler/reviewboard/reviewboard/../reviewboard/scmtools/perforce.py"
in __init__
  17. self.p4.port = repository.mirror_path or repository.path
File "/usr/lib/python2.5/site-packages/p4.py" in __setattr__
  359. setattr(self.p4client, name, value)
File "/usr/lib/python2.5/site-packages/p4.py" in __setattr__
  72. setattr(self.p4c, name, value)

  TypeError at /r/new/
  P4Client attribute values must be strings


It seems that for some reason (I'm not that familiar with python) the data
I have entered in my Repository configuration is being interpreted as type
unicode. And one of those setattr methods doesn't accept unicode, only
string types.

The offending line is in perforce.py
  17. self.p4.port = repository.mirror_path or repository.path
and if I change it to:
      self.p4.port = str(repository.mirror_path) or str(repository.path)
that resolves the problem.
(I also have to add str() to the 2 lines for user and password immediately
after this line.)

Is that the best way to resolve it?
david
#1 david
There's really no other way to resolve it -- p4python won't magically start
supporting unicode :)

Those changes are in SVN now.  Thanks for the report.
  • +Fixed
  • +Component-SCMTools
  • +david