Re: how to discover what values produced an exception?

Liste des GroupesRevenir à cl python 
Sujet : Re: how to discover what values produced an exception?
De : olegsivokon (at) *nospam* gmail.com (Left Right)
Groupes : comp.lang.python
Date : 03. May 2024, 19:19:23
Autres entêtes
Message-ID : <mailman.9.1715017020.3326.python-list@python.org>
References : 1 2
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

Date Sujet#  Auteur
3 May 24 * how to discover what values produced an exception?12Johanne Fairchild
3 May 24 +* Re: how to discover what values produced an exception?4Stefan Ram
4 May 24 i`* Re: how to discover what values produced an exception?3Stefan Ram
4 May 24 i +- Re: how to discover what values produced an exception?1Stefan Ram
4 May 24 i `- Re: how to discover what values produced an exception?1Stefan Ram
3 May 24 +* Re: how to discover what values produced an exception?3Thomas Passin
4 May 24 i`* Re: how to discover what values produced an exception?2Alan Bawden
6 May 24 i `- Re: how to discover what values produced an exception?1Chris Angelico
4 May 24 +- Re: how to discover what values produced an exception?1dieter.maurer
4 May 24 +- Re: how to discover what values produced an exception?12QdxY4RzWzUUiLuE
4 May 24 +- Re: how to discover what values produced an exception?1Stefan Ram
3 May 24 `- Re: how to discover what values produced an exception?1Left Right

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal