Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
b6313575
Commit
b6313575
authored
Sep 01, 2020
by
Xavier Thompson
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Emit error when a const cypclass reference requires a write lock
parent
629acd77
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
Cython/Compiler/CypclassTransforms.py
Cython/Compiler/CypclassTransforms.py
+3
-0
tests/errors/cypclass_lock_error.pyx
tests/errors/cypclass_lock_error.pyx
+8
-0
No files found.
Cython/Compiler/CypclassTransforms.py
View file @
b6313575
...
@@ -542,6 +542,9 @@ class CypclassLockTransform(Visitor.EnvTransform):
...
@@ -542,6 +542,9 @@ class CypclassLockTransform(Visitor.EnvTransform):
return
written_node
return
written_node
ref_id
=
self
.
reference_identifier
(
written_node
)
ref_id
=
self
.
reference_identifier
(
written_node
)
if
ref_id
:
if
ref_id
:
if
ref_id
.
type
.
is_const
:
error
(
written_node
.
pos
,
"Reference '%s' is const but requires a write lock"
%
self
.
id_to_name
(
ref_id
))
return
written_node
if
not
self
.
wlocked
[
ref_id
]
>
0
:
if
not
self
.
wlocked
[
ref_id
]
>
0
:
if
lock_mode
==
"checklock"
:
if
lock_mode
==
"checklock"
:
error
(
written_node
.
pos
,
(
error
(
written_node
.
pos
,
(
...
...
tests/errors/cypclass_lock_error.pyx
View file @
b6313575
...
@@ -32,6 +32,13 @@ cdef void global_lock_taking():
...
@@ -32,6 +32,13 @@ cdef void global_lock_taking():
with
wlocked
global_cyobject
:
with
wlocked
global_cyobject
:
global_cyobject
.
setter
(
global_cyobject
.
getter
()
+
1
)
global_cyobject
.
setter
(
global_cyobject
.
getter
()
+
1
)
cdef
take_non_const
(
A
a
):
pass
cdef
take_const
(
const
A
a
):
take_non_const
(
a
)
_ERRORS
=
u"""
_ERRORS
=
u"""
20:4: Reference 'obj' is not correctly locked in this expression (write lock required)
20:4: Reference 'obj' is not correctly locked in this expression (write lock required)
21:4: Reference 'obj' is not correctly locked in this expression (read lock required)
21:4: Reference 'obj' is not correctly locked in this expression (read lock required)
...
@@ -40,4 +47,5 @@ _ERRORS = u"""
...
@@ -40,4 +47,5 @@ _ERRORS = u"""
25:4: Reference 'obj' is not correctly locked in this expression (read lock required)
25:4: Reference 'obj' is not correctly locked in this expression (read lock required)
26:21: Reference 'obj' is not correctly locked in this expression (read lock required)
26:21: Reference 'obj' is not correctly locked in this expression (read lock required)
32:17: Can only lock local variables or arguments
32:17: Can only lock local variables or arguments
40:19: Reference 'a' is const but requires a write lock
"""
"""
Xavier Thompson
@xavier_thompson
mentioned in commit
fb11f2d4
·
Sep 11, 2020
mentioned in commit
fb11f2d4
mentioned in commit fb11f2d4c41084b18c2f3b86590b8a2ad21e0002
Toggle commit list
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