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
Boxiang Sun
cython
Commits
dc4c6c5c
Commit
dc4c6c5c
authored
Jul 07, 2010
by
Craig Citro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bug with automatic conversion of public attributes to properties.
parent
27b5165d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
3 deletions
+31
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-1
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+13
-1
tests/errors/e_extweakref.pyx
tests/errors/e_extweakref.pyx
+1
-0
tests/run/extpropertyref.pyx
tests/run/extpropertyref.pyx
+15
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
dc4c6c5c
...
...
@@ -3427,7 +3427,8 @@ class AttributeNode(ExprNode):
def
generate_deletion_code
(
self
,
code
):
interned_attr_cname
=
code
.
intern_identifier
(
self
.
attribute
)
self
.
obj
.
generate_evaluation_code
(
code
)
if
self
.
is_py_attr
:
if
self
.
is_py_attr
or
(
isinstance
(
self
.
entry
.
scope
,
Symtab
.
PropertyScope
)
and
self
.
entry
.
scope
.
entries
.
has_key
(
u'__del__'
)):
code
.
put_error_if_neg
(
self
.
pos
,
'PyObject_DelAttr(%s, %s)'
%
(
self
.
obj
.
py_result
(),
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
dc4c6c5c
...
...
@@ -952,6 +952,15 @@ property NAME:
def __set__(self, value):
ATTR = value
"""
,
level
=
'c_class'
)
basic_pyobject_property
=
TreeFragment
(
u"""
property NAME:
def __get__(self):
return ATTR
def __set__(self, value):
ATTR = value
def __del__(self):
ATTR = None
"""
,
level
=
'c_class'
)
basic_property_ro
=
TreeFragment
(
u"""
property NAME:
def __get__(self):
...
...
@@ -1055,7 +1064,10 @@ property NAME:
def
create_Property
(
self
,
entry
):
if
entry
.
visibility
==
'public'
:
template
=
self
.
basic_property
if
entry
.
type
.
is_pyobject
:
template
=
self
.
basic_pyobject_property
else
:
template
=
self
.
basic_property
elif
entry
.
visibility
==
'readonly'
:
template
=
self
.
basic_property_ro
property
=
template
.
substitute
({
...
...
tests/errors/e_extweakref.pyx
View file @
dc4c6c5c
...
...
@@ -15,6 +15,7 @@ cdef void f():
_ERRORS
=
u"""
5:20: Illegal use of special attribute __weakref__
5:20: Illegal use of special attribute __weakref__
5:20: Illegal use of special attribute __weakref__
5:20: Special attribute __weakref__ cannot be exposed to Python
8:22: Illegal use of special attribute __weakref__
8:22: Special attribute __weakref__ cannot be exposed to Python
...
...
tests/run/extpropertyref.pyx
View file @
dc4c6c5c
...
...
@@ -15,7 +15,7 @@ def tomato():
>>> lines = __test__.keys()
>>> len(lines)
2
3
>>> 'Spam.eggs.__get__ (line 5)' in lines
True
>>> 'tomato (line 11)' in lines
...
...
@@ -26,3 +26,17 @@ def tomato():
spam
=
Spam
()
lettuce
=
spam
.
eggs
return
lettuce
cdef
class
Bacon
(
object
):
cdef
object
number_of_slices
cdef
public
object
is_a_vegetable
def
breakfast
():
"""
>>> breakfast()
"""
cdef
Bacon
myslices
=
Bacon
()
myslices
.
is_a_vegetable
=
True
assert
myslices
.
is_a_vegetable
,
myslices
.
is_a_vegetable
del
myslices
.
is_a_vegetable
assert
myslices
.
is_a_vegetable
is
None
,
myslices
.
is_a_vegetable
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