[Patches] [ python-Patches-1093253 ] Refactoring Python/import.c

SourceForge.net noreply at sourceforge.net
Tue Jan 4 20:20:55 CET 2005


Patches item #1093253, was opened at 2004-12-30 13:50
Message generated for change (Comment added) made by theller
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1093253&group_id=5470

Category: Core (C code)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Thomas Heller (theller)
Assigned to: Nobody/Anonymous (nobody)
Summary: Refactoring Python/import.c

Initial Comment:
This patch refactores Python/import.c.

find_module() was changed to return an PyObject*
pointer which contains the module's pathname, instead
of filling out a char* buffer.

load_module() accepts the PyObject* pathname instead of
a char*.

The patch is probably missing some error checking, and
the 8 character hack for loading extensions on OS2 is
not implemented, but the test case runs without errors
on Windows XP pro.

If a change in spirit of this patch is accepted, I'm
willing to further work on it so that eventually
unicode entries on sys.path, which can not be encoded
with the default file system encodings, will work as
expected (currently they don't).

See also:
http://mail.python.org/pipermail/python-list/2004-December/256969.html

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

>Comment By: Thomas Heller (theller)
Date: 2005-01-04 20:20

Message:
Logged In: YES 
user_id=11105

New patch attached with multiple implementations of case_ok,
and more error checking: import.c.patch2

Slightly tested on OSX, Linux, Windows.

The case_ok function still needs to be fixed for RISCOS
(which I cannot test).

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

Comment By: Michael Hudson (mwh)
Date: 2004-12-31 15:17

Message:
Logged In: YES 
user_id=6656

Perhaps there should be multiple implementations of case_ok ... i.e.

#if PLAT1
int case_ok(...)
{
...
}
#elif PLAT2
int case_ok(...)
{
...
}
#endif

the current spaghetti is confusing, even by the standards of import.c...

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

Comment By: Thomas Heller (theller)
Date: 2004-12-31 15:11

Message:
Logged In: YES 
user_id=11105

Yes, I overlooked that the initialization of the variables
is inside an #if defined(MS_WINDOWS) block.
Probably it would be better to leave the signature of
case_ok() as before and call it through a wrapper which
converts the arguments.

I will prepare a new patch in a few days.

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

Comment By: Michael Hudson (mwh)
Date: 2004-12-31 14:57

Message:
Logged In: YES 
user_id=6656

Applied the patch and built on OS X.  This was the result:

$ ./python.exe 
'import site' failed; use -v for traceback
../Python/import.c:1496: failed assertion `dirlen <= MAXPATHLEN'
Abort trap

dirlen is 796092779, which seems fishy :)  An uninitialized variable, 
maybe?  Haven't looked, really...


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

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


More information about the Patches mailing list