Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
35045eee
Commit
35045eee
authored
May 03, 2019
by
martinRenou
Committed by
Wenzel Jakob
May 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add getters for exception type, value and traceback (#1641)
parent
9bb33131
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
include/pybind11/pybind11.h
+4
-4
include/pybind11/pytypes.h
+8
-4
No files found.
include/pybind11/pybind11.h
View file @
35045eee
...
@@ -1987,12 +1987,12 @@ class gil_scoped_release { };
...
@@ -1987,12 +1987,12 @@ class gil_scoped_release { };
#endif
#endif
error_already_set
::~
error_already_set
()
{
error_already_set
::~
error_already_set
()
{
if
(
type
)
{
if
(
m_
type
)
{
error_scope
scope
;
error_scope
scope
;
gil_scoped_acquire
gil
;
gil_scoped_acquire
gil
;
type
.
release
().
dec_ref
();
m_
type
.
release
().
dec_ref
();
value
.
release
().
dec_ref
();
m_
value
.
release
().
dec_ref
();
trace
.
release
().
dec_ref
();
m_
trace
.
release
().
dec_ref
();
}
}
}
}
...
...
include/pybind11/pytypes.h
View file @
35045eee
...
@@ -324,7 +324,7 @@ public:
...
@@ -324,7 +324,7 @@ public:
/// Constructs a new exception from the current Python error indicator, if any. The current
/// Constructs a new exception from the current Python error indicator, if any. The current
/// Python error indicator will be cleared.
/// Python error indicator will be cleared.
error_already_set
()
:
std
::
runtime_error
(
detail
::
error_string
())
{
error_already_set
()
:
std
::
runtime_error
(
detail
::
error_string
())
{
PyErr_Fetch
(
&
type
.
ptr
(),
&
value
.
ptr
(),
&
trace
.
ptr
());
PyErr_Fetch
(
&
m_type
.
ptr
(),
&
m_value
.
ptr
(),
&
m_
trace
.
ptr
());
}
}
error_already_set
(
const
error_already_set
&
)
=
default
;
error_already_set
(
const
error_already_set
&
)
=
default
;
...
@@ -335,7 +335,7 @@ public:
...
@@ -335,7 +335,7 @@ public:
/// Give the currently-held error back to Python, if any. If there is currently a Python error
/// Give the currently-held error back to Python, if any. If there is currently a Python error
/// already set it is cleared first. After this call, the current object no longer stores the
/// already set it is cleared first. After this call, the current object no longer stores the
/// error variables (but the `.what()` string is still available).
/// error variables (but the `.what()` string is still available).
void
restore
()
{
PyErr_Restore
(
type
.
release
().
ptr
(),
value
.
release
().
ptr
(),
trace
.
release
().
ptr
());
}
void
restore
()
{
PyErr_Restore
(
m_type
.
release
().
ptr
(),
m_value
.
release
().
ptr
(),
m_
trace
.
release
().
ptr
());
}
// Does nothing; provided for backwards compatibility.
// Does nothing; provided for backwards compatibility.
PYBIND11_DEPRECATED
(
"Use of error_already_set.clear() is deprecated"
)
PYBIND11_DEPRECATED
(
"Use of error_already_set.clear() is deprecated"
)
...
@@ -344,10 +344,14 @@ public:
...
@@ -344,10 +344,14 @@ public:
/// Check if the currently trapped error type matches the given Python exception class (or a
/// Check if the currently trapped error type matches the given Python exception class (or a
/// subclass thereof). May also be passed a tuple to search for any exception class matches in
/// subclass thereof). May also be passed a tuple to search for any exception class matches in
/// the given tuple.
/// the given tuple.
bool
matches
(
handle
ex
)
const
{
return
PyErr_GivenExceptionMatches
(
ex
.
ptr
(),
type
.
ptr
());
}
bool
matches
(
handle
ex
)
const
{
return
PyErr_GivenExceptionMatches
(
ex
.
ptr
(),
m_type
.
ptr
());
}
const
object
&
type
()
const
{
return
m_type
;
}
const
object
&
value
()
const
{
return
m_value
;
}
const
object
&
trace
()
const
{
return
m_trace
;
}
private
:
private
:
object
type
,
value
,
trace
;
object
m_type
,
m_value
,
m_
trace
;
};
};
/** \defgroup python_builtins _
/** \defgroup python_builtins _
...
...
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