Eliminate warning from new releases

I would like to encourage all Python committers to occasionally set the following environment variables

PYTHONDEVMODE=1
PYTHONUTF8=1
PYTHONWARNDEFAULTENCODING=1
PYTHONWARNINGS=default

when testing their releases, and endeavour to remove all warnings from their code, and to encourage the maintainers of the packages they require to do the same.

When I use these settings, a simple py -m pip list on Windows 10 with Python 3.12.3, I see these warnings (edited for brevity):

> py -m pip list
.\venv\Lib\site-packages\pip\_internal\configuration.py:284: EncodingWarning: UTF-8 Mode affects locale.getpreferredencoding(). Consider locale.getencoding() instead.
  locale_encoding = locale.getpreferredencoding(False)
.\venv\Lib\site-packages\pip\_internal\configuration.py:284: EncodingWarning: UTF-8 Mode affects locale.getpreferredencoding(). Consider locale.getencoding() instead.
  locale_encoding = locale.getpreferredencoding(False)
.\venv\Lib\site-packages\pip\_internal\metadata\importlib\_envs.py:111: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pip._vendor.pkg_resources import find_distributions
Package           Version
...

This doesn’t fit the purpose of the Ideas category. Moving to the general help/discussion section.

If you want to submit a PR to pip addressing these warnings, I’m sure it would be appreciated. Be aware, however, that pip supports Python back to version 3.7, so fixing the warnings without breaking pip on older versions of Python might be trickier than you imagine at first glance… :wink:

1 Like