Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9a2b2674
Commit
9a2b2674
authored
Dec 02, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Issue #10182: The re module doesn't truncate indices to 32 bits anymore.
Patch by Serhiy Storchaka.
parents
17485bf6
43fb54cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
6 deletions
+24
-6
Lib/test/test_re.py
Lib/test/test_re.py
+16
-1
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_sre.c
Modules/_sre.c
+5
-5
No files found.
Lib/test/test_re.py
View file @
9a2b2674
from
test.support
import
verbose
,
run_unittest
,
gc_collect
from
test.support
import
verbose
,
run_unittest
,
gc_collect
,
bigmemtest
,
_2G
import
io
import
re
from
re
import
Scanner
...
...
@@ -949,6 +949,21 @@ class ReTests(unittest.TestCase):
# Test behaviour when not given a string or pattern as parameter
self.assertRaises(TypeError, re.compile, 0)
# The huge memuse is because of re.sub() using a list and a join()
# to create the replacement result.
@bigmemtest(size=_2G, memuse=20)
def test_large(self, size):
# Issue #10182: indices were 32-bit-truncated.
s = 'a' * size
m = re.search('$', s)
self.assertIsNotNone(m)
self.assertEqual(m.start(), size)
self.assertEqual(m.end(), size)
r, n = re.subn('', '', s)
self.assertEqual(r, s)
self.assertEqual(n, size + 1)
def run_re_tests():
from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR
if verbose:
...
...
Misc/NEWS
View file @
9a2b2674
...
...
@@ -98,6 +98,9 @@ Core and Builtins
Library
-------
-
Issue
#
10182
:
The
re
module
doesn
't truncate indices to 32 bits anymore.
Patch by Serhiy Storchaka.
- Issue #16573: In 2to3, treat enumerate() like a consuming call, so superfluous
list() calls aren'
t
added
to
filter
(),
map
(),
and
zip
()
which
are
directly
passed
enumerate
().
...
...
Modules/_sre.c
View file @
9a2b2674
...
...
@@ -1618,7 +1618,7 @@ sre_literal_template(int charsize, char* ptr, Py_ssize_t len)
static
PyObject
*
sre_codesize
(
PyObject
*
self
,
PyObject
*
unused
)
{
return
Py
_BuildValue
(
"l"
,
sizeof
(
SRE_CODE
));
return
Py
Long_FromSize_t
(
sizeof
(
SRE_CODE
));
}
static
PyObject
*
...
...
@@ -2435,7 +2435,7 @@ next:
return
NULL
;
if
(
subn
)
return
Py_BuildValue
(
"N
i
"
,
item
,
n
);
return
Py_BuildValue
(
"N
n
"
,
item
,
n
);
return
item
;
...
...
@@ -3387,7 +3387,7 @@ match_start(MatchObject* self, PyObject* args)
}
/* mark is -1 if group is undefined */
return
Py
_BuildValue
(
"i"
,
self
->
mark
[
index
*
2
]);
return
Py
Long_FromSsize_t
(
self
->
mark
[
index
*
2
]);
}
static
PyObject
*
...
...
@@ -3410,7 +3410,7 @@ match_end(MatchObject* self, PyObject* args)
}
/* mark is -1 if group is undefined */
return
Py
_BuildValue
(
"i"
,
self
->
mark
[
index
*
2
+
1
]);
return
Py
Long_FromSsize_t
(
self
->
mark
[
index
*
2
+
1
]);
}
LOCAL
(
PyObject
*
)
...
...
@@ -3560,7 +3560,7 @@ static PyObject *
match_lastindex_get
(
MatchObject
*
self
)
{
if
(
self
->
lastindex
>=
0
)
return
Py
_BuildValue
(
"i"
,
self
->
lastindex
);
return
Py
Long_FromSsize_t
(
self
->
lastindex
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment