Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
67a68f13
Commit
67a68f13
authored
Dec 01, 2016
by
esquires
Committed by
Wenzel Jakob
Dec 01, 2016
Browse files
print traceback on failed import (#537)
parent
14bfe622
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
3 deletions
+2
-3
include/pybind11/common.h
include/pybind11/common.h
+0
-1
include/pybind11/pybind11.h
include/pybind11/pybind11.h
+2
-2
No files found.
include/pybind11/common.h
View file @
67a68f13
...
@@ -511,7 +511,6 @@ PYBIND11_RUNTIME_EXCEPTION(stop_iteration, PyExc_StopIteration)
...
@@ -511,7 +511,6 @@ PYBIND11_RUNTIME_EXCEPTION(stop_iteration, PyExc_StopIteration)
PYBIND11_RUNTIME_EXCEPTION
(
index_error
,
PyExc_IndexError
)
PYBIND11_RUNTIME_EXCEPTION
(
index_error
,
PyExc_IndexError
)
PYBIND11_RUNTIME_EXCEPTION
(
key_error
,
PyExc_KeyError
)
PYBIND11_RUNTIME_EXCEPTION
(
key_error
,
PyExc_KeyError
)
PYBIND11_RUNTIME_EXCEPTION
(
value_error
,
PyExc_ValueError
)
PYBIND11_RUNTIME_EXCEPTION
(
value_error
,
PyExc_ValueError
)
PYBIND11_RUNTIME_EXCEPTION
(
import_error
,
PyExc_ImportError
)
PYBIND11_RUNTIME_EXCEPTION
(
type_error
,
PyExc_TypeError
)
PYBIND11_RUNTIME_EXCEPTION
(
type_error
,
PyExc_TypeError
)
PYBIND11_RUNTIME_EXCEPTION
(
cast_error
,
PyExc_RuntimeError
)
/// Thrown when pybind11::cast or handle::call fail due to a type casting error
PYBIND11_RUNTIME_EXCEPTION
(
cast_error
,
PyExc_RuntimeError
)
/// Thrown when pybind11::cast or handle::call fail due to a type casting error
PYBIND11_RUNTIME_EXCEPTION
(
reference_cast_error
,
PyExc_RuntimeError
)
/// Used internally
PYBIND11_RUNTIME_EXCEPTION
(
reference_cast_error
,
PyExc_RuntimeError
)
/// Used internally
...
...
include/pybind11/pybind11.h
View file @
67a68f13
...
@@ -580,7 +580,7 @@ public:
...
@@ -580,7 +580,7 @@ public:
static
module
import
(
const
char
*
name
)
{
static
module
import
(
const
char
*
name
)
{
PyObject
*
obj
=
PyImport_ImportModule
(
name
);
PyObject
*
obj
=
PyImport_ImportModule
(
name
);
if
(
!
obj
)
if
(
!
obj
)
throw
import_error
(
"Module
\"
"
+
std
::
string
(
name
)
+
"
\"
not found!"
);
throw
error_already_set
(
);
return
reinterpret_steal
<
module
>
(
obj
);
return
reinterpret_steal
<
module
>
(
obj
);
}
}
...
@@ -1495,7 +1495,7 @@ PYBIND11_NOINLINE inline void print(tuple args, dict kwargs) {
...
@@ -1495,7 +1495,7 @@ PYBIND11_NOINLINE inline void print(tuple args, dict kwargs) {
}
else
{
}
else
{
try
{
try
{
file
=
module
::
import
(
"sys"
).
attr
(
"stdout"
);
file
=
module
::
import
(
"sys"
).
attr
(
"stdout"
);
}
catch
(
const
import_error
&
)
{
}
catch
(
const
error_already_set
&
)
{
/* If print() is called from code that is executed as
/* If print() is called from code that is executed as
part of garbage collection during interpreter shutdown,
part of garbage collection during interpreter shutdown,
importing 'sys' can fail. Give up rather than crashing the
importing 'sys' can fail. Give up rather than crashing the
...
...
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