xolox/python-humanfriendly

type error with Python3 in terminal.show_pager

edmw opened this issue · 2 comments

edmw commented

I get a type error when calling terminal.show_pager with Python3.5

>>> from humanfriendly import terminal
>>> terminal.show_pager("1 2 3")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mib/tmp/python-humanfriendly/humanfriendly/terminal.py", line 392, in show_pager
    pager.communicate(input=formatted_text)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1053, in communicate

    self._stdin_write(input)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1015, in _stdin_write
    self.stdin.write(input)
TypeError: a bytes-like object is required, not 'str'
xolox commented

Hi Michael, thanks for the feedback and sorry not picking this up this earlier. I added a test which indeed breaks on Python 3 builds and then tested the solution. I've since released version 1.44.8 which contains the fix.

edmw commented

Thanks