[Python-bugs-list] [ python-Bugs-424106 ] PyImport_ExecCodeModule not correct

noreply@sourceforge.net noreply@sourceforge.net
Wed, 13 Nov 2002 07:16:23 -0800


Bugs item #424106, was opened at 2001-05-14 21:30
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=424106&group_id=5470

Category: Documentation
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 3
Submitted By: Richard Jones (richard)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: PyImport_ExecCodeModule not correct

Initial Comment:
PyImport_ExecCodeModule doesn't handle package imports
correctly. Using it to import a module "A.B" will
result in an entry in sys.modules of "A.B" but no
information for module "A" will be created. The
documentation in the C API reference makes no statement
about this - just that the module name may be of the
form "package.module". Looking at the code in import.c,
there is definitely no handling of the package. If this
is the intended behaviour, please amend the
documentation (and possibly give some hint as to how
one _should_ go about importing a code object in a
package structure ;)


----------------------------------------------------------------------

>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-11-13 10:16

Message:
Logged In: YES 
user_id=3066

Fixed in Doc/api/utilities.tex revisions 1.7 and 1.3.8.2.

----------------------------------------------------------------------

Comment By: Richard Jones (richard)
Date: 2001-08-11 23:03

Message:
Logged In: YES 
user_id=6405

I might be missing something, but when I used this call, 
I couldn't find anything else that let me import a code 
object into a package. I ended up delving into the source 
code to attempt to "do the right thing". I can provide the 
code I wrote to integrate the imported package/module into 
sys.modules, if you like. Unfortunately, I don't have the 
code on me at the moment.

I think that if this function shouldn't handle the 
package case then there should be another function that 
does...



----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-08-09 14:33

Message:
Logged In: YES 
user_id=6380

It's a documentation issue.

This is a very low-level helper API in the set of import
APIs.

The package handling is done by the higher-level import
APIs.

If you want to fake importing A.B by providing a code
object, you will have to also fake the other stuff.

I'm leaving this open as a documentation issue, but beware
that this stuff is tricky -- your best bet is to study the
source code.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-08-09 14:15

Message:
Logged In: YES 
user_id=31435

Assigned to Guido cuz he understands this stuff much better.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=424106&group_id=5470