[issue36052] Assignment operator allows to assign to __debug__

2019-02-21 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-21 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:


New changeset 3ad91673057d410bf9f8c53df6bb8aa18c4b68ca by Pablo Galindo 
(Stéphane Wirtel) in branch 'master':
bpo-36052: Raise a SyntaxError when assigning a value to __debug__ with := 
(GH-11958)
https://github.com/python/cpython/commit/3ad91673057d410bf9f8c53df6bb8aa18c4b68ca


--

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

Thank you Pablo, if I see you at PyCon, maybe we could drink a good beer ;-)

--

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

When I started working on this I did not notice the extra comments here.
 
I will close my PR so Stéphane can do the PR.

--
nosy: +pablogsal

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
pull_requests: +11985

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
keywords: +patch
pull_requests: +11984
stage:  -> patch review

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Look at compile.c. The code for restricting other assignments is located here.

--

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
assignee:  -> matrixise

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

Hi @emily

Thank you for your help.

In fact, I have started to read Python-ast.c and ast.c, they are the main files 
for this kind of operations.

Thank you again,

--

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Emily Morehouse


Emily Morehouse  added the comment:

You should look in Python/ast.c. The naming convention follows some form of 
"named expression" (e.g. NamedExpr, ast_for_namedexpr).

I'll have more time to look later this week, but let me know if you have any 
questions.

--

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

ok, I found the commit of @emily 8f59ee01be3d83d5513a9a3f654a237d77d80d9a

and will try to find the assignment operator :=

--

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

ok, I will check for the assignment operator in the code.

maybe in the AST (Python-ast.c) but I think not

--

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

An idea for the fix? a direction where I could find the solution? ;-)

--
nosy: +matrixise

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

You need to add for the target of the assignment operator the same check as for 
other targets.

--

___
Python tracker 

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



[issue36052] Assignment operator allows to assign to __debug__

2019-02-20 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

All ways of assigning to __debug__ are forbidden:

>>> __debug__ = 1
  File "", line 1
SyntaxError: cannot assign to __debug__
>>> for __debug__ in []: pass
... 
  File "", line 1
SyntaxError: cannot assign to __debug__
>>> with cm() as __debug__: pass
... 
  File "", line 1
SyntaxError: cannot assign to __debug__
>>> class __debug__: pass
... 
  File "", line 1
SyntaxError: cannot assign to __debug__
>>> def __debug__(): pass
... 
  File "", line 1
SyntaxError: cannot assign to __debug__
>>> def foo(__debug__): pass
... 
  File "", line 1
SyntaxError: cannot assign to __debug__
>>> import __debug__
  File "", line 1
SyntaxError: cannot assign to __debug__

The only exception is the assignment operator.

>>> (__debug__ := 'spam')
'spam'
>>> globals()['__debug__']
'spam'

This looks like a bug.

--
components: Interpreter Core
messages: 336100
nosy: emilyemorehouse, gvanrossum, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Assignment operator allows to assign to __debug__
type: behavior
versions: Python 3.8

___
Python tracker 

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