Skip to content

Commit 54c9e42

Browse files
committed
scripts/augeas/gen-nutupsconf-aug.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 9bd31ff commit 54c9e42

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scripts/augeas/gen-nutupsconf-aug.py.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ import os
2727
import re
2828
import glob
2929

30+
HAVE_WARNINGS = False
31+
try:
32+
import warnings
33+
warnings.filterwarnings("error")
34+
HAVE_WARNINGS = True
35+
except Exception as x:
36+
# sys.stderr.write("WARNING: failed to import warnings or configure them: %s" % str(x))
37+
pass
38+
3039
try:
3140
# NOTE: Deprecated as of python3.14
3241
import codecs
@@ -47,6 +56,9 @@ except Exception as x:
4756
HAVE_CODECS = False
4857
USE_CODECS = False
4958

59+
if HAVE_WARNINGS:
60+
warnings.resetwarnings()
61+
5062
# Return a sorted list of unique entries, based on the input 'list'
5163
def sortUnique(list):
5264
newVarList = []

0 commit comments

Comments
 (0)