diff --git a/direct/src/stdpy/file.py b/direct/src/stdpy/file.py index f7125a3920..27257ad890 100644 --- a/direct/src/stdpy/file.py +++ b/direct/src/stdpy/file.py @@ -185,6 +185,13 @@ class StreamIOWrapper(io.IOBase): if isinstance(stream, core.Ostream): self.__writer = core.StreamWriter(stream, False) self.__lastWrite = True + if sys.version_info >= (3, 0): + # In Python 3, we use appendData, which only accepts bytes. + self.__write = self.__writer.appendData + else: + # In Python 2.7, we also accept unicode objects, which are + # implicitly converted to C++ strings. + self.__write = self.__writer.write def __repr__(self): s = "