Christian Heimes added the comment:
Here is a patch that solves the problem. However the patch is against
the py3k sources and I like somebody to review and test it. I don't have
enough disk space in my VMWare box to test it against the trunk or 2.5.
Reason for the problem: Windows' stat doesn't like trailing slashes.
----------
keywords: +patch
nosy: +georg.brandl
Added file: http://bugs.python.org/file8674/trailing_slash.patch
__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1293>
__________________________________
Index: Python/import.c
===================================================================
--- Python/import.c (revision 58747)
+++ Python/import.c (working copy)
@@ -2921,6 +2921,7 @@
NullImporter_init(NullImporter *self, PyObject *args, PyObject *kwds)
{
char *path;
+ Py_ssize_t len, i;
if (!_PyArg_NoKeywords("NullImporter()", kwds))
return -1;
@@ -2929,13 +2930,26 @@
&path))
return -1;
- if (strlen(path) == 0) {
+ len = strlen(path);
+ if (len == 0) {
PyErr_SetString(PyExc_ImportError, "empty pathname");
return -1;
} else {
struct stat statbuf;
int rv;
+ /* Remove trailing / and \. Windows' stat doesn't like them */
+ for (i=len-1; i > 0; i--) {
+#ifdef MS_WINDOWS
+ if (path[i] != '/' && path[i] != '\\') {
+#else
+ if (path[i] != '/') {
+#endif
+ break;
+ }
+ path[i] = '\0';
+ }
+
rv = stat(path, &statbuf);
if (rv == 0) {
/* it exists */
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com