473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Exception not captured

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
2 1173
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nick | last post by:
I am working on a VB.NET application and instead of throwing Try Catch blocks all over the place, I have a custom applcation context which has a exception handler.. Public Class ContextManager...
10
by: linq936 | last post by:
Hi, I have many assert() call in my code, now I am considering to replace them with exception. The reason I want to do this change is that with the program going bigger and bigger, it is hard to...
3
by: Robert Oschler | last post by:
I am trying to strip out the contents of all double-quoted phrases in a string. I tried the following: preg_match_all("/(?:\").*?(?:\")/i", $theString, $matches, PREG_PATTERN_ORDER); Given...
2
by: Mike | last post by:
I am trying to utilize Hashtable to facilitate mapping one value to another. I have successfully added several such pairs. When using the enumerators to find keys upon subsequent manipulation, I...
19
by: Diego F. | last post by:
I think I'll never come across that error. It happens when running code from a DLL that tries to write to disk. I added permissions in the project folder, the wwwroot and in IIS to NETWORK_SERVICE...
2
by: James Cooke | last post by:
Hi all, I want to catch a duplicate key exception. I do not want to provide that verbose message from the MSSQL server - I would put a user friendly message out, like "The item you have added...
2
by: Tim Reynolds | last post by:
Team, When my web service throws an exception and I am debugging on my PC - I get the exception back in my browser fine. My web.config shows <customErrors mode="Off"/> and this is working well. ...
2
by: news.microsoft.com | last post by:
Hi all. If I wanted to write something so that, when an exception was thrown, and the stack unwound, the stack trace was captured with the values of the parameters (instead of just the parameter...
1
by: mec1997 | last post by:
Hello, I am using the WIA 2.0 library to capture a photo in C# from a webcam. The problem is the image size that is captured using device.ExecuteComman(CommandID.wiaCommandTakePicture) is only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.