[Python-checkins] python/dist/src/Python import.c,2.240,2.241

jlt63@users.sourceforge.net jlt63 at users.sourceforge.net
Fri May 20 02:56:57 CEST 2005


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2513

Modified Files:
	import.c 
Log Message:
Patch #1197318: Cygwin case-sensitive import patch

A problem regarding importing symlinked modules was recently reported on the
Cygwin mailing list:

    http://cygwin.com/ml/cygwin/2005-04/msg00257.html

The following test case demonstrates the problem:

$ ls -l
total 1
lrwxrwxrwx    1 jt       None            6 Apr 23 13:32 bar.py -> foo.py
-rw-r--r--    1 jt       None           24 Apr 18 20:13 foo.py

$ python -c 'import bar'
Traceback (most recent call last):
File "<string>", line 1, in ?
ImportError: No module named bar

Since Cygwin's case_ok() uses a modified version of the Windows's version, the
symlinked bar module actually resolves to file foo.py instead of bar.py. This
obviously causes the matching code to fail (regardless of case).

The patch fixes this problem by making Cygwin use the Mac OS X case_ok()
instead of a modified Window's version.


Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.240
retrieving revision 2.241
diff -u -d -r2.240 -r2.241
--- import.c	7 Oct 2004 06:46:25 -0000	2.240
+++ import.c	20 May 2005 00:56:54 -0000	2.241
@@ -1377,16 +1377,13 @@
 /* First we may need a pile of platform-specific header files; the sequence
  * of #if's here should match the sequence in the body of case_ok().
  */
-#if defined(MS_WINDOWS) || defined(__CYGWIN__)
+#if defined(MS_WINDOWS)
 #include <windows.h>
-#ifdef __CYGWIN__
-#include <sys/cygwin.h>
-#endif
 
 #elif defined(DJGPP)
 #include <dir.h>
 
-#elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H)
+#elif (defined(__MACH__) && defined(__APPLE__) || defined(__CYGWIN__)) && defined(HAVE_DIRENT_H)
 #include <sys/types.h>
 #include <dirent.h>
 
@@ -1407,23 +1404,15 @@
  * match the sequence just above.
  */
 
-/* MS_WINDOWS || __CYGWIN__ */
-#if defined(MS_WINDOWS) || defined(__CYGWIN__)
+/* MS_WINDOWS */
+#if defined(MS_WINDOWS)
 	WIN32_FIND_DATA data;
 	HANDLE h;
-#ifdef __CYGWIN__
-	char tempbuf[MAX_PATH];
-#endif
 
 	if (Py_GETENV("PYTHONCASEOK") != NULL)
 		return 1;
 
-#ifdef __CYGWIN__
-	cygwin32_conv_to_win32_path(buf, tempbuf);
-	h = FindFirstFile(tempbuf, &data);
-#else
 	h = FindFirstFile(buf, &data);
-#endif
 	if (h == INVALID_HANDLE_VALUE) {
 		PyErr_Format(PyExc_NameError,
 		  "Can't find file for module %.100s\n(filename %.300s)",
@@ -1450,8 +1439,8 @@
 	}
 	return strncmp(ffblk.ff_name, name, namelen) == 0;
 
-/* new-fangled macintosh (macosx) */
-#elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H)
+/* new-fangled macintosh (macosx) or Cygwin */
+#elif (defined(__MACH__) && defined(__APPLE__) || defined(__CYGWIN__)) && defined(HAVE_DIRENT_H)
 	DIR *dirp;
 	struct dirent *dp;
 	char dirname[MAXPATHLEN + 1];



More information about the Python-checkins mailing list