[issue27999] Make "global after use" a SyntaxError

2016-09-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 804b71d43c85 by Guido van Rossum in branch 'default':
Issue #27999: Make "global after use" a SyntaxError, and ditto for nonlocal.
https://hg.python.org/cpython/rev/804b71d43c85

--
nosy: +python-dev

___
Python tracker 

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



[issue27999] Make "global after use" a SyntaxError

2016-09-09 Thread Guido van Rossum

Guido van Rossum added the comment:

Thanks again Ivan!

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue27999] Make "global after use" a SyntaxError

2016-09-09 Thread Guido van Rossum

Guido van Rossum added the comment:

I'll commit this.

--
assignee: docs@python -> gvanrossum

___
Python tracker 

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



[issue27999] Make "global after use" a SyntaxError

2016-09-09 Thread Ivan Levkivskyi

Ivan Levkivskyi added the comment:

Added few tests to the patch

--
Added file: http://bugs.python.org/file44503/patch-v2.diff

___
Python tracker 

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



[issue27999] Make "global after use" a SyntaxError

2016-09-09 Thread Ivan Levkivskyi

Ivan Levkivskyi added the comment:

I am attaching the patch.

Yury, I also added you here, just in case you have time for this.

Btw, while working on this I have found that the second restriction:

"""
Names listed in a global statement must not be ... in a for loop control 
target, class definition, function definition, or import statement.
"""

is not enforced at all, it does not give even a SyntaxWarning.
Is it something worth fixing?

--
keywords: +patch
nosy: +yselivanov
Added file: http://bugs.python.org/file44501/patch-v1.diff

___
Python tracker 

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



[issue27999] Make "global after use" a SyntaxError

2016-09-07 Thread Ivan Levkivskyi

Ivan Levkivskyi added the comment:

OK, then I think after will be safer. Let us came back to this right after PEP 
526.

--

___
Python tracker 

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



[issue27999] Make "global after use" a SyntaxError

2016-09-07 Thread Guido van Rossum

Guido van Rossum added the comment:

I strongly prefer to have it as a separate patch (either before or
after) to avoid the appearance of piggy-backing this in with a much
larger change.

--

___
Python tracker 

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



[issue27999] Make "global after use" a SyntaxError

2016-09-07 Thread Ivan Levkivskyi

Ivan Levkivskyi added the comment:

Yes, nonlocal will be fixed too. This will be a relatively small patch, but I 
am a bit afraid there could be merge conflicts (the code affected could overlap 
with changes for PEP 526).

Easiest way would be to simply make this a single patch with PEP 526 
implementation (this will actually even slightly simplify the implementation).

Alternatively we could fix this right after the implementation patch is 
applied. What do you prefer?

--

___
Python tracker 

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



[issue27999] Make "global after use" a SyntaxError

2016-09-07 Thread Guido van Rossum

Guido van Rossum added the comment:

I like fixing this. I suppose it'll be fixed for nonlocal too?

--

___
Python tracker 

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



[issue27999] Make "global after use" a SyntaxError

2016-09-07 Thread Ivan Levkivskyi

New submission from Ivan Levkivskyi:

The documentation at https://docs.python.org/3/reference/simple_stmts.html says 
that:

"Names listed in a global statement must not be used in the same code block 
textually preceding that global statement"

But then later:

"CPython implementation detail: The current implementation does not enforce the 
two restrictions,
but programs should not abuse this freedom, as future implementations may 
enforce them..."

Code like this

def f():
x = 1
global x

gives SyntaxWarning for several releases, maybe it is time to make it a 
SyntaxError?

--
assignee: docs@python
components: Documentation, Interpreter Core
messages: 274813
nosy: docs@python, gvanrossum, levkivskyi
priority: normal
severity: normal
status: open
title: Make "global after use" a SyntaxError
type: behavior
versions: Python 3.6

___
Python tracker 

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