non descriptive error
Ron Adam
rrr at ronadam.com
Wed Oct 12 16:26:30 EDT 2005
Steven D'Aprano wrote:
> Timothy Smith wrote:
>
>>>> i have NO idea what in there could be making it have such a strange
>>>> error. it just says "error" when you try run it. there nothing terribly
>>>> strange being done.
>
>
>> i am still coming across this error it's driving me nuts. usually i
>> can find what's wrong, but it is becoming an increasingly annoying
>> problem. i also get the same problem on a windows machine with the
>> same installed. this time it's nothing to do with the decimal module.
>> help!
>
>
> Go back to first principles. Can you grab all the modules being used,
> and search them for the string "error"? Ignore any hits which are in a
> comment. One of the others is almost certainly responsible.
>
> You can test that by changing the string to "this is a PITA" and see if
> your mysterious error message changes or not.
Maybe there's a way he can examine the traceback to find it.
I think there's probably a better way, but it may be a start.
####
def seetrace():
import inspect
print inspect.trace()
print ''.join(inspect.trace(5)[0][4])
try:
try:
#### suspect code block
a = 15+'c'
print 'hello'
for x in range(10):
a = x
####
except:
seetrace()
raise "my error" # you never see this
# This is why bare excepts are not a good idea.
except:
raise "Error: your error"
####
In this example you never see "my error" because the outer try over
rides it. but the prints's still print and give you information about
the actual error in this case.
[(<frame object at 0x009A5628>, 'gen.py', 17, '?', [" a =
15+'c'\n"], 0)]
try:
#### suspect code block
a = 15+'c'
print 'hello'
for x in range(10):
Traceback (most recent call last):
File "gen.py", line 26, in ?
raise "your error"
Error: your error
Hope this helps,
Ron
More information about the Python-list
mailing list