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
9a3027f2
Commit
9a3027f2
authored
Oct 12, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up new docstring handling code and fix compiler crash during Cython build
parent
48a8fa37
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+19
-13
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
9a3027f2
...
...
@@ -179,34 +179,40 @@ class PostParse(ScopeTrackingTransform):
'__cythonbufferdefaults__'
:
self
.
handle_bufferdefaults
}
def
_visit_DocS
tring
(
self
,
result
):
def
extract_docs
tring
(
self
,
result
):
if
hasattr
(
result
.
body
,
'stats'
)
and
result
.
body
.
stats
:
firstNode
=
result
.
body
.
stats
[
0
]
if
isinstance
(
firstNode
,
Nodes
.
ExprStatNode
)
and
firstNode
.
expr
.
is_string_literal
:
result
.
body
.
stats
=
result
.
body
.
stats
[
1
:]
self
.
doc
=
firstNode
.
expr
.
value
result
.
doc
=
self
.
doc
return
firstNode
.
expr
,
result
first_node
=
result
.
body
.
stats
[
0
]
if
isinstance
(
first_node
,
Nodes
.
ExprStatNode
)
and
first_node
.
expr
.
is_string_literal
:
string_node
=
first_node
.
expr
result
.
body
.
stats
[:]
=
result
.
body
.
stats
[
1
:]
if
isinstance
(
string_node
,
ExprNodes
.
BytesNode
):
warning
(
string_node
.
pos
,
"Python 3 requires docstrings to be unicode strings"
)
result
.
doc
=
string_node
.
value
elif
getattr
(
string_node
,
'unicode_value'
,
None
)
is
not
None
:
result
.
doc
=
string_node
.
unicode_value
else
:
result
.
doc
=
string_node
.
value
return
string_node
,
result
return
None
,
result
def
visit_FuncDefNode
(
self
,
node
):
doc
Node
,
result
=
self
.
_visit_DocS
tring
(
super
(
PostParse
,
self
).
visit_FuncDefNode
(
node
))
doc
_node
,
result
=
self
.
extract_docs
tring
(
super
(
PostParse
,
self
).
visit_FuncDefNode
(
node
))
return
result
def
visit_PyClassDefNode
(
self
,
node
):
doc
Node
,
result
=
self
.
_visit_DocS
tring
(
super
(
PostParse
,
self
).
visit_PyClassDefNode
(
node
))
if
doc
N
ode
:
result
.
classobj
.
doc
=
doc
N
ode
doc
_node
,
result
=
self
.
extract_docs
tring
(
super
(
PostParse
,
self
).
visit_PyClassDefNode
(
node
))
if
doc
_n
ode
:
result
.
classobj
.
doc
=
doc
_n
ode
return
result
def
visit_CClassDefNode
(
self
,
node
):
doc
Node
,
result
=
self
.
_visit_DocS
tring
(
super
(
PostParse
,
self
).
visit_CClassDefNode
(
node
))
doc
_node
,
result
=
self
.
extract_docs
tring
(
super
(
PostParse
,
self
).
visit_CClassDefNode
(
node
))
return
result
def
visit_ModuleNode
(
self
,
node
):
self
.
lambda_counter
=
1
self
.
genexpr_counter
=
1
doc
Node
,
result
=
self
.
_visit_DocS
tring
(
super
(
PostParse
,
self
).
visit_ModuleNode
(
node
))
doc
_node
,
result
=
self
.
extract_docs
tring
(
super
(
PostParse
,
self
).
visit_ModuleNode
(
node
))
return
result
def
visit_LambdaNode
(
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