Edgewall Software
Modify

Opened 16 years ago

Closed 16 years ago

#6535 closed defect (fixed)

Webadmin fails to save uft-8 (UnicodeDecodeError:)

Reported by: ilias@… Owned by: Christian Boos
Priority: normal Milestone: 0.11
Component: general Version: 0.11b1
Severity: normal Keywords: unicode
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 0: ordinal not in range(128)

Reproduction

  • got to admin/general/basics
  • add an utf-8 project name (e.g. copy/pase this one: Σχέδιο
  • Apply Changes

Request parameters:

{'__FORM_TOKEN': u'd9123783c98bf73d5a080637',
 'cat_id': None,
 'descr': u'Please add Project Description',
 'name': u'\u03a3\u03c7\u03ad\u03b4\u03b9\u03bf \u039f\u03c1\u03b8\u03bf\u03bd\u03bf\u03bc\u03af\u03b1\u03c2',
 'panel_id': None,
 'path_info': None,
 'url': u'http://example.org/'}

System Information

Trac 0.11b1
Python 2.4 (#1, Mar 22 2005, 21:42:42)
[GCC 3.3.5 20050117 (prerelease) (SUSE Linux)]
setuptools 0.6c7
SQLite 3.3.4
pysqlite 2.1.3
Genshi 0.5dev-r700
Pygments 0.7.1
Subversion 1.1.3 (r12730)

Attachments (1)

fix-config-save-r6367.diff (1.1 KB ) - added by Christian Boos 16 years ago.
Enforce unicode comparison between current value and default value from parent config

Download all attachments as: .zip

Change History (9)

comment:1 by Christian Boos, 16 years ago

Works fine for me … My test project name was already "Trac Dével (ü)", now it's "Trac Dével (ü) Σχέδιο" ;-)

Can you show us the backtrace?

comment:2 by ilias@…, 16 years ago

here it is

Python Traceback

Traceback (most recent call last):
  File "/var/www/vhosts/lazaridis.com/src/infra/trac/trac/web/main.py", line 398, in _dispatch_request
    dispatcher.dispatch(req)
  File "/var/www/vhosts/lazaridis.com/src/infra/trac/trac/web/main.py", line 195, in dispatch
    resp = chosen_handler.process_request(req)
  File "/var/www/vhosts/lazaridis.com/src/infra/trac/trac/admin/web_ui.py", line 108, in process_request
    path_info)
  File "/var/www/vhosts/lazaridis.com/src/infra/trac/trac/admin/web_ui.py", line 187, in render_admin_panel
    self.config.save()
  File "/var/www/vhosts/lazaridis.com/src/infra/trac/trac/config.py", line 184, in save
    if current is not False and current != default:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 0: ordinal not in range(128)

comment:3 by ilias@…, 16 years ago

more detailed

Code fragment:

 179. default = None
 180. if self.parent:
 181. default = self.parent.get(section, option)
 182. current = self.parser.has_option(section, option) and \
 183. self.parser.get(section, option)
 184. if current is not False and current != default:
 185. options.append((option, current))
 186. if options:
 187. sections.append((section, sorted(options)))
 188.  
 189. fileobj = open(self.filename, 'w')

Local variables:
Name	Value
current 	'\xce\xa3\xcf\x87\xce\xad\xce\xb4\xce\xb9\xce\xbf ...
default 	u'Please add the Name'
option 	'name'
options 	[]
section 	'project'
sections 	[('account-manager', [('password_store', 'HtPasswdStore')]), ...
self 	<Configuration ...

comment:4 by Christian Boos, 16 years ago

Component: webadmingeneral
Keywords: unicode added
Milestone: 0.11
Owner: changed from Christopher Lenz to Jonas Borgström

Ok, I see the problem (self.parent gives unicode back, and self.parser.get gives str back; the comparison promotes the str to unicode the automatic way)

comment:5 by ilias@…, 16 years ago

but why on my site and not at yours?

by Christian Boos, 16 years ago

Attachment: fix-config-save-r6367.diff added

Enforce unicode comparison between current value and default value from parent config

comment:6 by Christian Boos, 16 years ago

Owner: changed from Jonas Borgström to Christian Boos
Status: newassigned

I didn't have a parent config (i.e no [inherit] file =...) for that environment.

Could you please try the following fix?

attachment:fix-config-save-r6367.diff

comment:7 by ilias@…, 16 years ago

I've tried the fix, works fine on my side.

Thanks a lot.

comment:8 by Christian Boos, 16 years ago

Resolution: fixed
Status: assignedclosed

You're welcome, thanks for the report.

Fixed in [6368].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.