[Zope] Verrryy strange behavior (NameError)
Andrew Athan
aathan-zope-list%REMOVEME@memeplex.com
Fri, 6 Apr 2001 15:50:07 -0400
This is a multi-part message in MIME format.
------=_NextPart_000_00F7_01C0BEB1.40DB3310
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: 7bit
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.
-----Original Message-----
From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Andrew
Athan
Sent: Friday, April 06, 2001 3:21 PM
To: zope@zope.org
Subject: [Zope] Verrryy strange behavior (NameError)
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)
------=_NextPart_000_00F7_01C0BEB1.40DB3310
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 5.50.4611.1300" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT> </DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2>Ok,=20
folks, things just got really strange indeed.</FONT></SPAN></DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2>The=20
"bad" NameError behavior seems highly dependent on a line THAT NEVER =
EXECUTES=20
and which occurs much AFTER where I get the exception. Namely, =
later on in=20
the validate() function is the following clause (yes, I used the eval =
bit so=20
that the Python byte compiler, if it does invariant optimizations, =
doesn't=20
remove the code in the if).</FONT></SPAN></DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2>Near=20
line 11...</FONT></SPAN></DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2>_xxxxxxxxxxxxx=3D'sss'</FONT></SPAN></DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2>Near=20
line 236...</FONT></SPAN></DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2> print=20
'testing=3D%s'%_xxxxxxxxxxxxx</FONT></SPAN></DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2>Near=20
line 280...</FONT></SPAN></DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2> if =
hasattr(self,'loginForm')=20
and \<BR> =20
response.unauthorized.__name__=3D=3D'unauthorized':<BR> =
=20
if=20
eval('1=3D1')=3D=3D0:<BR> =
=20
print=20
'arghhhhhhhhhhhhhhhhhhhhhhh'<BR>  =
; =20
_xxxxxxxxxxxxx =3D 1<BR></FONT></SPAN></DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2>As=20
long as this code exists in the .py file, I get the name error. =20
arghhhhhhhhhhhhhhhh never prints, ever (other print statements above it=20
do). If I comment the _xxxxxxxxxxxx =3D 1 out, or change it to a =
different=20
name, the NameError exception does not occur at line 236. If I =
leave it=20
in, the exception occurs.</FONT></SPAN></DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2>Can=20
you say "voodoo"?</FONT></SPAN></DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2>A.</FONT></SPAN></DIV>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2> </DIV></FONT></SPAN>
<DIV><SPAN class=3D987044119-06042001><FONT face=3DArial color=3D#0000ff =
size=3D2> </DIV></FONT></SPAN>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
<DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
size=3D2>-----Original Message-----<BR><B>From:</B> =
zope-admin@zope.org=20
[mailto:zope-admin@zope.org]<B>On Behalf Of </B>Andrew =
Athan<BR><B>Sent:</B>=20
Friday, April 06, 2001 3:21 PM<BR><B>To:</B> =
zope@zope.org<BR><B>Subject:</B>=20
[Zope] Verrryy strange behavior (NameError)<BR><BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D230302904-06042001>I'm =
getting an=20
intermittent NameError trying to access a variable set in the external =
scope=20
of LoginManager.py . I call my variable _x and set it directly =
above=20
where _LogginInUser gets set. I then try to access it directly =
above a=20
line that accesses _LoggingInUser gets accessed. I just do a=20
simple print 'testing=3D%s'%_x. I get an exception. =
The line=20
that accesses _LoggingInUser doesn't.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D230302904-06042001>What =
gives?</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D230302904-06042001>Now =
get this ...=20
if I change the name to (13x's) _xxxxxxxxxxxxx , it=20
works.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D230302904-06042001>If I =
then change=20
the name to (6x's) _xxxxxx, it continues to work.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D230302904-06042001>If I =
then change=20
the name to (3x's) _xxx, it continues to work.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D230302904-06042001>(2x's) _xx=20
works</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D230302904-06042001>(1x's) _x doesn't=20
work!!!!</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D230302904-06042001>If I =
change the=20
line near the top of the file from</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001>_xx=3D'sss'</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001>to</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001>_xx=3D0</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D230302904-06042001>and =
change the=20
print to use a %d </SPAN></FONT><FONT face=3DArial =
size=3D2><SPAN=20
class=3D230302904-06042001>I get the NameError.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D230302904-06042001>If I =
change the=20
line back to _xx=3D'sss' and the print back to a %s I continue to get =
the=20
NameError ... even though that exact combination had worked a minute=20
=
before!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D230302904-06042001>If I =
then change=20
the variable back to have 13x's it starts working again. Is =
there some=20
deep problem with the python byte compiler or access control mangling =
features=20
of Zope? Or am I missing something stupid?</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D230302904-06042001>What =
in the world=20
is going on?</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001>A.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial><SPAN class=3D230302904-06042001>Traceback =
(innermost=20
last):<BR> File D:\CloakMail\lib\python\ZPublisher\Publish.py, =
line 238,=20
in publish_module<BR> File=20
D:\CloakMail\lib\python\ZPublisher\Publish.py, line 199, in =
publish<BR> =20
File D:\CLOAKM~1\lib\python\Zope\__init__.py, line 221, in=20
zpublisher_exception_hook<BR> (Object:=20
Traversable)<BR> File =
D:\CloakMail\lib\python\ZPublisher\Publish.py,=20
line 165, in publish<BR> File=20
D:\CloakMail\lib\python\ZPublisher\BaseRequest.py, line 450, in=20
traverse<BR> File=20
D:\CloakMail\lib\python\Products\LoginManager\LoginManager.py, line =
236, in=20
validate<BR> (Object: =
ProviderContainer)<BR>NameError: (see=20
above)<BR></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D230302904-06042001></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
=
class=3D230302904-06042001></SPAN></FONT> </DIV></BLOCKQUOTE></BODY>=
</HTML>
------=_NextPart_000_00F7_01C0BEB1.40DB3310--