selectel / pyte

Simple VTXXX-compatible linux terminal emulator
http://pyte.readthedocs.org/
GNU Lesser General Public License v3.0
649 stars 101 forks source link

TypeError: cannot use a string pattern on a bytes-like object, when running Tutorial #132

Closed ahmedkhalf closed 4 years ago

ahmedkhalf commented 4 years ago

Hi, I just installed pyte on python 3.7.5, windows 10, hoping to make my own terminal GUI using pygame but I ran across this error when running the tutorial.

C:\Users\ahmed>python
Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import unicode_literals
>>> import pyte
>>> screen = pyte.Screen(80, 24)
>>> stream = pyte.Stream(screen)
>>> stream.feed(b"Hello World!")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ahmed\AppData\Local\Programs\Python\Python37\lib\site-packages\pyte\streams.py", line 189, in feed
    match = match_text(data, offset)
TypeError: cannot use a string pattern on a bytes-like object

Thank you, Ahmed Khalf.

ahmedkhalf commented 4 years ago

Okay so I tried it with python 3.6.10, and python 3.5.6, and It still produces the same error... I don't really feel like using python 2 because it's already end of life.

ahmedkhalf commented 4 years ago

Okay so I just took a look at the source code hoping I could fix it and found this:

Stream only accepts text as input, but if for some reason you need to feed it with bytes, consider using :class:~pyte.streams.ByteStream instead.

Well, it would be great if you guys could update the docs. I'm leaving this open until a maintainer closes it.