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 ciprian.craciun
Recipients ciprian.craciun, ned.deily, ronaldoussoren
Date 2021-01-29.22:32:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Sometimes (especially from wrapper scripts) one would like to call Python with a script that should be read from a file-descriptor, like `python3 /dev/fd/9`;  most likely the backing is a file in `TMPDIR` (perhaps unlinked, like `bash`'s "here documents").

However on OSX (I've tried it on `10.15.7` and `10.13.6`), for some reason if that script is too "large" (more than a couple of characters) it just bails out, even if that file-descriptor is in fact backed by a file.

For example:
echo 'print("1234567890")' >/tmp/ && python3 /dev/fd/9 9</tmp/
# correctly prints 1234567890

echo 'print("12345678901234567890")' >/tmp/ && python3 /dev/fd/9 9</tmp/
# prints nothing, no error, no exit code, etc.

# alternative variant 1, with `bash` "here-documents"
python3 /dev/fd/9 9<<<'print("12345678901234567890")'
# still prints nothing.

# alternative variant 2, that uses `/dev/stdin` instead of `/dev/fd/N`
python3 /dev/stdin <<<'print("12345678901234567890")'
# still prints nothing.

# alternative variant 3, that uses `open` and `exec`
python3 -c 'exec(open("/dev/fd/9").read())' 9<<<'print("12345678901234567890")'
# correctly prints 12345678901234567890

The file `/tmp/` is just a simple script that prints that token.

I've tried both Python 3.9.1, 3.8.2 and even 2.7.18 and 2.7.16, all with the same results.  (This makes me think it's actually an OSX issue?)

On Linux this works flawlesly.  Furthermore if one uses something else like `cat`, `bash` or anything else it works.  Thus it is something related with Python on OSX.

Also as seen from the examples, this is not a "shell issue" or something similar;  it just seems to hit a corner case when the script path is `/dev/fd/...` or `/dev/stdin`
Date User Action Args
2021-01-29 22:32:21ciprian.craciunsetrecipients: + ciprian.craciun, ronaldoussoren, ned.deily
2021-01-29 22:32:21ciprian.craciunsetmessageid: <>
2021-01-29 22:32:21ciprian.craciunlinkissue43069 messages
2021-01-29 22:32:21ciprian.craciuncreate