Deutsch English Français Italiano |
<mailman.9.1715017020.3326.python-list@python.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Left Right <olegsivokon@gmail.com> 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> Bytes: 6825 >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=E2=80=AFPM 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