Skip to content

Commit a263897

Browse files
committed
Regexes use raw strings
Python 3.12 is less accepting than earlier pythons, and reports warnings if questionable-looking escapes are passed to it. That exposed the problem addressed here
1 parent 5b85ec1 commit a263897

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

gnuplotlib.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ def _getGnuplotFeatures():
11901190
out = subprocess.check_output((gnuplot_executable, '-e', "set view equal"),
11911191
stderr=subprocess.STDOUT,
11921192
env=env).decode()
1193-
if re.search("(undefined variable)|(unrecognized option)", out, re.I):
1193+
if re.search(r"(undefined variable)|(unrecognized option)", out, re.I):
11941194
equal_3d_works = False
11951195
except:
11961196
equal_3d_works = False
@@ -1241,7 +1241,7 @@ def is_gp():
12411241
h = processOptions.get('hardcopy')
12421242
return \
12431243
type(h) is str and \
1244-
re.match(".*\.gp$", h)
1244+
re.match(r".*\.gp$", h)
12451245
return \
12461246
processOptions.get('dump') or \
12471247
processOptions.get('terminal') == 'gp' or \
@@ -1409,7 +1409,7 @@ def _massageSubplotOptionsAndGetCmds(subplotOptions):
14091409

14101410
# This axis was set up with the 'set' plot option, so I don't touch
14111411
# it
1412-
if any ( re.match(" *set +{}range[\s=]".format(axis), s) for s in cmds ):
1412+
if any ( re.match(r" *set +{}range[\s=]".format(axis), s) for s in cmds ):
14131413
continue
14141414

14151415
# images generally have the origin at the top-left instead of the
@@ -1561,7 +1561,7 @@ def _startgnuplot(self):
15611561
# What is the default terminal?
15621562
self._printGnuplotPipe( "show terminal\n" )
15631563
errorMessage, warnings = self._checkpoint('printwarnings')
1564-
m = re.match("terminal type is +(.+?) +", errorMessage, re.I)
1564+
m = re.match(r"terminal type is +(.+?) +", errorMessage, re.I)
15651565
if m:
15661566
self.terminal_default = m.group(1)
15671567
else:
@@ -1740,10 +1740,10 @@ def _checkpoint(self, flags=''):
17401740
# yet arrived. I thus print out a checkpoint message and keep reading the
17411741
# child's STDERR pipe until I get that message back. Any errors would have
17421742
# been printed before this
1743-
waitforever = re.search('waitforever', flags)
1744-
final = re.search('final', flags)
1745-
printwarnings = re.search('printwarnings', flags)
1746-
ignore_known_test_failures = re.search('ignore_known_test_failures', flags)
1743+
waitforever = re.search(r'waitforever', flags)
1744+
final = re.search(r'final', flags)
1745+
printwarnings = re.search(r'printwarnings', flags)
1746+
ignore_known_test_failures = re.search(r'ignore_known_test_failures', flags)
17471747

17481748
# I always checkpoint() before exiting. Even if notest==1. Without this
17491749
# 'set terminal dumb' plots don't end up rendering anything: we kill the
@@ -1968,8 +1968,8 @@ def binaryFormatcmd(curve):
19681968

19691969
# to test the plot I plot a single record
19701970
fmtTest = fmt
1971-
fmtTest = re.sub('record=\d+', 'record=1', fmtTest)
1972-
fmtTest = re.sub('array=\(\d+,\d+\)', 'array=(2, 2)', fmtTest)
1971+
fmtTest = re.sub(r'record=\d+', 'record=1', fmtTest)
1972+
fmtTest = re.sub(r'array=\(\d+,\d+\)', 'array=(2, 2)', fmtTest)
19731973

19741974
return fmt,fmtTest
19751975

@@ -2197,7 +2197,7 @@ def reformat(curve):
21972197
curve['using'] = '(histbin($1)):(1.0) smooth ' + histogram_type
21982198

21992199
if 'with' not in curve:
2200-
if re.match('freq|fnorm', histogram_type) and 'with' not in curve:
2200+
if re.match(r'freq|fnorm', histogram_type) and 'with' not in curve:
22012201
curve['with'] = 'boxes fill solid border lt -1'
22022202
else:
22032203
curve['with'] = 'lines'

0 commit comments

Comments
 (0)