This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Change use of warnings.warn to logging.warning in a few places
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: andrei.avk, eric.araujo, rhettinger
Priority: low Keywords:

Created on 2021-12-13 22:45 by andrei.avk, last changed 2022-04-11 14:59 by admin.

Messages (5)
msg408488 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-12-13 22:45
In discussion on https://github.com/python/cpython/pull/29910 related to whether to use warnings.warn or logging.warning, I found two places in the library where it might make sense to change to logging.warning. There's probably other instances where the same change can be made but it's not easy to tell just by going through the list because the difference of when use one or the other is not always clearcut. If more instances are found, they can be added to this issue.

https://docs.python.org/3/howto/logging.html#when-to-use-logging

https://github.com/python/cpython/blob/eb483c46d62707bdf705491f76cf1fa9642fb47e/Lib/zoneinfo/_tzpath.py#L44

https://github.com/python/cpython/blob/f42a06ba279c916fb67289e47f9bc60dc5dee4ee/Lib/zipfile.py#L1480

The downside of making this change is that it may break 3rd party unit tests.
msg408513 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-12-14 01:45
> The downside of making this change is that it may break 3rd party unit tests.

I don’t see any upside.  The modules in question have been stable for a good while.  There’s no benefit to changing them. 

Also, there is no strong agreement that the standard library should ever prefer logging.warning() over the warnings module which has mechanisms for filtering the warnings, escalating them to errors, or limiting the number of times they are reported.
msg408668 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-12-16 02:14
Raymond: Makes sense; I didn't know there was disagreement about this. I will keep this issue open for a week and then close.
msg408806 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2021-12-17 18:46
To have a discussion about this, you should open a thread on discuss.
msg408863 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-12-18 17:45
https://discuss.python.org/t/logging-warning-vs-warnings-warn/12625/2
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90226
2021-12-18 17:45:18andrei.avksetmessages: + msg408863
2021-12-17 18:46:19eric.araujosetnosy: + eric.araujo
messages: + msg408806
2021-12-16 02:14:51andrei.avksetmessages: + msg408668
2021-12-14 01:45:39rhettingersetmessages: + msg408513
2021-12-14 01:44:08rhettingersetmessages: - msg408512
2021-12-14 01:39:54rhettingersetnosy: + rhettinger
messages: + msg408512
2021-12-13 22:45:11andrei.avkcreate