summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_re.py
Commit message (Collapse)AuthorAgeFilesLines
* RE: Add more tests for inline flag "x" and re.VERBOSE (GH-91854)Miss Islington (bot)2022-04-231-5/+27
| | | | | (cherry picked from commit 6b45076bd62407103433daea8acf085a99e6cb7e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.9] gh-91575: Update case-insensitive matching in re to the latest Unicode ↵Miss Islington (bot)2022-04-221-6/+49
| | | | | | | | | version (GH-91580). (GH-91661) (GH-91837) (cherry picked from commit 1c2fcebf3c5e2ab41d376bb481834445617c8f3c) (cherry picked from commit 1748816e80b23744667e239b49b477c0e283d201) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.9] gh-91700: Validate the group number in conditional expression in RE ↵Miss Islington (bot)2022-04-221-0/+2
| | | | | | | | | | | | | (GH-91702) (GH-91831) (GH-91836) In expression (?(group)...) an appropriate re.error is now raised if the group number refers to not defined group. Previously it raised RuntimeError: invalid SRE code. (cherry picked from commit 48ec61a89a959071206549819448405c2cea61b0) (cherry picked from commit 080781cd49b13da4a73db87b6f5e0c7aeec83e92) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.9] gh-90568: Fix exception type for \N with a named sequence in RE ↵Miss Islington (bot)2022-04-221-0/+4
| | | | | | | | | | (GH-91665) (GH-91830) (GH-91834) re.error is now raised instead of TypeError. (cherry picked from commit 6ccfa31421393910b52936e0447625db06f2a655) (cherry picked from commit 9c18d783c38fca57a63b61aa778d8a8d18945d95) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Add more tests for group names and refs in RE (GH-91695)Miss Islington (bot)2022-04-191-15/+41
| | | | | (cherry picked from commit 74070085da5322ac83c954f101f2caa150655be2) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-39394: Improve warning message in the re module (GH-31988)Miss Islington (bot)2022-03-191-3/+6
| | | | | | | A warning about inline flags not at the start of the regular expression now contains the position of the flag. (cherry picked from commit 4142961b9f5ad3bf93976a6a7162f8049e354018) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-40443: Remove unused imports in tests (GH-19805)Victor Stinner2020-04-291-1/+1
|
* bpo-36548: Improve the repr of re flags. (GH-12715)Serhiy Storchaka2019-05-311-0/+12
|
* bpo-36929: Modify io/re tests to allow for missing mod name (#13392)Max Bernstein2019-05-211-12/+16
| | | | | | | | | | | | | | | | | | * bpo-36929: Modify io/re tests to allow for missing mod name For a vanishingly small number of internal types, CPython sets the tp_name slot to mod_name.type_name, either in the PyTypeObject or the PyType_Spec. There are a few minor places where this surfaces: * Custom repr functions for those types (some of which ignore the tp_name in favor of using a string literal, such as _io.TextIOWrapper) * Pickling error messages The test suite only tests the former. This commit modifies the test suite to allow Python implementations to omit the module prefix. https://bugs.python.org/issue36929
* bpo-29571: Fix test_re.test_locale_flag() (GH-12099)Victor Stinner2019-02-281-2/+1
| | | | | | | | | Use locale.getpreferredencoding() rather than locale.getlocale() to get the locale encoding. With some locales, locale.getlocale() returns the wrong encoding. For example, on Fedora 29, locale.getlocale() returns ISO-8859-1 encoding for the "en_IN" locale, whereas locale.getpreferredencoding() reports the correct encoding: UTF-8.
* bpo-34294: re module, fix wrong capturing groups in rare cases. (GH-11546)animalize2019-02-181-0/+34
| | | | | | Need to reset capturing groups between two SRE(match) callings in loops, this fixes wrong capturing groups in rare cases. Also add a missing index in re.rst.
* bpo-30688: Support \N{name} escapes in re patterns. (GH-5588)Serhiy Storchaka2018-02-091-0/+36
| | | Co-authored-by: Jonathan Eunice <jonathan.eunice@gmail.com>
* bpo-32308: Replace empty matches adjacent to a previous non-empty match in ↵Serhiy Storchaka2018-01-041-14/+9
| | | | re.sub(). (#4846)
* Fix improper use of re.escape() in tests. (#4814)Serhiy Storchaka2017-12-121-1/+1
|
* bpo-25054, bpo-1647489: Added support of splitting on zerowidth patterns. ↵Serhiy Storchaka2017-12-041-13/+31
| | | | | | (#4471) Also fixed searching patterns that could match an empty string.
* bpo-30349: Raise FutureWarning for nested sets and set operations (#1553)Serhiy Storchaka2017-11-161-1/+46
| | | | in regular expressions.
* bpo-31690: Allow the inline flags "a", "L", and "u" to be used as group ↵Serhiy Storchaka2017-10-241-8/+14
| | | | flags for RE. (#3885)
* bpo-30397: Add re.Pattern and re.Match. (#1646)Serhiy Storchaka2017-10-041-2/+2
|
* bpo-30978: str.format_map() now passes key lookup exceptions through. (#2790)Serhiy Storchaka2017-08-031-1/+1
| | | Previously any exception was replaced with a KeyError exception.
* bpo-30605: Fix compiling binary regexs with BytesWarnings enabled. (#2016)Roy Williams2017-06-101-2/+14
| | | | Running our unit tests with `-bb` enabled triggered this failure.
* bpo-30375: Correct the stacklevel of regex compiling warnings. (#1595)Serhiy Storchaka2017-05-161-3/+14
| | | | | | Warnings emitted when compile a regular expression now always point to the line in the user code. Previously they could point into inners of the re module if emitted from inside of groups or conditionals.
* bpo-30299: Display a bytecode when compile a regex in debug mode. (#1491)Serhiy Storchaka2017-05-141-0/+27
| | | | | `re.compile(..., re.DEBUG)` now displays the compiled bytecode in human readable form.
* bpo-30340: Enhanced regular expressions optimization. (#1542)Serhiy Storchaka2017-05-141-14/+12
| | | | This increased the performance of matching some patterns up to 25 times.
* bpo-30298: Weaken the condition of deprecation warnings for inline ↵Serhiy Storchaka2017-05-101-14/+45
| | | | | | | | modifiers. (#1490) Now allowed several subsequential inline modifiers at the start of the pattern (e.g. '(?i)(?s)...'). In verbose mode whitespaces and comments now are allowed before and between inline modifiers (e.g. '(?x) (?i) (?s)...').
* bpo-30285: Optimize case-insensitive matching and searching (#1482)Serhiy Storchaka2017-05-091-0/+9
| | | | of regular expressions.
* bpo-30277: Replace _sre.getlower() with _sre.ascii_tolower() and ↵Serhiy Storchaka2017-05-051-10/+16
| | | | _sre.unicode_tolower(). (#1468)
* bpo-30215: Make re.compile() locale agnostic. (#1361)Serhiy Storchaka2017-05-051-0/+32
| | | | | | Compiled regular expression objects with the re.LOCALE flag no longer depend on the locale at compile time. Only the locale at matching time affects the result of matching.
* bpo-10076: Compiled regular expression and match objects now are copyable. ↵Serhiy Storchaka2017-04-161-0/+9
| | | | (#1000)
* bpo-29995: re.escape() now escapes only special characters. (#1007)Serhiy Storchaka2017-04-131-18/+19
|
* bpo-29919: Remove unused imports found by pyflakes (#137)Victor Stinner2017-03-271-2/+2
| | | Make also minor PEP8 coding style fixes on modified imports.
* Revert "bpo-29571: Use correct locale encoding in test_re (#149)" (#554)Benjamin Peterson2017-03-081-1/+1
| | | This reverts commit ace5c0fdd9b962e6e886c29dbcea72c53f051dc4.
* Revert "make the locale_flag fallback code work again (#375)" (#387)Benjamin Peterson2017-03-021-2/+3
| | | This reverts commit 43f5df5bfaea5a07c913d12cb92f78f997feb371.
* make the locale_flag fallback code work again (#375)Benjamin Peterson2017-03-011-3/+2
|
* bpo-29571: Use correct locale encoding in test_re (#149)Nick Coghlan2017-02-181-1/+1
| | | | | | | ``local.getlocale(locale.LC_CTYPE)`` and ``locale.getpreferredencoding(False)`` may give different answers in some cases (such as the ``en_IN`` locale). ``re.LOCALE`` uses the latter, so update the test case to match.
* Issue #29444: Fixed out-of-bounds buffer access in the group() method ofSerhiy Storchaka2017-02-041-0/+10
|\ | | | | | | the match object. Based on patch by WGH.
| * Issue #29444: Fixed out-of-bounds buffer access in the group() method ofSerhiy Storchaka2017-02-041-0/+10
| |\ | | | | | | | | | the match object. Based on patch by WGH.
| | * Issue #29444: Fixed out-of-bounds buffer access in the group() method ofSerhiy Storchaka2017-02-041-0/+10
| | | | | | | | | | | | the match object. Based on patch by WGH.
| * | Issue #27030: Unknown escapes in re.sub() replacement template are allowedSerhiy Storchaka2016-12-061-1/+1
| | | | | | | | | | | | again. But they still are deprecated and will be disabled in 3.7.
* | | Remove unused imports.Serhiy Storchaka2016-12-161-3/+0
| | |
* | | Issue #28765: _sre.compile() now checks the type of groupindex and indexgroupVictor Stinner2016-11-221-1/+1
|/ / | | | | | | | | | | groupindex must a dictionary and indexgroup must be a tuple. Previously, indexgroup was a list. Use a tuple to reduce the memory usage.
* | Issue #28727: Optimize pattern_richcompare() for a==aVictor Stinner2016-11-221-0/+4
| | | | | | | | A pattern is equal to itself.
* | Implement rich comparison for _sre.SRE_PatternVictor Stinner2016-11-211-2/+45
| | | | | | | | | | | | | | Issue #28727: Regular expression patterns, _sre.SRE_Pattern objects created by re.compile(), become comparable (only x==y and x!=y operators). This change should fix the issue #18383: don't duplicate warning filters when the warnings module is reloaded (thing usually only done in unit tests).
* | Issue #28082: Add basic unit tests on re enumsVictor Stinner2016-11-141-0/+6
| |
* | Issue #25953: re.sub() now raises an error for invalid numerical groupSerhiy Storchaka2016-10-231-21/+22
| | | | | | | | | | | | | | reference in replacement template even if the pattern is not found in the string. Error message for invalid group reference now includes the group index and the position of the reference. Based on patch by SilentGhost.
* | Issue #11957: Restored re tests for passing count and maxsplit as positionalSerhiy Storchaka2016-09-251-0/+5
|\ \ | |/ | | | | arguments.
| * Issue #11957: Restored re tests for passing count and maxsplit as positionalSerhiy Storchaka2016-09-251-0/+5
| | | | | | | | arguments.
| * Backported tests for issue #28070.Serhiy Storchaka2016-09-101-0/+3
| |
* | Issue #22493: Warning message emitted by using inline flags in the middle ofSerhiy Storchaka2016-09-161-2/+15
| | | | | | | | | | regular expression now contains a (truncated) regex pattern. Patch by Tim Graham.
* | Issue 24454: Improve the usability of the re match object named group APIEric V. Smith2016-09-111-0/+44
| |
* | Issue #22493: Inline flags now should be used only at the start of theSerhiy Storchaka2016-09-111-0/+3
| | | | | | | | | | regular expression. Deprecation warning is emitted if uses them in the middle of the regular expression.