Buffer type checking cleanup/rewrite (now uses use_utility_code)
[cython.git] / tests / run / strfunction.pyx
1 __doc__ = u"""
2    >>> s('test', **encoding)
3    b'test'
4    >>> z
5    b'test'
6    >>> c('testing')
7    b'testing'
8    >>> sub('testing a subtype')
9    b'testing a subtype'
10    >>> subs('testing a subtype', **encoding)
11    b'testing a subtype'
12
13 #   >>> csub('testing a subtype')
14 #   'testing a subtype'
15 #   >>> csubs('testing a subtype')
16 #   'testing a subtype'
17 """
18
19 import sys
20 if sys.version_info[0] >= 3:
21     encoding = {u'encoding' : u'ASCII'}
22 else:
23     encoding = {}
24     __doc__ = __doc__.replace(u" b'", u" '")
25
26 s = str
27 z = str('test')
28
29 def c(string):
30     return str(string, **encoding)
31
32 class subs(str):
33     pass
34
35 def sub(string):
36     return subs(string, **encoding)
37
38 #cdef class subs(str):
39 #    pass
40
41 #def csub(string):
42 #    return csubs(string, **encoding)