jaraco / jaraco.clipboard

MIT License
21 stars 1 forks source link

TypeError: a bytes-like object is required, not 'str' #2

Closed ruxtain closed 6 years ago

ruxtain commented 6 years ago
> from jaraco import clipboard
> clipboard.paste_html()

Traceback (most recent call last):
  File "C:\bin\code.py", line 4, in <module>
    clipboard.paste_html()
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\jaraco\clipboard\Windows.py", line 9, in paste_html
    wclip.get_html().html
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\jaraco\windows\clipboard.py", line 156, in get_html
    result = GetClipboardData(clipboard.CF_HTML)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\jaraco\windows\clipboard.py", line 110, in GetClipboardData
    return data_handlers[type](handle)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\jaraco\windows\clipboard.py", line 72, in __init__
    self.data = text_string(handle)
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\jaraco\windows\clipboard.py", line 57, in text_string
    return nts(raw_data(handle))
  File "C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\jaraco\windows\clipboard.py", line 48, in nts
    result, null, rest = s.partition('\x00')
TypeError: a bytes-like object is required, not 'str'

Can you have a look please?

jaraco commented 6 years ago

Well, this one is a bit tricky. The underlying issue is in the jaraco.windows project... but I'll have to dig into the APIs to determine how MS encodes HTML on the clipboard.

jaraco commented 6 years ago

I've moved this issue to jaraco/jaraco.windows#13.

jaraco commented 6 years ago

This issue should be fixed with jaraco.windows 3.9.1. Please upgrade it in your environment and report back if it's successful and if it does what you need/expect.