This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author izbyshev
Recipients gregory.p.smith, izbyshev
Date 2018-02-14.21:10:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
When redirecting, subprocess attempts to achieve the following state: each fd to be redirected to is less than or equal to the fd it is redirected from, which is necessary because redirection occurs in the ascending order of destination descriptors. It fails to do so if a low fd (< 2) is redirected to stderr and another low fd is closed, which may lead to an incorrect redirection, for example:

$ cat
import os
import subprocess
import sys

os.close(0)[sys.executable, '-c',
                 'import sys; print("Hello", file=sys.stderr)'],

$ python3 2>/dev/null
$ python3 >/dev/null

Expected behavior:
$ python3 >/dev/null
$ python3 2>/dev/null
Date User Action Args
2018-02-14 21:10:48izbyshevsetrecipients: + izbyshev, gregory.p.smith
2018-02-14 21:10:48izbyshevsetmessageid: <>
2018-02-14 21:10:48izbyshevlinkissue32844 messages
2018-02-14 21:10:48izbyshevcreate