[Python-checkins] CVS: python/dist/src/Python import.c,2.181,2.182
Tim Peters
tim_one@users.sourceforge.net
Sat, 04 Aug 2001 01:12:38 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv379/python/dist/src/Python
Modified Files:
import.c
Log Message:
Derived from SF patch #446899 Permit import of .pyw under Windows, from
David Bolen.
Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.181
retrieving revision 2.182
diff -C2 -d -r2.181 -r2.182
*** import.c 2001/08/02 04:15:00 2.181
--- import.c 2001/08/04 08:12:36 2.182
***************
*** 71,74 ****
--- 71,77 ----
static const struct filedescr _PyImport_StandardFiletab[] = {
{".py", "r", PY_SOURCE},
+ #ifdef MS_WIN32
+ {".pyw", "r", PY_SOURCE},
+ #endif
{".pyc", "rb", PY_COMPILED},
{0, 0}
***************
*** 514,524 ****
make_compiled_pathname(char *pathname, char *buf, size_t buflen)
{
! size_t len;
!
! len = strlen(pathname);
if (len+2 > buflen)
return NULL;
! strcpy(buf, pathname);
! strcpy(buf+len, Py_OptimizeFlag ? "o" : "c");
return buf;
--- 517,533 ----
make_compiled_pathname(char *pathname, char *buf, size_t buflen)
{
! size_t len = strlen(pathname);
if (len+2 > buflen)
return NULL;
!
! #ifdef MS_WIN32
! /* Treat .pyw as if it were .py. The case of ".pyw" must match
! that used in _PyImport_StandardFiletab. */
! if (len >= 4 && strcmp(&pathname[len-4], ".pyw") == 0)
! --len; /* pretend 'w' isn't there */
! #endif
! memcpy(buf, pathname, len);
! buf[len] = Py_OptimizeFlag ? 'o' : 'c';
! buf[len+1] = '\0';
return buf;