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:

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: