You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError: a bytes-like object is required, not 'str' #700
(venv) Ori@gordio ~/Development/python/sk-numbers
❱bpython
bpython version 0.16 on top of Python 3.6.2 /Users/gordio/Development/python/sk-numbers/venv/bin/python3
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,2.5,3])
[<matplotlib.lines.Line2D object at 0x10cd60320>]
>>> plt.show()
Traceback (most recent call last):
File "<input>", line 1, in <module>
plt.show()
File "/Users/gordio/Development/python/sk-numbers/venv/lib/python3.6/site-pack
ages/matplotlib/pyplot.py", line 253, in show
return _show(*args, **kw)
File "/Users/gordio/Development/python/sk-numbers/venv/lib/python3.6/site-pack
ages/itermplot/__init__.py", line 131, in show
figmanager.show()
File "/Users/gordio/Development/python/sk-numbers/venv/lib/python3.6/site-pack
ages/itermplot/__init__.py", line 275, in show
imgcat(data.getbuffer(), fn)
File "/Users/gordio/Development/python/sk-numbers/venv/lib/python3.6/site-pack
ages/itermplot/__init__.py", line 115, in imgcat
sys.stdout.write(buf)
File "/Users/gordio/Development/python/sk-numbers/venv/lib/python3.6/site-pack
ages/bpython/curtsiesfrontend/coderunner.py", line 213, in write
self.on_write(s, *args, **kwargs)
File "/Users/gordio/Development/python/sk-numbers/venv/lib/python3.6/site-pack
ages/bpython/curtsiesfrontend/repl.py", line 1128, in send_to_stdout
lines = output.split('\n')
TypeError: a bytes-like object is required, not 'str'
So if I understand it correctly, this software is trying to write binary data to the stdout to display an image? @thomasballinger We could put a try except structure in send_to_stdout, if it's really needed.
Hmmmmm so we ought to be allowing bytes to pass through huh? This actually may be related to a unicode width-predicting issue I'm hoping to look at: there are some things like escape codes and binary image data that make predicting what the terminal will look like difficult for bpython, so maybe we should just be printing and then seeing where the cursor is.
That said, I think the odds of this being supported in curtsies are pretty low, it seems like it could interfere with the terminal-rewriting rewind behavior I'm unreasonably fond of.
Should I open a new issue or contribute here, I get this error when trying to use the click library. It happens if I first import click and then result = click.prompt('anytext') but does not happen if I do this exact same step in the native python 3.8 repl. Let me know if a new issue is needed or if I should add any more information here.
Activity
ata2001 commentedon Aug 15, 2017
Hi @gordio! Could you check, whether the issue is still present with the latest (0.17) release?
gordio commentedon Aug 15, 2017
@ata2001 yep, still exist on
bpython version 0.18.dev2 on top of Python 3.6.2ata2001 commentedon Aug 16, 2017
So if I understand it correctly, this software is trying to write binary data to the stdout to display an image? @thomasballinger We could put a try except structure in
send_to_stdout, if it's really needed.gordio commentedon Aug 16, 2017
Yep.
ata2001 commentedon Aug 16, 2017
@gordio Please apply this patch, run bpython with the
-Loption, reproduce the error, and post the contents of bpython.log!gordio commentedon Aug 16, 2017
bpython.log!
ata2001 commentedon Aug 17, 2017
@gordio Thank you! The error comes from bpython trying to split the image with a string as a separator.
Is there any way, I could test it on a GNU/linux system?
gordio commentedon Aug 17, 2017
I don't know. But you can install https://github.com/daleroberts/itermplot and test.
thomasballinger commentedon Feb 14, 2018
Hmmmmm so we ought to be allowing bytes to pass through huh? This actually may be related to a unicode width-predicting issue I'm hoping to look at: there are some things like escape codes and binary image data that make predicting what the terminal will look like difficult for bpython, so maybe we should just be printing and then seeing where the cursor is.
That said, I think the odds of this being supported in curtsies are pretty low, it seems like it could interfere with the terminal-rewriting rewind behavior I'm unreasonably fond of.
slipsnip commentedon Jun 9, 2020
Should I open a new issue or contribute here, I get this error when trying to use the click library. It happens if I first import click and then
result = click.prompt('anytext')but does not happen if I do this exact same step in the native python 3.8 repl. Let me know if a new issue is needed or if I should add any more information here.thomasballinger commentedon Jul 11, 2020
@slipsnip Please open a new issue, that sounds easier to address (and more urgent)
sebastinas commentedon Oct 15, 2021
This was fixed in b63051e.
Also mention #700