[3.13] GH-79714: Add mention of stderr for clarity to ArgumentParser.exit() (GH-123932) (#124331)

GH-79714: Add mention of stderr for clarity to ArgumentParser.exit() (GH-123932)
(cherry picked from commit 5f5c0b9c23)

Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-09-24 00:50:24 +02:00 committed by GitHub
parent 1503835b1b
commit a052faf58e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1455,7 +1455,7 @@ The ``deprecated`` keyword argument of
specifies if the argument is deprecated and will be removed specifies if the argument is deprecated and will be removed
in the future. in the future.
For arguments, if ``deprecated`` is ``True``, then a warning will be For arguments, if ``deprecated`` is ``True``, then a warning will be
printed to standard error when the argument is used:: printed to :data:`sys.stderr` when the argument is used::
>>> import argparse >>> import argparse
>>> parser = argparse.ArgumentParser(prog='snake.py') >>> parser = argparse.ArgumentParser(prog='snake.py')
@ -2235,8 +2235,8 @@ Exiting methods
.. method:: ArgumentParser.exit(status=0, message=None) .. method:: ArgumentParser.exit(status=0, message=None)
This method terminates the program, exiting with the specified *status* This method terminates the program, exiting with the specified *status*
and, if given, it prints a *message* before that. The user can override and, if given, it prints a *message* to :data:`sys.stderr` before that.
this method to handle these steps differently:: The user can override this method to handle these steps differently::
class ErrorCatchingArgumentParser(argparse.ArgumentParser): class ErrorCatchingArgumentParser(argparse.ArgumentParser):
def exit(self, status=0, message=None): def exit(self, status=0, message=None):
@ -2246,8 +2246,8 @@ Exiting methods
.. method:: ArgumentParser.error(message) .. method:: ArgumentParser.error(message)
This method prints a usage message including the *message* to the This method prints a usage message, including the *message*, to
standard error and terminates the program with a status code of 2. :data:`sys.stderr` and terminates the program with a status code of 2.
Intermixed parsing Intermixed parsing