Commit 78ef8342 authored by Stefan Behnel's avatar Stefan Behnel

let str() in Py3 represent the unicode type

parent 04f8cc68
...@@ -493,7 +493,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -493,7 +493,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("#if PY_MAJOR_VERSION >= 3") code.putln("#if PY_MAJOR_VERSION >= 3")
code.putln(" #define PyBaseString_Type PyUnicode_Type") code.putln(" #define PyBaseString_Type PyUnicode_Type")
code.putln(" #define PyString_Type PyBytes_Type") code.putln(" #define PyString_Type PyUnicode_Type")
code.putln(" #define PyString_CheckExact PyBytes_CheckExact") code.putln(" #define PyString_CheckExact PyBytes_CheckExact")
code.putln(" #define PyInt_Type PyLong_Type") code.putln(" #define PyInt_Type PyLong_Type")
code.putln(" #define PyInt_Check(op) PyLong_Check(op)") code.putln(" #define PyInt_Check(op) PyLong_Check(op)")
......
__doc__ = u""" __doc__ = u"""
>>> s('test', **encoding) >>> str('test')
b'test' 'test'
>>> z >>> z
b'test' 'test'
>>> c('testing') >>> c('testing')
b'testing' 'testing'
>>> sub('testing a subtype') >>> sub('testing a subtype')
b'testing a subtype' 'testing a subtype'
>>> subs('testing a subtype', **encoding) >>> subs('testing a subtype')
b'testing a subtype' 'testing a subtype'
# >>> csub('testing a subtype') # >>> csub('testing a subtype')
# 'testing a subtype' # 'testing a subtype'
...@@ -16,27 +16,20 @@ __doc__ = u""" ...@@ -16,27 +16,20 @@ __doc__ = u"""
# 'testing a subtype' # 'testing a subtype'
""" """
import sys
if sys.version_info[0] >= 3:
encoding = {u'encoding' : u'ASCII'}
else:
encoding = {}
__doc__ = __doc__.replace(u" b'", u" '")
s = str s = str
z = str('test') z = str('test')
def c(string): def c(string):
return str(string, **encoding) return str(string)
class subs(str): class subs(str):
pass pass
def sub(string): def sub(string):
return subs(string, **encoding) return subs(string)
#cdef class subs(str): #cdef class subs(str):
# pass # pass
#def csub(string): #def csub(string):
# return csubs(string, **encoding) # return csubs(string)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment