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: Patch for bug 580952: import lock should be exposed
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, jdhildeb
Priority: low Keywords: patch

Created on 2003-02-09 04:22 by jdhildeb, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python2.2.2-import.patch jdhildeb, 2003-02-09 04:27 patch against 2.2.2
python2.3-2.2.99-import.patch jdhildeb, 2003-02-09 04:28 patch against 2.3-2.2.99
Messages (4)
msg42734 - (view) Author: Jason Hildebrand (jdhildeb) Date: 2003-02-09 04:22
See bug 580952 for all the details.

I've attached patches against Python 2.3-2.2.99 (it
would be great to have this in for 2.3 final), and also
against Python 2.2.2 (for the next 2.2.x maintenance
release).
msg42735 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-02-12 21:57
Logged In: YES 
user_id=6380

I've applied the 2.3 patch, with some changes to avoid the
fatal error in unlock_import().

Open issues:

- This needs docs. Jason, can you provide a doc patch?

- Why do you want this backported to 2.2? It's a new feature
after all. Jason, can you comment on that?
msg42736 - (view) Author: Jason Hildebrand (jdhildeb) Date: 2003-02-13 16:32
Logged In: YES 
user_id=173690

Yes, I can provide a doc patch.  Is there anything that
needs to be updated other than Doc/lib/libimp.tex?  (I'm new
to the python source tree)

Re: backporting:  Here's my reasoning:

For a multithreaded Python app which needs to use an import
hook, there is no way to do this reliably without access to
the internal import lock.  If the app uses a separate lock
it is possible for a deadlock to happen (see bug 580952 for
explanation), yet if no locking is done the runtime
environment can get really screwed up (I've seen it happen).  

So from the perspective of such an app, the Python import
API is buggy/incomplete because it provides no safe way to
use an import hook.  Therefore I view this patch more as a
fix than a new feature.
msg42737 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-02-13 17:11
Logged In: YES 
user_id=6380

Neal Norwitz already add the docs and a test. :-)

Some belated feedback on your patch: when returning Py_None,
you must Py_INCREF(Py_None)! Also, please use trailing \ in
multi-line string literals; the C std requires this even
though GCC doesn't. :-)  (Thanks Neal!)
History
Date User Action Args
2022-04-10 16:06:40adminsetgithub: 37943
2003-02-09 04:22:26jdhildebcreate