python: use raw strings when appropriate
We had some incorrectly escaped strings that are now causing SyntaxWarnings with Python 3.12 * bin/options.py, python/spot/aux_.py, python/spot/ltsmin.i, python/spot/__init__.py: Here. * NEWS: Mention the fix.
This commit is contained in:
parent
dbe31c72c8
commit
e6362b785b
5 changed files with 16 additions and 13 deletions
3
NEWS
3
NEWS
|
|
@ -320,6 +320,9 @@ New in spot 2.11.6.dev (not yet released)
|
||||||
- The configure script failed to detect the include path for Python 3.12.
|
- The configure script failed to detect the include path for Python 3.12.
|
||||||
(Issue #577.)
|
(Issue #577.)
|
||||||
|
|
||||||
|
- Some incorrectly escaped strings in Python code were causing
|
||||||
|
warnings with Python 3.12.
|
||||||
|
|
||||||
New in spot 2.11.6 (2023-08-01)
|
New in spot 2.11.6 (2023-08-01)
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,10 @@ import subprocess
|
||||||
with open('Makefile.am', 'r') as mf:
|
with open('Makefile.am', 'r') as mf:
|
||||||
lines = mf.read()
|
lines = mf.read()
|
||||||
|
|
||||||
lines = re.sub('\s*\\\\\s*', ' ', lines)
|
lines = re.sub(r'\s*\\\s*', ' ', lines)
|
||||||
bin_programs = re.search('bin_PROGRAMS\s*=([\w \t]*)', lines).group(1).split()
|
bin_programs = re.search(r'bin_PROGRAMS\s*=([\w \t]*)', lines).group(1).split()
|
||||||
|
|
||||||
optre = re.compile('(-\w), (--[\w=-]+)')
|
optre = re.compile(r'(-\w), (--[\w=-]+)')
|
||||||
|
|
||||||
d = {}
|
d = {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -344,8 +344,8 @@ class formula:
|
||||||
return str_sclatex_psl(self, parenth)
|
return str_sclatex_psl(self, parenth)
|
||||||
elif format == 'mathjax' or format == 'j':
|
elif format == 'mathjax' or format == 'j':
|
||||||
return (str_sclatex_psl(self, parenth).
|
return (str_sclatex_psl(self, parenth).
|
||||||
replace("``", "\\unicode{x201C}").
|
replace("``", r"\unicode{x201C}").
|
||||||
replace("\\textrm{''}", "\\unicode{x201D}"))
|
replace(r"\textrm{''}", r"\unicode{x201D}"))
|
||||||
elif format == 'dot' or format == 'd':
|
elif format == 'dot' or format == 'd':
|
||||||
ostr = ostringstream()
|
ostr = ostringstream()
|
||||||
print_dot_psl(ostr, self)
|
print_dot_psl(ostr, self)
|
||||||
|
|
@ -466,16 +466,16 @@ class formula:
|
||||||
@_extend(atomic_prop_set)
|
@_extend(atomic_prop_set)
|
||||||
class atomic_prop_set:
|
class atomic_prop_set:
|
||||||
def _repr_latex_(self):
|
def _repr_latex_(self):
|
||||||
res = '$\{'
|
res = r'$\{'
|
||||||
comma = ''
|
comma = ''
|
||||||
for ap in self:
|
for ap in self:
|
||||||
apname = ap.to_str('j')
|
apname = ap.to_str('j')
|
||||||
if not '\\unicode{' in apname:
|
if not r'\unicode{' in apname:
|
||||||
apname = "\\unicode{x201C}" + apname + "\\unicode{x201D}"
|
apname = r"\unicode{x201C}" + apname + r"\unicode{x201D}"
|
||||||
res += comma
|
res += comma
|
||||||
comma = ', '
|
comma = ', '
|
||||||
res += apname
|
res += apname
|
||||||
res += '\}$'
|
res += r'\}$'
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1445,12 +1445,12 @@ class twa_word:
|
||||||
res += bdd_to_formula(letter, bd).to_str('j')
|
res += bdd_to_formula(letter, bd).to_str('j')
|
||||||
if len(res) > 1:
|
if len(res) > 1:
|
||||||
res += '; '
|
res += '; '
|
||||||
res += '\\mathsf{cycle}\\{'
|
res += r'\mathsf{cycle}\{'
|
||||||
for idx, letter in enumerate(self.cycle):
|
for idx, letter in enumerate(self.cycle):
|
||||||
if idx:
|
if idx:
|
||||||
res += '; '
|
res += '; '
|
||||||
res += bdd_to_formula(letter, bd).to_str('j')
|
res += bdd_to_formula(letter, bd).to_str('j')
|
||||||
return res + '\\}$'
|
return res + r'\}$'
|
||||||
|
|
||||||
def as_svg(self):
|
def as_svg(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ def extend(*classes):
|
||||||
# parameter is inverted. https://gitlab.com/graphviz/graphviz/issues/1605
|
# parameter is inverted. https://gitlab.com/graphviz/graphviz/issues/1605
|
||||||
# In our case, the scale parameters should both be <= 1, so we can
|
# In our case, the scale parameters should both be <= 1, so we can
|
||||||
# detect when that is not the case.
|
# detect when that is not the case.
|
||||||
svgscale_regex = re.compile('transform="scale\(([\d.]+) ([\d.]+)\) rotate')
|
svgscale_regex = re.compile(r'transform="scale\(([\d.]+) ([\d.]+)\) rotate')
|
||||||
|
|
||||||
def _gvfix(matchobj):
|
def _gvfix(matchobj):
|
||||||
xs = float(matchobj.group(1))
|
xs = float(matchobj.group(1))
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ def load(filename):
|
||||||
p = subprocess.run(['spins', filename], stdout=subprocess.PIPE,
|
p = subprocess.run(['spins', filename], stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
universal_newlines=True)
|
universal_newlines=True)
|
||||||
if p.stdout: print(re.sub('^\s*\[\.*\s*\]\n', '', p.stdout,
|
if p.stdout: print(re.sub(r'^\s*\[\.*\s*\]\n', '', p.stdout,
|
||||||
flags=re.MULTILINE), file=sys.stderr)
|
flags=re.MULTILINE), file=sys.stderr)
|
||||||
if p.stderr: print(p.stderr, file=sys.stderr)
|
if p.stderr: print(p.stderr, file=sys.stderr)
|
||||||
p.check_returncode()
|
p.check_returncode()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue