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
dd57a34e
Commit
dd57a34e
authored
Dec 26, 2015
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved error handling at module import time
parent
9d573f44
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
include/pybind11/common.h
+14
-2
include/pybind11/pybind11.h
+4
-1
No files found.
include/pybind11/common.h
View file @
dd57a34e
...
...
@@ -67,12 +67,24 @@
#endif
#if PY_MAJOR_VERSION >= 3
#define PYBIND11_PLUGIN(name) \
#define PYBIND11_PLUGIN
_IMPL
(name) \
extern "C" PYBIND11_EXPORT PyObject *PyInit_##name()
#else
#define PYBIND11_PLUGIN(name) \
#define PYBIND11_PLUGIN
_IMPL
(name) \
extern "C" PYBIND11_EXPORT PyObject *init##name()
#endif
#define PYBIND11_PLUGIN(name) \
static PyObject *pybind11_init(); \
PYBIND11_PLUGIN_IMPL(name) { \
try { \
return pybind11_init(); \
} catch (const std::exception &e) { \
PyErr_SetString(PyExc_ImportError, e.what()); \
return nullptr; \
} \
} \
PyObject *pybind11_init()
NAMESPACE_BEGIN
(
pybind11
)
...
...
include/pybind11/pybind11.h
View file @
dd57a34e
...
...
@@ -471,7 +471,10 @@ public:
}
static
module
import
(
const
char
*
name
)
{
return
module
(
PyImport_ImportModule
(
name
),
false
);
PyObject
*
obj
=
PyImport_ImportModule
(
name
);
if
(
!
obj
)
throw
std
::
runtime_error
(
"Module
\"
"
+
std
::
string
(
name
)
+
"
\"
not found!"
);
return
module
(
obj
,
false
);
}
};
...
...
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