Hi all,
I find that I semi-frequently get the cryptic message
import site failed; use -v for traceback
printed on standard error when an arbitrary python script receives
SIGINT while the python interpreter
is still firing up. If I use -v for traceback I get something along
the lines of
'import site' failed; traceback:
Traceback (most recent call last):
File "/usr/lib/python2.4/site.py", line 61, in ?
import os
File "/usr/lib/python2.4/os.py", line 683, in ?
import copy_reg as _copy_reg
File "/usr/lib/python2.4/copy_reg.py", line 5, in ?
"""
KeyboardInterrupt
Is this a bug? I couldn't find any code, but I imagine something like
try:
import site
except:
sys.stderr.write("import site failed; use -v for traceback\n")
which should surely allow a KeyboardInterrupt exception through?
Regards,
Geoff Bache 6 1416
To clarify: this is more serious than an incorrect error message, as
the intended interrupt gets swallowed and
script execution proceeds. Sometimes I seem to get half-imported
modules as well,
the script failing later with something like
AttributeError: 'module' object has no attribute 'getenv'
when trying to call os.getenv
Regards,
Geoff Bache
On Jun 18, 12:51 am, geoffbache <geoff.ba...@jeppesen.comwrote:
[snip]
Is this a bug? I couldn't find any code, but I imagine something like
try:
import site
except:
sys.stderr.write("import site failed; use -v for traceback\n")
which should surely allow a KeyboardInterrupt exception through?
Surely?? A bare "except" catches *all* remaining uncaught exceptions.
Allowing a KeyboardInterrupt exception through would require:
except KeyboardInterrupt:
pass
John Machin <sj******@lexicon.netwrites:
On Jun 18, 12:51 am, geoffbache <geoff.ba...@jeppesen.comwrote:
[snip]
Is this a bug? I couldn't find any code, but I imagine something like
try:
import site
except:
sys.stderr.write("import site failed; use -v for traceback\n")
which should surely allow a KeyboardInterrupt exception through?
Surely?? A bare "except" catches *all* remaining uncaught exceptions.
I parsed that "should" as "this should be changed".
Allowing a KeyboardInterrupt exception through would require:
except KeyboardInterrupt:
pass
Actually, to allow it through would require re-raising it:
except KeyboardInterrupt:
raise
Yes, I think that's what Geoff is saying "should" be done :-)
--
\ "When I was born I was so surprised I couldn't talk for a year |
`\ and a half." -- Gracie Allen |
_o__) |
Ben Finney
On Jun 18, 12:26 pm, Ben Finney <bignose+hates-s...@benfinney.id.au>
wrote:
John Machin <sjmac...@lexicon.netwrites:
On Jun 18, 12:51 am, geoffbache <geoff.ba...@jeppesen.comwrote:
[snip]
Is this a bug? I couldn't find any code, but I imagine something like
try:
import site
except:
sys.stderr.write("import site failed; use -v for traceback\n")
which should surely allow a KeyboardInterrupt exception through?
Surely?? A bare "except" catches *all* remaining uncaught exceptions.
I parsed that "should" as "this should be changed".
Allowing a KeyboardInterrupt exception through would require:
except KeyboardInterrupt:
pass
Actually, to allow it through would require re-raising it:
except KeyboardInterrupt:
raise
Yes, I think that's what Geoff is saying "should" be done :-)
And all of what he was saying or not saying or should have been saying
was prefaced by "I imagine" anyway :-)
Ben is correct in his interpretation of what I'm trying to say. The
code "should surely be changed" so that it lets a KeyboardInterrupt
exception through.
Geoff This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Benjamin |
last post by:
Hello,
I need some advice on a financial application I'm doing. First, I suppose
I should give a little background so you know where I'm coming from. For
5 years I earned my living doing COBOL...
|
by: Jeff Wagner |
last post by:
I have a project of converting numerous DOS cmd shell scripts to Python. Is there a tutorial to
getting started?
Thanks, Jeff
|
by: 50295 |
last post by:
Hi everyone,
This one is better experienced than explained, so I'm including a code
sample below. Please and save (as an html file) and view with NN or
Firefox (or maybe even Mozilla), and then...
|
by: rurpy |
last post by:
Is there an effcient way (more so than cgi) of using Python
with Microsoft IIS? Something equivalent to Perl-ISAPI?
|
by: phoolimin |
last post by:
Dear all,
I am trying to embed python into another scripting language, to do this
I need to solve a number of problems on importing or compiling python
script. First let me state what exactly I...
|
by: metaperl |
last post by:
Hello, I am responsible for converting 30 loosey-goosey Perl scripts
into 30 well-documented easy to understand and use Python scripts.
No one has said anything in particular about how this...
|
by: Carroll, Barry |
last post by:
Greetings:
Personally, I don't think top-posting is the most annoying newsgroup
habit. I think it's making a big fuss about minor inconveniences.
One of the nicest things about being human...
|
by: Mark |
last post by:
Hi, I'm new to python and looking for a better idiom to use for the
manner I have been organising my python scripts. I've googled all over
the place about this but found absolutely nothing.
I'm...
|
by: braver |
last post by:
Is there any trick to get rid of having to type the annoying,
character-eating "self." prefix everywhere in a class? Sometimes I
avoid OO just not to deal with its verbosity. In fact, I try to...
|
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,...
|
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...
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |