Commit graph

74 commits

Author SHA1 Message Date
Georg Brandl
a4f46e1292 Remove unused imports in test modules. 2010-02-07 17:03:15 +00:00
Ezio Melotti
0e4e73240a Increased the overflow value on test_dealloc to make sure that it is big enough even for wide builds. 2010-01-23 10:43:05 +00:00
Antoine Pitrou
efdddd3370 Issue #3299: Fix possible crash in the _sre module when given bad
argument values in debug mode.  Patch by Victor Stinner.
2010-01-14 17:25:24 +00:00
Benjamin Peterson
96e319e5ac don't need to mess up sys.path 2009-10-15 15:39:15 +00:00
Mark Dickinson
fe67bd9168 Issue #6561: '\d' regular expression should not match characters of
category [No]; only those of category [Nd].  (Backport of r74237
from py3k.)
2009-07-28 20:35:03 +00:00
Benjamin Peterson
5c8da86f3a convert usage of fail* to assert* 2009-06-30 22:57:08 +00:00
Guido van Rossum
e3c4fd9cc0 - Issue #3629: Fix sre "bytecode" validator for an end case.
Reviewed by Amaury.
2008-09-10 14:27:00 +00:00
Brett Cannon
672237dc6c warnings.catch_warnings() now returns a list or None instead of the custom
WarningsRecorder object. This makes the API simpler to use as no special object
must be learned.

Closes issue 3781.
Review by Benjamin Peterson.
2008-09-09 00:49:16 +00:00
Georg Brandl
30de77b97d #3654: fix duplicate test method name. Review by Benjamin P. 2008-08-24 18:11:07 +00:00
Amaury Forgeot d'Arc
d08a8ebf2a Closing issue1761.
Surprising behaviour of the "$" regexp: it matches the
end of the string, AND just before the newline at the end
of the string::

    re.sub('$', '#', 'foo\n') == 'foo#\n#'

Python is consistent with Perl and the pcre library, so
we just document it.
Guido prefers "\Z" to match only the end of the string.
2008-01-10 21:59:42 +00:00
Guido van Rossum
ae04c3356e Issue #1700, reported by Nguyen Quan Son, fix by Fredruk Lundh:
Regular Expression inline flags not handled correctly for some unicode
characters.  (Forward port from 2.5.2.)
2008-01-03 19:12:44 +00:00
Raymond Hettinger
80016c9555 Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes. 2007-12-19 18:13:31 +00:00
Guido van Rossum
1ff91d95a2 Patch # 1140 (my code, approved by Effbot).
Make sure the type of the return value of re.sub(x, y, z) is the type
of y+x (i.e. unicode if either is unicode, str if they are both str)
even if there are no substitutions or if x==z (which triggered various
special cases in join_list()).

Could be backported to 2.5; no need to port to 3.0.
2007-09-10 22:02:25 +00:00
Brett Cannon
2ee4128e9b Remove test.test_support.guard_warnings_filter.
test.test_support.catch_warning is more full-featured and provides the same
functionality.

Since guard_warnings_filter was added in 2.6 there is no
backwards-compatibility issues.
2007-08-14 05:51:06 +00:00
Neal Norwitz
0d4c06e06e Whitespace normalization. Ugh, we really need to do this more often.
You might want to review this change as it's my first time.  Be gentle. :-)
2007-04-25 06:30:05 +00:00
Raymond Hettinger
01a807db2a Array module's buffer interface can now handle empty arrays. 2007-04-02 22:54:21 +00:00
Žiga Seilnacht
7492e4260e Bug #1675967: re patterns pickled with older Python versions can
now be unpickled. Will backport.
2007-03-21 20:07:56 +00:00
Neal Norwitz
94a9c09e10 Rename sre.py -> re.py 2006-03-16 06:30:02 +00:00
Gustavo Niemeyer
6fa0c5a452 Bug #1202493: Fixing SRE parser to handle '{}' as perl does, rather than
considering it exactly like a '*'.
2005-09-14 08:54:39 +00:00
Michael W. Hudson
e7fa1af85b M-x untabify 2005-06-03 13:55:58 +00:00
Andrew M. Kuchling
3554cad009 [Bug #1177831] Exercise (?(id)yes|no) for a group other than the first one 2005-06-02 13:38:45 +00:00
Tim Peters
0e9980f75a Whitespace normalization. 2004-09-12 03:49:31 +00:00
Gustavo Niemeyer
0506c64086 Fixing bug #817234, which made SRE get into an infinite loop on
empty final matches with finditer(). New test cases included
for this bug and for #581080.
2004-09-03 18:11:59 +00:00
Gustavo Niemeyer
a01a2ee933 Applying modified version of patch #1018386, which fixes
some escaping bugs in SRE.
2004-09-03 17:06:10 +00:00
Raymond Hettinger
027bb633b6 Add weakref support to sockets and re pattern objects. 2004-05-31 03:09:25 +00:00
Martin v. Löwis
7d9c6c7e8c Fix _sre.CODESIZE on 64-bit machines in UCS-4 mode. Fixes #931848.
Backported to 2.3.
2004-05-07 07:18:13 +00:00
Hye-Shik Chang
9f62eccb66 SF #926075: Fixed the bug that returns a wrong pattern object for
a string or unicode object in sre.compile() when a different type
pattern with the same value exists.
2004-04-20 21:30:07 +00:00
Tim Peters
58eb11cf62 Whitespace normalization. 2004-01-18 20:29:55 +00:00
Gustavo Niemeyer
ad3fc44ccb Implemented non-recursive SRE matching. 2003-10-17 22:13:16 +00:00
Just van Rossum
12723bacea Fix and test for bug #764548:
Use isinstance() instead of comparing types directly, to enable
subclasses of str and unicode to be used as patterns.
Blessed by /F.
2003-07-02 20:03:04 +00:00
Just van Rossum
6802c6e764 fixed typo in comment 2003-07-02 14:36:59 +00:00
Gustavo Niemeyer
25fe0bf91a Many new tests, based on gcov's coverage information.
From gcov's output (based on a locally changed _sre.c):

  82.07% of 1372 source lines executed in file ./Modules/_sre.c
2003-06-20 00:25:14 +00:00
Walter Dörwald
21d3a32b99 Combine the functionality of test_support.run_unittest()
and test_support.run_classtests() into run_unittest()
and use it wherever possible.

Also don't use "from test.test_support import ...", but
"from test import test_support" in a few spots.

From SF patch #662807.
2003-05-01 17:45:56 +00:00
Gustavo Niemeyer
3646ab98af Fix for part of the problem mentioned in #725149 by Greg Chapman.
This problem is related to a wrong behavior from mark_save/restore(),
which don't restore the mark_stack_base before restoring the marks.
Greg's suggestion was to change the asserts, which happen to be
the only recursive ops that can continue the loop, but the problem would
happen to any operation with the same behavior. So, rather than
hardcoding this into asserts, I have changed mark_save/restore() to
always restore the stackbase before restoring the marks.

Both solutions should fix these two cases, presented by Greg:

>>> re.match('(a)(?:(?=(b)*)c)*', 'abb').groups()
('b', None)
>>> re.match('(a)((?!(b)*))*', 'abb').groups()
('b', None, None)

The rest of the bug and patch in #725149 must be discussed further.
2003-04-27 13:25:21 +00:00
Gustavo Niemeyer
c34f2555bd Applied patch #725106, by Greg Chapman, fixing capturing groups
within repeats of alternatives. The only change to the original
patch was to convert the tests to the new test_re.py file.

This patch fixes cases like:

>>> re.match('((a)|b)*', 'abc').groups()
('b', '')

Which is wrong (it's impossible to match the empty string),
and incompatible with other regex systems, like the following
examples show:

% perl -e '"abc" =~ /^((a)|b)*/; print "$1 $2\n";'
b a

% echo "abc" | sed -r -e "s/^((a)|b)*/\1 \2|/"
b a|c
2003-04-27 12:34:14 +00:00
Skip Montanaro
5ba0054e69 final bit of tests converted from test_sre 2003-04-25 16:00:14 +00:00
Skip Montanaro
1e703c6278 more tests converted from test_sre 2003-04-25 15:40:28 +00:00
Skip Montanaro
2726fcd4b6 more tests from test_sre 2003-04-25 14:31:54 +00:00
Skip Montanaro
7d9963fea8 copy a few tests from test_sre 2003-04-25 14:12:40 +00:00
Guido van Rossum
46144be02c Fix test_limitations(). The match there is *expected* to raise
RuntimeError.
2003-04-25 01:40:11 +00:00
Skip Montanaro
8ed06da754 first cut at unittest version of re tests 2003-04-24 19:43:18 +00:00
Barry Warsaw
408b6d34de Complete the absolute import patch for the test suite. All relative
imports of test modules now import from the test package.  Other
related oddities are also fixed (like DeprecationWarning filters that
weren't specifying the full import part, etc.).  Also did a general
code cleanup to remove all "from test.test_support import *"'s.  Other
from...import *'s weren't changed.
2002-07-30 23:27:12 +00:00
Barry Warsaw
04f357cffe Get rid of relative imports in all unittests. Now anything that
imports e.g. test_support must do so using an absolute package name
such as "import test.test_support" or "from test import test_support".

This also updates the README in Lib/test, and gets rid of the
duplicate data dirctory in Lib/test/data (replaced by
Lib/email/test/data).

Now Tim and Jack can have at it. :)
2002-07-23 19:04:11 +00:00
Guido van Rossum
e056e4d15c Check in a testcase for SF bug #449000: re.sub(r'\n', ...) broke. 2001-08-10 14:52:48 +00:00
Fredrik Lundh
17741be466 SRE 2.1b1: don't do unicode tests under 1.5.2, or on unicode
strings/patterns.
2001-03-22 15:51:28 +00:00
Eric S. Raymond
2846b0ab41 String method conversion.
(This one was trivial -- no actual string. references in it!)
2001-02-09 12:00:47 +00:00
Marc-André Lemburg
3661908a6a This patch removes all uses of "assert" in the regression test suite
and replaces them with a new API verify(). As a result the regression
suite will also perform its tests in optimization mode.

Written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
2001-01-17 19:11:13 +00:00
Fred Drake
132dce2246 Update the code to better reflect recommended style:
Use != instead of <> since <> is documented as "obsolescent".
Use "is" and "is not" when comparing with None or type objects.
2000-12-12 23:11:42 +00:00
Fred Drake
004d5e6880 Make reindent.py happy (convert everything to 4-space indents!). 2000-10-23 17:22:08 +00:00
Fred Drake
8ae9ce5e5b Better conformance to the Python Style Guide: use spaces around operators. 2000-08-18 16:09:56 +00:00