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)
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)
Please do not send messages as html. not everyone uses outlook to read mail, and it gets trashed (i.e., sent to /dev/null, and in the email program.)
I'm sending this in case my sagga helps some other relative newcomer. I suspect this problem has something to do with python1.5.2's (or Zope's hackery of...) handling of namespaces within modules & classes. What I needed was access to a "static global" variable to store some state for me. (No, I haven't looked into threads, their existance, or such issues in Zope). What I was doing was: _stateVariable=0 .... class .... def fun() .... _stateVariable=1 and this was causing me all kinds of grief. By changing the code to _stateVariable = {'a':0} ... class ... def fun() ... _stateVariable['a']=1 everything works just fine. Now, can someone give me the shortcut to understand WHHHYYY? A. -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Andrew Athan Sent: Friday, April 06, 2001 3:50 PM To: zope@zope.org 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)
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)
My flame suit's worn man, take it easy before ya kill me. Even understanding the rules of the list, I made the mistake of posting HTML because Outlook is a pain in the butt to control--I missed an option deep in one of the panels somewhere. I make this point only to suggest that a filter that convert posts to non-MIME plain-text might be a "good thing." A. -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Phil Harris Sent: Friday, April 06, 2001 5:48 PM To: Andrew Athan; zope@zope.org Subject: Re: [Zope] Verrryy strange behavior (NameError) 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) _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Even understanding the rules of the list, I made the mistake of posting HTML because Outlook is a pain in the butt to control--I missed an option deep in one of the panels somewhere.
get a better mail client ;-) (said he posting from Outlook Express 'cos he's at home ;-)
I make this point only to suggest that a filter that convert posts to non-MIME plain-text might be a "good thing."
I'm sure the mailman maintainers would love one. It's written in python :-) (BTW, I posted a rough hack at a parser to do just this a couple of days ago, maybe that would make a good starting point?) cheers, Chris
participants (4)
-
Andrew Athan -
Chris Withers -
ghaley@mail.venaca.com -
Phil Harris