FlorianRhiem / pyGLFW

Python bindings for GLFW
MIT License
233 stars 36 forks source link

Process.Communicate failure, expects string not bytes #5

Closed Jerdak closed 10 years ago

Jerdak commented 10 years ago

In Python 3.4 glfw.py[130]: out = process.communicate(_to_char_p(filename))[0] fails with TypeError: must be str, not bytes

As far as I can tell, when universal_newlines=True is set in the previous line it tells subprocess to use type _io.TextIOWrapper for stdin. TextIOWrapper expects string input, not bytes:

All streams are careful about the type of data you give to them. For example giving a str object to the write() method of a binary stream will raise a TypeError. So will giving a bytes object to the write() method of a text stream.

I can get around the problem by scrapping the use of the _to_char_p lambda and just passing the string filename.

FlorianRhiem commented 10 years ago

This should've been fixed already in commit f2c1d73. Can you try upgrading your version of glfw.py?

Jerdak commented 10 years ago

Bugger, my bad. I'm maintaining code for both 2.7 and 3.4 and I didn't push the updated code to both versions. Sorry about that.