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
589e6a68
Commit
589e6a68
authored
Jan 22, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ban creating instances of None
parent
5aabdb34
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
src/runtime/types.cpp
src/runtime/types.cpp
+1
-0
test/tests/none__class__.py
test/tests/none__class__.py
+5
-0
No files found.
src/runtime/types.cpp
View file @
589e6a68
...
...
@@ -3913,6 +3913,7 @@ void setupRuntime() {
none_cls
->
giveAttr
(
"__nonzero__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
noneNonzero
,
BOXED_BOOL
,
1
)));
none_cls
->
giveAttr
(
"__doc__"
,
None
);
none_cls
->
tp_hash
=
(
hashfunc
)
_Py_HashPointer
;
none_cls
->
tp_new
=
NULL
;
// don't allow creating instances
none_cls
->
freeze
();
none_cls
->
tp_repr
=
none_repr
;
...
...
test/tests/none__class__.py
View file @
589e6a68
print
None
.
__class__
print
type
(
None
).
__doc__
,
None
.
__doc__
try
:
type
(
None
)()
except
TypeError
as
e
:
print
e
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