This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author valhallasw
Recipients benjamin.peterson, docs@python, pitrou, r.david.murray, valhallasw, vstinner
Date 2013-08-29.20:25:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1377807953.52.0.536183205972.issue18870@psf.upfronthosting.co.za>
In-reply-to
Content
On the lowest level, this affects exec, eval(), compile() and input() (!). On a higher level, more modules are affected:

modules ast, codeop, compiler, cProfile, dis, distutils (not sure), doctest, idlelib, ihooks, pdb, pkgutil, plat-mac, py_compile, rexec, runpy and timeit all call compile()

modules dbd, compiler, gettext, idlelib, lib2to3, lib-tk.turtle, logging, mhlib, pdb, plat-irix5, plat-mac, rexec, rlcompleter and warnings all call eval()

and modules Bastion, bdb, code, collections, cProfile, distutils, doctest, idlelib, ihooks, imputil, pdb, plat-irix5, plat-irix6, plat-mac, profile, rexec, site, timeit and trace all call exec.

Not all of them necessarily take user-supplied code - I haven't checked that.


After checking tests/test_pep263.py, it seems the behavior is a bit more complicated than I initially thought: a str parameter is considered latin-1 unless either
 a) an utf-8 bom is present, in which case it is considered utf-8
 b) an # encoding: XXX  line is present, in which case it is considered
    to be in that encoding

In any case, I have attached a doc patch for exec, eval(), compile(), and ast.literal_eval(), because I think these are the most widely used. I think input() does not need a doc change because it explicitly refers to eval().

I ignored the subtleties noted above for the doc patch, simplifying to 'pass either a Unicode or a latin-1 encoded string'.
History
Date User Action Args
2013-08-29 20:25:53valhallaswsetrecipients: + valhallasw, pitrou, vstinner, benjamin.peterson, r.david.murray, docs@python
2013-08-29 20:25:53valhallaswsetmessageid: <1377807953.52.0.536183205972.issue18870@psf.upfronthosting.co.za>
2013-08-29 20:25:53valhallaswlinkissue18870 messages
2013-08-29 20:25:53valhallaswcreate