Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The biggest difference between time and space is that you can't reuse time. -- Merrick Furst


devel / comp.lang.python / Re: how to discover what values produced an exception?

SubjectAuthor
* how to discover what values produced an exception?Johanne Fairchild
+* Re: how to discover what values produced an exception?Stefan Ram
|`* Re: how to discover what values produced an exception?Stefan Ram
| +- Re: how to discover what values produced an exception?Stefan Ram
| `- Re: how to discover what values produced an exception?Stefan Ram
+* Re: how to discover what values produced an exception?Alan Bawden
|`- Re: how to discover what values produced an exception?Chris Angelico
+- Re: how to discover what values produced an exception?Thomas Passin
+- Re: how to discover what values produced an exception?dieter.maurer
+- Re: how to discover what values produced an exception?2QdxY4RzWzUUiLuE
+- Re: how to discover what values produced an exception?Stefan Ram
`- Re: how to discover what values produced an exception?Left Right

1
how to discover what values produced an exception?

<8734qz9ey0.fsf@tudado.org>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25454&group=comp.lang.python#25454

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jfairch...@tudado.org (Johanne Fairchild)
Newsgroups: comp.lang.python
Subject: how to discover what values produced an exception?
Date: Fri, 03 May 2024 10:56:39 -0300
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <8734qz9ey0.fsf@tudado.org>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Fri, 03 May 2024 15:56:43 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="260e4e4c2eb408d75e8a4a3d38908633";
logging-data="620172"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tLaDydT98Cz7UI1U8DhGnR4QGrHI1dr0="
Cancel-Lock: sha1:AEZsn63TzbmB6R6xsrP7PUx2ets=
sha1:dWetucWpOrSD8kVLs4XNNSKV0AI=
 by: Johanne Fairchild - Fri, 3 May 2024 13:56 UTC

How to discover what values produced an exception? Or perhaps---why
doesn't the Python traceback show the values involved in the TypeError?
For instance:

--8<-------------------------------------------------------->8---
>>> (0,0) < 4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: '<' not supported between instances of 'tuple' and 'int'
--8<-------------------------------------------------------->8---

It could have said something like:

--8<-------------------------------------------------------->8---
TypeError: '<' not supported between instances of 'tuple' and 'int'
in (0,0) < 4.
--8<-------------------------------------------------------->8---

We would know which were the values that caused the problem, which would
be very helpful.

Re: how to discover what values produced an exception?

<exceptions-20240503152349@ram.dialup.fu-berlin.de>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25455&group=comp.lang.python#25455

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.neodome.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: how to discover what values produced an exception?
Date: 3 May 2024 14:26:58 GMT
Organization: Stefan Ram
Lines: 75
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <exceptions-20240503152349@ram.dialup.fu-berlin.de>
References: <8734qz9ey0.fsf@tudado.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 09xumdQQZsY92pxfm79zxQBprX/BKxlDyyL1ahb7RwBSB4
Cancel-Lock: sha1:cYhD6NaHQJZZl5vE7cXP801Nfc0= sha256:FU2WceNYa9o9olmj3bTwdnPmIcCsBQEk7afIoe9UlZo=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
 by: Stefan Ram - Fri, 3 May 2024 14:26 UTC

Johanne Fairchild <jfairchild@tudado.org> wrote or quoted:
>How to discover what values produced an exception?

An exception isn't always tied to a value. I could, like, write:

if 3 > 2: "".call()

And I'd get an AttributeError exception. Can I now say the
values 3 and 2 caused this exception? Or was it the empty
string? Or the lack of a call method?

Let me try your example here: In the console:

|>>> ( 0, 0 )< 4
|TypeError: '<' not supported between instances of 'tuple' and 'int'

In this case, the values aren't important, one could even
say they're a distraction. What matters are the types of the
values, and those were given. However, the values are visible
in the console as they were typed in. In a script:

|Traceback (most recent call last):
| File "Main.py", line 1, in <module>
| ( 0, 0 )< 4
|TypeError: '<' not supported between instances of 'tuple' and 'int'

. Now I can see the offending line, which in this case even spills
the beans on the values.

Sometimes you really need those values. If they're values of global
names, you can kind of get them in the IDLE shell up to a point.

So I write this script in the IDLE editor and then run it:

a = 4
( 0, 0 )< a

. Now I get this in the IDLE console:

|Traceback (most recent call last):
| File "Main.py", line 2, in <module>
| ( 0, 0 )< a
|TypeError: '<' not supported between instances of 'tuple' and 'int'

. Then I can type

a

into the console, hit Return, and I see the value 4.

This script here has local variables, and that trick ain't
gonna fly no more:

def main():
a = 4
( 0, 0 )< a

main()

Now you got to add a debug print statement and run the script again.

def main():
a = 4
print( a )
( 0, 0 )< a

main()

In a bigger script there's all kinds of values and variables,
and sometimes the Python implementation can't know which ones
are critical for an exception, so the programmer's got to step
in and write those debug print statements.

(You could also use the IDLE debugger to see local variables,
but I prefer debug print statements.)

Re: how to discover what values produced an exception?

<86r0eimq3c.fsf@williamsburg.bawden.org>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25458&group=comp.lang.python#25458

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.network!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!bawden.eternal-september.org!.POSTED!not-for-mail
From: ala...@csail.mit.edu (Alan Bawden)
Newsgroups: comp.lang.python
Subject: Re: how to discover what values produced an exception?
Date: Fri, 03 May 2024 19:29:43 -0400
Organization: ITS Preservation Society
Lines: 47
Message-ID: <86r0eimq3c.fsf@williamsburg.bawden.org>
References: <8734qz9ey0.fsf@tudado.org>
<918e3522-03e0-40e7-928d-bbf87698a7b3@tompassin.net>
<mailman.4.1714772954.3326.python-list@python.org>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sat, 04 May 2024 01:29:46 +0200 (CEST)
Injection-Info: bawden.eternal-september.org; posting-host="bb54c05ff7b658c943be99c1f787e152";
logging-data="859898"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+H3YrnwGM/87n4HTg5kzuT"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)
Cancel-Lock: sha1:oL1NGID4D1FzGdk3G+mb+hLbUIQ=
sha1:7FizeFR5qFkdpz2R/vL+BWYO1QU=
 by: Alan Bawden - Fri, 3 May 2024 23:29 UTC

