New submission from Stefan Behnel <sco...@users.sourceforge.net>:

This is a follow-up to issue 13429, which deals with setting __file__ on newly 
created extension modules earlier than it is currently the case.

Currently, the module init function of extension modules lacks a way to find 
out the context in which it is being imported, e.g. its package path or its 
location in the file system. This makes it tricky for extension modules to do 
things like loading package resources or using relative imports at init time.

This can be fixed by allowing the init function to take a context struct as 
argument, which would contain object pointers to the FQ package name and file 
path, and potentially other information.

I think this would be backwards compatible to existing code, because C should 
allow the caller of the init function to pack additional arguments on the stack 
that the called function simply doesn't care about. From CPython 3.3 on, 
however, new and updated code could benefit from this feature.

----------
components: Extension Modules, Interpreter Core
messages: 147931
nosy: scoder
priority: normal
severity: normal
status: open
title: Pass context information into the extension module init function
type: feature request
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13431>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to