Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 47294:4fe192d48960 legacy-trunk
Renamed PyString to PyBytes
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Mon, 26 May 2008 12:51:38 +0000 |
| parents | 59ab2cf002fa |
| children | 1062b7dec95b |
comparison
equal
deleted
inserted
replaced
| 47292:abafccfe7501 | 47294:4fe192d48960 |
|---|---|
| 227 #ifdef Py_USING_UNICODE | 227 #ifdef Py_USING_UNICODE |
| 228 | 228 |
| 229 static PyObject * | 229 static PyObject * |
| 230 sys_getdefaultencoding(PyObject *self) | 230 sys_getdefaultencoding(PyObject *self) |
| 231 { | 231 { |
| 232 return PyString_FromString(PyUnicode_GetDefaultEncoding()); | 232 return PyBytes_FromString(PyUnicode_GetDefaultEncoding()); |
| 233 } | 233 } |
| 234 | 234 |
| 235 PyDoc_STRVAR(getdefaultencoding_doc, | 235 PyDoc_STRVAR(getdefaultencoding_doc, |
| 236 "getdefaultencoding() -> string\n\ | 236 "getdefaultencoding() -> string\n\ |
| 237 \n\ | 237 \n\ |
| 259 | 259 |
| 260 static PyObject * | 260 static PyObject * |
| 261 sys_getfilesystemencoding(PyObject *self) | 261 sys_getfilesystemencoding(PyObject *self) |
| 262 { | 262 { |
| 263 if (Py_FileSystemDefaultEncoding) | 263 if (Py_FileSystemDefaultEncoding) |
| 264 return PyString_FromString(Py_FileSystemDefaultEncoding); | 264 return PyBytes_FromString(Py_FileSystemDefaultEncoding); |
| 265 Py_INCREF(Py_None); | 265 Py_INCREF(Py_None); |
| 266 return Py_None; | 266 return Py_None; |
| 267 } | 267 } |
| 268 | 268 |
| 269 PyDoc_STRVAR(getfilesystemencoding_doc, | 269 PyDoc_STRVAR(getfilesystemencoding_doc, |
| 288 "c_call", "c_exception", "c_return"}; | 288 "c_call", "c_exception", "c_return"}; |
| 289 PyObject *name; | 289 PyObject *name; |
| 290 int i; | 290 int i; |
| 291 for (i = 0; i < 7; ++i) { | 291 for (i = 0; i < 7; ++i) { |
| 292 if (whatstrings[i] == NULL) { | 292 if (whatstrings[i] == NULL) { |
| 293 name = PyString_InternFromString(whatnames[i]); | 293 name = PyBytes_InternFromString(whatnames[i]); |
| 294 if (name == NULL) | 294 if (name == NULL) |
| 295 return -1; | 295 return -1; |
| 296 whatstrings[i] = name; | 296 whatstrings[i] = name; |
| 297 } | 297 } |
| 298 } | 298 } |
| 889 PyObject *list = PyList_New(0); | 889 PyObject *list = PyList_New(0); |
| 890 int i; | 890 int i; |
| 891 if (list == NULL) | 891 if (list == NULL) |
| 892 return NULL; | 892 return NULL; |
| 893 for (i = 0; PyImport_Inittab[i].name != NULL; i++) { | 893 for (i = 0; PyImport_Inittab[i].name != NULL; i++) { |
| 894 PyObject *name = PyString_FromString( | 894 PyObject *name = PyBytes_FromString( |
| 895 PyImport_Inittab[i].name); | 895 PyImport_Inittab[i].name); |
| 896 if (name == NULL) | 896 if (name == NULL) |
| 897 break; | 897 break; |
| 898 PyList_Append(list, name); | 898 PyList_Append(list, name); |
| 899 Py_DECREF(name); | 899 Py_DECREF(name); |
| 929 Py_XDECREF(warnoptions); | 929 Py_XDECREF(warnoptions); |
| 930 warnoptions = PyList_New(0); | 930 warnoptions = PyList_New(0); |
| 931 if (warnoptions == NULL) | 931 if (warnoptions == NULL) |
| 932 return; | 932 return; |
| 933 } | 933 } |
| 934 str = PyString_FromString(s); | 934 str = PyBytes_FromString(s); |
| 935 if (str != NULL) { | 935 if (str != NULL) { |
| 936 PyList_Append(warnoptions, str); | 936 PyList_Append(warnoptions, str); |
| 937 Py_DECREF(str); | 937 Py_DECREF(str); |
| 938 } | 938 } |
| 939 } | 939 } |
| 1304 Py_XDECREF(sysin); | 1304 Py_XDECREF(sysin); |
| 1305 Py_XDECREF(sysout); | 1305 Py_XDECREF(sysout); |
| 1306 Py_XDECREF(syserr); | 1306 Py_XDECREF(syserr); |
| 1307 | 1307 |
| 1308 SET_SYS_FROM_STRING("version", | 1308 SET_SYS_FROM_STRING("version", |
| 1309 PyString_FromString(Py_GetVersion())); | 1309 PyBytes_FromString(Py_GetVersion())); |
| 1310 SET_SYS_FROM_STRING("hexversion", | 1310 SET_SYS_FROM_STRING("hexversion", |
| 1311 PyInt_FromLong(PY_VERSION_HEX)); | 1311 PyInt_FromLong(PY_VERSION_HEX)); |
| 1312 svnversion_init(); | 1312 svnversion_init(); |
| 1313 SET_SYS_FROM_STRING("subversion", | 1313 SET_SYS_FROM_STRING("subversion", |
| 1314 Py_BuildValue("(ssz)", "CPython", branch, | 1314 Py_BuildValue("(ssz)", "CPython", branch, |
| 1335 PY_MICRO_VERSION, s, | 1335 PY_MICRO_VERSION, s, |
| 1336 PY_RELEASE_SERIAL)); | 1336 PY_RELEASE_SERIAL)); |
| 1337 SET_SYS_FROM_STRING("api_version", | 1337 SET_SYS_FROM_STRING("api_version", |
| 1338 PyInt_FromLong(PYTHON_API_VERSION)); | 1338 PyInt_FromLong(PYTHON_API_VERSION)); |
| 1339 SET_SYS_FROM_STRING("copyright", | 1339 SET_SYS_FROM_STRING("copyright", |
| 1340 PyString_FromString(Py_GetCopyright())); | 1340 PyBytes_FromString(Py_GetCopyright())); |
| 1341 SET_SYS_FROM_STRING("platform", | 1341 SET_SYS_FROM_STRING("platform", |
| 1342 PyString_FromString(Py_GetPlatform())); | 1342 PyBytes_FromString(Py_GetPlatform())); |
| 1343 SET_SYS_FROM_STRING("executable", | 1343 SET_SYS_FROM_STRING("executable", |
| 1344 PyString_FromString(Py_GetProgramFullPath())); | 1344 PyBytes_FromString(Py_GetProgramFullPath())); |
| 1345 SET_SYS_FROM_STRING("prefix", | 1345 SET_SYS_FROM_STRING("prefix", |
| 1346 PyString_FromString(Py_GetPrefix())); | 1346 PyBytes_FromString(Py_GetPrefix())); |
| 1347 SET_SYS_FROM_STRING("exec_prefix", | 1347 SET_SYS_FROM_STRING("exec_prefix", |
| 1348 PyString_FromString(Py_GetExecPrefix())); | 1348 PyBytes_FromString(Py_GetExecPrefix())); |
| 1349 SET_SYS_FROM_STRING("maxsize", | 1349 SET_SYS_FROM_STRING("maxsize", |
| 1350 PyInt_FromSsize_t(PY_SSIZE_T_MAX)); | 1350 PyInt_FromSsize_t(PY_SSIZE_T_MAX)); |
| 1351 SET_SYS_FROM_STRING("maxint", | 1351 SET_SYS_FROM_STRING("maxint", |
| 1352 PyInt_FromLong(PyInt_GetMax())); | 1352 PyInt_FromLong(PyInt_GetMax())); |
| 1353 SET_SYS_FROM_STRING("py3kwarning", | 1353 SET_SYS_FROM_STRING("py3kwarning", |
| 1370 if (s[0] == 0) | 1370 if (s[0] == 0) |
| 1371 value = "big"; | 1371 value = "big"; |
| 1372 else | 1372 else |
| 1373 value = "little"; | 1373 value = "little"; |
| 1374 SET_SYS_FROM_STRING("byteorder", | 1374 SET_SYS_FROM_STRING("byteorder", |
| 1375 PyString_FromString(value)); | 1375 PyBytes_FromString(value)); |
| 1376 } | 1376 } |
| 1377 #ifdef MS_COREDLL | 1377 #ifdef MS_COREDLL |
| 1378 SET_SYS_FROM_STRING("dllhandle", | 1378 SET_SYS_FROM_STRING("dllhandle", |
| 1379 PyLong_FromVoidPtr(PyWin_DLLhModule)); | 1379 PyLong_FromVoidPtr(PyWin_DLLhModule)); |
| 1380 SET_SYS_FROM_STRING("winver", | 1380 SET_SYS_FROM_STRING("winver", |
| 1381 PyString_FromString(PyWin_DLLVersionString)); | 1381 PyBytes_FromString(PyWin_DLLVersionString)); |
| 1382 #endif | 1382 #endif |
| 1383 if (warnoptions == NULL) { | 1383 if (warnoptions == NULL) { |
| 1384 warnoptions = PyList_New(0); | 1384 warnoptions = PyList_New(0); |
| 1385 } | 1385 } |
| 1386 else { | 1386 else { |
| 1421 return NULL; | 1421 return NULL; |
| 1422 for (i = 0; ; i++) { | 1422 for (i = 0; ; i++) { |
| 1423 p = strchr(path, delim); | 1423 p = strchr(path, delim); |
| 1424 if (p == NULL) | 1424 if (p == NULL) |
| 1425 p = strchr(path, '\0'); /* End of string */ | 1425 p = strchr(path, '\0'); /* End of string */ |
| 1426 w = PyString_FromStringAndSize(path, (Py_ssize_t) (p - path)); | 1426 w = PyBytes_FromStringAndSize(path, (Py_ssize_t) (p - path)); |
| 1427 if (w == NULL) { | 1427 if (w == NULL) { |
| 1428 Py_DECREF(v); | 1428 Py_DECREF(v); |
| 1429 return NULL; | 1429 return NULL; |
| 1430 } | 1430 } |
| 1431 PyList_SetItem(v, i, w); | 1431 PyList_SetItem(v, i, w); |
| 1466 | 1466 |
| 1467 /* argv[0] is the script pathname if known */ | 1467 /* argv[0] is the script pathname if known */ |
| 1468 if (i == 0) { | 1468 if (i == 0) { |
| 1469 char* fn = decc$translate_vms(argv[0]); | 1469 char* fn = decc$translate_vms(argv[0]); |
| 1470 if ((fn == (char *)0) || fn == (char *)-1) | 1470 if ((fn == (char *)0) || fn == (char *)-1) |
| 1471 v = PyString_FromString(argv[0]); | 1471 v = PyBytes_FromString(argv[0]); |
| 1472 else | 1472 else |
| 1473 v = PyString_FromString( | 1473 v = PyBytes_FromString( |
| 1474 decc$translate_vms(argv[0])); | 1474 decc$translate_vms(argv[0])); |
| 1475 } else | 1475 } else |
| 1476 v = PyString_FromString(argv[i]); | 1476 v = PyBytes_FromString(argv[i]); |
| 1477 #else | 1477 #else |
| 1478 PyObject *v = PyString_FromString(argv[i]); | 1478 PyObject *v = PyBytes_FromString(argv[i]); |
| 1479 #endif | 1479 #endif |
| 1480 if (v == NULL) { | 1480 if (v == NULL) { |
| 1481 Py_DECREF(av); | 1481 Py_DECREF(av); |
| 1482 av = NULL; | 1482 av = NULL; |
| 1483 break; | 1483 break; |
| 1577 if (n > 1) | 1577 if (n > 1) |
| 1578 n--; /* Drop trailing separator */ | 1578 n--; /* Drop trailing separator */ |
| 1579 #endif /* Unix */ | 1579 #endif /* Unix */ |
| 1580 } | 1580 } |
| 1581 #endif /* All others */ | 1581 #endif /* All others */ |
| 1582 a = PyString_FromStringAndSize(argv0, n); | 1582 a = PyBytes_FromStringAndSize(argv0, n); |
| 1583 if (a == NULL) | 1583 if (a == NULL) |
| 1584 Py_FatalError("no mem for sys.path insertion"); | 1584 Py_FatalError("no mem for sys.path insertion"); |
| 1585 if (PyList_Insert(path, 0, a) < 0) | 1585 if (PyList_Insert(path, 0, a) < 0) |
| 1586 Py_FatalError("sys.path.insert(0) failed"); | 1586 Py_FatalError("sys.path.insert(0) failed"); |
| 1587 Py_DECREF(a); | 1587 Py_DECREF(a); |
