Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 50743:e8154bd322cb
Merged revisions 68540 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68540 | martin.v.loewis | 2009-01-12 08:57:11 +0100 (Mo, 12 Jan 2009) | 2 lines
Issue #4915: Port sysmodule to Windows CE.
........
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Mon, 12 Jan 2009 07:59:10 +0000 |
| parents | efef5fc45a9a |
| children | 4cc49d978ec2 |
comparison
equal
deleted
inserted
replaced
| 50741:5f4c2de95091 | 50743:e8154bd322cb |
|---|---|
| 1255 v = value; \ | 1255 v = value; \ |
| 1256 if (v != NULL) \ | 1256 if (v != NULL) \ |
| 1257 PyDict_SetItemString(sysdict, key, v); \ | 1257 PyDict_SetItemString(sysdict, key, v); \ |
| 1258 Py_XDECREF(v) | 1258 Py_XDECREF(v) |
| 1259 | 1259 |
| 1260 /* Check that stdin is not a directory | |
| 1261 Using shell redirection, you can redirect stdin to a directory, | |
| 1262 crashing the Python interpreter. Catch this common mistake here | |
| 1263 and output a useful error message. Note that under MS Windows, | |
| 1264 the shell already prevents that. */ | |
| 1265 #if !defined(MS_WINDOWS) | |
| 1260 { | 1266 { |
| 1261 /* XXX: does this work on Win/Win64? (see posix_fstat) */ | |
| 1262 struct stat sb; | 1267 struct stat sb; |
| 1263 if (fstat(fileno(stdin), &sb) == 0 && | 1268 if (fstat(fileno(stdin), &sb) == 0 && |
| 1264 S_ISDIR(sb.st_mode)) { | 1269 S_ISDIR(sb.st_mode)) { |
| 1265 /* There's nothing more we can do. */ | 1270 /* There's nothing more we can do. */ |
| 1266 /* Py_FatalError() will core dump, so just exit. */ | 1271 /* Py_FatalError() will core dump, so just exit. */ |
| 1267 PySys_WriteStderr("Python error: <stdin> is a directory, cannot continue\n"); | 1272 PySys_WriteStderr("Python error: <stdin> is a directory, cannot continue\n"); |
| 1268 exit(EXIT_FAILURE); | 1273 exit(EXIT_FAILURE); |
| 1269 } | 1274 } |
| 1270 } | 1275 } |
| 1276 #endif | |
| 1271 | 1277 |
| 1272 /* stdin/stdout/stderr are now set by pythonrun.c */ | 1278 /* stdin/stdout/stderr are now set by pythonrun.c */ |
| 1273 | 1279 |
| 1274 PyDict_SetItemString(sysdict, "__displayhook__", | 1280 PyDict_SetItemString(sysdict, "__displayhook__", |
| 1275 PyDict_GetItemString(sysdict, "displayhook")); | 1281 PyDict_GetItemString(sysdict, "displayhook")); |
| 1481 void | 1487 void |
| 1482 PySys_SetArgv(int argc, wchar_t **argv) | 1488 PySys_SetArgv(int argc, wchar_t **argv) |
| 1483 { | 1489 { |
| 1484 #if defined(HAVE_REALPATH) | 1490 #if defined(HAVE_REALPATH) |
| 1485 wchar_t fullpath[MAXPATHLEN]; | 1491 wchar_t fullpath[MAXPATHLEN]; |
| 1486 #elif defined(MS_WINDOWS) | 1492 #elif defined(MS_WINDOWS) && !defined(MS_WINCE) |
| 1487 wchar_t fullpath[MAX_PATH]; | 1493 wchar_t fullpath[MAX_PATH]; |
| 1488 #endif | 1494 #endif |
| 1489 PyObject *av = makeargvobject(argc, argv); | 1495 PyObject *av = makeargvobject(argc, argv); |
| 1490 PyObject *path = PySys_GetObject("path"); | 1496 PyObject *path = PySys_GetObject("path"); |
| 1491 if (av == NULL) | 1497 if (av == NULL) |
| 1527 } | 1533 } |
| 1528 #endif /* HAVE_READLINK */ | 1534 #endif /* HAVE_READLINK */ |
| 1529 #if SEP == '\\' /* Special case for MS filename syntax */ | 1535 #if SEP == '\\' /* Special case for MS filename syntax */ |
| 1530 if (argc > 0 && argv0 != NULL && wcscmp(argv0, L"-c") != 0) { | 1536 if (argc > 0 && argv0 != NULL && wcscmp(argv0, L"-c") != 0) { |
| 1531 wchar_t *q; | 1537 wchar_t *q; |
| 1532 #ifdef MS_WINDOWS | 1538 #if defined(MS_WINDOWS) && !defined(MS_WINCE) |
| 1539 /* This code here replaces the first element in argv with the full | |
| 1540 path that it represents. Under CE, there are no relative paths so | |
| 1541 the argument must be the full path anyway. */ | |
| 1533 wchar_t *ptemp; | 1542 wchar_t *ptemp; |
| 1534 if (GetFullPathNameW(argv0, | 1543 if (GetFullPathNameW(argv0, |
| 1535 sizeof(fullpath)/sizeof(fullpath[0]), | 1544 sizeof(fullpath)/sizeof(fullpath[0]), |
| 1536 fullpath, | 1545 fullpath, |
| 1537 &ptemp)) { | 1546 &ptemp)) { |
