minor fix on relative import: close fp if exception occured during imp.find_module
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10628 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
9fbab46bd4
commit
4d3e448b38
1 changed files with 5 additions and 2 deletions
|
|
@ -703,8 +703,11 @@ public:
|
|||
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);
|
||||
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, "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, "else:\n", NULL);
|
||||
Printf(f_shadow, tab4 "import %s\n", module);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue