#19204 closed Bug (fixed)
Python2-style exception syntax is still used in django.utils.unittest (and should be updated)
Reported by: | Jim Garrison | Owned by: | Aymeric Augustin |
---|---|---|---|
Component: | Python 3 | Version: | 1.5-alpha-1 |
Severity: | Release blocker | Keywords: | py3k |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Installing the Django 1.5a1 package through pip on python 3.2 shows some SyntaxError warnings, due to using python2-style syntax for catching exceptions:
/tmp/venv/bin$ ./pip-3.2 install https://www.djangoproject.com/download/1.5a1/tarball/ Downloading/unpacking https://www.djangoproject.com/download/1.5a1/tarball/ Downloading (7.7MB): 7.7MB downloaded Cannot determine compression type for file /tmp/pip-6_1a4e-unpack/tarball.ksh Running setup.py egg_info for package from https://www.djangoproject.com/download/1.5a1/tarball/ warning: no previously-included files matching '__pycache__' found under directory '*' warning: no previously-included files matching '*.py[co]' found under directory '*' Installing collected packages: Django Running setup.py install for Django changing mode of build/scripts-3.2/django-admin.py from 644 to 755 File "/tmp/venv/lib/python3.2/site-packages/django/utils/unittest/loader.py", line 92 except Exception, e: ^ SyntaxError: invalid syntax File "/tmp/venv/lib/python3.2/site-packages/django/utils/unittest/case.py", line 327 except SkipTest, e: ^ SyntaxError: invalid syntax File "/tmp/venv/lib/python3.2/site-packages/django/utils/unittest/main.py", line 153 except getopt.error, msg: ^ SyntaxError: invalid syntax File "/tmp/venv/lib/python3.2/site-packages/django/utils/unittest/suite.py", line 141 except Exception, e: ^ SyntaxError: invalid syntax warning: no previously-included files matching '__pycache__' found under directory '*' warning: no previously-included files matching '*.py[co]' found under directory '*' changing mode of /tmp/venv/bin/django-admin.py to 755 Successfully installed Django Cleaning up...
It's not clear to me why these files were not updated with the new exception syntax, but I've attached a patch that does just that.
Attachments (1)
Change History (9)
by , 12 years ago
Attachment: | 0001-py3k-Use-python3-syntax-for-exceptions-in-django.uti.patch added |
---|
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Component: | Testing framework → Python 3 |
---|---|
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
We are not alone here
https://github.com/kennethreitz/requests/issues/738
I tried a really quick warnings.filterwarnings but didn't work on my first attempt, but I think that route may still bear fruit
I agree that we should not be patching the vendored unittest here - this may be a bug in the way py3 packaging and the way it handles split projects with the bytecompiling done at install.
comment:3 by , 12 years ago
Severity: | Normal → Release blocker |
---|
Eventually I've changed my mind on this.
There are only a few except
statements to change. And the backport of unittest2 will go away as soon as we drop support for Python 2.6.
If we agree to make this change, let's do it before 1.5 final.
comment:4 by , 12 years ago
Owner: | changed from | to
---|
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The backport of unittest2 is only there for Python 2.6.
I avoid modifying vendored library unless I absolutely need to.
I wasn't aware it would trigger warnings during installation.