Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 96ca691

Browse files
committed
Make sys.path and sys.argv into lists of strings.
Remove the hack in test_popen.py to overcome this issue.
1 parent aa588c4 commit 96ca691

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

Lib/test/test_popen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class PopenTest(unittest.TestCase):
2121

2222
def _do_test_commandline(self, cmdline, expected):
23-
cmd = '%s -c "import sys; print(list(map(str, sys.argv)))" %s'
23+
cmd = '%s -c "import sys; print(sys.argv)" %s'
2424
cmd = cmd % (python, cmdline)
2525
data = os.popen(cmd).read()
2626
got = eval(data)[1:] # strip off argv[0]

Python/sysmodule.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ makepathobject(char *path, int delim)
11451145
p = strchr(path, delim);
11461146
if (p == NULL)
11471147
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));
11491149
if (w == NULL) {
11501150
Py_DECREF(v);
11511151
return NULL;
@@ -1190,14 +1190,14 @@ makeargvobject(int argc, char **argv)
11901190
if (i == 0) {
11911191
char* fn = decc$translate_vms(argv[0]);
11921192
if ((fn == (char *)0) || fn == (char *)-1)
1193-
v = PyString_FromString(argv[0]);
1193+
v = PyUnicode_FromString(argv[0]);
11941194
else
1195-
v = PyString_FromString(
1195+
v = PyUnicode_FromString(
11961196
decc$translate_vms(argv[0]));
11971197
} else
1198-
v = PyString_FromString(argv[i]);
1198+
v = PyUnicode_FromString(argv[i]);
11991199
#else
1200-
PyObject *v = PyString_FromString(argv[i]);
1200+
PyObject *v = PyUnicode_FromString(argv[i]);
12011201
#endif
12021202
if (v == NULL) {
12031203
Py_DECREF(av);
@@ -1301,7 +1301,7 @@ PySys_SetArgv(int argc, char **argv)
13011301
#endif /* Unix */
13021302
}
13031303
#endif /* All others */
1304-
a = PyString_FromStringAndSize(argv0, n);
1304+
a = PyUnicode_FromStringAndSize(argv0, n);
13051305
if (a == NULL)
13061306
Py_FatalError("no mem for sys.path insertion");
13071307
if (PyList_Insert(path, 0, a) < 0)

0 commit comments

Comments
 (0)