[issue33527] Invalid child function scope

2018-05-15 Thread gasokiw

New submission from gasokiw :

When you try to reassign variable with same name as one of parameters/arguments 
of parent function to local scope in child function, even if it doesn't 
actually get ran, the argument/parameter is not passed to child function 
anymore. 
In practice this happens when you make decorator with arguments/parameters and 
make wrapper function inside it.

As workaround you can redeclare those arguments/parameters in new variables in 
parent function then rewrite them back in child function. ( as seen in 
child_function_scope_bodge.py )

Please view attachment to better understand the issue.

--
files: example and workaround.zip
messages: 316725
nosy: gasokiw
priority: normal
severity: normal
status: open
title: Invalid child function scope
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6
Added file: https://bugs.python.org/file47594/example and workaround.zip

___
Python tracker 

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



[issue33527] Invalid child function scope

2018-05-15 Thread R. David Murray

R. David Murray  added the comment:

Please post an example, and not a zip file.  Given your description (which 
indeed is not enough to understand what you think the problem is by itself), I 
think you should be able to post a few lines of python code into the issue in 
order to explain what you see as the problem.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue33527] Invalid child function scope

2018-05-18 Thread Terry J. Reedy

Change by Terry J. Reedy :


--
stage:  -> test needed
versions:  -Python 3.4, Python 3.5

___
Python tracker 

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



[issue33527] Invalid child function scope

2018-06-04 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

>From the zip file, the "bug" is:

# 

def parent_function2( argument1 ):
def child_function():
print( argument1 )
if False:
argument1 = None  # Same function but with fake 
assignment

return child_function

# 

This doesn't work because "argument1" is a local variable in the nested 
function, and not the same as "argument1" in the outer function.  This is 
expected behavior.

The workaround from the same zipfile is to assign the argument of the outer 
function to a local variable in that outer function, that way the value can be 
used in the inner function. That is a valid way to deal with this, although I'd 
use a different name in the inner function.

The "nonlocal" keyword in Python 3 might be useful here, but that depends on 
whether or not you want changes to "argument1" in the inner function to affect 
the value of "argument1" in the outer function.

All in all I don't think there's a bug in Python here.

--
nosy: +ronaldoussoren

___
Python tracker 

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



[issue33527] Invalid child function scope

2018-06-04 Thread R. David Murray


Change by R. David Murray :


--
resolution:  -> not a bug
stage: test needed -> 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