[Git][NTPsec/ntpsec][master] Use raw strings for regular expressions

Gary E. Miller (@garyedmundsmiller) gitlab at mg.gitlab.com
Wed Oct 2 19:27:35 UTC 2024



Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
964e0011 by Matt Selsky at 2024-10-01T00:05:38-04:00
Use raw strings for regular expressions

Per https://docs.python.org/3/whatsnew/3.12.html:

A backslash-character pair that is not a valid escape sequence now generates a
SyntaxWarning, instead of DeprecationWarning.

See https://github.com/python/cpython/issues/98401

The warnings without this change are:

attic/calc_tickadj/calc_tickadj:74: SyntaxWarning: invalid escape sequence '\d'
contrib/cpu-temp-log:60: SyntaxWarning: invalid escape sequence '\s'

- - - - -


2 changed files:

- attic/calc_tickadj/calc_tickadj
- contrib/cpu-temp-log


Changes:

=====================================
attic/calc_tickadj/calc_tickadj
=====================================
@@ -71,7 +71,7 @@ if __name__ == '__main__':
         sys.stderr.write("Could not open drift file: %s\n" % drift_file)
         sys.exit(1)
 
-    m = re.match("[+-]?\d+\.?[0-9]+", drift)
+    m = re.match(r"[+-]?\d+\.?[0-9]+", drift)
     if not m:
         sys.stderr.write("Invalid drift file value '%s'\n" % drift)
         sys.exit(1)


=====================================
contrib/cpu-temp-log
=====================================
@@ -57,7 +57,7 @@ except:
 lines = output.split('\n')
 
 # this regex matches temperature output lines from 'sensors -u'
-pat = re.compile('^\s+temp\d+_input:\s+([\d\.]+).*$')
+pat = re.compile(r'^\s+temp\d+_input:\s+([\d\.]+).*$')
 
 now = int(time.time())
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/964e0011dc201e5454839925dea93e9328740a61

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/964e0011dc201e5454839925dea93e9328740a61
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20241002/1d4f3f24/attachment-0001.htm>


More information about the vc mailing list