This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PyImport_ExecCodeModule not correct
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, gvanrossum, richard, tim.peters
Priority: low Keywords:

Created on 2001-05-15 01:30 by richard, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (5)
msg4770 - (view) Author: Richard Jones (richard) * (Python committer) Date: 2001-05-15 01:30
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 ;)
msg4771 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-08-09 18:15
Logged In: YES 
user_id=31435

Assigned to Guido cuz he understands this stuff much better.
msg4772 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-08-09 18:33
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.
msg4773 - (view) Author: Richard Jones (richard) * (Python committer) Date: 2001-08-12 03:03
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...

msg4774 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2002-11-13 15:16
Logged In: YES 
user_id=3066

Fixed in Doc/api/utilities.tex revisions 1.7 and 1.3.8.2.
History
Date User Action Args
2022-04-10 16:04:03adminsetgithub: 34506
2001-05-15 01:30:36richardcreate