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.

Author ronaldoussoren
Recipients gasokiw, r.david.murray, ronaldoussoren
Date 2018-06-04.12:54:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1528116873.65.0.592728768989.issue33527@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-06-04 12:54:33ronaldoussorensetrecipients: + ronaldoussoren, r.david.murray, gasokiw
2018-06-04 12:54:33ronaldoussorensetmessageid: <1528116873.65.0.592728768989.issue33527@psf.upfronthosting.co.za>
2018-06-04 12:54:33ronaldoussorenlinkissue33527 messages
2018-06-04 12:54:33ronaldoussorencreate