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

Crash when printing non-unicode #122

Open
BenWiederhake opened this issue Oct 18, 2019 · 0 comments
Open

Crash when printing non-unicode #122

BenWiederhake opened this issue Oct 18, 2019 · 0 comments

Comments

@BenWiederhake
Copy link
Contributor

I hope this is the actual cause of bpython#747. window.py:43 currently says:

self.out_stream.write(msg)

However, this fails when the arument is not encodable in the current encoding.

Here's how to reproduce this is in an Unicode environment:

python3 -c 'import sys; sys.stdout.write("\ud800")'

Fails immediately with:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position 0: surrogates not allowed

So the obvious™ thing to do is call msg.encode(errors='replace') or something.

However:

  • What is the charset? Is it still always unicode?
  • Is msg really always text?

Those are questions I cannot answer by myself.

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