Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Clarify that Popen.returncode does not get auto-set when the process terminates #87452

Closed
anntzer mannequin opened this issue Feb 21, 2021 · 2 comments
Closed

[doc] Clarify that Popen.returncode does not get auto-set when the process terminates #87452

anntzer mannequin opened this issue Feb 21, 2021 · 2 comments
Assignees
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy stdlib Python modules in the Lib dir

Comments

@anntzer
Copy link
Mannequin

anntzer mannequin commented Feb 21, 2021

BPO 43286

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-02-21.15:56:24.983>
labels = ['easy', '3.9', '3.10', '3.11', 'library', 'docs']
title = '[doc] Clarify that Popen.returncode does not get auto-set when the process terminates'
updated_at = <Date 2021-11-27.19:08:00.355>
user = 'https://github.com/anntzer'

bugs.python.org fields:

activity = <Date 2021-11-27.19:08:00.355>
actor = 'Antony.Lee'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation', 'Library (Lib)']
creation = <Date 2021-02-21.15:56:24.983>
creator = 'Antony.Lee'
dependencies = []
files = []
hgrepos = []
issue_num = 43286
keywords = ['easy']
message_count = 1.0
messages = ['387463']
nosy_count = 1.0
nosy_names = ['docs@python']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue43286'
versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

Linked PRs

@anntzer
Copy link
Mannequin Author

anntzer mannequin commented Feb 21, 2021

Currently, the documentation for Popen.returncode states

The child return code, set by poll() and wait() (and indirectly by communicate()). A None value indicates that the process hasn’t terminated yet.

A negative value -N indicates that the child was terminated by signal N (POSIX only).

As far back as https://bugs.python.org/issue1727024 it had been suggested that this fails to emphasize an important piece of information, namely that this attribute can be outdated (it is *only* set if poll() or wait() are called; this is not obvious, e.g. returncode could have beeen implemented as a property that auto-calls poll()). I do realize that a strict reading of the docs does suggest the actual behavior, but a bit of explicitness won't hurt...

The wording suggested in https://bugs.python.org/issue1727024 seems clearer to me ("Note: The value stored in returncode may be out-of-date. Use poll() to reliably find the current return code.").

@anntzer anntzer mannequin added the 3.10 only security fixes label Feb 21, 2021
@anntzer anntzer mannequin assigned docspython Feb 21, 2021
@anntzer anntzer mannequin added docs Documentation in the Doc dir 3.10 only security fixes labels Feb 21, 2021
@anntzer anntzer mannequin assigned docspython Feb 21, 2021
@anntzer anntzer mannequin added the docs Documentation in the Doc dir label Feb 21, 2021
@iritkatriel iritkatriel added easy 3.9 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir labels Nov 27, 2021
@iritkatriel iritkatriel changed the title Clarify that Popen.returncode does not get auto-set when the process terminates [doc] Clarify that Popen.returncode does not get auto-set when the process terminates Nov 27, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
zitterbewegung added a commit to zitterbewegung/cpython that referenced this issue May 3, 2022
zitterbewegung added a commit to zitterbewegung/cpython that referenced this issue May 3, 2022
zitterbewegung added a commit to zitterbewegung/cpython that referenced this issue Jul 9, 2022
@gpshead gpshead self-assigned this Apr 24, 2023
gpshead added a commit to zitterbewegung/cpython that referenced this issue Apr 24, 2023
gpshead pushed a commit that referenced this issue Apr 24, 2023
Clarifies that it remains None until a method checking the child process status has been called and noticed it has terminated.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 24, 2023
Clarifies that it remains None until a method checking the child process status has been called and noticed it has terminated.
(cherry picked from commit 68f5836)

Co-authored-by: Joshua Herman <30265+zitterbewegung@users.noreply.github.com>
@gpshead
Copy link
Member

gpshead commented Apr 24, 2023

thanks, good clarification. merged.

@gpshead gpshead closed this as completed Apr 24, 2023
carljm added a commit to carljm/cpython that referenced this issue Apr 24, 2023
* main: (53 commits)
  pythongh-102498 Clean up unused variables and imports in the email module  (python#102482)
  pythongh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (python#99244)
  pythongh-99032: datetime docs: Encoding is no longer relevant (python#93365)
  pythongh-94300: Update datetime.strptime documentation (python#95318)
  pythongh-103776: Remove explicit uses of $(SHELL) from Makefile (pythonGH-103778)
  pythongh-87092: fix a few cases of incorrect error handling in compiler (python#103456)
  pythonGH-103727: Avoid advancing tokenizer too far in f-string mode (pythonGH-103775)
  Revert "Add tests for empty range equality (python#103751)" (python#103770)
  pythongh-94518: Port 23-argument `_posixsubprocess.fork_exec` to Argument Clinic (python#94519)
  pythonGH-65022: Fix description of copyreg.pickle function (python#102656)
  pythongh-103323: Get the "Current" Thread State from a Thread-Local Variable (pythongh-103324)
  pythongh-91687: modernize dataclass example typing (python#103773)
  pythongh-103746: Test `types.UnionType` and `Literal` types together (python#103747)
  pythongh-103765: Fix 'Warning: py:class reference target not found: ModuleSpec' (pythonGH-103769)
  pythongh-87452: Improve the Popen.returncode docs
  Removed unnecessary escaping of asterisks (python#103714)
  pythonGH-102973: Slim down Fedora packages in the dev container (python#103283)
  pythongh-103091: Add PyUnstable_Type_AssignVersionTag (python#103095)
  Add tests for empty range equality (python#103751)
  pythongh-103712: Increase the length of the type name in AttributeError messages (python#103713)
  ...
carljm added a commit to carljm/cpython that referenced this issue Apr 24, 2023
* superopt: (82 commits)
  pythongh-101517: fix line number propagation in code generated for except* (python#103550)
  pythongh-103780: Use patch instead of mock in asyncio unix events test (python#103782)
  pythongh-102498 Clean up unused variables and imports in the email module  (python#102482)
  pythongh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (python#99244)
  pythongh-99032: datetime docs: Encoding is no longer relevant (python#93365)
  pythongh-94300: Update datetime.strptime documentation (python#95318)
  pythongh-103776: Remove explicit uses of $(SHELL) from Makefile (pythonGH-103778)
  pythongh-87092: fix a few cases of incorrect error handling in compiler (python#103456)
  pythonGH-103727: Avoid advancing tokenizer too far in f-string mode (pythonGH-103775)
  Revert "Add tests for empty range equality (python#103751)" (python#103770)
  pythongh-94518: Port 23-argument `_posixsubprocess.fork_exec` to Argument Clinic (python#94519)
  pythonGH-65022: Fix description of copyreg.pickle function (python#102656)
  pythongh-103323: Get the "Current" Thread State from a Thread-Local Variable (pythongh-103324)
  pythongh-91687: modernize dataclass example typing (python#103773)
  pythongh-103746: Test `types.UnionType` and `Literal` types together (python#103747)
  pythongh-103765: Fix 'Warning: py:class reference target not found: ModuleSpec' (pythonGH-103769)
  pythongh-87452: Improve the Popen.returncode docs
  Removed unnecessary escaping of asterisks (python#103714)
  pythonGH-102973: Slim down Fedora packages in the dev container (python#103283)
  pythongh-103091: Add PyUnstable_Type_AssignVersionTag (python#103095)
  ...
ambv added a commit that referenced this issue Apr 25, 2023
Clarifies that it remains None until a method checking the child process
status has been called and noticed it has terminated.
(cherry picked from commit 68f5836)

Co-authored-by: Joshua Herman <30265+zitterbewegung@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

2 participants