Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Plastic gun. Ingenious. More coffee, please." -- The Phantom comics


devel / comp.lang.python / Re: getting source code line of error?

SubjectAuthor
* getting source code line of error?Ulli Horlacher
`* Re: getting source code line of error?Marco Sulla
 `* Re: getting source code line of error?Stefan Ram
  `* Re: getting source code line of error?Stefan Ram
   `* Re: getting source code line of error?Ulli Horlacher
    +- Re: getting source code line of error?Stefan Ram
    `- Re: getting source code line of error?Paolo G. Cantore

1
getting source code line of error?

<sn845l$pc1$1@news2.informatik.uni-stuttgart.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.enyo.de!news.uni-stuttgart.de!.POSTED!not-for-mail
From: frams...@rus.uni-stuttgart.de (Ulli Horlacher)
Newsgroups: comp.lang.python
Subject: getting source code line of error?
Date: Fri, 19 Nov 2021 12:09:26 +0000 (UTC)
Organization: University of Stuttgart, FRG
Lines: 27
Message-ID: <sn845l$pc1$1@news2.informatik.uni-stuttgart.de>
X-Trace: news2.informatik.uni-stuttgart.de 1637323766 25985 129.69.1.129 (19 Nov 2021 12:09:26 GMT)
X-Complaints-To: news@news.uni-stuttgart.de
NNTP-Posting-Date: Fri, 19 Nov 2021 12:09:26 +0000 (UTC)
User-Agent: tin/2.4.5-20200522 ("Millburn") (Linux/5.4.0-90-generic (x86_64))
 by: Ulli Horlacher - Fri, 19 Nov 2021 12:09 UTC

I am trying to get the source code line of the last error.
I know traceback.format_exc() but this contains much more information, e.g.:

Traceback (most recent call last):
File "./error.py", line 18, in main
x=1/0
ZeroDivisionError: division by zero

I could extract the source code line with re.search(), but is there an
easier way?

I have:

exc_type,exc_str,exc_tb = sys.exc_info()
fname = exc_tb.tb_frame.f_code.co_filename
line = exc_tb.tb_lineno
print('%s in %s line %d' % (exc_str,fname,line))

But I also want to output the line itself, not only its number.

--
Ullrich Horlacher Server und Virtualisierung
Rechenzentrum TIK
Universitaet Stuttgart E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a Tel: ++49-711-68565868
70569 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/

Re: getting source code line of error?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: Marco.Su...@gmail.com (Marco Sulla)
Newsgroups: comp.lang.python
Subject: Re: getting source code line of error?
Date: Fri, 19 Nov 2021 20:13:52 +0100
Lines: 34
Message-ID: <mailman.51.1637349272.19479.python-list@python.org>
References: <sn845l$pc1$1@news2.informatik.uni-stuttgart.de>
<CABbU2U8xXY29rA3GBCPOVkJak7M3Tm0QK5FdDerCSvxeO=oX2w@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de Xx1cMDBZJQqvaLmbwkKM3wxpv7luuPYqWRHIXVlr8Q2g==
Return-Path: <elbarbun@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=KUPO12YF;
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; 'subject:error': 0.07; '18,': 0.09;
'itself,': 0.09; 'received:209.85.219': 0.09; 'url:de': 0.09;
'way?': 0.09; 'url:mailman': 0.15; 'division': 0.16;
'from:name:marco sulla': 0.16; 'subject:code': 0.16;
'subject:source': 0.16; 'url-ip:129/8': 0.16; 'wrote:': 0.16;
'to:addr:python-list': 0.20; 'fri,': 0.22; 'code': 0.23; '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; 'tried': 0.26;
'output': 0.28; 'module': 0.31; 'url-ip:188/8': 0.31; 'extract':
0.32; 'zero': 0.32; 'message-id:@mail.gmail.com': 0.32; 'but':
0.32; 'there': 0.33; 'server': 0.33; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'trying': 0.35;
'from:addr:gmail.com': 0.35; 'source': 0.36; 'main': 0.37;
'received:209.85': 0.37; 'file': 0.38; 'could': 0.38;
'received:209': 0.39; 'want': 0.40; 'format': 0.62; 'skip:z 10':
0.62; 'skip:t 20': 0.66; 'skip:e 20': 0.67; 'tel:': 0.68; '2021':
0.71; 'und': 0.76; 'e-mail:': 0.88; 'number.': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=aJvKworlV6VMRzYrjEWWEQhiRHZYl1Qy+AlYODT/YwM=;
b=KUPO12YF/itNtmERub/nwbIsigXu5hEKsaTvYJOKkxjAQv9e9IA0COVTUQQG7FMfXh
WFVG2dGcL3q43ewcJT/ZmVnmwB6ESdbI2lBpH2fbmBzbvqTfM4t2TvgChFvf9AASakhX
ZCm19hWPO/SmICHFlIZ/lYI1tEmTMieNNeoI7g0p1PH+NuR2uk+ZeAa8UcDCOkH7M0dS
/rLXD0YHAAF0n2LME0K5tKPX8xXueR1x4arLa10mS+KPDFQKX5zYqS1T5q0B6c1NDJxi
gxtUSmfOv5O+GyyWYWGBPo7qK/tntFvmTfevwurXF0NQaEQZCWURi9KsxNTI1E+gDcRv
Qt/Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=aJvKworlV6VMRzYrjEWWEQhiRHZYl1Qy+AlYODT/YwM=;
b=igMLa4pNh0gFCru/AMyF5QfrrJsGK6gfRub7NMWxU/KSuHyuwFZCX92empHOIlJOtt
Y/iR/vaeyQ9EjvPRoE7IXDN9ltGpWjcaMwzv896xbu+qPSrwZBjojaK7vHnLrFQjt4mV
Ki0cV25mUkBiMa8E/GGFqDYpBtuHsFz5jtT0fMDk7fBxaLxDTc9mokDUpd6BebVqtWZX
UPF+Ji9KjHFVHKVsZ0JTawypmjOqGTGhHKbLf9RpRbSxcw3ViQMMLT6kk417l7ps1Peb
oYCsfA3bATrmv7bJonSq+FirJKmWgDatonZB4wSLxYDwLDZ6TdZM5uSt1OqcyDZlbylj
kGMg==
X-Gm-Message-State: AOAM531OmTsjC1I9LlKu41hhPdLJ6ZZ4ta7xxgPB+P7qtym7EYEa1GTy
45l292FfxNvbQCsBAOE+Xv25R9zPfBNawyScwxYkokul
X-Google-Smtp-Source: ABdhPJz38zk49Cw52nL5DeEZtlJB/yVgBHM2PmOrBxMr8YCHn1Xqx4MHWe/9+nh9sWQ97Ih2h0/2iCjmkhXqNOzNzMg=
X-Received: by 2002:a5b:d41:: with SMTP id f1mr39079219ybr.447.1637349269678;
Fri, 19 Nov 2021 11:14:29 -0800 (PST)
In-Reply-To: <sn845l$pc1$1@news2.informatik.uni-stuttgart.de>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.37
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: <CABbU2U8xXY29rA3GBCPOVkJak7M3Tm0QK5FdDerCSvxeO=oX2w@mail.gmail.com>
X-Mailman-Original-References: <sn845l$pc1$1@news2.informatik.uni-stuttgart.de>
 by: Marco Sulla - Fri, 19 Nov 2021 19:13 UTC

Have you tried the logger module and the format options?

On Fri, 19 Nov 2021 at 19:09, Ulli Horlacher
<framstag@rus.uni-stuttgart.de> wrote:
>
> I am trying to get the source code line of the last error.
> I know traceback.format_exc() but this contains much more information, e.g.:
>
> Traceback (most recent call last):
> File "./error.py", line 18, in main
> x=1/0
> ZeroDivisionError: division by zero
>
> I could extract the source code line with re.search(), but is there an
> easier way?
>
>
> I have:
>
> exc_type,exc_str,exc_tb = sys.exc_info()
> fname = exc_tb.tb_frame.f_code.co_filename
> line = exc_tb.tb_lineno
> print('%s in %s line %d' % (exc_str,fname,line))
>
> But I also want to output the line itself, not only its number.
>
> --
> Ullrich Horlacher Server und Virtualisierung
> Rechenzentrum TIK
> Universitaet Stuttgart E-Mail: horlacher@tik.uni-stuttgart.de
> Allmandring 30a Tel: ++49-711-68565868
> 70569 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/
> --
> https://mail.python.org/mailman/listinfo/python-list

Re: getting source code line of error?

<traceback-20211119203816@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: getting source code line of error?
Date: 19 Nov 2021 19:39:28 GMT
Organization: Stefan Ram
Lines: 21
Expires: 1 Mar 2022 11:59:58 GMT
Message-ID: <traceback-20211119203816@ram.dialup.fu-berlin.de>
References: <sn845l$pc1$1@news2.informatik.uni-stuttgart.de> <CABbU2U8xXY29rA3GBCPOVkJak7M3Tm0QK5FdDerCSvxeO=oX2w@mail.gmail.com> <mailman.51.1637349272.19479.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de mQVn4R5Ipl9NMhZF72ORgQdOgbT+jPhxUq5WqZJdXzgc67
X-Copyright: (C) Copyright 2021 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
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Fri, 19 Nov 2021 19:39 UTC

Marco Sulla <Marco.Sulla.Python@gmail.com> writes:
>Have you tried the logger module and the format options?

source code:

import traceback

try:
1/0
except Exception as inst:
print( traceback.format_exc() )

output:

Traceback (most recent call last):
File "main.py", line 4, in <module>
1/0
ZeroDivisionError: division by zero

Re: getting source code line of error?

<lineno-20211120195208@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.uzoreto.com!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: getting source code line of error?
Date: 20 Nov 2021 18:52:45 GMT
Organization: Stefan Ram
Lines: 20
Expires: 1 Mar 2022 11:59:58 GMT
Message-ID: <lineno-20211120195208@ram.dialup.fu-berlin.de>
References: <sn845l$pc1$1@news2.informatik.uni-stuttgart.de> <CABbU2U8xXY29rA3GBCPOVkJak7M3Tm0QK5FdDerCSvxeO=oX2w@mail.gmail.com> <mailman.51.1637349272.19479.python-list@python.org> <traceback-20211119203816@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 Re999nwqiJuKu8zxcC2LYwma+oKhHwiOVI+qDwD8OVGTVG
X-Copyright: (C) Copyright 2021 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
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Sat, 20 Nov 2021 18:52 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>except Exception as inst:
> print( traceback.format_exc() )

More to the point of getting the line number:

import sys
import traceback

try:
1/0
except ZeroDivisionError as exception:
_, _, exc_traceback = sys.exc_info()
print( exc_traceback.tb_lineno )
traceback = traceback.TracebackException.from_exception( exception )
print( traceback.stack[ 0 ].lineno )

.

Re: getting source code line of error?

<snbhgk$kqd$1@news2.informatik.uni-stuttgart.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.enyo.de!news.uni-stuttgart.de!.POSTED!not-for-mail
From: frams...@rus.uni-stuttgart.de (Ulli Horlacher)
Newsgroups: comp.lang.python
Subject: Re: getting source code line of error?
Date: Sat, 20 Nov 2021 19:15:32 +0000 (UTC)
Organization: University of Stuttgart, FRG
Lines: 21
Message-ID: <snbhgk$kqd$1@news2.informatik.uni-stuttgart.de>
References: <sn845l$pc1$1@news2.informatik.uni-stuttgart.de> <CABbU2U8xXY29rA3GBCPOVkJak7M3Tm0QK5FdDerCSvxeO=oX2w@mail.gmail.com> <mailman.51.1637349272.19479.python-list@python.org> <traceback-20211119203816@ram.dialup.fu-berlin.de> <lineno-20211120195208@ram.dialup.fu-berlin.de>
X-Trace: news2.informatik.uni-stuttgart.de 1637435732 21325 129.69.1.129 (20 Nov 2021 19:15:32 GMT)
X-Complaints-To: news@news.uni-stuttgart.de
NNTP-Posting-Date: Sat, 20 Nov 2021 19:15:32 +0000 (UTC)
User-Agent: tin/2.4.5-20200522 ("Millburn") (Linux/5.4.0-90-generic (x86_64))
 by: Ulli Horlacher - Sat, 20 Nov 2021 19:15 UTC

Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> ram@zedat.fu-berlin.de (Stefan Ram) writes:
> >except Exception as inst:
> > print( traceback.format_exc() )
>
> More to the point of getting the line number:

As I wrote in my initial posting:
I already have the line number. I am looking for the source code line!

So far I use:

m = re.search(r'\n\s*(.+)\n.*\n$',traceback.format_exc())
if m: print('%s %s' % (prefix,m.group(1)))

--
Ullrich Horlacher Server und Virtualisierung
Rechenzentrum TIK
Universitaet Stuttgart E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a Tel: ++49-711-68565868
70569 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/

Re: getting source code line of error?

<Traceback-20211121001316@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: getting source code line of error?
Date: 20 Nov 2021 23:15:09 GMT
Organization: Stefan Ram
Lines: 34
Expires: 1 Mar 2022 11:59:58 GMT
Message-ID: <Traceback-20211121001316@ram.dialup.fu-berlin.de>
References: <sn845l$pc1$1@news2.informatik.uni-stuttgart.de> <CABbU2U8xXY29rA3GBCPOVkJak7M3Tm0QK5FdDerCSvxeO=oX2w@mail.gmail.com> <mailman.51.1637349272.19479.python-list@python.org> <traceback-20211119203816@ram.dialup.fu-berlin.de> <lineno-20211120195208@ram.dialup.fu-berlin.de> <snbhgk$kqd$1@news2.informatik.uni-stuttgart.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de iP955QGbmqCx2Isg6N9PSA0Hpe4vJqll1c+aZ1wNJUbewE
X-Copyright: (C) Copyright 2021 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
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Sat, 20 Nov 2021 23:15 UTC

Ulli Horlacher <framstag@rus.uni-stuttgart.de> writes:
>Stefan Ram <ram@zedat.fu-berlin.de> wrote:
>>ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>>except Exception as inst:
>>>print( traceback.format_exc() )
>>More to the point of getting the line number:
>As I wrote in my initial posting:
>I already have the line number. I am looking for the source code line!

Sorry, that would be (might require Python 3.5 or later):

import traceback

try:
1/0
except ZeroDivisionError as exception:
traceback = traceback.TracebackException.from_exception( exception )
print( traceback.stack[ 0 ].line )

traceback.TracebackException.from_exception captures
attributes from an exception to an object of the class
traceback.TracebackException while ensuring that no
references are held.

traceback.stack is a StackSummary, which is a subclass
of the class list.

traceback.stack[ 0 ] is a FrameSummary object containing the
attributes "filename", "lineno", "name", and "line" representing
the information that is usually printed for a stack trace.
The line is a string with leading and trailing whitespace stripped;
if the source is not available it is None.

Re: getting source code line of error?

<snbvr3$j4m$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: paolo.ca...@t-online.de (Paolo G. Cantore)
Newsgroups: comp.lang.python
Subject: Re: getting source code line of error?
Date: Sun, 21 Nov 2021 00:20:02 +0100
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <snbvr3$j4m$1@dont-email.me>
References: <sn845l$pc1$1@news2.informatik.uni-stuttgart.de>
<CABbU2U8xXY29rA3GBCPOVkJak7M3Tm0QK5FdDerCSvxeO=oX2w@mail.gmail.com>
<mailman.51.1637349272.19479.python-list@python.org>
<traceback-20211119203816@ram.dialup.fu-berlin.de>
<lineno-20211120195208@ram.dialup.fu-berlin.de>
<snbhgk$kqd$1@news2.informatik.uni-stuttgart.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 20 Nov 2021 23:20:03 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="fdd8338b8981cab3131fef37f15030de";
logging-data="19606"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+k+VX1JrmElg4DuN6n3vRuy0kUdxRqtIk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:XPWEvK+oZmoF7SeIR8HuRCsAYPQ=
In-Reply-To: <snbhgk$kqd$1@news2.informatik.uni-stuttgart.de>
Content-Language: de-DE
 by: Paolo G. Cantore - Sat, 20 Nov 2021 23:20 UTC

Am 20.11.21 um 20:15 schrieb Ulli Horlacher:
> Stefan Ram <ram@zedat.fu-berlin.de> wrote:
>> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>> except Exception as inst:
>>> print( traceback.format_exc() )
>>
>> More to the point of getting the line number:
>
> As I wrote in my initial posting:
> I already have the line number. I am looking for the source code line!
>
> So far I use:
>
> m = re.search(r'\n\s*(.+)\n.*\n$',traceback.format_exc())
> if m: print('%s %s' % (prefix,m.group(1)))
>
Stefan Ram's solution missed only the line content. Here it is.

import sys
import traceback

try:
1/0
except ZeroDivisionError as exception:
tr = traceback.TracebackException.from_exception( exception )
x = tr.stack[0]
print("Exception %s in line %s: %s" % (exception, x.lineno, x.line))

The traceback object does not only contain the lineno but also the
content of the offending line.

--------------
Paolo

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor