STINNER Victor <victor.stin...@haypocalc.com> added the comment: > Yes, I could, but I think this is not an IDLE issue > (...) > File "uuu.py", line 8, in <module> > ii.runsource(source) > (...) > File "c:\python30\lib\codeop.py", line 70, in _maybe_compile > for line in source.split("\n"): > TypeError: Type str doesn't support the buffer API
compile() works as expected. Your problem is related to InteractiveInterpreter().runsource(source) which is part of IDLE. runsource() is not compatible with bytes, only 'str' type is accepted. The error comes from bytes.split(str): _maybe_compile() should use source.split(b'\n') if source type is bytes. Or runsource() should reject bytes directly. > source = str(source, 'cp1252') #<<<<<<<<<< > ii.runsource(source) > > Output: (ok) Yes, runsource() (only) works with the str type. > I suspect the miscellaneous discussions one finds from people attempting > to write a "correct" execfile() for Python 3 are coming from this. Please see issues: - issue #5524: execfile() removed from Python3 - issue #4628: No universal newline support for compile() when using bytes ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4626> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com