fedora-selinux / selinux-policy

selinux-policy for Fedora is a large patch off the mainline
GNU General Public License v2.0
164 stars 165 forks source link

Declare regexes in segenxml.py as raw strings to prevent deprecation warnings #2086

Closed dawud closed 4 months ago

dawud commented 5 months ago

CI builds generate noise for 'invalid escape sequences', e.g.:

/builddir/build/BUILD/selinux-policy-c4eb5c5ddbc9f4f7e8e7b907f903f1d2cfb6140a/support/segenxml.py:46: SyntaxWarning: invalid escape sequence '\s'
  INTERFACE = re.compile("^\s*(interface|template)\(`(\w*)'")
/builddir/build/BUILD/selinux-policy-c4eb5c5ddbc9f4f7e8e7b907f903f1d2cfb6140a/support/segenxml.py:55: SyntaxWarning: invalid escape sequence '\s'
  BOOLEAN = re.compile("^\s*gen_(tunable|bool)\(\s*(\w*)\s*,\s*(true|false)\s*\)")
/builddir/build/BUILD/selinux-policy-c4eb5c5ddbc9f4f7e8e7b907f903f1d2cfb6140a/support/segenxml.py:66: SyntaxWarning: invalid escape sequence '\s'
  XML_COMMENT = re.compile("^##\s+(.*?)\s*$")

Declaring regexes as raw strings instead should get rid of those warnings:

>>> import re
>>> INTERFACE = re.compile("^\s*(interface|template)\(`(\w*)'")
<stdin>:1: SyntaxWarning: invalid escape sequence '\s'
>>> INTERFACE = re.compile(r"^\s*(interface|template)\(`(\w*)'")
>>>
packit-as-a-service[bot] commented 5 months ago

Cockpit tests failed for commit fe0d29eec9d0bed5b8f9cdae439a57d3312420d9. @martinpitt, @jelly, @mvollmer please check.

martinpitt commented 5 months ago

As there's no movement on the two SELinux issues (https://bugzilla.redhat.com/show_bug.cgi?id=2274451 and https://bugzilla.redhat.com/show_bug.cgi?id=2265927) or the TF one, I sent a PR to ignore these two: https://github.com/cockpit-project/bots/pull/6222

This will stop the constant "rawhide error" notifications, and prevent introducing new ones (as I don't check the logs carefully any more otherwise).

zpytela commented 4 months ago

Thanks for reporting. I am going to close this pr in favor of https://github.com/fedora-selinux/selinux-policy/pull/2087 which is a superset.