[issue35069] Unexecuted import in function causes UnboundLocalError

2018-10-25 Thread James Hewitt
James Hewitt added the comment: So just the fact that somewhere in the function a name is referenced, even if that code isn't actually executed, is enough to change the local namespace. I think I knew that, but didn't know that's what it meant :) I guess the moral is, p

[issue35069] Unexecuted import in function causes UnboundLocalError

2018-10-25 Thread James Hewitt
James Hewitt added the comment: I don't quite follow... the 'import logging.config' statement should never be executed, and if it is commented out the program works fine as written. It's as if the mere presence of the statement in the code causes 'logging&#

[issue35069] Unexecuted import in function causes UnboundLocalError

2018-10-25 Thread James Hewitt
James Hewitt added the comment: Sure, it's at https://pastebin.com/L1RMPD7K -James On 10/25/2018 12:30 PM, Stéphane Wirtel wrote: > > Stéphane Wirtel added the comment: > > Could you share a pastebin? Thank you > >> Le 25 oct. 2018 à 21:28, James Hewitt a écrit

[issue35069] Unexecuted import in function causes UnboundLocalError

2018-10-25 Thread James Hewitt
New submission from James Hewitt : Having 'import logging.config' in an if statement in a function causes a namespace issue, despite the fact that the import is not reached. Example code: --- #!/usr/bin/env python3 # Test weird import bug import logging config = {} c