[Patches] [ python-Patches-683257 ] Patch for bug 580952: import lock should be exposed

SourceForge.net noreply@sourceforge.net
Thu, 13 Feb 2003 09:11:48 -0800


Patches item #683257, was opened at 2003-02-08 23:22
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=683257&group_id=5470

Category: Core (C code)
Group: Python 2.3
>Status: Closed
Resolution: Accepted
Priority: 3
Submitted By: Jason Hildebrand (jdhildeb)
Assigned to: Guido van Rossum (gvanrossum)
Summary: Patch for bug 580952: import lock should be exposed

Initial Comment:

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).


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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2003-02-13 12:11

Message:
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!)

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

Comment By: Jason Hildebrand (jdhildeb)
Date: 2003-02-13 11:32

Message:
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.


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

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-02-12 16:57

Message:
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?

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

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