comparison Python/sysmodule.c @ 42099:6727cc9ed09f

Make sys.path and sys.argv into lists of strings. Remove the hack in test_popen.py to overcome this issue.
author Guido van Rossum <guido@python.org>
date Fri, 15 Jun 2007 03:49:03 +0000
parents 825041fc8e2c
children 4d2aa4bfb2d6
comparison
equal deleted inserted replaced
42098:5838bec7c115 42099:6727cc9ed09f
1143 return NULL; 1143 return NULL;
1144 for (i = 0; ; i++) { 1144 for (i = 0; ; i++) {
1145 p = strchr(path, delim); 1145 p = strchr(path, delim);
1146 if (p == NULL) 1146 if (p == NULL)
1147 p = strchr(path, '\0'); /* End of string */ 1147 p = strchr(path, '\0'); /* End of string */
1148 w = PyString_FromStringAndSize(path, (Py_ssize_t) (p - path)); 1148 w = PyUnicode_FromStringAndSize(path, (Py_ssize_t) (p - path));
1149 if (w == NULL) { 1149 if (w == NULL) {
1150 Py_DECREF(v); 1150 Py_DECREF(v);
1151 return NULL; 1151 return NULL;
1152 } 1152 }
1153 PyList_SetItem(v, i, w); 1153 PyList_SetItem(v, i, w);
1188 1188
1189 /* argv[0] is the script pathname if known */ 1189 /* argv[0] is the script pathname if known */
1190 if (i == 0) { 1190 if (i == 0) {
1191 char* fn = decc$translate_vms(argv[0]); 1191 char* fn = decc$translate_vms(argv[0]);
1192 if ((fn == (char *)0) || fn == (char *)-1) 1192 if ((fn == (char *)0) || fn == (char *)-1)
1193 v = PyString_FromString(argv[0]); 1193 v = PyUnicode_FromString(argv[0]);
1194 else 1194 else
1195 v = PyString_FromString( 1195 v = PyUnicode_FromString(
1196 decc$translate_vms(argv[0])); 1196 decc$translate_vms(argv[0]));
1197 } else 1197 } else
1198 v = PyString_FromString(argv[i]); 1198 v = PyUnicode_FromString(argv[i]);
1199 #else 1199 #else
1200 PyObject *v = PyString_FromString(argv[i]); 1200 PyObject *v = PyUnicode_FromString(argv[i]);
1201 #endif 1201 #endif
1202 if (v == NULL) { 1202 if (v == NULL) {
1203 Py_DECREF(av); 1203 Py_DECREF(av);
1204 av = NULL; 1204 av = NULL;
1205 break; 1205 break;
1299 if (n > 1) 1299 if (n > 1)
1300 n--; /* Drop trailing separator */ 1300 n--; /* Drop trailing separator */
1301 #endif /* Unix */ 1301 #endif /* Unix */
1302 } 1302 }
1303 #endif /* All others */ 1303 #endif /* All others */
1304 a = PyString_FromStringAndSize(argv0, n); 1304 a = PyUnicode_FromStringAndSize(argv0, n);
1305 if (a == NULL) 1305 if (a == NULL)
1306 Py_FatalError("no mem for sys.path insertion"); 1306 Py_FatalError("no mem for sys.path insertion");
1307 if (PyList_Insert(path, 0, a) < 0) 1307 if (PyList_Insert(path, 0, a) < 0)
1308 Py_FatalError("sys.path.insert(0) failed"); 1308 Py_FatalError("sys.path.insert(0) failed");
1309 Py_DECREF(a); 1309 Py_DECREF(a);