stderr duplication failed in console scripts
See original GitHub issueDescription
I use a console_scripts
entry point with a test function. If I do pip install . or use setup.py to make a binary dist then install it, under some shell like Git Bash, running the created test-script.exe
. stdin
, stdout
and stderr
should all be set to a TextIOWrapper
however, stderr
is set to None
.
The stderr
handle is apparently not correctly set.
This is probably related to https://github.com/pypa/pip/issues/10444 and the fix introduced in Distlib 0.3.4 for a similar issue.
Expected behavior
$ test-script.exe
stdin=<_io.TextIOWrapper name='<stdin>' mode='r' encoding='cp1252'>
stdout=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='cp1252'>
stderr=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='cp1252'>
pip version
22.0
Python version
Python 3.7
OS
Windows
How to Reproduce
# setup.py
from setuptools import setup
setup(
name="test",
packages=["testing"],
entry_points={
"console_scripts": [
"test-script=testing:main"
]
}
)
# testing/__init__.py
import sys
def main():
print(f"stdin={sys.stdin}")
print(f"stdout={sys.stdout}")
print(f"stderr={sys.stderr}")
Output
# With pip 21.*
$ test-script.exe
stdin=<_io.TextIOWrapper name='<stdin>' mode='r' encoding='cp1252'>
stdout=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='cp1252'>
stderr=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='cp1252'>
# With pip 22.0, 22.0.1 and 22.0.2
$ test-script.exe
stdin=<_io.TextIOWrapper name='<stdin>' mode='r' encoding='cp1252'>
stdout=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='cp1252'>
stderr=None
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:55 (26 by maintainers)
Top Results From Across the Web
duplication of messages in stderr and stdout python logging
I'm using a small script and running it directly, and so the filter_maker will be in the __main__ module (as indicated in the...
Read more >20.8. Error Reporting and Logging - PostgreSQL
The default is to log to stderr only. This parameter can only be set in the postgresql.conf file or on the server command...
Read more >2 Server Error Message Reference - MySQL :: Developer Zone
Message: Can't write; duplicate key in table '%s'. Error number: 1024 ... Message: The used command is not allowed with this MySQL version....
Read more >Node.js v19.3.0 Documentation
new Console(stdout[, stderr][, ignoreErrors]); new Console(options) ... Script cached data; DEP0111: process.binding(); DEP0112: dgram private APIs ...
Read more >bash - Copy stdout and stderr to a log file and leave them on ...
Copy stdout and stderr to a log file and leave them on the console within the script itself [duplicate] · Ask Question. Asked...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is good context, thanks for noting this here @eli-schwartz!
I think having a visible (albeit cryptic) error that users can discover is better than a silent error that they can’t. Further, CLI entry points are a lot more common than GUI entry points and I’m pretty sure the right thing to do here is to downgrade distlib to 0.3.3 until @vsajip is able able to fix this issue in distlib.
I’ll cut a bugfix for this.
I have an example of a very common use case affected by this bug.
Imagine a python developer using Jenkins to run his unit tests, using pytest, on a Windows host.
Now because he start using pip 22.x (he updated because pip warned him that he was not using the latest version), running
pytest
will not produce any output on the console, tests will not run and there is no reporting.Now how is this user supposed to root cause this issue? There is no output at all since stderr is None.
And this is not a intermittent issue, in the affected environment (like Jenkins on Windows in this example), stderr will always be None.
@pfmoore, I hope this helps you understand the importance of getting this bug fixed.