[Python-Dev] confusing exec error message in 3.0 (original) (raw)

Michael Foord fuzzyman at voidspace.org.uk
Thu Aug 28 00:55:56 CEST 2008


Georg Brandl wrote:

Fredrik Lundh schrieb:

(using 3.0a4)

>>> exec(open("file.py")) Traceback (most recent call last): File "", line 1, in TypeError: exec() arg 1 must be a string, file, or code object, not TextIOWrapper so what's "file" referring to here? (the above works under 2.5, of course) See http://bugs.python.org/issue1762972 -- it has been decided to drop that possibility. I've a patch that fixes the wrong error message in http://bugs.python.org/issue3706.

In order to obtain a string from a Python source code file, honouring encoding cookies, the tokenize module has a 'detect_encoding' function that could be useful.

Michael

Georg


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk

-- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/ http://www.trypython.org/ http://www.ironpython.info/ http://www.theotherdelia.co.uk/ http://www.resolverhacks.net/



More information about the Python-Dev mailing list