[issue23556] Scope for raise without argument is different in Python 2 and 3

2015-12-23 Thread John Mark Vandenberg

John Mark Vandenberg added the comment:

In pyflakes we've looked at some of the strange scenarios where a raise without 
argument is 'legal'.  A patch to report errors for some of these was rejected 
because they are legal. See https://github.com/pyflakes/pyflakes/pull/57  The 
worst example of 'legal' is an exception in one module can be re-raised by 
another module.

--
nosy: +jayvdb

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23556] Scope for raise without argument is different in Python 2 and 3

2015-07-29 Thread Martin Panter

Martin Panter added the comment:

Here is a patch for Python 3. The re-raise behaviour reported by Antoine is 
already tested in test_raise.TestRaise.test_except_reraise().

My patch also clarifies some details about how __context__ is set:

* Context is the exception being handled, not necessarily the last exception
* “With” statements can influence context
* Re-raising does not set context; must be new exception object
* Add test case when context is not the last exception

I’m not so experienced with Python 2’s exception handling, so I haven’t got a 
patch for that. I suspect there is some shared “last exception” context. I 
wonder how it interacts with generators, multi-threading, __del__() and other 
callbacks, etc.

--
keywords: +patch
stage:  - patch review
versions: +Python 3.5, Python 3.6
Added file: http://bugs.python.org/file40053/raise-scope-py3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23556
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23556] Scope for raise without argument is different in Python 2 and 3

2015-07-21 Thread Ethan Furman

Changes by Ethan Furman et...@stoneleaf.us:


--
nosy:  -ethan.furman

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23556
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23556] Scope for raise without argument is different in Python 2 and 3

2015-03-13 Thread Ethan Furman

Changes by Ethan Furman et...@stoneleaf.us:


--
nosy: +ethan.furman

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23556
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23556] Scope for raise without argument is different in Python 2 and 3

2015-03-07 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


--
assignee:  - docs@python
components: +Documentation
nosy: +docs@python

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23556
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23556] Scope for raise without argument is different in Python 2 and 3

2015-03-07 Thread Martin Panter

Martin Panter added the comment:

For the Python 3 case, the documentation is vague and probably wrong, depending 
on what you understand “the current scope” to mean. I think it should read 
something like

. . . raise re-raises the current exception that is being handled. If no 
exception is being handled, a RuntimeError exception is raised indicating that 
this is an error.

I’m not sure but I suspect Python 2 is different because does not save the 
original exception when it handles a nested exception. In other words, at the 
point where the nested “bar” exception is raised inside the “foo” handler, 
Python forgets that “foo” was being handled.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23556
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23556] Scope for raise without argument is different in Python 2 and 3

2015-03-01 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


--
nosy: +vadmium

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23556
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23556] Scope for raise without argument is different in Python 2 and 3

2015-03-01 Thread Antoine Amarilli

New submission from Antoine Amarilli:

Hello,

Python 2.7.8 and Python 3.4.2 (from Debian testing) have a different behavior 
on the attached file. Python 2 raises bar, Python 3 raises foo.

I can't find an adequate explanation in the documentation for this behavior 
difference. It probably relates to 
https://docs.python.org/3/reference/compound_stmts.html#try (search for When 
an exception has been assigned) but this is unsatisfying because it only talks 
about the as target construction, which is not used in the example.

I think that at least the documentation should be clarified to point out what 
raise without arguments will do. Currently the documentation of this in 
Python 2 and 3 is the same even though the behavior is different 
https://docs.python.org/2/reference/simple_stmts.html#raise 
https://docs.python.org/3/reference/simple_stmts.html#raise.

Note: this question was originally asked on SO: 
http://stackoverflow.com/q/28698622/414272. I reported this as a bug at Terry 
Jan Reedy's request 
https://stackoverflow.com/q/28698622/414272#comment45707744_28698622.

--
files: raise.py
messages: 236957
nosy: a3nm
priority: normal
severity: normal
status: open
title: Scope for raise without argument is different in Python 2 and 3
type: behavior
versions: Python 2.7, Python 3.4
Added file: http://bugs.python.org/file38285/raise.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23556
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23556] Scope for raise without argument is different in Python 2 and 3

2015-03-01 Thread SilentGhost

SilentGhost added the comment:

There is this bit in https://docs.python.org/3/library/exceptions.html : 

 When raising a new exception (rather than using a bare raise to re-raise the 
 exception currently being handled),...

I presume this can be also suitable for tutorial if it's not already there.

--
components: +Interpreter Core
nosy: +SilentGhost

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23556
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23556] Scope for raise without argument is different in Python 2 and 3

2015-03-01 Thread SilentGhost

Changes by SilentGhost ghost@gmail.com:


--
nosy: +collinwinter

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23556
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com