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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
cython
Commits
a63e3c42
Commit
a63e3c42
authored
Aug 18, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt CypclassLockTransform for python2.7 compatibility
parent
c49ca39a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
Cython/Compiler/CypclassTransforms.py
Cython/Compiler/CypclassTransforms.py
+18
-9
No files found.
Cython/Compiler/CypclassTransforms.py
View file @
a63e3c42
...
...
@@ -9,8 +9,6 @@ import cython
cython
.
declare
(
Naming
=
object
,
PyrexTypes
=
object
,
EncodedString
=
object
,
error
=
object
)
from
collections
import
defaultdict
from
contextlib
import
ExitStack
from
itertools
import
chain
from
.
import
Naming
from
.
import
Nodes
...
...
@@ -456,6 +454,16 @@ class CypclassLockTransform(Visitor.EnvTransform):
return
self
.
StackLock
(
self
,
obj_entry
,
state
)
def
with_nested_stacklocks
(
self
,
stacklocks_iterator
,
body_callback
):
# Poor mans's nested context managers
try
:
stacklock
=
next
(
stacklocks_iterator
)
except
StopIteration
:
return
body_callback
()
with
stacklock
:
return
self
.
with_nested_stacklocks
(
stacklocks_iterator
,
body_callback
)
class
AccessContext
:
"""
Context manager to track the kind of access (reading, writing ...).
...
...
@@ -571,13 +579,14 @@ class CypclassLockTransform(Visitor.EnvTransform):
def
visit_CFuncDefNode
(
self
,
node
):
cyp_class_args
=
(
e
for
e
in
node
.
local_scope
.
arg_entries
if
e
.
type
.
is_cyp_class
)
with
ExitStack
()
as
locked_args_stack
:
for
arg
in
cyp_class_args
:
is_rlocked
=
arg
.
type
.
is_const
or
arg
.
is_self_arg
and
node
.
entry
.
type
.
is_const_method
arg_id
=
arg
# Mark each cypclass arguments as locked within the function body
locked_args_stack
.
enter_context
(
self
.
stacklock
(
arg_id
,
"rlocked"
if
is_rlocked
else
"wlocked"
))
self
.
visit
(
node
.
body
)
arg_locks
=
[]
for
arg
in
cyp_class_args
:
is_rlocked
=
arg
.
type
.
is_const
or
arg
.
is_self_arg
and
node
.
entry
.
type
.
is_const_method
arg_id
=
arg
# Mark each cypclass arguments as locked within the function body
arg_locks
.
append
(
self
.
stacklock
(
arg_id
,
"rlocked"
if
is_rlocked
else
"wlocked"
))
with_body
=
lambda
:
self
.
visit
(
node
.
body
)
self
.
with_nested_stacklocks
(
iter
(
arg_locks
),
with_body
)
return
node
def
visit_LockCypclassNode
(
self
,
node
):
...
...
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