Svoboda | Graniru | BBC Russia | Golosameriki | Facebook
BBC RussianHomePhabricator
Log In
Maniphest T57170

imagecopy_self.py uses re.sub flags argument which isnt in py2.6
Closed, DeclinedPublic

Description

Originally from: http://sourceforge.net/p/pywikipediabot/bugs/1519/
Reported by: drtrigon
Created on: 2012-10-09 15:08:56
Subject: trunk 10450 not py2.6 compatible
Original description:
Hello all\!

As Merlijn suggested at \[1\] I should also report this here too. I would solve it myself but a quick shot does not seam appropriate.

\[1\] https://jira.toolserver.org/browse/TS-1466

Python code using:
>>> import re
>>> re.sub\(..., flags=...\)

does not work in python 2.6 because the optional parameter \'flags\' was introduced in python 2.7. As Merlijn noted, this should be replaced by
>>> re.compile\(..., flags=...\).sub\(...\)

A fast \'grep \"flags\" \*\' in my pywikipedia directory of revision 10450, yields at least following matches:

imagecopy\_self.py: match = re.search\(regex, text, flags=re.IGNORECASE\)
imagecopy\_self.py: contents\[u\'permission\'\] = re.sub\(regex, u\'\', contents\[u\'permission\'\], flags=re.IGNORECASE\)
imagecopy\_self.py: text = re.sub\(toRemove, u\'\', text, flags=re.IGNORECASE\)
imagecopy\_self.py: text = re.sub\(regex, u\'\', text, flags=re.IGNORECASE\)
imagecopy\_self.py: match = re.search\(regex, text, flags=re.IGNORECASE\)
imagecopy\_self.py: result = re.sub\(regex, replacement, match.group\(0\), flags=re.IGNORECASE\)

...so there are at least 4 problematic cases which should be changed. I am not aware if a similar issues exists with \'re.search\'.

Thanks and greetings


Version: compat-(1.0)
Severity: normal
See Also:
https://sourceforge.net/p/pywikipediabot/bugs/1519

Details

Reference
bz55170

Related Objects

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 2:24 AM
bzimport set Reference to bz55170.
bzimport added a subscriber: Unknown Object (????).

This ist still a fix-me of python release change r8814 which was done to fix another regex bug. mybe we had to create version dependant code :-\(

jayvdb renamed this task from compat not py2.6 compatible to compat uses re.sub flags argument which isnt in py2.6.Nov 30 2014, 2:49 PM
jayvdb removed a project: Pywikibot-General.
jayvdb set Security to None.
jayvdb removed a subscriber: Unknown Object (????).
jayvdb subscribed.

re.search (and re.match) has the flags argument in 2.6.

Only re.sub* doesnt have the flags argument.

I've audited core code; no problems there.

jayvdb renamed this task from compat uses re.sub flags argument which isnt in py2.6 to imagecopy_self.py uses re.sub flags argument which isnt in py2.6.Nov 30 2014, 2:50 PM
jayvdb moved this task from Backlog to Unported (still maintained) on the Pywikibot-compat board.
Aklapper lowered the priority of this task from Low to Lowest.Jun 5 2015, 1:41 PM
Aklapper subscribed.

Pywikibot has two versions: Compat and Core. This task was filed about the older version, called Pywikibot-compat, which is not under active development anymore. Hence I'm lowering the priority of this task to reflect the reality. Unfortunately, the Pywikibot team does not have the manpower to retest every single bug report / feature request against the (maintained) Pywikibot code base. Furthermore, the code base of Pywikibot-Compat has changed a lot compared to the code base of Pywikibot-Core so there is a chance that the problem described in this task might not exist anymore. Please help: Unfortunately manpower is limited and does not allow testing every single reported task again. If you have time and interest in Pywikibot, please upgrade to Pywikibot-Core and add a comment to this task if the problem in this task still happens in Pywikibot-Core (or directly edit the task by removing the Pywikibot-compat project and adding the Pywikibot project to this task). To learn more about Pywikibot and to get involved in its development, please check out https://www.mediawiki.org/wiki/Manual:Pywikibot/Development Thank you for your understanding.

Xqt moved this task from Unported (still maintained) to Backlog on the Pywikibot-compat board.
Xqt subscribed.

Declined due to decommission compat