This patch adds a new Python C API called PyString_AsStringAndSize()
which implements the automatic conversion from Unicode to a string
object using the default encoding.
The new API is then put to use to have eval() and exec accept
Unicode objects as code parameter. This closes bugs #110924
and #113890.
As side-effect, the traditional C APIs PyString_Size() and
PyString_AsString() will also accept Unicode objects as
parameters.
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index ef7c09b..68cae81 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -355,6 +355,13 @@
del z
exec 'z=1+1'
if z <> 2: raise TestFailed, 'exec \'z=1+1\''
+ z = None
+ del z
+ exec u'z=1+1\n'
+ if z <> 2: raise TestFailed, 'exec u\'z=1+1\'\\n'
+ del z
+ exec u'z=1+1'
+ if z <> 2: raise TestFailed, 'exec u\'z=1+1\''
f()
g = {}
exec 'z = 1' in g