#7876 closed defect (fixed)
python 2.6 breaks attachments/milestone editing/likely more
Reported by: | 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: |
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)
Change History (7)
comment:1 by , 16 years ago
Keywords: | python26 added |
---|
by , 16 years ago
Attachment: | trac-py26.patch added |
---|
A patch that fixes a couple of Python 2.6 compatibility problems
comment:2 by , 16 years ago
Owner: | set to |
---|---|
Status: | new → 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 by , 16 years ago
Priority: | normal → high |
---|---|
Severity: | major → 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 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → 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 by , 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 , 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:
- 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
- Remove ubuntu trac packages:
sudo dpkg -r trac
And install from sources:
- Dopwnload latest from: http://trac.edgewall.org/wiki/TracDownload/
- cd /tmp
- Extract
- cd /tmp/Trac-0.11.5
- sudo python ./setup.py install
- Add /usr/local/bin to PATH
- /etc/init.d/apache2 restart
Note that I use SVN/SQLITE. Users of BAZAR/GIT or MYSQL/POSTGRESS may need to add other packages
#7816 was closed as a duplicate.