the call stack
[26/Sep/2007:14:18:01] ENGINE CherryPy shut down
Traceback (most recent call last):
File "C:\Programme\eclipse32\plugins\org.python.pydev.debug_1.3.9\pysrc\pydevd.py", line 784, in ?
debugger.run(setup['file'], None, None)
File "C:\Programme\eclipse32\plugins\org.python.pydev.debug_1.3.9\pysrc\pydevd.py", line 636, in run
execfile(file, globals, locals) #execute the script
-----------our code deleted-----------
cherrypy.engine.start(blocking=not asService)
File "C:\Programme\Python24\Lib\site-packages\cherrypy\_cpengine.py", line 93, in start
self.block()
File "C:\Programme\Python24\Lib\site-packages\cherrypy\_cpengine.py", line 103, in block
self.autoreload()
File "C:\Programme\Python24\Lib\site-packages\cherrypy\_cpengine.py", line 168, in autoreload
if filename:
TypeError: __nonzero__ should return an int
the following is the code segment out of the module _cpengine
sysfiles = []
for k, m in sys.modules.items():
if re.match(self.autoreload_match, k):
if hasattr(m, "__loader__"):
if hasattr(m.__loader__, "archive"):
k = m.__loader__.archive
k = getattr(m, "__file__", None)
sysfiles.append(k)
for filename in sysfiles + self.reload_files:
if filename:
if type(filename) != str:
continue
if filename.endswith(".pyc"):
filename = filename[:-1]
oldtime = self.mtimes.get(filename, 0)
if oldtime is None:
# Module with no .py file. Skip it.
continue
try:
mtime = os.stat(filename).st_mtime
except OSError:
# Either a module with no .py file, or it's been deleted.
mtime = None
if filename not in self.mtimes:
# If a module has no .py file, this will be None.
self.mtimes[filename] = mtime
else:
if mtime is None or mtime > oldtime:
# The file has been deleted or modified.
self.reexec()
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It does not work.
We have got a item out of sys.modules.items() k, m =("psyco", Null).
according the code segment out of cherrypy module and your definition of class,
if hasattr(m, "__loader__"):
if hasattr(m.__loader__, "archive"):
k = m.__loader__.archive
k = getattr(m, "__file__", None)
we got Null as the value k and it will be used as filename to get file information!.
No change even if I add the definition def __nonzero__(self): return 0
because you define the function __setattr__
Maybe there is really something wrong with the module of project cherrypy, or?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Actually, maybe the Null object can be further configured to respond to things as CherryPy would expect... shouldn't be so hard -- you just have to check which are the actual protocols that CherryPy depends on (so, if you're able to make that work, please send me a patch with the changes you did).
They probably weren't expecting anything different from a module in sys.modules (although that's actually not so uncommon), but seeing it as a bug or not depends a lot on your point of view.
Cheers,
Fabio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have tested again, where I get the error message. I found that there will be wrong if I use sys.modules because
psyco is already paared with Null object, not with <module 'psyco' from 'C:\Programme\Python243\lib\site-packages\psyco\__init__.pyc'> as value!
My workaround is, I added the following code segment at the beginning of my application
if "psyco" in sys.modules:
del sys.modules["psyco"]
It works for me, but it is only for me because in this project i do not use psco for optimation!
I think your pydev has manipulated sys.modules, Is it right? Why do you need to manipulate it?
Sorry, I have not enough knowleage to patch your pydev.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Maybe the following can help you to fix the problem!
autoreload of cherrypy checked how to find the module by calling the function hasattr(obj, attr).
the function hasattr will be implemented by call getattr(obj, attr) in turn, which you implemented thru
__getattr__ for the Null object. In this way, we get always True if calling hasattr.
At the end, cherrypy gets the value by calling the function getattr and we get always
the Null object if there is no such attribute. Therefore under cherrypy we get never the default value None even if calling getattr(obj, attr, None)!
That is the reason why cherrypy failed. I still do not understand why only psyco has Null as module, not the really module as others.
hope to help you to find a solution.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The Null object pattern responds to any queries with a return to itself or None, and it's put in the place of the psyco module so that users don't have to worry about how is psyco used... but I think that maybe the whole Null object pattern may not be suitable enough for general cases where programs try to work too much with sys.modules... I'll try reducing the Null object interface to only respond to the actual psyco module interface instead of having the full pattern available there.
Cheers,
Fabio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have problem by using the newest pydev 1.3.9 if I start debugging under Eclipse because I use psyco too.
I have post a message to the group cherrypy.
http://groups.google.com/group/cherrypy-users/browse_thread/thread/d00a51bb1d3404a5#
Is there some stack trace there? What happens wrong? (I didn't get what was the error from the description)
Thanks for the reply.
the call stack
[26/Sep/2007:14:18:01] ENGINE CherryPy shut down
Traceback (most recent call last):
File "C:\Programme\eclipse32\plugins\org.python.pydev.debug_1.3.9\pysrc\pydevd.py", line 784, in ?
debugger.run(setup['file'], None, None)
File "C:\Programme\eclipse32\plugins\org.python.pydev.debug_1.3.9\pysrc\pydevd.py", line 636, in run
execfile(file, globals, locals) #execute the script
-----------our code deleted-----------
cherrypy.engine.start(blocking=not asService)
File "C:\Programme\Python24\Lib\site-packages\cherrypy\_cpengine.py", line 93, in start
self.block()
File "C:\Programme\Python24\Lib\site-packages\cherrypy\_cpengine.py", line 103, in block
self.autoreload()
File "C:\Programme\Python24\Lib\site-packages\cherrypy\_cpengine.py", line 168, in autoreload
if filename:
TypeError: __nonzero__ should return an int
the following is the code segment out of the module _cpengine
sysfiles = []
for k, m in sys.modules.items():
if re.match(self.autoreload_match, k):
if hasattr(m, "__loader__"):
if hasattr(m.__loader__, "archive"):
k = m.__loader__.archive
k = getattr(m, "__file__", None)
sysfiles.append(k)
for filename in sysfiles + self.reload_files:
if filename:
if type(filename) != str:
continue
if filename.endswith(".pyc"):
filename = filename[:-1]
oldtime = self.mtimes.get(filename, 0)
if oldtime is None:
# Module with no .py file. Skip it.
continue
try:
mtime = os.stat(filename).st_mtime
except OSError:
# Either a module with no .py file, or it's been deleted.
mtime = None
if filename not in self.mtimes:
# If a module has no .py file, this will be None.
self.mtimes[filename] = mtime
else:
if mtime is None or mtime > oldtime:
# The file has been deleted or modified.
self.reexec()
Try editing org.python.pydev.debug_1.3.9\pysrc\pydevd_constants.py
and add to the Null class:
def __nonzero__(self): return 0
Cheers,
Fabio
Thanks.
It does not work.
We have got a item out of sys.modules.items() k, m =("psyco", Null).
according the code segment out of cherrypy module and your definition of class,
if hasattr(m, "__loader__"):
if hasattr(m.__loader__, "archive"):
k = m.__loader__.archive
k = getattr(m, "__file__", None)
we got Null as the value k and it will be used as filename to get file information!.
No change even if I add the definition def __nonzero__(self): return 0
because you define the function __setattr__
Maybe there is really something wrong with the module of project cherrypy, or?
Actually, maybe the Null object can be further configured to respond to things as CherryPy would expect... shouldn't be so hard -- you just have to check which are the actual protocols that CherryPy depends on (so, if you're able to make that work, please send me a patch with the changes you did).
They probably weren't expecting anything different from a module in sys.modules (although that's actually not so uncommon), but seeing it as a bug or not depends a lot on your point of view.
Cheers,
Fabio
Thanks again.
I have tested again, where I get the error message. I found that there will be wrong if I use sys.modules because
psyco is already paared with Null object, not with <module 'psyco' from 'C:\Programme\Python243\lib\site-packages\psyco\__init__.pyc'> as value!
My workaround is, I added the following code segment at the beginning of my application
if "psyco" in sys.modules:
del sys.modules["psyco"]
It works for me, but it is only for me because in this project i do not use psco for optimation!
I think your pydev has manipulated sys.modules, Is it right? Why do you need to manipulate it?
Sorry, I have not enough knowleage to patch your pydev.
Maybe the following can help you to fix the problem!
autoreload of cherrypy checked how to find the module by calling the function hasattr(obj, attr).
the function hasattr will be implemented by call getattr(obj, attr) in turn, which you implemented thru
__getattr__ for the Null object. In this way, we get always True if calling hasattr.
At the end, cherrypy gets the value by calling the function getattr and we get always
the Null object if there is no such attribute. Therefore under cherrypy we get never the default value None even if calling getattr(obj, attr, None)!
That is the reason why cherrypy failed. I still do not understand why only psyco has Null as module, not the really module as others.
hope to help you to find a solution.
The Null object pattern responds to any queries with a return to itself or None, and it's put in the place of the psyco module so that users don't have to worry about how is psyco used... but I think that maybe the whole Null object pattern may not be suitable enough for general cases where programs try to work too much with sys.modules... I'll try reducing the Null object interface to only respond to the actual psyco module interface instead of having the full pattern available there.
Cheers,
Fabio
Hi,
Just to tell that I have the same issue. I had to rollback to 1.3.8 :( I cannot change my organization build system.
Will it be solve in the next pydev release?
Thanks in advance,
Olivier