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
Kirill Smelkov
cython
Commits
12b64d68
Commit
12b64d68
authored
Dec 04, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent inheriting from PyVarObjects: tuple, bytes and str
parent
cba8fe49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+4
-0
tests/errors/builtin_type_inheritance.pyx
tests/errors/builtin_type_inheritance.pyx
+17
-0
No files found.
Cython/Compiler/Nodes.py
View file @
12b64d68
...
...
@@ -3203,6 +3203,10 @@ class CClassDefNode(ClassDefNode):
base_class_entry
.
type
.
scope
.
directives
[
'final'
]:
error
(
self
.
pos
,
"Base class '%s' of type '%s' is final"
%
(
self
.
base_class_name
,
self
.
class_name
))
elif
base_class_entry
.
type
.
is_builtin_type
and
\
base_class_entry
.
type
.
name
in
(
'tuple'
,
'str'
,
'bytes'
):
error
(
self
.
pos
,
"inheritance from PyVarObject types like '%s' is not currently supported"
%
base_class_entry
.
type
.
name
)
else
:
self
.
base_type
=
base_class_entry
.
type
has_body
=
self
.
body
is
not
None
...
...
tests/errors/builtin_type_inheritance.pyx
0 → 100644
View file @
12b64d68
# current restriction: cannot inherit from PyVarObject (see ticket #152)
cdef
class
MyTuple
(
tuple
):
pass
cdef
class
MyBytes
(
bytes
):
pass
cdef
class
MyStr
(
str
):
# only in Py2, but can't know that during compilation
pass
_ERRORS
=
"""
4:5: inheritance from PyVarObject types like 'tuple' is not currently supported
7:5: inheritance from PyVarObject types like 'bytes' is not currently supported
10:5: inheritance from PyVarObject types like 'str' is not currently supported
"""
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