Thomas Passin <list1@tompassin.net> writes:

On 5/3/2024 9:56 AM, Johanne Fairchild via Python-list wrote:
> How to discover what values produced an exception? Or perhaps---why
> doesn't the Python traceback show the values involved in the TypeError?
> For instance:
>
> --8<-------------------------------------------------------->8---
>>>> (0,0) < 4
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: '<' not supported between instances of 'tuple' and 'int'
> --8<-------------------------------------------------------->8---
>
> It could have said something like:
>
> --8<-------------------------------------------------------->8---
> TypeError: '<' not supported between instances of 'tuple' and 'int'
> in (0,0) < 4.
> --8<-------------------------------------------------------->8---
>
> We would know which were the values that caused the problem, which would
> be very helpful.

In this example it would not help at all to know the actual values. Knowing
that you are trying to compare incomparable types is enough.

In general, it absolutely can help. The programmer can sometimes
recognize where a value of unexpected type came from just by looking at
it, allowing her to quickly deduce just what went wrong without further
investigation.

A good error message shouldn't withhold any information that can
_easily_ be included. Debugging is more art than science, so there is
no real way to predict what information might prove useful in solving
the crime. I emphasized "easily" because of course you have to draw the
line somewhere.

The fact that Python error messages often fail to mention the actual
objects that caused the error has always annoyed me. I've always
presumed that for some reason it just wasn't easy to do. And it's never
been more than a minor annoyance to me.

So the OP is not wrong for wishing for this. Other programming
languages do it. Other Python programmers miss it.

- Alan

Re: how to discover what values produced an exception?

<mailman.4.1714772954.3326.python-list@python.org>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25459&group=comp.lang.python#25459

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!rocksolid2!news.neodome.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: lis...@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: how to discover what values produced an exception?
Date: Fri, 3 May 2024 17:39:46 -0400
Lines: 25
Message-ID: <mailman.4.1714772954.3326.python-list@python.org>
References: <8734qz9ey0.fsf@tudado.org>
<918e3522-03e0-40e7-928d-bbf87698a7b3@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de YImOBnBaBqRgxw/tQyFf8w6/nm94wbLZGjk+SGRB2Pww==
Cancel-Lock: sha1:JRmCS+Z1uROFZdJhsbsYfJd8KLI= sha256:Cc+evXWve8L7eLd9bwK/bn74obqxAmPCL9gX0BoFNQw=
Return-Path: <list1@tompassin.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=tompassin.net header.i=@tompassin.net header.b=jhFl7Pte;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'traceback': 0.04; '(most':
0.05; 'last):': 0.05; 'enough.': 0.09; 'subject:how': 0.09;
'typeerror:': 0.09; 'values.': 0.09; '9:56': 0.16; '>>>>': 0.16;
'received:10.0.0': 0.16; 'received:64.90': 0.16;
'received:64.90.62': 0.16; 'received:64.90.62.162': 0.16;
'received:dreamhost.com': 0.16; 'subject:values': 0.16;
'subject:what': 0.16; 'wrote:': 0.16; 'python': 0.16; 'values':
0.17; 'to:addr:python-list': 0.20; 'problem,': 0.22; 'actual':
0.25; 'header:User-Agent:1': 0.30; 'am,': 0.31; "doesn't": 0.32;
'"",': 0.32; 'python-list': 0.32; 'received:10.0': 0.32;
'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'header:In-Reply-To:1':
0.34; 'trying': 0.35; 'file': 0.38; 'could': 0.38; 'something':
0.40; 'involved': 0.63; 'types': 0.67; 'header:Received:6': 0.67;
'received:64': 0.67; 'compare': 0.69; 'knowing': 0.71; 'discover':
0.80; 'caused': 0.86
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1714772387; a=rsa-sha256;
cv=none;
b=ZCGcU0vgHfkb8da7KDlGneKiqDt4wfyDnJSik/4U1eI7qeB5YCDjEOJx8tz0ufNB4TEqtJ
UbMdUFDHaK//7qPFri/2NfuIl8trEqr42bycnhV//fzrN7Mf1go3kuzbVAxvrPkEomfhZb
yAa9E+T9f5Q7iad/NZsYQ533GO2pPFpLP4H1mAkXfOzaYra+fV1pv6Q5yxHqlQxWH+h3xg
HXC8EFxEhO9Mqw7/AtZUmdoBNVS4VGF2j7xpLkWsdJZdKWZYVbWfIqZzvEiV36vfiYShLs
Vwz8VxWwzfflLAjkwjV8dfg3/kNK1V1ad/81YWx+7YXGrLmc2NwYjxSpD5jcCQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1714772387;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=+7vlGHl78VGIIpkqQG6wNcd8GO0+wak2QZA2expfOVU=;
b=tpU9tqotCoQfSgXoygUHqYBwDmRQDP4I0FtGImOsvZr0xXrtxu1W+91vRP85oHJue+G/IF
2OEOb9BrfNjBaaVbjJMB2PiXmLfcYWQHinLCZFtKkKiA7IXLiuyx+ai32PkA7xaAX6kRWV
z6u13HAT8WJXtBCy7SpNFRE8sJ0abX7ThE/EesNmOZllZl8sgEq7Ouz1RY+meZ9VGvb9ls
nmi0p9P/YPTY6qFLEhmRkJexTIFWCX7HEAJsUUZWoqfbQsSAD6+s8YGVtMdCEzEWeBgfkb
Ylx8N8nXM6+frpJQz0/KCwZcxuzfztsJxdiWX1TTUZb+oYP+hrPEOotl7OrsiA==
ARC-Authentication-Results: i=1; rspamd-5bcfdc8c55-5flws;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Tangy-Broad: 06c01fa16ea7d210_1714772387993_935053137
X-MC-Loop-Signature: 1714772387993:2554773767
X-MC-Ingress-Time: 1714772387992
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1714772387;
bh=+7vlGHl78VGIIpkqQG6wNcd8GO0+wak2QZA2expfOVU=;
h=Date:From:Subject:To:Content-Type:Content-Transfer-Encoding;
b=jhFl7Pte4nq3micrEVRVEaZONB1srs+WXfrgIWRbow9kGsYJYSIxC2+Pko4YgzWFE
/gcesmysuKtTqclvefJb+lktTpxT4N40z7FiPgBJha3KY5hVmuPJTFTCrpzjigGTQ3
O12P+kazaE8ZOV6zkA4Ub3KoV/C3+Hu8e9HIObpCthtf2RghCo0weyf1YSUXUcjAb7
LpQm6Ug+y9JEgrqq6yz7NEdxxAa7F7EGSKlVybQEe4E9+H30p6LFrmuDxwvUUEVSme
9ESdNOFSYWlqHTaik9Mi9kIkLpagLd+ayYgO78kWlq9/Q5SN54yS5Tw5H28x7/ElEQ
UywwELw8xJTWA==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <8734qz9ey0.fsf@tudado.org>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <918e3522-03e0-40e7-928d-bbf87698a7b3@tompassin.net>
X-Mailman-Original-References: <8734qz9ey0.fsf@tudado.org>
 by: Thomas Passin - Fri, 3 May 2024 21:39 UTC

