Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
circuitpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
circuitpython
Commits
f4a12dca
Commit
f4a12dca
authored
Feb 27, 2017
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py/objarray: Disallow slice-assignment to read-only memoryview.
Also comes with a test for this. Fixes issue #2904.
parent
23ccb3e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
0 deletions
+8
-0
py/objarray.c
py/objarray.c
+4
-0
tests/basics/memoryview1.py
tests/basics/memoryview1.py
+4
-0
No files found.
py/objarray.c
View file @
f4a12dca
...
...
@@ -418,6 +418,10 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
uint8_t
*
dest_items
=
o
->
items
;
#if MICROPY_PY_BUILTINS_MEMORYVIEW
if
(
o
->
base
.
type
==
&
mp_type_memoryview
)
{
if
((
o
->
typecode
&
0x80
)
==
0
)
{
// store to read-only memoryview not allowed
return
MP_OBJ_NULL
;
}
if
(
len_adj
!=
0
)
{
goto
compat_error
;
}
...
...
tests/basics/memoryview1.py
View file @
f4a12dca
...
...
@@ -18,6 +18,10 @@ try:
m
[
0
]
=
1
except
TypeError
:
print
(
"TypeError"
)
try
:
m
[
0
:
2
]
=
b'00'
except
TypeError
:
print
(
"TypeError"
)
# test writing to bytearray
b
=
bytearray
(
b
)
...
...
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