Issue 2350: 'exceptions' import fixer - Python tracker

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
process
Status: closed Resolution: wont fix
Dependencies: Superseder: Close 2to3 issues and list them here
View: 45544
Assigned To: Nosy List: benjamin.peterson, berker.peksag, brett.cannon, cjmayo, collinwinter, douglas, iritkatriel, jcea, loewis
Priority: normal Keywords:

Created on 2008-03-17 19:22 by brett.cannon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

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 (11)
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.
msg379318 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-10-22 17:54
Updating the versions, though it seems that you may want to close this as rejected based on the discussion.