Edgewall Software

Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#7876 closed defect (fixed)

python 2.6 breaks attachments/milestone editing/likely more

Reported by: adam@… Owned by: Jonas Borgström
Priority: high Milestone: 0.11.3
Component: general Version: 0.11.2
Severity: critical Keywords: python26
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:


the python 2.6 changelog entry:

The cgi module will now read variables from the query string of an HTTP POST request. This makes it possible to use form actions with URLs that include query strings such as “/cgi-bin/add.py?category=1”.

seems to break attachments for me. The query string is


and "action" is, of course, also a hidden posted with the form. This causes attachment.py (370):

if action == 'new':

to fail, because req.args.get('action', 'view') returns an array [q'new', q'new'].

Attachments in tickets and wiki pages are affected, as is edit milestone and (given the source of the problem) likely exists for other POST'ed forms throughout trac.

I'm using trac-0.11.2 with python-2.6.0 on apache2-2.2.10 with apache2-mod_python-3.3.1 (the openSuSE-11.1 RC1 packages).

I looked through the code and found a few instances where a POST will expect scalar values and not check. To get my team up and running I patched trac locally by replacing calls to get with calls to getfirst each time my team stumbles into a broken form. This sweeps the problem under that carpet (if, for example, the query string's value differs from the form field's value for some reason), but at least its not python 2.6 specific.

Attachments (1)

trac-py26.patch (3.4 KB ) - added by Jonas Borgström 16 years ago.
A patch that fixes a couple of Python 2.6 compatibility problems

Download all attachments as: .zip

Change History (7)

comment:1 by Remy Blank, 16 years ago

Keywords: python26 added

#7816 was closed as a duplicate.

by Jonas Borgström, 16 years ago

Attachment: trac-py26.patch added

A patch that fixes a couple of Python 2.6 compatibility problems

comment:2 by Jonas Borgström, 16 years ago

Owner: set to Jonas Borgström
Status: newassigned

I've just attached a patch that fixes all Python 2.6 issues I've found so far:

Avoid py2.6's new FieldStorage behavior by temporarily hiding the QUERY_STRING header for POST-requests.
Deprecation warning in core.py
BaseException.message is now deprecated.
Removed failing test test_from_exception_using_str
As of Python 2.6 exceptions can no longer return unicode strings in __str__()

I would love to get some feedback on these changes before committing them. I'll also try to setup a py2.6 build host.

comment:3 by Christian Boos, 16 years ago

Priority: normalhigh
Severity: majorcritical

I tried to get away from the ?action=new URL in Attachment POSTs, but didn't find how to do it yet. So restoring pre-2.6 behavior seems appropriate to me as an interim measure, like you indicated in the comment.

comment:4 by Jonas Borgström, 16 years ago

Resolution: fixed
Status: assignedclosed

This was fixed in [7774] but I forgot to close this ticket. Since most Linux distributions are still on py2.5 I'm not sure how much testing this has got yet. It would be great to get some feedback from people actually testing/running Trac on py2.6.

comment:5 by guardian, 16 years ago

attachments are working again when running python 2.6 + mod_wsgi 2.3 + 0.11stable-r7787 / archlinux

thank you

comment:6 by anonymous, 15 years ago

Note for Ubuntu 9.0.4 users:

  • The trac package that is installed with Ubuntu 9.0.4 do suffer from the above bug and will not do attachment

The fix is:

  1. Check trac version:
    > dpkg --status trac
    Package: trac
    Status: install ok installed
    Priority: optional
    Section: web
    Installed-Size: 3048
    Maintainer: Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>
    Architecture: all
    Version: 0.11.1-2.1
  2. Remove ubuntu trac packages:
    sudo dpkg -r trac

And install from sources:

  1. Dopwnload latest from: http://trac.edgewall.org/wiki/TracDownload/
  2. cd /tmp
  3. Extract
  4. cd /tmp/Trac-0.11.5
  5. sudo python ./setup.py install
  6. Add /usr/local/bin to PATH
  7. /etc/init.d/apache2 restart

Note that I use SVN/SQLITE. Users of BAZAR/GIT or MYSQL/POSTGRESS may need to add other packages

Modify Ticket

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