From 166ee6fee9c5e2356605e89abf72c23f3bd0cb74 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 28 Oct 2024 11:41:15 +0100 Subject: [PATCH] Python bindings: __init__.py: remove calls to warnings.simplefilter() Fixes #11140 This changes the global warnings configuration, which is not appropriate to do inside a library. --- swig/python/osgeo/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/swig/python/osgeo/__init__.py b/swig/python/osgeo/__init__.py index f746a86456ec..f5e090cf0370 100644 --- a/swig/python/osgeo/__init__.py +++ b/swig/python/osgeo/__init__.py @@ -93,8 +93,7 @@ def ver_str(ver): if fail_on_unsupported_version: raise Exception(msg) else: - from warnings import warn, simplefilter - simplefilter('always', DeprecationWarning) + from warnings import warn warn(msg, DeprecationWarning) elif this_python_version_will_be_deprecated_in_gdal_version: msg = 'You are using Python {} with GDAL {}. ' \ @@ -106,6 +105,5 @@ def ver_str(ver): ver_str(next_version_of_gdal_will_use_python_version), ver_str(this_python_version_will_be_deprecated_in_gdal_version)) - from warnings import warn, simplefilter - simplefilter('always', DeprecationWarning) + from warnings import warn warn(msg, DeprecationWarning)