classification
Title: 'exceptions' import fixer
Type: enhancement Stage: patch review
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, berker.peksag, brett.cannon, cjmayo, collinwinter, douglas, jcea, loewis
Priority: normal Keywords: needs review, patch

Created on 2008-03-17 19:22 by brett.cannon, last changed 2012-12-30 17:30 by benjamin.peterson.

Files
File name Uploaded Description Edit
exceptions_fixer.patch benjamin.peterson, 2008-08-25 17:55
issue2350.diff berker.peksag, 2012-12-30 17:24 review
Messages (10)
msg63718 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-03-17 19:22
Importing 'exceptions' should raise at least a Py3K warning, if not a
full DeprecationWarning.
msg63769 - (view) Author: Douglas Mayle (douglas) * Date: 2008-03-17 20:53
I ran python through a debugger and found that the exceptions module is
imported automatically at load time.  Because of this, when "import
exceptions" is parsed, the module is already loaded, and PyImport_Import
is not called.  In order to correct this, we'll have to either catch
this at the AST, or just handle it in 2to3...
msg71886 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-24 21:51
I'm not sure how we could implement a warning on import of exceptions
aside from implementing it in the compiler. I suppose 2to3 could just
remove the import...
msg71902 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-08-24 23:39
On Sun, Aug 24, 2008 at 2:51 PM, Benjamin Peterson
<report@bugs.python.org> wrote:
>
> Benjamin Peterson <musiccomposition@gmail.com> added the comment:
>
> I'm not sure how we could implement a warning on import of exceptions
> aside from implementing it in the compiler. I suppose 2to3 could just
> remove the import...
>

... and would also have to change all references. But that would
probably work out fine.
msg71949 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-25 17:55
Here's my 2to3 fixer for the job. It cleanly removes the imports and
changes the usage.
msg72971 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-09-10 16:02
Given that this is now a request for a fixer, and not a request for a
deprecation warning, I don't see why this is considered a release
blocker. Lowering the priority to normal. Even if the fixer isn't added
to the 2to3 copy shipped with 2.6.0, I think 2to3 improvements can well
be incorporated into 2.6.1 (including additional fixers).
msg172772 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-10-12 19:31
Brett: Why did you close the issue? Benjamin's change was never committed...
msg172773 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-10-12 19:39
I don't remember.
msg178590 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2012-12-30 17:24
I've converted Benjamin's patch to extended diff format, fixed some
PEP 8 violations and typos, removed the {get, set}_prefix usage, added
more tests and updated the documentation.
msg178591 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2012-12-30 17:30
This is something people can easily convert in there 2.x code, so I don't think the need for it is great.
History
Date User Action Args
2016-12-09 19:29:58berker.peksaglinkissue28922 superseder
2012-12-30 17:30:59benjamin.petersonsetassignee: collinwinter ->
messages: + msg178591
2012-12-30 17:24:51berker.peksagsetfiles: + issue2350.diff
nosy: + berker.peksag
messages: + msg178590

2012-10-20 13:03:25cjmayosetnosy: + cjmayo
2012-10-19 19:04:45jceasetnosy: + jcea

versions: + Python 2.7, Python 3.2, Python 3.3, Python 3.4, - Python 2.6
2012-10-15 13:04:20brett.cannonlinkissue16214 superseder
2012-10-12 19:39:02brett.cannonsetstatus: closed -> open
resolution: fixed ->
messages: + msg172773

stage: patch review
2012-10-12 19:31:04loewissetmessages: + msg172772
2008-12-03 23:35:59brett.cannonsetstatus: open -> closed
resolution: fixed
2008-09-10 16:02:56loewissetpriority: release blocker -> normal
nosy: + loewis
messages: + msg72971
2008-09-09 13:14:07barrysetpriority: deferred blocker -> release blocker
2008-09-04 01:10:11benjamin.petersonsetpriority: release blocker -> deferred blocker
2008-08-25 17:56:35benjamin.petersonsetkeywords: + needs review, - 26backport
2008-08-25 17:55:57benjamin.petersonsetfiles: + exceptions_fixer.patch
assignee: collinwinter
type: enhancement
components: + 2to3 (2.x to 3.x conversion tool)
title: Warn against importing 'exceptions' -> 'exceptions' import fixer
keywords: + patch
nosy: + collinwinter
messages: + msg71949
2008-08-24 23:39:54brett.cannonsetmessages: + msg71902
2008-08-24 21:51:35benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg71886
2008-08-21 18:34:27brett.cannonsetpriority: critical -> release blocker
2008-03-17 20:53:28douglassetnosy: + douglas
messages: + msg63769
2008-03-17 20:14:26brett.cannonsetpriority: release blocker -> critical
2008-03-17 19:22:08brett.cannoncreate