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
7a1213a3
Commit
7a1213a3
authored
Dec 28, 2019
by
Stefan Behnel
Committed by
GitHub
Dec 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix temp variable handling for the super() class cell. (GH-3289)
Closes GH-3246.
parent
bfcaf163
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
18 deletions
+45
-18
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+12
-13
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+14
-4
tests/run/py3k_super.pyx
tests/run/py3k_super.pyx
+19
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
7a1213a3
...
...
@@ -9136,21 +9136,20 @@ class ClassCellInjectorNode(ExprNode):
def
analyse_expressions
(
self
,
env
):
return
self
def
generate_evaluation_code
(
self
,
code
):
if
self
.
is_active
:
self
.
allocate_temp_result
(
code
)
code
.
putln
(
'%s = PyList_New(0); %s'
%
(
self
.
result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
def
generate_result_code
(
self
,
code
):
assert
self
.
is_active
code
.
putln
(
'%s = PyList_New(0); %s'
%
(
self
.
result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
def
generate_injection_code
(
self
,
code
,
classobj_cname
):
if
self
.
is_active
:
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"CyFunctionClassCell"
,
"CythonFunction.c"
))
code
.
put_error_if_neg
(
self
.
pos
,
'__Pyx_CyFunction_InitClassCell(%s, %s)'
%
(
self
.
result
(),
classobj_cname
))
assert
self
.
is_active
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"CyFunctionClassCell"
,
"CythonFunction.c"
))
code
.
put_error_if_neg
(
self
.
pos
,
'__Pyx_CyFunction_InitClassCell(%s, %s)'
%
(
self
.
result
(),
classobj_cname
))
class
ClassCellNode
(
ExprNode
):
...
...
Cython/Compiler/Nodes.py
View file @
7a1213a3
...
...
@@ -4596,12 +4596,22 @@ class PyClassDefNode(ClassDefNode):
self
.
metaclass
.
generate_evaluation_code
(
code
)
self
.
dict
.
generate_evaluation_code
(
code
)
cenv
.
namespace_cname
=
cenv
.
class_obj_cname
=
self
.
dict
.
result
()
self
.
class_cell
.
generate_evaluation_code
(
code
)
class_cell
=
self
.
class_cell
if
class_cell
is
not
None
and
not
class_cell
.
is_active
:
class_cell
=
None
if
class_cell
is
not
None
:
class_cell
.
generate_evaluation_code
(
code
)
self
.
body
.
generate_execution_code
(
code
)
self
.
class_result
.
generate_evaluation_code
(
code
)
self
.
class_cell
.
generate_injection_code
(
code
,
self
.
class_result
.
result
())
self
.
class_cell
.
generate_disposal_code
(
code
)
if
class_cell
is
not
None
:
class_cell
.
generate_injection_code
(
code
,
self
.
class_result
.
result
())
if
class_cell
is
not
None
:
class_cell
.
generate_disposal_code
(
code
)
class_cell
.
free_temps
(
code
)
cenv
.
namespace_cname
=
cenv
.
class_obj_cname
=
self
.
classobj
.
result
()
self
.
target
.
generate_assignment_code
(
self
.
class_result
,
code
)
self
.
dict
.
generate_disposal_code
(
code
)
...
...
tests/run/py3k_super.pyx
View file @
7a1213a3
# mode: run
# tag: py3k_super
# tag: py3k_super
, gh3246
class
A
(
object
):
def
method
(
self
):
...
...
@@ -89,3 +89,21 @@ cdef class CClassSub(CClassBase):
# return super().method_cp()
# cdef method_c(self):
# return super().method_c()
def
freeing_class_cell_temp_gh3246
():
# https://github.com/cython/cython/issues/3246
"""
>>> abc = freeing_class_cell_temp_gh3246()
>>> abc().a
1
"""
class
SimpleBase
(
object
):
def
__init__
(
self
):
self
.
a
=
1
class
ABC
(
SimpleBase
):
def
__init__
(
self
):
super
().
__init__
()
return
ABC
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