Edgewall Software
Modify

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#7876 closed defect (fixed)

python 2.6 breaks attachments/milestone editing/likely more

Reported by: adam@… Owned by: jonas
Priority: high Milestone: 0.11.3
Component: general Version: 0.11.2
Severity: critical Keywords: python26
Cc:
Release Notes:
API Changes:

Description

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

http://XXX/trac/yyy/attachment/wiki/APage/?action=new&attachfilebutton=Attach+file

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 6 years ago.
A patch that fixes a couple of Python 2.6 compatibility problems

Download all attachments as: .zip

Change History (7)

comment:1 Changed 6 years ago by rblank

  • Keywords python26 added

#7816 was closed as a duplicate.

Changed 6 years ago by jonas

A patch that fixes a couple of Python 2.6 compatibility problems

comment:2 Changed 6 years ago by jonas

  • Owner set to jonas
  • Status changed from new to assigned

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

FieldStorage?
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 Changed 6 years ago by cboos

  • Priority changed from normal to high
  • Severity changed from major to critical

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 Changed 6 years ago by jonas

  • Resolution set to fixed
  • Status changed from assigned to closed

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 Changed 6 years ago by guardian

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

thank you

comment:6 Changed 5 years ago by anonymous

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed The owner will remain jonas.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from jonas to the specified user.
Author


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

 
Note: See TracTickets for help on using tickets.