On 5/3/2024 9:56 AM, Johanne Fairchild via Python-list wrote:
> How to discover what values produced an exception? Or perhaps---why
> doesn't the Python traceback show the values involved in the TypeError?
> For instance:
>
> --8<-------------------------------------------------------->8---
>>>> (0,0) < 4
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: '<' not supported between instances of 'tuple' and 'int'
> --8<-------------------------------------------------------->8---
>
> It could have said something like:
>
> --8<-------------------------------------------------------->8---
> TypeError: '<' not supported between instances of 'tuple' and 'int'
> in (0,0) < 4.
> --8<-------------------------------------------------------->8---
>
> We would know which were the values that caused the problem, which would
> be very helpful.

In this example it would not help at all to know the actual values.
Knowing that you are trying to compare incomparable types is enough.

Re: how to discover what values produced an exception?

<method-20240504145813@ram.dialup.fu-berlin.de>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25460&group=comp.lang.python#25460

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: how to discover what values produced an exception?
Date: 4 May 2024 14:15:02 GMT
Organization: Stefan Ram
Lines: 36
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <method-20240504145813@ram.dialup.fu-berlin.de>
References: <8734qz9ey0.fsf@tudado.org> <exceptions-20240503152349@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de T6bbYBZcrNwm6YyY2mwMmAupunLO1SYSATsfdPjVyXg3BG
Cancel-Lock: sha1:AAvIF3dx8ULUakAv0u9By7F6aUs= sha256:CLylVsDbg2ljv0DpcyLkVDds7DV2yF+9R0Me2JQoJO4=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
 by: Stefan Ram - Sat, 4 May 2024 14:15 UTC

ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
>Sometimes you really need those values. If they're values of global
>names, you can kind of get them in the IDLE shell up to a point.

The way I see it, the issue here isn't just on Python,
the language - it's also on us, the coders! I mean, when
I define my own function, I can roll with something like:
def function( value ):
if value > 0:
return log( value )
else:
raise ZeroDivisionError( 'domain error' )

print( function( -1 ))

. Or I can go with something like this:

def function( value ):
if value > 0:
return log( value )
else:
message = 'domain error: '
message += '\nThe argument value was: '+ repr( value ) + '.'
message += '\nbut a value > 0 was expected.'
raise ZeroDivisionError( message )

print( function( -1 ))

. And you know what? The second option's gonna give you this output:

ZeroDivisionError: math domain error:
The argument value was: -1.
but a value > 0 was expected.

.

Re: how to discover what values produced an exception?

<ValueError-20240504154737@ram.dialup.fu-berlin.de>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25461&group=comp.lang.python#25461

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: how to discover what values produced an exception?
Date: 4 May 2024 14:47:52 GMT
Organization: Stefan Ram
Lines: 6
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <ValueError-20240504154737@ram.dialup.fu-berlin.de>
References: <8734qz9ey0.fsf@tudado.org> <exceptions-20240503152349@ram.dialup.fu-berlin.de> <method-20240504145813@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de T8C/oNsifib3vAULaR/7OAM7JbaHk7JorRGb5FEiMOl8km
Cancel-Lock: sha1:S98cCkx0kqtrUsQTYwqactaAQGs= sha256:DU7FF5akHbnInd0+kqq8gFmr2PnpZz0VTT3iY+W+txA=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
 by: Stefan Ram - Sat, 4 May 2024 14:47 UTC

ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
> raise ZeroDivisionError( 'domain error' )
....
> raise ZeroDivisionError( message )

I meant "ValueError", not "ZeroDivisionErrror"!

Re: how to discover what values produced an exception?

