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
Gwenaël Samain
cython
Commits
24f0ceee
Commit
24f0ceee
authored
Apr 14, 2010
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not emit C code for unused special method docstrings
parent
12ad333d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
3 deletions
+51
-3
Cython/Compiler/AnalysedTreeTransforms.py
Cython/Compiler/AnalysedTreeTransforms.py
+2
-1
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+1
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+5
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+5
-0
tests/compile/specmethdocstring.pyx
tests/compile/specmethdocstring.pyx
+22
-0
tests/run/autotestdict.pyx
tests/run/autotestdict.pyx
+16
-0
No files found.
Cython/Compiler/AnalysedTreeTransforms.py
View file @
24f0ceee
...
...
@@ -11,7 +11,8 @@ import Symtab
class
AutoTestDictTransform
(
ScopeTrackingTransform
):
# Handles autotestdict directive
blacklist
=
[
'__cinit__'
,
'__dealloc__'
,
'__richcmp__'
,
'__nonzero__'
]
blacklist
=
[
'__cinit__'
,
'__dealloc__'
,
'__richcmp__'
,
'__nonzero__'
,
'__len__'
,
'__contains__'
]
def
visit_ModuleNode
(
self
,
node
):
if
node
.
is_pxd
:
...
...
Cython/Compiler/ModuleNode.py
View file @
24f0ceee
...
...
@@ -1535,7 +1535,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def
generate_method_table
(
self
,
env
,
code
):
code
.
putln
(
""
)
code
.
putln
(
"static
struct
PyMethodDef %s[] = {"
%
"static PyMethodDef %s[] = {"
%
env
.
method_table_cname
)
for
entry
in
env
.
pyfunc_entries
:
code
.
put_pymethoddef
(
entry
,
","
)
...
...
Cython/Compiler/Nodes.py
View file @
24f0ceee
...
...
@@ -2086,7 +2086,11 @@ class DefNode(FuncDefNode):
code
.
putln
(
"%s; /*proto*/"
%
header
)
if
proto_only
:
return
if
self
.
entry
.
doc
and
Options
.
docstrings
:
if
(
Options
.
docstrings
and
self
.
entry
.
doc
and
(
not
self
.
entry
.
is_special
or
self
.
entry
.
signature
.
method_flags
())
and
not
self
.
entry
.
scope
.
is_property_scope
):
docstr
=
self
.
entry
.
doc
if
docstr
.
is_unicode
:
docstr
=
docstr
.
utf8encode
()
...
...
Cython/Compiler/Symtab.py
View file @
24f0ceee
...
...
@@ -207,6 +207,8 @@ class Scope(object):
# return_type PyrexType or None Return type of function owning scope
# is_py_class_scope boolean Is a Python class scope
# is_c_class_scope boolean Is an extension type scope
# is_cpp_class_scope boolean Is a C++ class scope
# is_property_scope boolean Is a extension type property scope
# scope_prefix string Disambiguator for C names
# in_cinclude boolean Suppress C declaration code
# qualified_name string "
modname
" or "
modname
.
classname
"
...
...
@@ -220,6 +222,7 @@ class Scope(object):
is_py_class_scope = 0
is_c_class_scope = 0
is_cpp_class_scope = 0
is_property_scope = 0
is_module_scope = 0
scope_prefix = ""
in_cinclude = 0
...
...
@@ -1619,6 +1622,8 @@ class PropertyScope(Scope):
# a property of an extension type.
#
# parent_type PyExtensionType The type to which the property belongs
is_property_scope
=
1
def
declare_pyfunction
(
self
,
name
,
pos
):
# Add an entry for a method.
...
...
tests/compile/specmethdocstring.pyx
View file @
24f0ceee
cdef
class
C
:
def
__cinit__
(
self
):
"This is an unusable docstring."
def
__init__
(
self
):
"This is an unusable docstring."
def
__dealloc__
(
self
):
"This is an unusable docstring."
def
__richcmp__
(
self
,
other
,
int
op
):
"This is an unusable docstring."
def
__nonzero__
(
self
):
"This is an unusable docstring."
return
False
def
__contains__
(
self
,
other
):
"This is an unusable docstring."
property
foo
:
def
__get__
(
self
):
"So is this."
def
__set__
(
self
,
x
):
"And here is another one."
def
__add__
(
self
,
other
):
"usable docstring"
def
__iter__
(
self
):
"usable docstring"
return
False
def
__next__
(
self
):
"usable docstring"
return
False
tests/run/autotestdict.pyx
View file @
24f0ceee
...
...
@@ -110,4 +110,20 @@ cdef class MyCdefClass:
False
"""
def
__len__
(
self
):
"""
Should not be included, as it can't be looked up with getattr in Py 3.1
>>> True
False
"""
def
__contains__
(
self
,
value
):
"""
Should not be included, as it can't be looked up with getattr in Py 3.1
>>> True
False
"""
cdef
func
()
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