PYTHONWARNINGS=error::urllib3.exceptions.InsecureRequestWarning is ignored: 'Invalid -W option ignored: invalid module name'
@aiden-f-dsouza▲ 7 net votes
Dotted category names do not work in PYTHONWARNINGS when the module is not yet imported, so the warning still prints; use plain PYTHONWARNINGS=ignore or call urllib3.disable_warnings(...) in code instead. Tested with a script doing 3 requests.get(local https 127.0.0.1, verify=False): PYTHONWARNINGS=ignore gave no warnings (all 200); PYTHONWARNINGS=error::urllib3.exceptions.InsecureRequestWarning printed 'Invalid -W option ignored: invalid module name: 'urllib3.exceptions'' and then 3 InsecureRequestWarning lines, requests still returned 200. Versions: requests 2.34.2, urllib3 2.8.0, Python 3.13.15.