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
7902d9d2
Commit
7902d9d2
authored
Sep 16, 2015
by
asaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow unicode for module.__doc__, and allow recall module.__init__
parent
60bab2ea
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
src/runtime/types.cpp
src/runtime/types.cpp
+12
-5
test/tests/modules.py
test/tests/modules.py
+10
-0
No files found.
src/runtime/types.cpp
View file @
7902d9d2
...
@@ -2143,14 +2143,21 @@ Box* typeMro(BoxedClass* self) {
...
@@ -2143,14 +2143,21 @@ Box* typeMro(BoxedClass* self) {
Box
*
moduleInit
(
BoxedModule
*
self
,
Box
*
name
,
Box
*
doc
)
{
Box
*
moduleInit
(
BoxedModule
*
self
,
Box
*
name
,
Box
*
doc
)
{
RELEASE_ASSERT
(
PyModule_Check
(
self
),
""
);
RELEASE_ASSERT
(
PyModule_Check
(
self
),
""
);
RELEASE_ASSERT
(
name
->
cls
==
str_cls
,
""
);
RELEASE_ASSERT
(
name
->
cls
==
str_cls
,
""
);
RELEASE_ASSERT
(
!
doc
||
doc
->
cls
==
str_cls
,
""
);
RELEASE_ASSERT
(
!
doc
||
doc
->
cls
==
str_cls
||
doc
->
cls
==
unicode_cls
,
""
);
doc
=
doc
?
doc
:
None
;
HCAttrs
*
attrs
=
self
->
getHCAttrsPtr
();
HCAttrs
*
attrs
=
self
->
getHCAttrsPtr
();
RELEASE_ASSERT
(
attrs
->
hcls
->
attributeArraySize
()
==
0
,
""
);
if
(
attrs
->
hcls
->
attributeArraySize
()
==
0
)
{
attrs
->
hcls
=
HiddenClass
::
makeSingleton
();
attrs
->
hcls
=
HiddenClass
::
makeSingleton
();
self
->
giveAttr
(
"__name__"
,
name
);
self
->
giveAttr
(
"__name__"
,
name
);
self
->
giveAttr
(
"__doc__"
,
doc
?
doc
:
boxString
(
""
));
self
->
giveAttr
(
"__doc__"
,
doc
);
}
else
{
self
->
setattr
(
internStringMortal
(
"__name__"
),
name
,
NULL
);
self
->
setattr
(
internStringMortal
(
"__doc__"
),
doc
,
NULL
);
}
return
None
;
return
None
;
}
}
...
...
test/tests/modules.py
View file @
7902d9d2
import
empty_module
import
empty_module
import
math
import
math
import
types
x
=
repr
(
empty_module
)
x
=
repr
(
empty_module
)
...
@@ -9,3 +10,12 @@ print x[0:29]
...
@@ -9,3 +10,12 @@ print x[0:29]
print
x
[
-
2
:]
print
x
[
-
2
:]
print
repr
(
math
)[:
10
]
print
repr
(
math
)[:
10
]
m
=
types
.
ModuleType
(
"foo"
)
print
m
.
__doc__
,
type
(
m
.
__doc__
)
m
=
types
.
ModuleType
(
"foo"
,
"bar"
)
print
m
.
__doc__
,
type
(
m
.
__doc__
)
m
=
types
.
ModuleType
(
"foo"
,
u"bar"
)
print
m
.
__doc__
,
type
(
m
.
__doc__
)
m
.
__init__
(
"bar"
,
"baz"
)
print
m
.
__doc__
,
type
(
m
.
__doc__
)
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