Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Doc/using/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ additional methods of invocation:
appropriately named script from that directory.
* When called with ``-c command``, it executes the Python statement(s) given as
*command*. Here *command* may contain multiple statements separated by
newlines. Leading whitespace is significant in Python statements!
newlines.
* When called with ``-m module-name``, the given module is located on the
Python module path and executed as a script.

Expand All @@ -75,6 +75,7 @@ source.

.. versionchanged:: 3.14
*command* is automatically dedented before execution.
Only supports spaces and tabs and doesn't normalize empty lines.

.. option:: -m <module-name>

Expand Down
4 changes: 2 additions & 2 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1188,8 +1188,8 @@ Other language changes
(Contributed by Tomasz Pytel in :gh:`132329`.)

* The command-line option :option:`-c` now automatically dedents its code
argument before execution. The auto-dedentation behavior mirrors
:func:`textwrap.dedent`.
argument before execution. Only supports spaces and tabs and doesn't
normalize empty lines.
(Contributed by Jon Crall and Steven Sun in :gh:`103998`.)

* Improve error message when an object supporting the synchronous
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ extern Py_ssize_t _PyUnicode_InsertThousandsGrouping(
int forward);

/* Dedent a string.
Behaviour is expected to be an exact match of `textwrap.dedent`.
Only supports spaces and tabs and doesn't normalize empty lines.
Return a new reference on success, NULL with exception set on error.
*/
extern PyObject* _PyUnicode_Dedent(PyObject *unicode);
Expand Down
5 changes: 3 additions & 2 deletions Misc/NEWS.d/3.14.0b1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1881,8 +1881,9 @@ Improve error message when :exc:`TypeError` occurs during
.. nonce: BS3uVt
.. section: Core and Builtins

String arguments passed to "-c" are now automatically dedented as if by
:func:`textwrap.dedent`. This allows "python -c" invocations to be indented
String arguments passed to "-c" are now automatically dedented.
Only supports spaces and tabs and doesn't normalize empty lines.
This allows "python -c" invocations to be indented
in shell scripts without causing indentation errors. (Patch by Jon Crall and
Steven Sun)

Expand Down
2 changes: 1 addition & 1 deletion Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -14389,7 +14389,7 @@ search_longest_common_leading_whitespace(
}

/* Dedent a string.
Behaviour is expected to be an exact match of `textwrap.dedent`.
Only supports spaces and tabs and doesn't normalize empty lines.
Return a new reference on success, NULL with exception set on error.
*/
PyObject *
Expand Down
Loading