<mailman.5.1714841343.3326.python-list@python.org>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25462&group=comp.lang.python#25462

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: dieter.m...@online.de
Newsgroups: comp.lang.python
Subject: Re: how to discover what values produced an exception?
Date: Sat, 4 May 2024 18:24:29 +0200
Lines: 30
Message-ID: <mailman.5.1714841343.3326.python-list@python.org>
References: <8734qz9ey0.fsf@tudado.org>
<26166.24893.646556.142871@ixdm.fritz.box>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de EGZO7LDZs3o11vicDGQa+wbWIxlSJFVFUv1oIPkmysfA==
Cancel-Lock: sha1:rBfXIo5uSGhY90M+uLZUH8v7AKg= sha256:alm7V/WbAXp+8X0jUwhLfV3ldywGGuCahN0+cOGHrxs=
Return-Path: <dieter.maurer@online.de>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=online.de header.i=dieter.maurer@online.de
header.b=QwZumJeb; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'traceback': 0.04; '(most':
0.05; 'last):': 0.05; 'received:212.227': 0.07; 'cc:addr:python-
list': 0.09; 'received:212.227.126': 0.09; 'subject:how': 0.09;
'values.': 0.09; 'cc:no real name:2**0': 0.14; '>>>>': 0.16;
'subject:values': 0.16; 'subject:what': 0.16; 'python': 0.16;
'values': 0.17; 'bug': 0.19; 'cc:addr:python.org': 0.20;
'exception': 0.22; 'problem,': 0.22; 'code': 0.23; 'received:de':
0.23; 'cc:2**0': 0.25; 'thorough': 0.26; '"",': 0.32;
'received:kundenserver.de': 0.32; 'received:mout.kundenserver.de':
0.32; 'header:In-Reply-To:1': 0.34; 'fix': 0.36; 'cases': 0.36;
'source': 0.36; 'special': 0.37; 'received:192.168': 0.37; 'file':
0.38; 'could': 0.38; 'much.': 0.39; 'wrote': 0.39; 'something':
0.40; 'received:212': 0.62; 'involved': 0.63; 'required': 0.65;
'analysis': 0.69; 'discover': 0.80; 'typically,': 0.84; 'caused':
0.86
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=online.de;
s=s42582890; t=1714841340; x=1715446140; i=dieter.maurer@online.de;
bh=+6GJbPnrRdFvM9D4gXl/CJsChqP5HMYjnNve1RtjRTg=;
h=X-UI-Sender-Class:MIME-Version:Content-Type:
Content-Transfer-Encoding:Message-ID:Date:From:To:Cc:Subject:
In-Reply-To:References:cc:content-transfer-encoding:content-type:
date:from:message-id:mime-version:reply-to:subject:to;
b=QwZumJeb12dAsTjiYAAUDYzcxcxdLOvYwfQikpdp+dDEb7iWQV7R5RXUFrXU/4wo
Vsy2c/bM0JTNc6L4e2nYfRyaZ2lpzBKB3I6ZuF5cD+2OIpJJ0oAGopJHWlR9tMZeK
LZKic27D1CZBO39p+nbEqhVNgoGaqSFvhLqkmZSDbNC3fs2M7vOpVOXxE6lFI0JOz
uLzirPqtVKirI5AlGMboJMellTcM70rjXx3mHLwPIjFV//Ghrs7jnm0rp7kvWjFjU
Z3Xx15qULPF8GkMY8pyDxKxe8pRTKSDhQKbsmZnJLZZ5o5elvxSzy8vEtuPre3e58
D8/j/m1Wn22aazv1sg==
X-UI-Sender-Class: 6003b46c-3fee-4677-9b8b-2b628d989298
In-Reply-To: <8734qz9ey0.fsf@tudado.org>
X-Mailer: VM 8.0.12-devo-585 under 21.4 (patch 24) "Standard C" XEmacs Lucid
(x86_64-linux-gnu)
X-Provags-ID: V03:K1:aYz5fBM8+DvVCvGI4A3zZD2efh081cKjNe+VJT4y2otb4qvf/Ob
G/AbDLpI8VWfo5YkVPhO5GmU1yve7OfTBZKVe8hMCuKv8Vphj0WsoIm7JJRzeqsWDfj155e
D3ACUsUpT1lIpU9Uwriwvsx2t6MKDC5aTMxFj+QtALZvyyyadrncpyXXWCiA5ASmS6LlZGd
FCa2Xd0FG1kW/puW9/PyQ==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:3RtUg17sFbY=;DFLjbGfVliFrgXtId3A/EFoX63b
3oypxdYUCqpaqcVU0I7inPFql9FsoRA9rZ9vryNtG6NIpsLJUoJTQDxccnAx9URAZbZuvndw2
47LE3Lih3+DmJgZsN5p4XSHkZNC/xoUE75LGANDPBnqkuAO6pVsa15qj5SFxPzyb8zD0I2sLf
8Wy50uyXOh7kylSmhF2S1YjMrXkBAKSXVaIpe6MP7V9WhhbdiUZY4FgDAgu3kWUdEAadrN65I
Ucf4WTv0WhJ3yhE51SbizHl0OGUqKQK1pmIsbkbloR6HU9OVE5PK3XaQn5JR4CP0Z3MUyI0SF
h4PX4+KHBzoOXfIBWCfnELugY/sf0vFEWQAekyIDI1qFlHvD5vGogSqlTkbSAqxC7Rij/sfJB
3doMsUTNRo09ITKXYvO77MKCFIWykuPVg8eg3qzFxMtSRwme1YNtFicupeyNgyJRFuAHXKK+V
fPzPrkeU4pUxHr3qSwpS/TuiCNu6i6qPMVTr2foTlw6gH+AlLZfXI4h9Z4e8bvCWSfPHqNhzH
X3jZXuzbEEcL3hyIbsXQGu9NHLtPZ0zzDfl42+xi+z8maFz+5jpS+GZFLaxUpJn405UEaXroj
n2y5I+AC9RrK5eCEUJhDocaLwMO3+MxLzx65H1FqMlyJr+B2jvW0DBjcuQzkUVleEp6N87AfI
zxjq4Gik4drOJd0vRR1nvj1ykvZdlZrEK3d6bY0FtUvPweuik/STk+PmGq87bAcGgtSWxKtOV
ynantlvytWDouY/WA0uEVOtv5fLIf87gLXv0JInGH+y1XRUNjYSDLQ=
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <26166.24893.646556.142871@ixdm.fritz.box>
X-Mailman-Original-References: <8734qz9ey0.fsf@tudado.org>
 by: dieter.m...@online.de - Sat, 4 May 2024 16:24 UTC

