Ok,
folks, things just got really strange indeed.
The
"bad" NameError behavior seems highly dependent on a line THAT NEVER EXECUTES
and which occurs much AFTER where I get the exception. Namely, later on
in the validate() function is the following clause (yes, I used the eval bit
so that the Python byte compiler, if it does invariant optimizations, doesn't
remove the code in the if).
Near
line 11...
_xxxxxxxxxxxxx='sss'
Near
line 236...
print
'testing=%s'%_xxxxxxxxxxxxx
Near
line 280...
if hasattr(self,'loginForm')
and \
response.unauthorized.__name__=='unauthorized':
if
eval('1=1')==0:
print
'arghhhhhhhhhhhhhhhhhhhhhhh'
_xxxxxxxxxxxxx = 1
As
long as this code exists in the .py file, I get the name error.
arghhhhhhhhhhhhhhhh never prints, ever (other print statements above it
do). If I comment the _xxxxxxxxxxxx = 1 out, or change it to a different
name, the NameError exception does not occur at line 236. If I leave it
in, the exception occurs.
Can
you say "voodoo"?
A.
I'm getting an
intermittent NameError trying to access a variable set in the external scope
of LoginManager.py . I call my variable _x and set it directly above
where _LogginInUser gets set. I then try to access it directly above a
line that accesses _LoggingInUser gets accessed. I just do a
simple print 'testing=%s'%_x. I get an exception. The line
that accesses _LoggingInUser doesn't.
What
gives?
Now get this ...
if I change the name to (13x's) _xxxxxxxxxxxxx , it
works.
If I then change
the name to (6x's) _xxxxxx, it continues to work.
If I then change
the name to (3x's) _xxx, it continues to work.
(2x's) _xx
works
(1x's) _x
doesn't work!!!!
If I change the
line near the top of the file from
_xx='sss'
to
_xx=0
and change the
print to use a %d I get the NameError.
If I change the
line back to _xx='sss' and the print back to a %s I continue to get the
NameError ... even though that exact combination had worked a minute
before!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
If I then change
the variable back to have 13x's it starts working again. Is there some
deep problem with the python byte compiler or access control mangling
features of Zope? Or am I missing something
stupid?
What in the
world is going on?
A.
Traceback (innermost
last):
File D:\CloakMail\lib\python\ZPublisher\Publish.py, line
238, in publish_module
File
D:\CloakMail\lib\python\ZPublisher\Publish.py, line 199, in
publish
File D:\CLOAKM~1\lib\python\Zope\__init__.py, line 221, in
zpublisher_exception_hook
(Object:
Traversable)
File D:\CloakMail\lib\python\ZPublisher\Publish.py,
line 165, in publish
File
D:\CloakMail\lib\python\ZPublisher\BaseRequest.py, line 450, in
traverse
File
D:\CloakMail\lib\python\Products\LoginManager\LoginManager.py, line 236, in
validate
(Object: ProviderContainer)
NameError:
(see above)