Message328475
This is expected behaviour: import is a form of assignment.
"import logging", like "logging = 1", tells the compiler to treat logging as a local variable (unless you declare logging as global). As the exception says, you are trying to access the logging local variable before it has been assigned to.
You can (and should!) give a SHORT and SIMPLE demonstration, without any excess and irrelevant code:
py> def demo():
... if False:
... import logging
... logging
...
py> demo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in demo
UnboundLocalError: local variable 'logging' referenced before assignment
So this is expected behaviour. |
|
Date |
User |
Action |
Args |
2018-10-25 19:58:31 | steven.daprano | set | recipients:
+ steven.daprano, matrixise, jhewitt |
2018-10-25 19:58:31 | steven.daprano | set | messageid: <1540497511.96.0.788709270274.issue35069@psf.upfronthosting.co.za> |
2018-10-25 19:58:31 | steven.daprano | link | issue35069 messages |
2018-10-25 19:58:31 | steven.daprano | create | |
|