[issue45294] Conditional import fails and produce UnboundLocalError, if a variable machting import name is used before

2021-09-26 Thread arts stars


New submission from arts stars :

Hello,

I have this situation:

def test():

if True :
print("Exception"+DiaObjectFactoryHelper)
else:
from . import DiaObjectFactoryHelper
pass

test()
---
it generates instead of (like the the line 'from . import' is commented) : 
"NameError: name 'DiaObjectFactoryHelper' is not defined"
this:
UnboundLocalError: local variable 'DiaObjectFactoryHelper' referenced before 
assignment


PS: The github authentificatiion did not work, did not manage to grab email 
even if set public

--
messages: 402663
nosy: stars-of-stras
priority: normal
severity: normal
status: open
title: Conditional import fails and produce UnboundLocalError, if a variable 
machting import name is used before
versions: Python 3.9

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



[issue45294] Conditional import fails and produce UnboundLocalError, if a variable machting import name is used before

2021-09-27 Thread arts stars


arts stars  added the comment:

It is not for debuging my code. your answer is really middleclass sorry to say 
that.

you admit its a due the undefined name of var DiaObjectFactoryHelper
that is exactly I wanted to point out. 

I solved my issue not having answer like in the FAQ like you simply repeated 
here.

This is a parsing issue error I revealed here. The if... should pe 
PRIORITARIZED before checking what it is said in the FAQ.

--

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