reconstruct the relative import, now the generated code looks better
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10629 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4d3e448b38
commit
9fc127d68b
1 changed files with 11 additions and 8 deletions
|
|
@ -701,14 +701,17 @@ public:
|
|||
* code conditional on the python version.
|
||||
*/
|
||||
Printv(f_shadow, "if version_info >= (2,6,0):\n", NULL);
|
||||
Printv(f_shadow, tab4, "from os.path import dirname\n", NULL);
|
||||
Printv(f_shadow, tab4, "import imp\n", NULL);
|
||||
Printv(f_shadow, tab4, "try:\n", NULL);
|
||||
Printf(f_shadow, tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module);
|
||||
Printf(f_shadow, tab8 "%s = imp.load_module('%s', fp, pathname, description)\n", module, module);
|
||||
Printv(f_shadow, tab4, "except:\n", NULL);
|
||||
Printf(f_shadow, tab8, "if fp is not None: fp.close()\n", NULL);
|
||||
Printv(f_shadow, tab4, "del fp, pathname, description, imp, dirname\n", NULL);
|
||||
Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL);
|
||||
Printv(f_shadow, tab8, "from os.path import dirname\n", NULL);
|
||||
Printv(f_shadow, tab8, "import imp\n", NULL);
|
||||
Printv(f_shadow, tab8, "try:\n", NULL);
|
||||
Printf(f_shadow, tab4 tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module);
|
||||
Printf(f_shadow, tab4 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module);
|
||||
Printv(f_shadow, tab8, "finally:\n", NULL);
|
||||
Printv(f_shadow, tab4 tab8, "if fp is not None: fp.close()\n", NULL);
|
||||
Printv(f_shadow, tab8, "return _mod\n", NULL);
|
||||
Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module);
|
||||
Printv(f_shadow, tab4, "del swig_import_helper\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