Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#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)

0001-py3k-Use-python3-syntax-for-exceptions-in-django.uti.patch (6.2 KB ) - added by Jim Garrison 12 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 by Aymeric Augustin, 12 years ago

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.

comment:2 by Preston Holmes, 12 years ago

Component: Testing frameworkPython 3
Patch needs improvement: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

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 Aymeric Augustin, 12 years ago

Severity: NormalRelease blocker

Eventually I've changed my mind on this.

There are only 4 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.

Version 0, edited 12 years ago by Aymeric Augustin (next)

comment:4 by Aymeric Augustin, 12 years ago

Owner: changed from nobody to Aymeric Augustin

comment:5 by Claude Paroz, 12 years ago

The required changes are really minor, go for it!

comment:6 by Florian Apolloner <florian@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 4a71b842662162e0892a9269179421ff2191adba:

Fixed #19204 -- Replaced python2-style exception syntax.

Thanks to garrison for the report and patch.

comment:7 by Florian Apolloner <florian@…>, 12 years ago

In ef98ae2910a6b5c86e1e0b003110455778e63324:

[1.5.X] Fixed #19204 -- Replaced python2-style exception syntax.

Thanks to garrison for the report and patch.

Backport of 4a71b842662162e0892a9269179421ff2191adba from master

comment:8 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

In 7f264e02f4480c49d1440be882416a10951c2165:

Fixed #20680 -- Deprecated django.utils.unittest.

Refs #19204.

Note: See TracTickets for help on using tickets.
Back to Top