__doc__ = u"""
>>> test_modify()
-0 1 2 3 4
+0
+1
+2
+3
+4
+<BLANKLINE>
(4, 0)
>>> test_fix()
-0 1 2 3 4
+0
+1
+2
+3
+4
+<BLANKLINE>
4
>>> test_break()
-0 1 2
+0
+1
+2
+<BLANKLINE>
(2, 0)
>>> test_return()
-0 1 2
+0
+1
+2
(2, 0)
"""
def test_modify():
cdef int i, n = 5
for i in range(n):
- print i,
+ print i
n = 0
print
return i,n
def test_fix():
cdef int i
for i in range(5):
- print i,
+ print i
print
return i
def test_break():
cdef int i, n = 5
for i in range(n):
- print i,
+ print i
n = 0
if i == 2:
break
+ else:
+ print "FAILED!"
print
return i,n
def test_return():
cdef int i, n = 5
for i in range(n):
- print i,
+ print i
n = 0
if i == 2:
return i,n
__doc__ = u"""
- >>> py_x = br'\\\\'
- >>> assert x == py_x
+ >>> b == br'\\\\'
+ True
+ >>> s == r'\\\\'
+ True
+ >>> u == ur'\\\\'
+ True
"""
import sys
if sys.version_info[0] < 3:
__doc__ = __doc__.replace(u" br'", u" r'")
+else:
+ __doc__ = __doc__.replace(u" ur'", u" r'")
-x = r'\\'
+b = br'\\'
+s = r'\\'
+u = ur'\\'
__doc__ = u"""
>>> x = X()
>>> x.slots
- [b'']
+ ['']
"""
-import sys
-if sys.version_info[0] < 3:
- __doc__ = __doc__.replace(u"b'", u"'")
-
class X:
slots = ["", ]
__doc__ = u"""
>>> test_str(1)
- b'b'
+ 'b'
>>> test_unicode_ascii(2)
u'c'
>>> test_int_list(2)
3
>>> test_str_list(1)
- b'bcd'
+ 'bcd'
>>> test_int_tuple(2)
3
>>> test_str_tuple(0)
- b'a'
+ 'a'
>>> test_mix_tuple(1)
- b'abc'
+ 'abc'
>>> test_mix_tuple(0)
1
"""
__doc__ = __doc__.replace(u" b'", u" '")
def test_str(n):
- if IS_PY3:
- return bytes(["abcd"[n]])
- else:
- return "abcd"[n]
+ return "abcd"[n]
def test_unicode_ascii(n):
return u"abcd"[n]
-__doc__ = """# disabled in Py3
+
+import sys
+if sys.version_info[0] < 3:
+ __doc__ = u"""
+
>>> test(0)
0L
>>> test(1)
1L
- >>> import sys
>>> sys.maxint + 1 > sys.maxint
True
>>> type(sys.maxint * 2 + 1) is long
True
>>> test(256 ** unsigned_long_size() - 1) > sys.maxint
True
-"""
+ """
+else:
+ __doc__ = u"""
+ >>> test(0)
+ 0
+ >>> test(1)
+ 1
+ >>> test(256 ** unsigned_long_size() - 1) > 0
+ True
+ """
def test(k):
cdef unsigned long m
# -*- coding: utf-8 -*-
-__doc__ = r"""
+__doc__ = br"""
>>> sa
- b'abc'
+ 'abc'
>>> ua
u'abc'
>>> b
u'S\xf8k ik\xfc\xd6\xe4abc'
>>> null
u'\x00'
-""".decode(u"ASCII") + """
+""".decode("ASCII") + b"""
>>> len(sa)
3
>>> len(ua)
12
>>> len(null)
1
-""".decode(u"ASCII") + u"""
+""".decode("ASCII") + u"""
>>> ua == u'abc'
True
>>> b == u'123'
# This file is written in UTF-8, but it has no encoding declaration,
# so it just defaults to UTF-8 (PEP 3120).
-__doc__ = r"""
+__doc__ = br"""
>>> sa
- b'abc'
+ 'abc'
>>> ua
u'abc'
>>> b
u'S\xf8k ik\xfc\xd6\xe4abc'
>>> null
u'\x00'
-""".decode(u"ASCII") + """
+""".decode("ASCII") + b"""
>>> len(sa)
3
>>> len(ua)
12
>>> len(null)
1
-""".decode(u"ASCII") + u"""
+""".decode("ASCII") + u"""
>>> ua == u'abc'
True
>>> b == u'123'
# -*- coding: latin-1 -*-
-__doc__ = r"""
+__doc__ = br"""
>>> sa
- b'abc'
+ 'abc'
>>> ua
u'abc'
>>> b
u'S\xf8k ik\xfc\xd6\xe4abc'
>>> null
u'\x00'
-""".decode(u"ASCII") + """
+""".decode("ASCII") + b"""
>>> len(sa)
3
>>> len(ua)
12
>>> len(null)
1
-""".decode(u"ASCII") + u"""
+""".decode("ASCII") + u"""
>>> ua == u'abc'
True
>>> b == u'123'