Miki Tebeka wrote:

> Hello All,
> 
> Can someone please explain how is the following code fragment possible?
> (If you're interested I can place the whole project somewhere).
> 
> def checkout(dest, log):
>     '''Get latest version from SCM
> 
>         client - SCM client to use
>         dest - Destination directory
>     '''
>     try:
>         SCM.checkout(dest, log)
>     except SCMError, e:
>         raise NightlyError("Checkout")
>     except Exception, e:
>         import inspect
>         file = inspect.getsourcefile(e.__class__)
>         line = inspect.getsourcelines(e.__class__)[1]
>         print "%s:%d" % (file, line)
>         file = inspect.getsourcefile(SCMError)
>         line = inspect.getsourcelines(SCMError)[1]
>         print "%s:%d" % (file, line)
>         print SCMError is e.__class__
>         raise SystemExit
> 
> I get to the second "except" clause, and the printout is:
> /home/mikit/work/nightly/scm/common.py:3
> /home/mikit/work/nightly/scm/common.py:3
> False
> 
> How is this possible?

Some kind of duplicate import, maybe? E.g.:

>>> import sys
>>> import inspect
>>> getsource = inspect.getsource
>>> del sys.modules["inspect"]
>>> import inspect
>>> getsource is inspect.getsource
False

Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to