Skip to content

Commit b05fb12

Browse files
committed
scripts/python/module/setup.py.in: try to actually catch warnings (e.g. DeprecationWarning) to use correct form of open() [networkupstools#3256]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent 9dd88ff commit b05fb12

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scripts/python/module/setup.py.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ import sys
1010

1111
here = os.path.abspath(os.path.dirname(__file__))
1212

13+
HAVE_WARNINGS = False
14+
try:
15+
import warnings
16+
warnings.filterwarnings("error")
17+
HAVE_WARNINGS = True
18+
except Exception as x:
19+
# sys.stderr.write("WARNING: failed to import warnings or configure them: %s" % str(x))
20+
pass
21+
1322
try:
1423
# NOTE: Deprecated as of python3.14
1524
import codecs
@@ -30,6 +39,9 @@ except Exception as x:
3039
HAVE_CODECS = False
3140
USE_CODECS = False
3241

42+
if HAVE_WARNINGS:
43+
warnings.resetwarnings()
44+
3345
# README.txt appears from README.adoc during package or CI build
3446
if USE_CODECS:
3547
with codecs.open(os.path.join(here, "README.txt"), encoding="utf-8") as fh:

0 commit comments

Comments
 (0)