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
01a807db
Commit
01a807db
authored
Apr 02, 2007
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Array module's buffer interface can now handle empty arrays.
parent
e6e660bd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
Lib/test/test_re.py
Lib/test/test_re.py
+7
-0
Modules/arraymodule.c
Modules/arraymodule.c
+6
-0
No files found.
Lib/test/test_re.py
View file @
01a807db
...
...
@@ -601,6 +601,13 @@ class ReTests(unittest.TestCase):
self.assertEqual(iter.next().span(), (4, 4))
self.assertRaises(StopIteration, iter.next)
def test_empty_array(self):
# SF buf 1647541
import array
for typecode in 'cbBuhHiIlLfd':
a = array.array(typecode)
self.assertEqual(re.compile("
bla
").match(a), None)
self.assertEqual(re.compile("").match(a).groups(), ())
def run_re_tests():
from test.re_tests import benchmarks, tests, SUCCEED, FAIL, SYNTAX_ERROR
...
...
Modules/arraymodule.c
View file @
01a807db
...
...
@@ -1745,6 +1745,8 @@ static PyMappingMethods array_as_mapping = {
(
objobjargproc
)
array_ass_subscr
};
static
const
void
*
emptybuf
=
""
;
static
Py_ssize_t
array_buffer_getreadbuf
(
arrayobject
*
self
,
Py_ssize_t
index
,
const
void
**
ptr
)
{
...
...
@@ -1754,6 +1756,8 @@ array_buffer_getreadbuf(arrayobject *self, Py_ssize_t index, const void **ptr)
return
-
1
;
}
*
ptr
=
(
void
*
)
self
->
ob_item
;
if
(
*
ptr
==
NULL
)
*
ptr
=
emptybuf
;
return
self
->
ob_size
*
self
->
ob_descr
->
itemsize
;
}
...
...
@@ -1766,6 +1770,8 @@ array_buffer_getwritebuf(arrayobject *self, Py_ssize_t index, const void **ptr)
return
-
1
;
}
*
ptr
=
(
void
*
)
self
->
ob_item
;
if
(
*
ptr
==
NULL
)
*
ptr
=
emptybuf
;
return
self
->
ob_size
*
self
->
ob_descr
->
itemsize
;
}
...
...
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