Page MenuHomePhabricator

Use inline re.flags in Pywikibot
Closed, ResolvedPublic

Description

Introduction

Added support of modifier spans in regular expressions. Examples: '(?i:p)ython' matches 'python' and 'Python', but not 'PYTHON'; '(?i)g(?-i:v)r' matches 'GvR' and 'gvr', but not 'GVR'.
https://docs.python.org/3.6/whatsnew/3.6.html#re

What to do

textlib.case_escape() is used to circumvent this Python 3.5 restriction. Use the new inline flags for regex patterns instead.
These issues can be found at https://codesearch.wmcloud.org/pywikibot/?q=case_escape%5C(&i=nope&files=&excludeFiles=&repos=

Split patches into parts of only a couple of affected files. This makes it easier to review.

Useful links

Related Objects

StatusSubtypeAssignedTask
ResolvedReleaseXqt
ResolvedXqt

Event Timeline

@Xqt Should I remove case_escape() from textlib.py or just leave it there and use inline flags for regex patterns wherever required?

No activity since months

Change 942668 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [IMPR] use inline re.IGNORECASE flag in textlib.case_escape function

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

Change 942668 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] use inline re.IGNORECASE flag in textlib.case_escape function

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