Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

#4742 closed defect (fixed)

trac-admin: output stream in trouble

Reported by: Emmanuel Blot Owned by: Emmanuel Blot
Priority: low Milestone: 0.11
Component: admin/console Version: devel
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

When trac-admin project permission list is invoked, the command fails with the following error:

Trac [/Users/eblot/Trac/Db/trunk]> permission list
Command failed: encode() argument 1 must be string, not None

The same error also occurs if the permissions are listed for a specific user.

The trouble comes from the print_table() method. When it attempts to retrieve the defaut encoding for the output stream, the defaut encoding may be defined to 'None' rather than being undefined. In such a case, the getattr() built-in function return 'None' instead of the fallback parameter ('utf-8').
This leads to evaluate None as the charset rather than 'utf-8'. Maybe this is Mac OS X -only issue, I did not test it on other platforms.

The following patch solves the issue - as I'm not sure it does the exact same thing that was originally expected, I did not commit it to the trunk. Let me know if you want me to commit it.

  • trac/util/text.py

     
    110110def print_table(data, headers=None, sep='  ', out=None):
    111111    if out is None:
    112112        out = sys.stdout
    113     charset = getattr(out, 'encoding', 'utf-8')
     113    charset = getattr(out, 'encoding', None) or 'utf-8'
    114114    data = list(data)
    115115    if headers:
    116116        data.insert(0, headers)

Attachments (0)

Change History (3)

comment:1 by Emmanuel Blot, 17 years ago

Owner: changed from Christopher Lenz to Emmanuel Blot
Status: newassigned
Summary: trac-admin: 'permission list' failuretrac-admin: output stream in trouble

I just bumped into this issue once more, this time with Linux Debian.

The same issue occurs when the trac-admin standard output is piped to the stdin of any other process.

If nobody objects, I'll apply this patch today.

comment:2 by Christian Boos, 17 years ago

Reproduced on Windows as well, where your fix works as well. Please apply.

comment:3 by Emmanuel Blot, 17 years ago

Resolution: fixed
Status: assignedclosed

Applied in [5210]

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Emmanuel Blot.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Emmanuel Blot 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.