Page MenuHomePhabricator

test_replace_tag_file is failing on Python 2.7.2
Closed, ResolvedPublic

Description

https://ci.appveyor.com/project/Ladsgroup/pywikibot-g4xqx/build/1.0.225/job/83ny5p3qel5stcpi#L4717

======================================================================
ERROR: test_replace_tag_file (tests.textlib_tests.TestReplaceExcept)
Test replacing not inside file links.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\projects\pywikibot-g4xqx\tests\textlib_tests.py", line 1305, in test_replace_tag_file
    'x', 'y', ['file'], site=self.site),
  File "c:\projects\pywikibot-g4xqx\pywikibot\textlib.py", line 377, in replaceExcept
    excMatch = dontTouchR.search(text, index)
MemoryError

This has occurred after the change in 8ede851d8c0655b7eb021e69003e96215da01231 (T191113)

It's a known bug in older versions of python, resolved in https://bugs.python.org/issue9669 (duplicate: https://bugs.python.org/issue12177)

Event Timeline

This comment was removed by Dalba.
Xqt triaged this task as High priority.Apr 1 2018, 8:15 PM
Dalba changed the task status from Resolved to Declined.
Dalba assigned this task to Xqt.
This comment was removed by Dalba.
Dalba renamed this task from test_replace_tag_file is failing on Python 2.6 and 3.3 to test_replace_tag_file is failing on Python 2.7.2.Apr 2 2018, 2:23 AM
Dalba updated the task description. (Show Details)
Dalba removed Xqt as the assignee of this task.Apr 2 2018, 2:46 AM
Dalba added a subscriber: Xqt.

According to changelogs the first versions of python with the fixed released are 2.7.4 release candidate 1, 3.3.1 release candidate 1, and 3.4.0 alpha 1.

3.4.0 alpha 1 is the first release of 3.4 series and we have dropped support for 3.3.
So we only have this issue with 2.7.2 and 2.7.3.
We could consider dropping support for them but we need a deprecation period. Till then, I suggest using the old regex for those versions.

On second thought, consuming 100% of CPU (T191113) is not that better than a MemoryError. There must be a better way.

Change 423447 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] Draft

https://gerrit.wikimedia.org/r/423447

Change 423447 abandoned by Dalba:
Draft

Reason:
Have not tested it yet, submitted by mistake

https://gerrit.wikimedia.org/r/423447

Change 423451 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] textlib.py: Do not use * quantifier in positive lookaheads of FILE_LINK_REGEX

https://gerrit.wikimedia.org/r/423451

Change 423451 merged by jenkins-bot:
[pywikibot/core@master] textlib.py: Avoid zero-width matching groups

https://gerrit.wikimedia.org/r/423451

Dalba removed Dalba as the assignee of this task.Apr 2 2018, 9:42 AM
Dalba removed a project: Patch-For-Review.

The patch failed to resolve the issue.

Change 423463 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] Use the old FILE_LINK_REGEX regex for Python versions older than 2.7.4

https://gerrit.wikimedia.org/r/423463

Change 423463 merged by jenkins-bot:
[pywikibot/core@master] Use the old FILE_LINK_REGEX regex for Python versions older than 2.7.4

https://gerrit.wikimedia.org/r/423463

Dalba claimed this task.