changeset 51168:a9e00554b3e4 stable

procutil: move stdin assignment outside of try-finally block There is an stdin variable in the global scope of this module. And in the `finally` block of this try-finally statement we're checking `if stdin is not None`. Let's make sure we don't confuse code check tools into thinking we want to use global stdin by moving this line of code outside of `try`. This was caught by pytype 2023.11.21 on Python 3.11.2.
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 02 Dec 2023 15:10:28 -0300
parents b79f13d6ef25
children 71bd09bebbe3
files mercurial/utils/procutil.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/utils/procutil.py	Sat Dec 02 15:02:03 2023 -0300
+++ b/mercurial/utils/procutil.py	Sat Dec 02 15:10:28 2023 -0300
@@ -686,8 +686,9 @@
         # we can't use close_fds *and* redirect stdin. I'm not sure that we
         # need to because the detached process has no console connection.
 
+        stdin = None
+
         try:
-            stdin = None
             if stdin_bytes is not None:
                 stdin = pycompat.unnamedtempfile()
                 stdin.write(stdin_bytes)