Message84160
> 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 |
|
Date |
User |
Action |
Args |
2009-03-25 15:23:19 | vstinner | set | recipients:
+ vstinner, brett.cannon, sjmachin, amaury.forgeotdarc, benjamin.peterson, jmfauth |
2009-03-25 15:23:16 | vstinner | link | issue4626 messages |
2009-03-25 15:23:15 | vstinner | create | |
|