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
bfb0ec4a
Commit
bfb0ec4a
authored
Sep 28, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Now that object has __doc__, fix others
Otherwise they would inherit object's __doc__
parent
754ddae3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+4
-0
src/runtime/types.cpp
src/runtime/types.cpp
+19
-1
No files found.
src/runtime/objmodel.cpp
View file @
bfb0ec4a
...
...
@@ -636,6 +636,10 @@ void BoxedClass::freeze() {
assert
(
!
is_constant
);
assert
(
tp_name
);
// otherwise debugging will be very hard
auto
doc_str
=
getStaticString
(
"__doc__"
);
if
(
!
hasattr
(
doc_str
))
giveAttr
(
incref
(
doc_str
),
boxString
(
tp_name
));
fixup_slot_dispatchers
(
this
);
if
(
instancesHaveDictAttrs
()
||
instancesHaveHCAttrs
())
{
...
...
src/runtime/types.cpp
View file @
bfb0ec4a
...
...
@@ -1791,6 +1791,17 @@ static Box* functionNonzero(BoxedFunction* self) {
Py_RETURN_TRUE
;
}
static
Box
*
im_doc
(
Box
*
b
,
void
*
)
noexcept
{
RELEASE_ASSERT
(
b
->
cls
==
instancemethod_cls
,
""
);
auto
doc_str
=
getStaticString
(
"__doc__"
);
try
{
return
getattr
(
static_cast
<
BoxedInstanceMethod
*>
(
b
)
->
func
,
doc_str
);
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
return
NULL
;
}
}
extern
"C"
{
Box
*
Py_None
=
NULL
;
Box
*
NotImplemented
=
NULL
;
...
...
@@ -4234,7 +4245,10 @@ void setupRuntime() {
none_cls
->
giveAttr
(
"__base__"
,
object_cls
);
Py_INCREF
(
Py_None
);
object_cls
->
giveAttr
(
"__base__"
,
Py_None
);
object_cls
->
giveAttr
(
"__doc__"
,
boxString
(
"The most base type"
));
type_cls
->
giveAttr
(
"__doc__"
,
boxString
(
"type(object) -> the object's type
\n
type(name, bases, dict) -> a new type"
));
// Not sure why CPython defines sizeof(PyTupleObject) to include one element,
// but we copy that, which means we have to subtract that extra pointer to get the tp_basicsize:
...
...
@@ -4574,10 +4588,14 @@ void setupRuntime() {
instancemethod_cls
->
giveAttrBorrowed
(
"__func__"
,
instancemethod_cls
->
getattr
(
getStaticString
(
"im_func"
)));
instancemethod_cls
->
giveAttrMember
(
"im_self"
,
T_OBJECT
,
offsetof
(
BoxedInstanceMethod
,
obj
));
instancemethod_cls
->
giveAttrBorrowed
(
"__self__"
,
instancemethod_cls
->
getattr
(
getStaticString
(
"im_self"
)));
instancemethod_cls
->
freeze
();
instancemethod_cls
->
giveAttrMember
(
"im_class"
,
T_OBJECT
,
offsetof
(
BoxedInstanceMethod
,
im_class
),
true
);
// TODO: this should be handled via a getattro instead (which proxies to the function):
instancemethod_cls
->
giveAttrDescriptor
(
"__doc__"
,
im_doc
,
NULL
);
instancemethod_cls
->
freeze
();
slice_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
BoxedCode
::
create
((
void
*
)
sliceNew
,
UNKNOWN
,
4
,
false
,
false
,
"slice.__new__"
),
{
NULL
,
Py_None
}));
...
...
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