fix the previous commit -- new approach using imp module
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10627 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
9ff8981708
commit
9fbab46bd4
1 changed files with 5 additions and 4 deletions
|
|
@ -701,10 +701,11 @@ public:
|
|||
* code conditional on the python version.
|
||||
*/
|
||||
Printv(f_shadow, "if version_info >= (2,6,0):\n", NULL);
|
||||
Printv(f_shadow, tab4, "try:\n", NULL);
|
||||
Printf(f_shadow, tab8 "from . import %s\n", module);
|
||||
Printv(f_shadow, tab4, "except ValueError:\n");
|
||||
Printf(f_shadow, tab8 "import %s\n", module);
|
||||
Printv(f_shadow, tab4, "from os.path import dirname\n", NULL);
|
||||
Printv(f_shadow, tab4, "import imp\n", NULL);
|
||||
Printf(f_shadow, tab4 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module);
|
||||
Printf(f_shadow, tab4 "%s = imp.load_module('%s', fp, pathname, description)\n", module, module);
|
||||
Printv(f_shadow, tab4, "del fp, pathname, description, imp, dirname\n", NULL);
|
||||
Printv(f_shadow, "else:\n", NULL);
|
||||
Printf(f_shadow, tab4 "import %s\n", module);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue