[Python-Dev] (no subject)
Stefan Spoettl
spoettl at hotmail.com
Mon Jan 24 17:39:54 CET 2011
Using:Python 2.7.0+ (r27:82500, Sep 15 2010, 18:14:55) [GCC 4.4.5] on linux2(Ubuntu 10.10)
Method to reproduce error:
1. Defining a module which is later imported by another:
---------------------------------------------------------------------
class SomeThing:
def __init__(self): self.variable = 'Where is my bytecode?'
def deliver(self): return self.variable
if __name__ == '__main__': obj = SomeThing() print obj.deliver()
---------------------------------------------------------------------
2. Run this module:Output of the Python Shell: Where is my bytecode? >>>
3. Defining the importing module:
---------------------------------------------------------------------
class UseSomeThing:
def __init__(self, something): self.anything = something
def giveanything(self): return self.anything
if __name__ == '__main__': anything = UseSomeThing(SomeThing.SomeThing().deliver()).giveanything() print anything
---------------------------------------------------------------------
4. Run this module:Output of the Python Shell: Where is my bytecode >>>(One can find SomeThing.pyc on the disc.)
5. Changing the imported module:
---------------------------------------------------------------------class SomeThing: def __init__(self): self.variable = 'What the hell is this? It could not be Python!' def deliver(self): return self.variableif __name__ == '__main__': obj = SomeThing() print obj.deliver()---------------------------------------------------------------------
6. Run the changed module:Output of the Python Shell: What the hell is this? It could not be Python! >>>
7. Run the importing module again:Output of the Python Shell: Where is my bytecode? >>>8. Deleting the bytecode of the imported module makes no effect!
Remark: I think that I have observed yesterday late night a similar effect on Windows XPwith Python 2.7.1 and Python 3.1.3. But when I have tried it out today in the morning theerror hasn't appeared. So it may be that the Python interpreter isn't working correctly onlyon Ubuntu 10.10.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110124/3fabf5b2/attachment-0001.html>
More information about the Python-Dev
mailing list