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
633872e3
Commit
633872e3
authored
Mar 26, 2011
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge #11675
parents
01606dea
89461ef8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
1 deletion
+22
-1
Lib/multiprocessing/sharedctypes.py
Lib/multiprocessing/sharedctypes.py
+3
-1
Lib/test/test_multiprocessing.py
Lib/test/test_multiprocessing.py
+15
-0
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/multiprocessing/sharedctypes.py
View file @
633872e3
...
...
@@ -80,7 +80,9 @@ def RawArray(typecode_or_type, size_or_initializer):
type_
=
typecode_to_type
.
get
(
typecode_or_type
,
typecode_or_type
)
if
isinstance
(
size_or_initializer
,
int
):
type_
=
type_
*
size_or_initializer
return
_new_value
(
type_
)
obj
=
_new_value
(
type_
)
ctypes
.
memset
(
ctypes
.
addressof
(
obj
),
0
,
ctypes
.
sizeof
(
obj
))
return
obj
else
:
type_
=
type_
*
len
(
size_or_initializer
)
result
=
_new_value
(
type_
)
...
...
Lib/test/test_multiprocessing.py
View file @
633872e3
...
...
@@ -916,6 +916,21 @@ class _TestArray(BaseTestCase):
self
.
assertEqual
(
list
(
arr
[:]),
seq
)
@
unittest
.
skipIf
(
c_int
is
None
,
"requires _ctypes"
)
def
test_array_from_size
(
self
):
size
=
10
# Test for zeroing (see issue #11675).
# The repetition below strengthens the test by increasing the chances
# of previously allocated non-zero memory being used for the new array
# on the 2nd and 3rd loops.
for
_
in
range
(
3
):
arr
=
self
.
Array
(
'i'
,
size
)
self
.
assertEqual
(
len
(
arr
),
size
)
self
.
assertEqual
(
list
(
arr
),
[
0
]
*
size
)
arr
[:]
=
range
(
10
)
self
.
assertEqual
(
list
(
arr
),
list
(
range
(
10
)))
del
arr
@
unittest
.
skipIf
(
c_int
is
None
,
"requires _ctypes"
)
def
test_rawarray
(
self
):
self
.
test_array
(
raw
=
True
)
...
...
Misc/NEWS
View file @
633872e3
...
...
@@ -10,6 +10,10 @@ What's New in Python 3.2.1?
Core and Builtins
-----------------
- Issue #11675: multiprocessing.[Raw]Array objects created from an integer size
are now zeroed on creation. This matches the behaviour specified by the
documentation.
- Issue #11395: io.FileIO().write() clamps the data length to 32,767 bytes on
Windows if the file is a TTY to workaround a Windows bug. The Windows console
returns an error (12: not enough space error) on writing into stdout if
...
...
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