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

import prettyprinter empties stdin when stdin reads from file. #89

Open
Kenny2github opened this issue Sep 9, 2022 · 0 comments
Open

Comments

@Kenny2github
Copy link

  • PrettyPrinter version: 0.18.0
  • Python version: 3.9.6
  • Operating System: Windows 10 Command Prompt

Description

I was trying to prettyprint the result of operating on sys.stdin.read() when I noticed that the result of that function call was always ''. I isolated the problem to the import of prettyprinter - reading stdin operates correctly before the import, and reads the empty string after. Note: This only happens when a file (not a command's output!) is being redirected to stdin.

What I Did

C:\Users\Public>echo test>tmp.txt

C:\Users\Public>echo test | py -c "import sys; from prettyprinter import pprint; pprint(sys.stdin.read())"
'test \n'

C:\Users\Public>py -c "import sys; from prettyprinter import pprint; pprint(sys.stdin.read())" < tmp.txt
''

C:\Users\Public>type tmp.txt | py -c "import sys; from prettyprinter import pprint; pprint(sys.stdin.read())"
'test\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant