Fix for problem importing modules in packages in Pymacs.py (0.12)

François Pinard pinard at iro.umontreal.ca
Thu Jan 3 22:31:42 CET 2002


[Syver Enstad]

> This fixes the problem I was having with importing modules like 
> Emacs.extensions.

Wow!  Thanks a lot.

> >From pymacs.py, first is new code, second is original 0.12 version

I implemented your very solution, yet it a bit differently.  Unless you
tell me there is a blunt below, I'll put out Pymacs 0.13 soon.


--- pymacs.py~	Thu Jan  3 16:23:32 2002
+++ pymacs.py	Thu Jan  3 16:23:09 2002
@@ -172,6 +172,10 @@
             finally:
                 if directory:
                     del sys.path[0]
+            # Whenever MODULE_NAME is of the form [PACKAGE.]...MODULE,
+            # __import__ returns the outer PACKAGE, not the module.
+            for component in string.split(module_name, '.')[1:]:
+                object = getattr(object, component)
     except ImportError:
         return None
     interactions = object.__dict__.get('interactions', {})

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list