Johanne Fairchild wrote at 2024-5-3 10:56 -0300:
>How to discover what values produced an exception? Or perhaps---why
>doesn't the Python traceback show the values involved in the TypeError?
>For instance:
>
>--8<-------------------------------------------------------->8---
>>>> (0,0) < 4
>Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
>TypeError: '<' not supported between instances of 'tuple' and 'int'
>--8<-------------------------------------------------------->8---
>
>It could have said something like:
>
>--8<-------------------------------------------------------->8---
>TypeError: '<' not supported between instances of 'tuple' and 'int'
> in (0,0) < 4.
>--8<-------------------------------------------------------->8---
>
>We would know which were the values that caused the problem, which would
>be very helpful.

Typically, the traceback informs you about the source code line
where the exception has been raised.
When the source line contains literals, you see the values.
If not, then only in special (speak: rather simple) cases the
knowledge of the values will help much.
Usually, a more thorough analysis is required to find out the bug
location and how to fix the bug.

Re: how to discover what values produced an exception?

<stopgag-20240504200742@ram.dialup.fu-berlin.de>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25463&group=comp.lang.python#25463

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: how to discover what values produced an exception?
Date: 4 May 2024 19:08:26 GMT
Organization: Stefan Ram
Lines: 15
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <stopgag-20240504200742@ram.dialup.fu-berlin.de>
References: <8734qz9ey0.fsf@tudado.org> <exceptions-20240503152349@ram.dialup.fu-berlin.de> <method-20240504145813@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de zrzmWc67oEQ5hlHQSLXGFwSz1xXwVtGDp1v4Wf9SdWKbh0
Cancel-Lock: sha1:jYgHATFDevl2IpHqq459ioZN4+s= sha256:gHoi3/cSS50EBPW6ax+OpMYWYBrhODTuCn3zbgBZcJc=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
 by: Stefan Ram - Sat, 4 May 2024 19:08 UTC

ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
>def function( value ):
> if value > 0:
> return log( value )
> else:
> raise ZeroDivisionError( 'domain error' )

Otherwise, I reckon the stopgap solution for dealing with those
"features" would be something like this . . .

try:
function( value )
except ValueError:
print( 'value =', value )
raise

Re: how to discover what values produced an exception?

<mailman.6.1714852629.3326.python-list@python.org>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25464&group=comp.lang.python#25464

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: 2QdxY4Rz...@potatochowder.com
Newsgroups: comp.lang.python
Subject: Re: how to discover what values produced an exception?
Date: Sat, 4 May 2024 15:33:00 -0400
Lines: 36
Message-ID: <mailman.6.1714852629.3326.python-list@python.org>
References: <8734qz9ey0.fsf@tudado.org>
<ZjaNbCKXwgqDOC8R@anomaly>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de U/m+gcItBuC3j7UqUXJsfAE4rLnWlOkOWKG6yaErtF3g==
Cancel-Lock: sha1:wJAuzhvLkYUYYLWzFN0dTO4pfsw= sha256:tDChsIwkIEXwsvbx0jOXZHj/F0dcsdMdyne4zQDNp1s=
Return-Path: <2QdxY4RzWzUUiLuE@potatochowder.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=potatochowder.com header.i=@potatochowder.com
header.b=gr608v3e; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'def': 0.04;
'traceback': 0.04; '(most': 0.05; 'last):': 0.05; 'cases.': 0.09;
'subject:how': 0.09; 'typeerror:': 0.09;
'from:addr:2qdxy4rzwzuuilue': 0.16; 'from:addr:potatochowder.com':
0.16; 'received:136.243': 0.16; 'received:172.58': 0.16;
'received:www458.your-server.de': 0.16; 'received:your-server.de':
0.16; 'refuse': 0.16; 'run-time': 0.16; 'subject:values': 0.16;
'subject:what': 0.16; 'useful.': 0.16; 'wrote:': 0.16; 'python':
0.16; 'values': 0.17; 'to:addr:python-list': 0.20; 'problem,':
0.22; 'received:de': 0.23; "isn't": 0.27; 'function': 0.27; '>>>':
0.28; 'printed': 0.28; "doesn't": 0.32; '"",': 0.32; 'python-
list': 0.32; 'received:136': 0.32; "i'm": 0.33; 'printing': 0.34;
'header:In-Reply-To:1': 0.34; 'those': 0.36; 'lists': 0.37;
"it's": 0.37; 'file': 0.38; 'could': 0.38; 'least': 0.39; 'safe':
0.39; 'something': 0.40; 'involved': 0.63; 'similar': 0.65;
'types': 0.67; 'knowing': 0.71; 'discover': 0.80; 'received:88':
0.84; 'caused': 0.86
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=potatochowder.com; s=default2305; h=In-Reply-To:Content-Type:MIME-Version:
References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc:
Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID;
bh=fWc7axUUHiBV+kb9rjkm7QuIg+tUXX0RzeE6l8VzP6k=; b=gr608v3eVWj8ZvOAcHACH5ztT6
3ZuXGtBNtmphLXBGQcIpUVz7Fe01xz6pE6NYWlM2pdPNc9zi5DX3BLMz5vpktgaiAfcpFpCcWH4h/
u2sar7ptcWDudCgisF4cwnJPRrC9R+accJiXubRDjv5tRMkf4jt9ZvhFFI7hVlVcSzk/5xSZZK9j+
ZDftlgwA6SR0tMauezEDHbfL75Kfk3Mkk4ZeHJgECENGbEyUWtqi/y4WYLHLQozxM2mCets8Yfork
N+miC28kLMWBv9MzOXspCBbUju3JviatYSpru3sAQDksfgBd7F1MGJFy99wFzzdVgiO+Lmcve/ioy
NHTwleKg==;
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <8734qz9ey0.fsf@tudado.org>
X-Authenticated-Sender: 2QdxY4RzWzUUiLuE@potatochowder.com
X-Virus-Scanned: Clear (ClamAV 0.103.10/27265/Sat May 4 10:23:33 2024)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <ZjaNbCKXwgqDOC8R@anomaly>
X-Mailman-Original-References: <8734qz9ey0.fsf@tudado.org>
 by: 2QdxY4Rz...@potatochowder.com - Sat, 4 May 2024 19:33 UTC

On 2024-05-03 at 10:56:39 -0300,
Johanne Fairchild via Python-list <python-list@python.org> wrote:

> How to discover what values produced an exception? Or perhaps---why
> doesn't the Python traceback show the values involved in the TypeError?
> For instance:
>
> --8<-------------------------------------------------------->8---
> >>> (0,0) < 4
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: '<' not supported between instances of 'tuple' and 'int'
> --8<-------------------------------------------------------->8---
>
> It could have said something like:
>
> --8<-------------------------------------------------------->8---
> TypeError: '<' not supported between instances of 'tuple' and 'int'
> in (0,0) < 4.
> --8<-------------------------------------------------------->8---
>
> We would know which were the values that caused the problem, which would
> be very helpful.

I'm not disagreeing that knowing the values could be useful in many
cases. In the general case, though, it's not practical. Consider a
function like this:

def f(x, y):
return g(x) < h(y)

The printed values of x, y, g(x), and h(y) could all be millions of (or
more) glyphs. Worse, one or more of those values could contain circular
lists or similar structures. And h or g could have changed x or y. In
summary, printing run-time values isn't always safe or useful. At least
printing the types is safe. In the face of ambiguity, refuse to guess.

Re: how to discover what values produced an exception?

<exceptions-20240504211223@ram.dialup.fu-berlin.de>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25466&group=comp.lang.python#25466

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: how to discover what values produced an exception?
Date: 4 May 2024 20:13:23 GMT
Organization: Stefan Ram
Lines: 14
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <exceptions-20240504211223@ram.dialup.fu-berlin.de>
References: <8734qz9ey0.fsf@tudado.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de kx95te4tPdlxA7z/vtthqAAXilNYcelOrhnDYN9fRdH4XH
Cancel-Lock: sha1:dswNWVslEFCS+Mc0CRZpSnlr0qg= sha256:6RgQPy18hnRxCk1n+8XShwbC7GV78s1nGZhAJQFFBrI=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
 by: Stefan Ram - Sat, 4 May 2024 20:13 UTC

Johanne Fairchild <jfairchild@tudado.org> wrote or quoted:
>We would know which were the values that caused the problem, which would
>be very helpful.

So, why don't critical values get automatically printed out when
exceptions happen?

In Python, printing out a value usually means calling a method
like "__str__" or "__repr__". But the thing is, the exception
could have been raised inside that very method. If you then try
to automatically print out a critical value, that could trigger
more exceptions or other issues. Basically, you could end up
activating all sorts of random code, and the consequences of
that in that kind of situation are hard to predict

Re: how to discover what values produced an exception?

<mailman.9.1715017020.3326.python-list@python.org>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25472&group=comp.lang.python#25472

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: olegsivo...@gmail.com (Left Right)
Newsgroups: comp.lang.python
Subject: Re: how to discover what values produced an exception?
Date: Fri, 3 May 2024 20:19:23 +0200
Lines: 39
Message-ID: <mailman.9.1715017020.3326.python-list@python.org>
References: <8734qz9ey0.fsf@tudado.org>
<CAJQBtgk77ix859ygnWW-Azr62pvpyJ4xzt5CevUQNL56jB6FLA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de LaiCVoEm4bpn2HFY87dfGAsUuKnOGJ/4i0AnjBZh/SIg==
Cancel-Lock: sha1:o8xsq4NS0JeFbKK0ePDYs8xbGdM= sha256:iP4bbljaiJjWFWXMY16wmM/jYapeUpu9y9ho4pzeH9M=
Return-Path: <olegsivokon@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=hmSjySld;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'generated': 0.03;
'traceback': 0.04; '(most': 0.05; 'error:': 0.05; 'last):': 0.05;
'environment,': 0.09; 'subject:how': 0.09; 'typeerror:': 0.09;
'url:mailman': 0.15; '(especially': 0.16; '(unless': 0.16; '2024':
0.16; 'examine': 0.16; 'subject:values': 0.16; 'subject:what':
0.16; 'tedious': 0.16; 'wrote:': 0.16; 'python': 0.16; 'values':
0.17; 'to:addr:python-list': 0.20; 'fri,': 0.22; 'problem,': 0.22;
'url-ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'url-ip:188.166/16': 0.25; 'local': 0.27;
'bit': 0.27; '>>>': 0.28; 'error': 0.29; 'url-ip:188/8': 0.31;
"doesn't": 0.32; '"",': 0.32; 'crazy': 0.32; 'extract': 0.32;
'python-list': 0.32; 'message-id:@mail.gmail.com': 0.32;
'printing': 0.34; 'work.': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35;
'errors': 0.36; 'really': 0.37; "it's": 0.37; 'file': 0.38;
'could': 0.38; 'error,': 0.38; 'quite': 0.39; 'something': 0.40;
'want': 0.40; 'try': 0.40; 'involved': 0.63; "you'd": 0.64;
'discover': 0.80; 'practical': 0.84; 'lose': 0.84; 'stack,': 0.84;
'caused': 0.86
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1714760374; x=1715365174; darn=python.org;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:from:to:cc:subject:date
:message-id:reply-to;
bh=qaLNsz1egBlwSVdXuP8OyokJpzvlh+vLv/VPd+ct28g=;
b=hmSjySldF3fCF7NduLm4BED6hVVTFT5L6bNpAmlrb7bsiWPn3R4ngWsxTcXFlaCxol
xTR4xjw8J0VKhEJXDlUx0s0EfaMP8sD0mokTqsMIAMJeGUJVhNz+wdlX7aWeGxtyRHuT
KZfv6wN6Hy8POyMJ+8OeDWK0Los0YcTaaWkuE9epeerjGza7Gofsg1Z8UdI3H5NSGNA5
cns/8XsgI/I1ZDp3zOy/8z9SPV7b78EP9uHFN7D4aQoeaA0EAKuXg6zqhxpQ6qe1p19A
FVoBHwOvqhnNRbYjpDctZnal87FixyFAWuOAqc+9u0uv5vQkbqK3O/UFmRsuoNxPVrUb
tKog==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1714760374; x=1715365174;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=qaLNsz1egBlwSVdXuP8OyokJpzvlh+vLv/VPd+ct28g=;
b=pOvFDSMUbNl+Q89P5PgMQABWOU0+zS90Szmdc1Fu2SCBT86In7d5vjIYm/bce1ZDhE
LtheSNojgS2dGrUOv3hpa4N7VOMWZsIPbLWFNtSKLGqrK5wumdSl/Edw9j49kZIhZMa/
i3v2x9AldV8WkxudcpN2cekfUY+67cjHoA0U68fV4jGe9ahZmYSDQMp6jPLMgkLGlMfH
NmFTDmqS6QaMmv3O4/ulPxTm5IDaWBxxz2cMEbDkHncgoFXsGwJOWy6XwvzcXZAuM5NU
0BqHQP6GgDuBuWnbVBeY2Bz7SRlgRRdp4ADdvMLsYynahqaXR6LC9183q4wNFhq1CSbE
YE6g==
X-Gm-Message-State: AOJu0YxoqnlqTTuYMyWMyUxvvZOI5zAXkczD3h+l1IcqM4ub953c2atO
5F2p3pdh5AegBTI1iKOQ24BYE5troi8KIEUT/0FxPD28gbO6c994HUWzhCn6TWw49ldhKvngKdr
DWAg2j11w3IX94EsYgc+BFuozzAvuHQ==
X-Google-Smtp-Source: AGHT+IE9gxHaeEM+hSin6atmo9jUkyKtjhjvAZa6es2TN10cPCAjZE3uwhbtzq6dGnudHNhdGOz5NN8/Q1IXn4S64i8=
X-Received: by 2002:a05:6122:4105:b0:4dc:fbc5:d47 with SMTP id
ce5-20020a056122410500b004dcfbc50d47mr3456088vkb.16.1714760374484; Fri, 03
May 2024 11:19:34 -0700 (PDT)
In-Reply-To: <8734qz9ey0.fsf@tudado.org>
X-Mailman-Approved-At: Mon, 06 May 2024 13:36:59 -0400
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAJQBtgk77ix859ygnWW-Azr62pvpyJ4xzt5CevUQNL56jB6FLA@mail.gmail.com>
X-Mailman-Original-References: <8734qz9ey0.fsf@tudado.org>
 by: Left Right - Fri, 3 May 2024 18:19 UTC

>From a practical perspective: not all values are printable (especially
if printing a value results in an error: then you'd lose the original
error, so, going crazy with printing of errors is usually not such a
hot idea).

But, if you want the values: you'd have to examine the stack, extract
the values from the local variables etc. It's easier to do this
interactively (unless you are in a multithreaded environment, where
pdb is broken). But, you could also try to find this information
automatically (by unwinding the stack to the place that generated the
error, examining the local variables etc.) It's tedious and prone to
errors. So, if you really want to do this automatically for every
error that's going to be quite a bit of work.

On Fri, May 3, 2024 at 6:58 PM Johanne Fairchild via Python-list
<python-list@python.org> wrote:
>
> How to discover what values produced an exception? Or perhaps---why
> doesn't the Python traceback show the values involved in the TypeError?
> For instance:
>
> --8<-------------------------------------------------------->8---
> >>> (0,0) < 4
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: '<' not supported between instances of 'tuple' and 'int'
> --8<-------------------------------------------------------->8---
>
> It could have said something like:
>
> --8<-------------------------------------------------------->8---
> TypeError: '<' not supported between instances of 'tuple' and 'int'
> in (0,0) < 4.
> --8<-------------------------------------------------------->8---
>
> We would know which were the values that caused the problem, which would
> be very helpful.
> --
> https://mail.python.org/mailman/listinfo/python-list

Re: how to discover what values produced an exception?

<mailman.10.1715017584.3326.python-list@python.org>

  copy mid

