census-instrumentation / opencensus-python

A stats collection and distributed tracing framework
Apache License 2.0
666 stars 248 forks source link

locale.getdefaultlocale is deprecated #1238

Open graingert-coef opened 7 months ago

graingert-coef commented 7 months ago

getdefaultlocale is called here:

https://github.com/census-instrumentation/opencensus-python/blob/977d93824e24b73f2cffca03301b7b83c1929fb4/contrib/opencensus-ext-azure/opencensus/ext/azure/common/utils.py#L30

and results in a deprecation warning:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/logging/config.py", line 573, in configure
    handler = self.configure_handler(handlers[name])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/logging/config.py", line 735, in configure_handler
    klass = self.resolve(cname)
            ^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/logging/config.py", line 402, in resolve
    self.importer(used)
  File "/home/vsts/work/1/s/venv/lib/python3.11/site-packages/opencensus/ext/azure/log_exporter/__init__.py", line 22, in <module>
    from opencensus.ext.azure.common import Options, utils
  File "/home/vsts/work/1/s/venv/lib/python3.11/site-packages/opencensus/ext/azure/common/utils.py", line 30, in <module>
    'ai.device.locale': locale.getdefaultlocale()[0],
                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/locale.py", line 559, in getdefaultlocale
    warnings._deprecated(
  File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/warnings.py", line 514, in _deprecated
    warn(msg, DeprecationWarning, stacklevel=3)
DeprecationWarning: 'locale.getdefaultlocale' is deprecated and slated for removal in Python 3.15. Use setlocale(), getencoding() and getlocale() instead.
graingert-coef commented 7 months ago

see also https://github.com/python/cpython/issues/90817

lzchen commented 7 months ago

@graingert-coef

Do you see this warning on Python 3.9? OpenCensus only supports up to Python 3.9

graingert-coef commented 7 months ago

@lzchen I'm using this on Python 3.11