Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
fe918ed5
Commit
fe918ed5
authored
Jun 26, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better to set __doc__ here
parent
3b485047
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
src/core/cfg.cpp
src/core/cfg.cpp
+0
-6
src/runtime/types.cpp
src/runtime/types.cpp
+4
-0
No files found.
src/core/cfg.cpp
View file @
fe918ed5
...
...
@@ -1668,19 +1668,13 @@ CFG* computeCFG(SourceInfo* source, std::vector<AST_stmt*> body) {
// It'd be ok to add __doc__ to the dict multiple times, since the last one would win
if
(
written_names
.
count
(
"__doc__"
)
==
0
)
{
bool
found_docstr
=
false
;
if
(
body
.
size
()
&&
body
[
0
]
->
type
==
AST_TYPE
::
Expr
)
{
AST_Expr
*
first_expr
=
ast_cast
<
AST_Expr
>
(
body
[
0
]);
if
(
first_expr
->
value
->
type
==
AST_TYPE
::
Str
)
{
found_docstr
=
true
;
rtn_dict
->
keys
.
push_back
(
new
AST_Str
(
"__doc__"
));
rtn_dict
->
values
.
push_back
(
first_expr
->
value
);
}
}
if
(
!
found_docstr
)
{
rtn_dict
->
keys
.
push_back
(
new
AST_Str
(
"__doc__"
));
rtn_dict
->
values
.
push_back
(
makeName
(
"None"
,
AST_TYPE
::
Load
));
}
}
// Even if the user never explicitly wrote to __module__, there was an
...
...
src/runtime/types.cpp
View file @
fe918ed5
...
...
@@ -313,6 +313,10 @@ extern "C" Box* createUserClass(std::string* name, Box* _base, Box* _attr_dict)
made
->
giveAttr
(
static_cast
<
BoxedString
*>
(
p
.
first
)
->
s
,
p
.
second
);
}
if
(
made
->
getattr
(
"__doc__"
)
==
NULL
)
{
made
->
giveAttr
(
"__doc__"
,
None
);
}
// Note: make sure to do this after assigning the attrs, since it will overwrite any defined __name__
made
->
setattr
(
"__name__"
,
boxString
(
*
name
),
NULL
);
...
...
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