By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,272 Members | 1,733 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,272 IT Pros & Developers. It's quick & easy.

Exception not captured

P: n/a
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?
Bye.
--
------------------------------------------------------------------------
Miki Tebeka <mi*********@zoran.com>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

Jul 18 '05 #2

P: n/a
In article <ma**************************************@python.o rg>,
Miki Tebeka <mi*********@zoran.com> wrote:
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?


I suspect you meant to do:

print "SCMError is", e.__class__

The way you have it now, it's printing out the result of the "is"
operator, which tests for identity.
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.