diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-27 00:24:52 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-27 00:24:52 (GMT) |
commit | 739cf4e3e6d7370ab6ddfc96637218eadfe81a13 (patch) | |
tree | 1544ea05db11272b5ecdc0f8e49113373e5c98cc /Python/frozenmain.c | |
parent | b5245bec936d22fddb6d14bd130218ac71ed8474 (diff) | |
download | cpython-739cf4e3e6d7370ab6ddfc96637218eadfe81a13.zip cpython-739cf4e3e6d7370ab6ddfc96637218eadfe81a13.tar.gz cpython-739cf4e3e6d7370ab6ddfc96637218eadfe81a13.tar.bz2 |
Py_FrozenMain() now uses _Py_char2wchar() to decode command line arguments, as
done in main()
Diffstat (limited to 'Python/frozenmain.c')
-rw-r--r-- | Python/frozenmain.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/Python/frozenmain.c b/Python/frozenmain.c index 3b64a6a..f628ddc 100644 --- a/Python/frozenmain.c +++ b/Python/frozenmain.c @@ -52,27 +52,13 @@ Py_FrozenMain(int argc, char **argv) oldloc = setlocale(LC_ALL, NULL); setlocale(LC_ALL, ""); for (i = 0; i < argc; i++) { -#ifdef HAVE_BROKEN_MBSTOWCS - size_t argsize = strlen(argv[i]); -#else - size_t argsize = mbstowcs(NULL, argv[i], 0); -#endif - size_t count; - if (argsize == (size_t)-1) { - fprintf(stderr, "Could not convert argument %d to string\n", i); - return 1; - } - argv_copy[i] = PyMem_RawMalloc((argsize+1)*sizeof(wchar_t)); - argv_copy2[i] = argv_copy[i]; + argv_copy[i] = _Py_char2wchar(argv[i], NULL); if (!argv_copy[i]) { - fprintf(stderr, "out of memory\n"); - return 1; - } - count = mbstowcs(argv_copy[i], argv[i], argsize+1); - if (count == (size_t)-1) { - fprintf(stderr, "Could not convert argument %d to string\n", i); + fprintf(stderr, "Unable to decode the command line argument #%i\n", + i + 1); return 1; } + argv_copy2[i] = argv_copy[i]; } setlocale(LC_ALL, oldloc); |