gh-103997: Automatically dedent the argument to "-c" (#103998)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <80244920+Eclips4@users.noreply.github.com>
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
Jon Crall 2025-04-18 04:39:30 -04:00 committed by GitHub
parent 50e518e886
commit fc0ec29889
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 266 additions and 0 deletions

View file

@ -11,6 +11,7 @@
#include "pycore_pylifecycle.h" // _Py_PreInitializeFromPyArgv()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_pythonrun.h" // _PyRun_AnyFileObject()
#include "pycore_unicodeobject.h" // _PyUnicode_Dedent()
/* Includes for exit_sigint() */
#include <stdio.h> // perror()
@ -244,6 +245,11 @@ pymain_run_command(wchar_t *command)
return pymain_exit_err_print();
}
Py_SETREF(unicode, _PyUnicode_Dedent(unicode));
if (unicode == NULL) {
goto error;
}
bytes = PyUnicode_AsUTF8String(unicode);
Py_DECREF(unicode);
if (bytes == NULL) {