https://news.novabbs.com/devel/article-flat.php?id=25473&group=comp.lang.python#25473

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!rocksolid2!news.neodome.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: how to discover what values produced an exception?
Date: Tue, 7 May 2024 03:46:09 +1000
Lines: 12
Message-ID: <mailman.10.1715017584.3326.python-list@python.org>
References: <8734qz9ey0.fsf@tudado.org>
<918e3522-03e0-40e7-928d-bbf87698a7b3@tompassin.net>
<mailman.4.1714772954.3326.python-list@python.org>
<86r0eimq3c.fsf@williamsburg.bawden.org>
<CAPTjJmr9HVoZk8rrDL-1t3V4aCBn_L266UAzSOXOJjSZ8GGyiA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de ZrAePscVNqyu5jVC3SMLDwfHs+NfqMiKEQhMifQyFuZg==
Cancel-Lock: sha1:kSwLnxjdhkflS9MpesixXcj3QMU= sha256:xJOhdqjJoFcKIJ8oN/JL99+3fvtpJGCLHxGb063Xmzk=
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=a6DnkqP3;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'debugging': 0.07;
'included.': 0.07; "shouldn't": 0.09; 'solving': 0.09;
'subject:how': 0.09; '03:38,': 0.16; '2024': 0.16; 'chrisa': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'subject:values': 0.16; 'subject:what': 0.16; 'wrote:': 0.16;
'tue,': 0.19; 'to:addr:python-list': 0.20; 'error': 0.29; 'python-
list': 0.32; 'message-id:@mail.gmail.com': 0.32; 'there': 0.33;
'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'way': 0.38; 'could': 0.38; 'alan':
0.40; 'something': 0.40; 'here.': 0.61; 'easy': 0.74;
'emphasized': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1715017582; x=1715622382; darn=python.org;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc:subject:date:message-id:reply-to;
bh=BzfoRr0IySgviGLI7LUqZcUom28FkOVEjmWRnCxR8YA=;
b=a6DnkqP3sm5j6WP96paNMFkLcDkY1fWrO4og6SxBTQz5rwhp08ncxoOi0XqYa8Kwog
gLg1S242iWVOTOKBmTDST0QS474R+Qh05/2mhIbsau9TXCJF/B1sgIGKoj+qaiZn5Y76
hU/QfTs30LKASRWDpfQSECFYOJFR2f0Mb88k31tX6mP7gcO1hesi2lH+euOLlA2JWJP1
LXRn513F/Raq9wjzZMtFXV2e5Ep1N5UAMszojIrQ87rutvg1X0HO0KPlDmp4nqCo3+J+
O5gaa5X+00+ZtoID2mZb5Wb3tYhcMlZ5up+xHlhVlptc157UjuP9Pvaq2kaaKv4kxLy0
W7Bg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1715017582; x=1715622382;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=BzfoRr0IySgviGLI7LUqZcUom28FkOVEjmWRnCxR8YA=;
b=sfNKd8qITeie3QTIhOtvazG7RHYq40HR7s19KrI0BD8fNEvwAtsum+DYw+PT0K0qz6
sDy9Uso1QIDlvDZbuLNg9QdAzI8iv90KTbGFxml9nnDMBslqVOk/57Ay1K4JbWK8AKYQ
Y2iSNKUoIVvb01wRTP+dOfmCvx/l6vYmu193Jcr5c9nZuBlVYG7mCeySsdVDSLrhg5jy
0oUyNEBJEoCZbAXSkXKqlAxlVs3cy2Ioqt1joJUimTPpiCcDl4M5sJZ2uoj1/+In1or0
nWZtLXr/sB6AuRjpdUOi6/qOH5hw3V0tmjdqpax3SSpUFJubBNUbgWjKehTIX+GRVD9L
BPCA==
X-Gm-Message-State: AOJu0YxXgBGlvmx20WedUJSE6EM1i14ccptbxWTgIFcAETQA3l53nXVO
fL2XPz/Yd9jZ3FZpiPjJrG65ZpATx+TXrU4+2sjwq23dlDIu6BOrCrAuIgmf8mW/j/i+W52RYhd
/YwltitGUguP/64oEyoAWDAgA7SFnQQ==
X-Google-Smtp-Source: AGHT+IF5uqk2JLX+L28bvoJ3S8P+dUKDG3XfEuP3lynhVtW7bMlaXyOLqYjtnAN4J7tAlsjF4Bj6aUIEFlngaR4IMZc=
X-Received: by 2002:a05:6512:3a81:b0:51b:ab9f:6b5c with SMTP id
2adb3069b0e04-5210ff9e2a1mr129282e87.1.1715017581867; Mon, 06 May 2024
10:46:21 -0700 (PDT)
In-Reply-To: <86r0eimq3c.fsf@williamsburg.bawden.org>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmr9HVoZk8rrDL-1t3V4aCBn_L266UAzSOXOJjSZ8GGyiA@mail.gmail.com>
X-Mailman-Original-References: <8734qz9ey0.fsf@tudado.org>
<918e3522-03e0-40e7-928d-bbf87698a7b3@tompassin.net>
<mailman.4.1714772954.3326.python-list@python.org>
<86r0eimq3c.fsf@williamsburg.bawden.org>
 by: Chris Angelico - Mon, 6 May 2024 17:46 UTC

On Tue, 7 May 2024 at 03:38, Alan Bawden via Python-list
<python-list@python.org> wrote:
> A good error message shouldn't withhold any information that can
> _easily_ be included. Debugging is more art than science, so there is
> no real way to predict what information might prove useful in solving
> the crime. I emphasized "easily" because of course you have to draw the
> line somewhere.

Emphasis on "easily" is correct here. How easy is it to report the
value of something that could be arbitrarily large?

ChrisA


devel / comp.lang.python / Re: how to discover what values produced an exception?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor