[Zope] Verrryy strange behavior (NameError)

Phil Harris phil.harris@zope.co.uk
Fri, 6 Apr 2001 22:48:10 +0100


Andrew I'm sorry to take this out on you, it's nothing personal.

WHAT PART OF NO HTML POSTS DON'T YOU PEOPLE UNDERSTAND?!?!

The rules of the list state and I quote,

<quote>
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
</quote>

Thanks for listening.


----- Original Message -----
From: Andrew Athan
To: zope@zope.org
Sent: Friday, April 06, 2001 8:50 PM
Subject: RE: [Zope] Verrryy strange behavior (NameError)



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)