Bug 2075460

Summary: bind fails to build with Python 3.11: Invalid regular expression for rule 't_DATESUFFIX'. global flags not at the start of the expression at position 17
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: bindAssignee: Petr Menšík <pemensik>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: aegorenk, anon.amish, dns-sig, mhroncok, mruprich, pemensik, thrnciar, vonsch, zdohnal
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: bind-9.16.29-1.fc37 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-06-04 20:34:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2087920    
Bug Blocks: 2016048    

Description Tomáš Hrnčiar 2022-04-14 09:41:09 UTC
bind fails to build with Python 3.11.0a7.

ERROR: /builddir/build/BUILD/bind-9.16.27/build/bin/python/isc/policy.py:63: Invalid regular expression for rule 't_DATESUFFIX'. global flags not at the start of the expression at position 17
ERROR: /builddir/build/BUILD/bind-9.16.27/build/bin/python/isc/policy.py:68: Invalid regular expression for rule 't_KEYTYPE'. global flags not at the start of the expression at position 14
ERROR: /builddir/build/BUILD/bind-9.16.27/build/bin/python/isc/policy.py:73: Invalid regular expression for rule 't_ALGNAME'. global flags not at the start of the expression at position 14

Global inline flags (e.g. (?i)) can now only be used at the start of the regular expressions. Using them not at the start of expression was deprecated since Python 3.6. (Contributed by Serhiy Storchaka in bpo-47066.)

https://bugs.python.org/issue?@action=redirect&bpo=47066
https://docs.python.org/3.11/whatsnew/3.11.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/04220914-bind/

For all our attempts to build bind with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/bind/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.11:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/

Let us know here if you have any questions.

Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Petr Menšík 2022-04-21 17:44:49 UTC
Python 3.11 does not like r'(?i)' on start of token matching functions. It worked fine on previous versions. Not sure if change in re or ply is responsible.

It switches on case insensitive compare on selected types. ply.lex() function has parameter reflags, which enabled re.VERBOSE by default. It might be possible to use it to pass aklso re.IGNORECASE. It seems to me all remaining patterns do not use letters, which might be affected. There should not be any change in accepted tokens.

Anyway, python tests do not pass to me even on F34. I have made candidate change, but it seems tests get stuck. But they provide some help with warnings at least:

tests/dnskey_test.py::DnskeyTest::test_fmttime
tests/dnskey_test.py::DnskeyTest::test_metdata
  /home/pemensik/fedora/bind/bind-9.16.28/build/bin/python/isc/dnskey.py:93: DeprecationWarning: 'U' mode is deprecated
    pfp = open(private_file, "rU")

tests/policy_test.py::PolicyTest::test_combined_pre_post
  /usr/lib/python3.9/site-packages/ply/lex.py:760: DeprecationWarning: Flags not at the start of the expression '(?P<t_DATESUFFIX>(?i' (truncated) but at position 17
    c = re.compile('(?P<%s>%s)' % (fname, _get_regex(f)), self.reflags)

tests/policy_test.py::PolicyTest::test_combined_pre_post
  /usr/lib/python3.9/site-packages/ply/lex.py:760: DeprecationWarning: Flags not at the start of the expression '(?P<t_KEYTYPE>(?i)\\b' (truncated) but at position 14
    c = re.compile('(?P<%s>%s)' % (fname, _get_regex(f)), self.reflags)

tests/policy_test.py::PolicyTest::test_combined_pre_post
  /usr/lib/python3.9/site-packages/ply/lex.py:760: DeprecationWarning: Flags not at the start of the expression '(?P<t_ALGNAME>(?i)\\b' (truncated) but at position 14
    c = re.compile('(?P<%s>%s)' % (fname, _get_regex(f)), self.reflags)

tests/policy_test.py::PolicyTest::test_combined_pre_post
  /usr/lib/python3.9/site-packages/ply/lex.py:498: DeprecationWarning: Flags not at the start of the expression '(?P<t_newline>\\n+)|(' (truncated) but at position 66
    lexre = re.compile(regex, reflags)

tests/policy_test.py::PolicyTest::test_combined_pre_post
  /usr/lib/python3.9/site-packages/ply/lex.py:498: DeprecationWarning: Flags not at the start of the expression '(?P<t_newline>\\n+)|(' (truncated) but at position 258
    lexre = re.compile(regex, reflags)

tests/policy_test.py::PolicyTest::test_combined_pre_post
  /usr/lib/python3.9/site-packages/ply/lex.py:498: DeprecationWarning: Flags not at the start of the expression '(?P<t_newline>\\n+)|(' (truncated) but at position 291
    lexre = re.compile(regex, reflags)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! KeyboardInterrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/usr/lib/python3.9/site-packages/ply/yacc.py:1094: KeyboardInterrupt

Comment 2 Petr Menšík 2022-06-04 20:34:34 UTC
Fixed by a rebase to version with a merged fix.