diff options
author | Stefan Behnel <scoder@users.berlios.de> | 2009-08-19 16:48:34 +0200 |
---|---|---|
committer | Stefan Behnel <scoder@users.berlios.de> | 2009-08-19 16:48:34 +0200 |
commit | 6caf44024293af135007b800505809c2ccc600b8 (patch) | |
tree | 8868b0769fcd8a143aafaba35a05e5f76c81b8df /tests/run/exectest.pyx | |
parent | 5bb27ff1ed3f114fed8aba0123e933ea06987bcd (diff) | |
download | cython-6caf44024293af135007b800505809c2ccc600b8.tar.gz |
extended exec() implementation, mostly copied from Py3.1
Diffstat (limited to 'tests/run/exectest.pyx')
-rw-r--r-- | tests/run/exectest.pyx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/run/exectest.pyx b/tests/run/exectest.pyx index 2e297756a..70a2a0d4c 100644 --- a/tests/run/exectest.pyx +++ b/tests/run/exectest.pyx @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + __doc__ = u""" #>>> a #Traceback (most recent call last): @@ -43,6 +45,21 @@ __doc__ = u""" >>> list(add_iter()) [2, 3, 4, 5] +>>> d = {} +>>> test_encoding(d, None) +>>> print(d['b']) +üöä + +>>> d = {} +>>> test_encoding_unicode(d, None) +>>> print(d['b']) +üöä + +>>> d = dict(a=1, c=3) +>>> test_compile(d) +>>> d['b'] +4 + >>> # errors >>> d1, d2 = {}, {} @@ -76,3 +93,23 @@ def test(): yield x+1 """ % varref in d return d[u'test'] + +import sys + +def test_encoding(d1, d2): + if sys.version_info[0] >= 3: + s = "b = 'üöä'" + else: + s = "# -*- coding: utf-8 -*-" + "\n" + "b = u'üöä'" + exec s in d1, d2 + +def test_encoding_unicode(d1, d2): + if sys.version_info[0] >= 3: + s = u"b = 'üöä'" + else: + s = u"b = u'üöä'" + exec s in d1, d2 + +def test_compile(d): + c = compile(u"b = a+c", u"<string>", u"exec") + exec c in d |