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
Gwenaël Samain
cython
Commits
b1d7b0de
Commit
b1d7b0de
authored
Sep 30, 2016
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Declare Exception as a builtin type.
This allows extending from it with a cdef class. Closes #724.
parent
ce9b4f5c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+3
-0
tests/run/builtin_type_inheritance_T608.pyx
tests/run/builtin_type_inheritance_T608.pyx
+11
-0
No files found.
Cython/Compiler/Builtin.py
View file @
b1d7b0de
...
...
@@ -324,6 +324,7 @@ builtin_types_table = [
BuiltinMethod
(
"add"
,
"TO"
,
"r"
,
"PySet_Add"
),
BuiltinMethod
(
"pop"
,
"T"
,
"O"
,
"PySet_Pop"
)]),
(
"frozenset"
,
"PyFrozenSet_Type"
,
[]),
(
"Exception"
,
"((PyTypeObject*)PyExc_Exception)[0]"
,
[]),
]
...
...
@@ -377,6 +378,8 @@ def init_builtin_types():
objstruct_cname
=
'PySetObject'
elif
name
==
'bool'
:
objstruct_cname
=
None
elif
name
==
'Exception'
:
objstruct_cname
=
"PyBaseExceptionObject"
else
:
objstruct_cname
=
'Py%sObject'
%
name
.
capitalize
()
the_type
=
builtin_scope
.
declare_builtin_type
(
name
,
cname
,
utility
,
objstruct_cname
)
...
...
tests/run/builtin_type_inheritance_T608.pyx
View file @
b1d7b0de
...
...
@@ -114,3 +114,14 @@ cdef class MyDict(dict):
True
"""
cdef
readonly
object
attr
cdef
class
MyException
(
Exception
):
"""
>>> raise MyException(3)
Traceback (most recent call last):
...
MyException: 3
"""
cdef
readonly
int
value
def
__cinit__
(
self
,
value
):
self
.
value
=
value
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