Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regular expression errors on Python 3.11 #48

Closed
mauritsvanrees opened this issue Oct 26, 2022 · 0 comments · Fixed by #49
Closed

Regular expression errors on Python 3.11 #48

mauritsvanrees opened this issue Oct 26, 2022 · 0 comments · Fixed by #49
Assignees

Comments

@mauritsvanrees
Copy link
Member

See Jenkins.

Error in test testCall (Products.PortalTransforms.tests.test_engine.TestEngine.testCall)
Traceback (most recent call last):
  File "/srv/python3.11/lib/python3.11/unittest/case.py", line 57, in testPartExecutor
    yield
  File "/srv/python3.11/lib/python3.11/unittest/case.py", line 623, in run
    self._callTestMethod(testMethod)
  File "/srv/python3.11/lib/python3.11/unittest/case.py", line 579, in _callTestMethod
    if method() is not None:
  File "/home/jenkins/workspace/plone-6.0-python-3.11/src/Products.PortalTransforms/Products/PortalTransforms/tests/test_engine.py", line 153, in testCall
    data = self.engine('HtmlToText', self.data)
  File "/home/jenkins/workspace/plone-6.0-python-3.11/src/Products.PortalTransforms/Products/PortalTransforms/TransformEngine.py", line 222, in __call__
    data = self.convert(name, orig, data, context, **kwargs)
  File "/home/jenkins/workspace/plone-6.0-python-3.11/src/Products.PortalTransforms/Products/PortalTransforms/TransformEngine.py", line 210, in convert
    data = transform.convert(orig, data, context=context, **kwargs)
  File "/home/jenkins/workspace/plone-6.0-python-3.11/src/Products.PortalTransforms/Products/PortalTransforms/Transform.py", line 202, in convert
    return self._v_transform.convert(*args, **kwargs)
  File "/home/jenkins/workspace/plone-6.0-python-3.11/src/Products.PortalTransforms/Products/PortalTransforms/tests/test_engine.py", line 29, in convert
    orig = self.__call__(orig)
  File "/home/jenkins/workspace/plone-6.0-python-3.11/src/Products.PortalTransforms/Products/PortalTransforms/tests/test_engine.py", line 25, in __call__
    orig = re.sub('<[^>]*>(?i)(?m)', '', orig)
  File "/srv/python3.11/lib/python3.11/re/__init__.py", line 185, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/srv/python3.11/lib/python3.11/re/__init__.py", line 294, in _compile
    p = _compiler.compile(pattern, flags)
  File "/srv/python3.11/lib/python3.11/re/_compiler.py", line 743, in compile
    p = _parser.parse(p, flags)
  File "/srv/python3.11/lib/python3.11/re/_parser.py", line 980, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/srv/python3.11/lib/python3.11/re/_parser.py", line 455, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/srv/python3.11/lib/python3.11/re/_parser.py", line 841, in _parse
    raise source.error('global flags not at the start '
re.error: global flags not at the start of the expression at position 7

In Python 3.10 you can already see a deprecation warning:

>>> import re
>>> re.sub(r'<[^>]*>(?i)(?m)', '', '')
<stdin>:1: DeprecationWarning: Flags not at the start of the expression '<[^>]*>(?i)(?m)' but at position 7
<stdin>:1: DeprecationWarning: Flags not at the start of the expression '<[^>]*>(?i)(?m)' but at position 11

Solution:

>>> import re
>>> re.sub(r'(?i)(?m)<[^>]*>', '', '')
@mauritsvanrees mauritsvanrees self-assigned this Oct 26, 2022
mauritsvanrees added a commit that referenced this issue Oct 26, 2022
mauritsvanrees added a commit that referenced this issue Oct 26, 2022
mister-roboto pushed a commit to plone/buildout.coredev that referenced this issue Oct 27, 2022
Branch: refs/heads/master
Date: 2022-10-26T15:24:45+02:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/Products.PortalTransforms@e27aac9

Fixed regular expression in tests on Python 3.11.

This fixes plone/Products.PortalTransforms#48

Files changed:
A news/48.bugfix
M Products/PortalTransforms/tests/test_engine.py
Repository: Products.PortalTransforms

Branch: refs/heads/master
Date: 2022-10-26T20:58:45-07:00
Author: David Glick (davisagli) <david@glicksoftware.com>
Commit: plone/Products.PortalTransforms@e73e91f

Merge pull request #49 from plone/maurits-regexp-311

Fixed regular expression in tests on Python 3.11.

Files changed:
A news/48.bugfix
M Products/PortalTransforms/tests/test_engine.py
mister-roboto pushed a commit to plone/buildout.coredev that referenced this issue Oct 27, 2022
Branch: refs/heads/master
Date: 2022-10-26T15:24:45+02:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/Products.PortalTransforms@e27aac9

Fixed regular expression in tests on Python 3.11.

This fixes plone/Products.PortalTransforms#48

Files changed:
A news/48.bugfix
M Products/PortalTransforms/tests/test_engine.py
Repository: Products.PortalTransforms

Branch: refs/heads/master
Date: 2022-10-26T20:58:45-07:00
Author: David Glick (davisagli) <david@glicksoftware.com>
Commit: plone/Products.PortalTransforms@e73e91f

Merge pull request #49 from plone/maurits-regexp-311

Fixed regular expression in tests on Python 3.11.

Files changed:
A news/48.bugfix
M Products/PortalTransforms/tests/test_engine.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant