-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Hi,
I tried to use a script using requests (v2.18.1) on a remote website without having any internet connectivity. Of course, this resulted in a long stack traces due to the absence of internet connectivity, as expected, which ended up with
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='updates.weboob.org', port=443): Max retries exceeded with url: /1.3/main/modules.list (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fe5f7474be0>: Failed to establish a new connection: [Errno -2] Name or service not known',))
Problem is that I catch any such exception and pass them to traceback.format_exc in order to have a nice error formatting in my logs.
Expected Result
Using something like
try:
my_code_calling_requests()
except Exception as e:
log.error(("Unknown exception raised: %s" % traceback.format_exc(e)))
I would have expected a nicely formatted exception in my logs.
Actual Result
Actually, it raised another exception, which I am not 100% sure to understand :/ Full traceback is:
Traceback (most recent call last):
File "MY_CODE", line 363, in <module>
traceback.format_exc(e)),
File "/usr/lib/python3.6/traceback.py", line 163, in format_exc
return "".join(format_exception(*sys.exc_info(), limit=limit, chain=chain))
File "/usr/lib/python3.6/traceback.py", line 117, in format_exception
type(value), value, tb, limit=limit).format(chain=chain))
File "/usr/lib/python3.6/traceback.py", line 486, in __init__
_seen=_seen)
File "/usr/lib/python3.6/traceback.py", line 486, in __init__
_seen=_seen)
File "/usr/lib/python3.6/traceback.py", line 486, in __init__
_seen=_seen)
File "/usr/lib/python3.6/traceback.py", line 497, in __init__
capture_locals=capture_locals)
File "/usr/lib/python3.6/traceback.py", line 332, in extract
if limit >= 0:
TypeError: '>=' not supported between instances of 'ConnectionError' and 'int'
System Information
{
"chardet": {
"version": "3.0.4"
},
"cryptography": {
"version": "1.9"
},
"implementation": {
"name": "CPython",
"version": "3.6.1"
},
"platform": {
"release": "4.11.7-1-ARCH",
"system": "Linux"
},
"pyOpenSSL": {
"openssl_version": "1010006f",
"version": "17.0.0"
},
"requests": {
"version": "2.18.1"
},
"system_ssl": {
"version": "1010006f"
},
"urllib3": {
"version": "1.21.1"
},
"using_pyopenssl": true
}
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels