Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
84fc66dd
Commit
84fc66dd
authored
May 03, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename 'unicode' to 'str' in its tp_name field. Rename 'str' to 'str8'.
Change all occurrences of unichr to chr.
parent
ef87d6ed
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
45 additions
and
66 deletions
+45
-66
Lib/HTMLParser.py
Lib/HTMLParser.py
+2
-2
Lib/encodings/punycode.py
Lib/encodings/punycode.py
+1
-1
Lib/sre_parse.py
Lib/sre_parse.py
+1
-1
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+13
-13
Lib/test/test_codeccallbacks.py
Lib/test/test_codeccallbacks.py
+3
-3
Lib/test/test_codecmaps_jp.py
Lib/test/test_codecmaps_jp.py
+1
-1
Lib/test/test_descr.py
Lib/test/test_descr.py
+1
-1
Lib/test/test_multibytecodec.py
Lib/test/test_multibytecodec.py
+2
-2
Lib/test/test_multibytecodec_support.py
Lib/test/test_multibytecodec_support.py
+3
-3
Lib/test/test_normalization.py
Lib/test/test_normalization.py
+2
-2
Lib/test/test_ucn.py
Lib/test/test_ucn.py
+1
-1
Lib/test/test_unicode.py
Lib/test/test_unicode.py
+5
-5
Lib/test/test_unicodedata.py
Lib/test/test_unicodedata.py
+4
-4
Lib/urllib.py
Lib/urllib.py
+1
-1
Objects/stringobject.c
Objects/stringobject.c
+1
-1
Objects/unicodeobject.c
Objects/unicodeobject.c
+1
-1
Python/bltinmodule.c
Python/bltinmodule.c
+3
-24
No files found.
Lib/HTMLParser.py
View file @
84fc66dd
...
@@ -370,7 +370,7 @@ class HTMLParser(markupbase.ParserBase):
...
@@ -370,7 +370,7 @@ class HTMLParser(markupbase.ParserBase):
c
=
int
(
s
[
1
:],
16
)
c
=
int
(
s
[
1
:],
16
)
else
:
else
:
c
=
int
(
s
)
c
=
int
(
s
)
return
uni
chr
(
c
)
return
chr
(
c
)
else
:
else
:
# Cannot use name2codepoint directly, because HTMLParser supports apos,
# Cannot use name2codepoint directly, because HTMLParser supports apos,
# which is not part of HTML 4
# which is not part of HTML 4
...
@@ -378,7 +378,7 @@ class HTMLParser(markupbase.ParserBase):
...
@@ -378,7 +378,7 @@ class HTMLParser(markupbase.ParserBase):
if
HTMLParser
.
entitydefs
is
None
:
if
HTMLParser
.
entitydefs
is
None
:
entitydefs
=
HTMLParser
.
entitydefs
=
{
'apos'
:
"'"
}
entitydefs
=
HTMLParser
.
entitydefs
=
{
'apos'
:
"'"
}
for
k
,
v
in
htmlentitydefs
.
name2codepoint
.
items
():
for
k
,
v
in
htmlentitydefs
.
name2codepoint
.
items
():
entitydefs
[
k
]
=
uni
chr
(
v
)
entitydefs
[
k
]
=
chr
(
v
)
try
:
try
:
return
self
.
entitydefs
[
s
]
return
self
.
entitydefs
[
s
]
except
KeyError
:
except
KeyError
:
...
...
Lib/encodings/punycode.py
View file @
84fc66dd
...
@@ -176,7 +176,7 @@ def insertion_sort(base, extended, errors):
...
@@ -176,7 +176,7 @@ def insertion_sort(base, extended, errors):
raise
UnicodeError
,
(
"Invalid character U+%x"
%
char
)
raise
UnicodeError
,
(
"Invalid character U+%x"
%
char
)
char
=
ord
(
'?'
)
char
=
ord
(
'?'
)
pos
=
pos
%
(
len
(
base
)
+
1
)
pos
=
pos
%
(
len
(
base
)
+
1
)
base
=
base
[:
pos
]
+
uni
chr
(
char
)
+
base
[
pos
:]
base
=
base
[:
pos
]
+
chr
(
char
)
+
base
[
pos
:]
bias
=
adapt
(
delta
,
(
extpos
==
0
),
len
(
base
))
bias
=
adapt
(
delta
,
(
extpos
==
0
),
len
(
base
))
extpos
=
newpos
extpos
=
newpos
return
base
return
base
...
...
Lib/sre_parse.py
View file @
84fc66dd
...
@@ -712,7 +712,7 @@ def parse_template(source, pattern):
...
@@ -712,7 +712,7 @@ def parse_template(source, pattern):
if
type
(
sep
)
is
type
(
""
):
if
type
(
sep
)
is
type
(
""
):
makechar
=
chr
makechar
=
chr
else
:
else
:
makechar
=
uni
chr
makechar
=
chr
while
1
:
while
1
:
this
=
sget
()
this
=
sget
()
if
this
is
None
:
if
this
is
None
:
...
...
Lib/test/test_builtin.py
View file @
84fc66dd
...
@@ -90,7 +90,7 @@ if have_unicode:
...
@@ -90,7 +90,7 @@ if have_unicode:
(
str
(
''
),
ValueError
),
(
str
(
''
),
ValueError
),
(
str
(
' '
),
ValueError
),
(
str
(
' '
),
ValueError
),
(
str
(
'
\
t
\
t
'
),
ValueError
),
(
str
(
'
\
t
\
t
'
),
ValueError
),
(
uni
chr
(
0x200
),
ValueError
),
(
chr
(
0x200
),
ValueError
),
]
]
class
TestFailingBool
:
class
TestFailingBool
:
...
@@ -221,7 +221,7 @@ class BuiltinTest(unittest.TestCase):
...
@@ -221,7 +221,7 @@ class BuiltinTest(unittest.TestCase):
mode
=
'eval'
,
source
=
'0'
,
filename
=
'tmp'
)
mode
=
'eval'
,
source
=
'0'
,
filename
=
'tmp'
)
if
have_unicode
:
if
have_unicode
:
compile
(
str
(
b'print(u"
\
xc3
\
xa5
")
\
n
'
,
'utf8'
),
''
,
'exec'
)
compile
(
str
(
b'print(u"
\
xc3
\
xa5
")
\
n
'
,
'utf8'
),
''
,
'exec'
)
self
.
assertRaises
(
TypeError
,
compile
,
uni
chr
(
0
),
'f'
,
'exec'
)
self
.
assertRaises
(
TypeError
,
compile
,
chr
(
0
),
'f'
,
'exec'
)
self
.
assertRaises
(
ValueError
,
compile
,
str
(
'a = 1'
),
'f'
,
'bad'
)
self
.
assertRaises
(
ValueError
,
compile
,
str
(
'a = 1'
),
'f'
,
'bad'
)
...
@@ -557,7 +557,7 @@ class BuiltinTest(unittest.TestCase):
...
@@ -557,7 +557,7 @@ class BuiltinTest(unittest.TestCase):
class
shiftunicode
(
str
):
class
shiftunicode
(
str
):
def
__getitem__
(
self
,
index
):
def
__getitem__
(
self
,
index
):
return
uni
chr
(
ord
(
str
.
__getitem__
(
self
,
index
))
+
1
)
return
chr
(
ord
(
str
.
__getitem__
(
self
,
index
))
+
1
)
self
.
assertEqual
(
self
.
assertEqual
(
filter
(
lambda
x
:
x
>=
str
(
"3"
),
shiftunicode
(
"1234"
)),
filter
(
lambda
x
:
x
>=
str
(
"3"
),
shiftunicode
(
"1234"
)),
str
(
"345"
)
str
(
"345"
)
...
@@ -676,7 +676,7 @@ class BuiltinTest(unittest.TestCase):
...
@@ -676,7 +676,7 @@ class BuiltinTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
getattr
,
sys
,
1
,
"foo"
)
self
.
assertRaises
(
TypeError
,
getattr
,
sys
,
1
,
"foo"
)
self
.
assertRaises
(
TypeError
,
getattr
)
self
.
assertRaises
(
TypeError
,
getattr
)
if
have_unicode
:
if
have_unicode
:
self
.
assertRaises
(
UnicodeError
,
getattr
,
sys
,
uni
chr
(
sys
.
maxunicode
))
self
.
assertRaises
(
UnicodeError
,
getattr
,
sys
,
chr
(
sys
.
maxunicode
))
def
test_hasattr
(
self
):
def
test_hasattr
(
self
):
import
sys
import
sys
...
@@ -684,7 +684,7 @@ class BuiltinTest(unittest.TestCase):
...
@@ -684,7 +684,7 @@ class BuiltinTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
hasattr
,
sys
,
1
)
self
.
assertRaises
(
TypeError
,
hasattr
,
sys
,
1
)
self
.
assertRaises
(
TypeError
,
hasattr
)
self
.
assertRaises
(
TypeError
,
hasattr
)
if
have_unicode
:
if
have_unicode
:
self
.
assertRaises
(
UnicodeError
,
hasattr
,
sys
,
uni
chr
(
sys
.
maxunicode
))
self
.
assertRaises
(
UnicodeError
,
hasattr
,
sys
,
chr
(
sys
.
maxunicode
))
def
test_hash
(
self
):
def
test_hash
(
self
):
hash
(
None
)
hash
(
None
)
...
@@ -789,7 +789,7 @@ class BuiltinTest(unittest.TestCase):
...
@@ -789,7 +789,7 @@ class BuiltinTest(unittest.TestCase):
self
.
assert_
(
isinstance
(
x
,
int
))
self
.
assert_
(
isinstance
(
x
,
int
))
if
have_unicode
:
if
have_unicode
:
x
=
int
(
uni
chr
(
0x661
)
*
600
)
x
=
int
(
chr
(
0x661
)
*
600
)
self
.
assert_
(
isinstance
(
x
,
int
))
self
.
assert_
(
isinstance
(
x
,
int
))
self
.
assertRaises
(
TypeError
,
int
,
1
,
12
)
self
.
assertRaises
(
TypeError
,
int
,
1
,
12
)
...
@@ -1387,7 +1387,7 @@ class BuiltinTest(unittest.TestCase):
...
@@ -1387,7 +1387,7 @@ class BuiltinTest(unittest.TestCase):
self
.
assertEqual
(
ord
(
'A'
),
65
)
self
.
assertEqual
(
ord
(
'A'
),
65
)
self
.
assertEqual
(
ord
(
'a'
),
97
)
self
.
assertEqual
(
ord
(
'a'
),
97
)
if
have_unicode
:
if
have_unicode
:
self
.
assertEqual
(
ord
(
uni
chr
(
sys
.
maxunicode
)),
sys
.
maxunicode
)
self
.
assertEqual
(
ord
(
chr
(
sys
.
maxunicode
)),
sys
.
maxunicode
)
self
.
assertRaises
(
TypeError
,
ord
,
42
)
self
.
assertRaises
(
TypeError
,
ord
,
42
)
if
have_unicode
:
if
have_unicode
:
self
.
assertRaises
(
TypeError
,
ord
,
str
(
"12"
))
self
.
assertRaises
(
TypeError
,
ord
,
str
(
"12"
))
...
@@ -1668,15 +1668,15 @@ class BuiltinTest(unittest.TestCase):
...
@@ -1668,15 +1668,15 @@ class BuiltinTest(unittest.TestCase):
def
test_unichr
(
self
):
def
test_unichr
(
self
):
if
have_unicode
:
if
have_unicode
:
self
.
assertEqual
(
uni
chr
(
32
),
str
(
' '
))
self
.
assertEqual
(
chr
(
32
),
str
(
' '
))
self
.
assertEqual
(
uni
chr
(
65
),
str
(
'A'
))
self
.
assertEqual
(
chr
(
65
),
str
(
'A'
))
self
.
assertEqual
(
uni
chr
(
97
),
str
(
'a'
))
self
.
assertEqual
(
chr
(
97
),
str
(
'a'
))
self
.
assertEqual
(
self
.
assertEqual
(
uni
chr
(
sys
.
maxunicode
),
chr
(
sys
.
maxunicode
),
str
((
'
\
\
U%08x'
%
(
sys
.
maxunicode
)).
encode
(
"ascii"
),
'unicode-escape'
)
str
((
'
\
\
U%08x'
%
(
sys
.
maxunicode
)).
encode
(
"ascii"
),
'unicode-escape'
)
)
)
self
.
assertRaises
(
ValueError
,
uni
chr
,
sys
.
maxunicode
+
1
)
self
.
assertRaises
(
ValueError
,
chr
,
sys
.
maxunicode
+
1
)
self
.
assertRaises
(
TypeError
,
uni
chr
)
self
.
assertRaises
(
TypeError
,
chr
)
# We don't want self in vars(), so these are static methods
# We don't want self in vars(), so these are static methods
...
...
Lib/test/test_codeccallbacks.py
View file @
84fc66dd
...
@@ -137,7 +137,7 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -137,7 +137,7 @@ class CodecCallbackTest(unittest.TestCase):
# base encodings.
# base encodings.
sin
=
"a
\
xac
\
u1234
\
u20ac
\
u8000
"
sin
=
"a
\
xac
\
u1234
\
u20ac
\
u8000
"
if
sys
.
maxunicode
>
0xffff
:
if
sys
.
maxunicode
>
0xffff
:
sin
+=
uni
chr
(
sys
.
maxunicode
)
sin
+=
chr
(
sys
.
maxunicode
)
sout
=
"a
\
\
xac
\
\
u1234
\
\
u20ac
\
\
u8000"
sout
=
"a
\
\
xac
\
\
u1234
\
\
u20ac
\
\
u8000"
if
sys
.
maxunicode
>
0xffff
:
if
sys
.
maxunicode
>
0xffff
:
sout
+=
"
\
\
U%08x"
%
sys
.
maxunicode
sout
+=
"
\
\
U%08x"
%
sys
.
maxunicode
...
@@ -509,7 +509,7 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -509,7 +509,7 @@ class CodecCallbackTest(unittest.TestCase):
)
)
# Use the correct exception
# Use the correct exception
cs
=
(
0
,
1
,
9
,
10
,
99
,
100
,
999
,
1000
,
9999
,
10000
,
0x3042
)
cs
=
(
0
,
1
,
9
,
10
,
99
,
100
,
999
,
1000
,
9999
,
10000
,
0x3042
)
s
=
""
.
join
(
uni
chr
(
c
)
for
c
in
cs
)
s
=
""
.
join
(
chr
(
c
)
for
c
in
cs
)
self
.
assertEquals
(
self
.
assertEquals
(
codecs
.
xmlcharrefreplace_errors
(
codecs
.
xmlcharrefreplace_errors
(
UnicodeEncodeError
(
"ascii"
,
s
,
0
,
len
(
s
),
"ouch"
)
UnicodeEncodeError
(
"ascii"
,
s
,
0
,
len
(
s
),
"ouch"
)
...
@@ -650,7 +650,7 @@ class CodecCallbackTest(unittest.TestCase):
...
@@ -650,7 +650,7 @@ class CodecCallbackTest(unittest.TestCase):
v
=
(
1
,
5
,
10
,
50
,
100
,
500
,
1000
,
5000
,
10000
,
50000
)
v
=
(
1
,
5
,
10
,
50
,
100
,
500
,
1000
,
5000
,
10000
,
50000
)
if
sys
.
maxunicode
>=
100000
:
if
sys
.
maxunicode
>=
100000
:
v
+=
(
100000
,
500000
,
1000000
)
v
+=
(
100000
,
500000
,
1000000
)
s
=
""
.
join
([
uni
chr
(
x
)
for
x
in
v
])
s
=
""
.
join
([
chr
(
x
)
for
x
in
v
])
codecs
.
register_error
(
"test.xmlcharrefreplace"
,
codecs
.
xmlcharrefreplace_errors
)
codecs
.
register_error
(
"test.xmlcharrefreplace"
,
codecs
.
xmlcharrefreplace_errors
)
for
enc
in
(
"ascii"
,
"iso-8859-15"
):
for
enc
in
(
"ascii"
,
"iso-8859-15"
):
for
err
in
(
"xmlcharrefreplace"
,
"test.xmlcharrefreplace"
):
for
err
in
(
"xmlcharrefreplace"
,
"test.xmlcharrefreplace"
):
...
...
Lib/test/test_codecmaps_jp.py
View file @
84fc66dd
...
@@ -21,7 +21,7 @@ class TestCP932Map(test_multibytecodec_support.TestBase_Mapping,
...
@@ -21,7 +21,7 @@ class TestCP932Map(test_multibytecodec_support.TestBase_Mapping,
(
'
\
xff
'
,
'
\
uf8f3
'
),
(
'
\
xff
'
,
'
\
uf8f3
'
),
]
]
for
i
in
range
(
0xa1
,
0xe0
):
for
i
in
range
(
0xa1
,
0xe0
):
supmaps
.
append
((
chr
(
i
),
uni
chr
(
i
+
0xfec0
)))
supmaps
.
append
((
chr
(
i
),
chr
(
i
+
0xfec0
)))
class
TestEUCJPCOMPATMap
(
test_multibytecodec_support
.
TestBase_Mapping
,
class
TestEUCJPCOMPATMap
(
test_multibytecodec_support
.
TestBase_Mapping
,
...
...
Lib/test/test_descr.py
View file @
84fc66dd
...
@@ -1122,7 +1122,7 @@ def slots():
...
@@ -1122,7 +1122,7 @@ def slots():
# this used to leak references
# this used to leak references
try
:
try
:
class
C
(
object
):
class
C
(
object
):
__slots__
=
[
uni
chr
(
128
)]
__slots__
=
[
chr
(
128
)]
except
(
TypeError
,
UnicodeEncodeError
):
except
(
TypeError
,
UnicodeEncodeError
):
pass
pass
else
:
else
:
...
...
Lib/test/test_multibytecodec.py
View file @
84fc66dd
...
@@ -210,9 +210,9 @@ class Test_ISO2022(unittest.TestCase):
...
@@ -210,9 +210,9 @@ class Test_ISO2022(unittest.TestCase):
def
test_bug1572832
(
self
):
def
test_bug1572832
(
self
):
if
sys
.
maxunicode
>=
0x10000
:
if
sys
.
maxunicode
>=
0x10000
:
myunichr
=
uni
chr
myunichr
=
chr
else
:
else
:
myunichr
=
lambda
x
:
unichr
(
0xD7C0
+
(
x
>>
10
))
+
uni
chr
(
0xDC00
+
(
x
&
0x3FF
))
myunichr
=
lambda
x
:
chr
(
0xD7C0
+
(
x
>>
10
))
+
chr
(
0xDC00
+
(
x
&
0x3FF
))
for
x
in
xrange
(
0x10000
,
0x110000
):
for
x
in
xrange
(
0x10000
,
0x110000
):
# Any ISO 2022 codec will cause the segfault
# Any ISO 2022 codec will cause the segfault
...
...
Lib/test/test_multibytecodec_support.py
View file @
84fc66dd
...
@@ -244,8 +244,8 @@ class TestBase:
...
@@ -244,8 +244,8 @@ class TestBase:
self
.
assertEqual
(
ostream
.
getvalue
(),
self
.
tstring
[
0
])
self
.
assertEqual
(
ostream
.
getvalue
(),
self
.
tstring
[
0
])
if
len
(
'
\
U00012345
'
)
==
2
:
# ucs2 build
if
len
(
'
\
U00012345
'
)
==
2
:
# ucs2 build
_unichr
=
uni
chr
_unichr
=
chr
def
uni
chr
(
v
):
def
chr
(
v
):
if
v
>=
0x10000
:
if
v
>=
0x10000
:
return
_unichr
(
0xd800
+
((
v
-
0x10000
)
>>
10
))
+
\
return
_unichr
(
0xd800
+
((
v
-
0x10000
)
>>
10
))
+
\
_unichr
(
0xdc00
+
((
v
-
0x10000
)
&
0x3ff
))
_unichr
(
0xdc00
+
((
v
-
0x10000
)
&
0x3ff
))
...
@@ -272,7 +272,7 @@ class TestBase_Mapping(unittest.TestCase):
...
@@ -272,7 +272,7 @@ class TestBase_Mapping(unittest.TestCase):
return
test_support
.
open_urlresource
(
self
.
mapfileurl
)
return
test_support
.
open_urlresource
(
self
.
mapfileurl
)
def
test_mapping_file
(
self
):
def
test_mapping_file
(
self
):
unichrs
=
lambda
s
:
''
.
join
(
map
(
uni
chr
,
map
(
eval
,
s
.
split
(
'+'
))))
unichrs
=
lambda
s
:
''
.
join
(
map
(
chr
,
map
(
eval
,
s
.
split
(
'+'
))))
urt_wa
=
{}
urt_wa
=
{}
for
line
in
self
.
open_mapping_file
():
for
line
in
self
.
open_mapping_file
():
...
...
Lib/test/test_normalization.py
View file @
84fc66dd
...
@@ -28,7 +28,7 @@ def unistr(data):
...
@@ -28,7 +28,7 @@ def unistr(data):
for
x
in
data
:
for
x
in
data
:
if
x
>
sys
.
maxunicode
:
if
x
>
sys
.
maxunicode
:
raise
RangeError
raise
RangeError
return
""
.
join
([
uni
chr
(
x
)
for
x
in
data
])
return
""
.
join
([
chr
(
x
)
for
x
in
data
])
class
NormalizationTest
(
unittest
.
TestCase
):
class
NormalizationTest
(
unittest
.
TestCase
):
def
test_main
(
self
):
def
test_main
(
self
):
...
@@ -77,7 +77,7 @@ class NormalizationTest(unittest.TestCase):
...
@@ -77,7 +77,7 @@ class NormalizationTest(unittest.TestCase):
# Perform tests for all other data
# Perform tests for all other data
for
c
in
range
(
sys
.
maxunicode
+
1
):
for
c
in
range
(
sys
.
maxunicode
+
1
):
X
=
uni
chr
(
c
)
X
=
chr
(
c
)
if
X
in
part1_data
:
if
X
in
part1_data
:
continue
continue
self
.
failUnless
(
X
==
NFC
(
X
)
==
NFD
(
X
)
==
NFKC
(
X
)
==
NFKD
(
X
),
c
)
self
.
failUnless
(
X
==
NFC
(
X
)
==
NFD
(
X
)
==
NFKC
(
X
)
==
NFKD
(
X
),
c
)
...
...
Lib/test/test_ucn.py
View file @
84fc66dd
...
@@ -96,7 +96,7 @@ class UnicodeNamesTest(unittest.TestCase):
...
@@ -96,7 +96,7 @@ class UnicodeNamesTest(unittest.TestCase):
import
unicodedata
import
unicodedata
count
=
0
count
=
0
for
code
in
xrange
(
0x10000
):
for
code
in
xrange
(
0x10000
):
char
=
uni
chr
(
code
)
char
=
chr
(
code
)
name
=
unicodedata
.
name
(
char
,
None
)
name
=
unicodedata
.
name
(
char
,
None
)
if
name
is
not
None
:
if
name
is
not
None
:
self
.
assertEqual
(
unicodedata
.
lookup
(
name
),
char
)
self
.
assertEqual
(
unicodedata
.
lookup
(
name
),
char
)
...
...
Lib/test/test_unicode.py
View file @
84fc66dd
...
@@ -90,7 +90,7 @@ class UnicodeTest(
...
@@ -90,7 +90,7 @@ class UnicodeTest(
"
\
\
xe2
\
\
xe3
\
\
xe4
\
\
xe5
\
\
xe6
\
\
xe7
\
\
xe8
\
\
xe9
\
\
xea
\
\
xeb
\
\
xec
\
\
xed
\
\
xee
\
\
xef"
"
\
\
xe2
\
\
xe3
\
\
xe4
\
\
xe5
\
\
xe6
\
\
xe7
\
\
xe8
\
\
xe9
\
\
xea
\
\
xeb
\
\
xec
\
\
xed
\
\
xee
\
\
xef"
"
\
\
xf0
\
\
xf1
\
\
xf2
\
\
xf3
\
\
xf4
\
\
xf5
\
\
xf6
\
\
xf7
\
\
xf8
\
\
xf9
\
\
xfa
\
\
xfb
\
\
xfc
\
\
xfd"
"
\
\
xf0
\
\
xf1
\
\
xf2
\
\
xf3
\
\
xf4
\
\
xf5
\
\
xf6
\
\
xf7
\
\
xf8
\
\
xf9
\
\
xfa
\
\
xfb
\
\
xfc
\
\
xfd"
"
\
\
xfe
\
\
xff'"
)
"
\
\
xfe
\
\
xff'"
)
testrepr
=
repr
(
''
.
join
(
map
(
uni
chr
,
xrange
(
256
))))
testrepr
=
repr
(
''
.
join
(
map
(
chr
,
xrange
(
256
))))
self
.
assertEqual
(
testrepr
,
latin1repr
)
self
.
assertEqual
(
testrepr
,
latin1repr
)
# Test repr works on wide unicode escapes without overflow.
# Test repr works on wide unicode escapes without overflow.
self
.
assertEqual
(
repr
(
"
\
U00010000
"
*
39
+
"
\
uffff
"
*
4096
),
self
.
assertEqual
(
repr
(
"
\
U00010000
"
*
39
+
"
\
uffff
"
*
4096
),
...
@@ -632,7 +632,7 @@ class UnicodeTest(
...
@@ -632,7 +632,7 @@ class UnicodeTest(
# Roundtrip safety for BMP (just the first 1024 chars)
# Roundtrip safety for BMP (just the first 1024 chars)
for c in xrange(1024):
for c in xrange(1024):
u =
uni
chr(c)
u = chr(c)
for encoding in ('
utf
-
7
', '
utf
-
8
', '
utf
-
16
', '
utf
-
16
-
le
',
for encoding in ('
utf
-
7
', '
utf
-
8
', '
utf
-
16
', '
utf
-
16
-
le
',
'
utf
-
16
-
be
', '
raw_unicode_escape
',
'
utf
-
16
-
be
', '
raw_unicode_escape
',
'
unicode_escape
', '
unicode_internal
'):
'
unicode_escape
', '
unicode_internal
'):
...
@@ -640,13 +640,13 @@ class UnicodeTest(
...
@@ -640,13 +640,13 @@ class UnicodeTest(
# Roundtrip safety for BMP (just the first 256 chars)
# Roundtrip safety for BMP (just the first 256 chars)
for c in xrange(256):
for c in xrange(256):
u =
uni
chr(c)
u = chr(c)
for encoding in ('
latin
-
1
',):
for encoding in ('
latin
-
1
',):
self.assertEqual(str(u.encode(encoding),encoding), u)
self.assertEqual(str(u.encode(encoding),encoding), u)
# Roundtrip safety for BMP (just the first 128 chars)
# Roundtrip safety for BMP (just the first 128 chars)
for c in xrange(128):
for c in xrange(128):
u =
uni
chr(c)
u = chr(c)
for encoding in ('
ascii
',):
for encoding in ('
ascii
',):
self.assertEqual(str(u.encode(encoding),encoding), u)
self.assertEqual(str(u.encode(encoding),encoding), u)
...
@@ -661,7 +661,7 @@ class UnicodeTest(
...
@@ -661,7 +661,7 @@ class UnicodeTest(
# This excludes surrogates: in the full range, there would be
# This excludes surrogates: in the full range, there would be
# a surrogate pair (
\
udbff
\
udc00
), which gets converted back
# a surrogate pair (
\
udbff
\
udc00
), which gets converted back
# to a non-BMP character (
\
U0010fc00
)
# to a non-BMP character (
\
U0010fc00
)
u = ''.join(map(
uni
chr, range(0,0xd800)+range(0xe000,0x10000)))
u = ''.join(map(chr, range(0,0xd800)+range(0xe000,0x10000)))
for encoding in ('
utf
-
8
',):
for encoding in ('
utf
-
8
',):
self.assertEqual(str(u.encode(encoding),encoding), u)
self.assertEqual(str(u.encode(encoding),encoding), u)
...
...
Lib/test/test_unicodedata.py
View file @
84fc66dd
...
@@ -21,7 +21,7 @@ class UnicodeMethodsTest(unittest.TestCase):
...
@@ -21,7 +21,7 @@ class UnicodeMethodsTest(unittest.TestCase):
def
test_method_checksum
(
self
):
def
test_method_checksum
(
self
):
h
=
hashlib
.
sha1
()
h
=
hashlib
.
sha1
()
for
i
in
range
(
65536
):
for
i
in
range
(
65536
):
char
=
uni
chr
(
i
)
char
=
chr
(
i
)
data
=
[
data
=
[
# Predicates (single char)
# Predicates (single char)
"01"
[
char
.
isalnum
()],
"01"
[
char
.
isalnum
()],
...
@@ -82,7 +82,7 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
...
@@ -82,7 +82,7 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
h
=
hashlib
.
sha1
()
h
=
hashlib
.
sha1
()
for
i
in
range
(
0x10000
):
for
i
in
range
(
0x10000
):
char
=
uni
chr
(
i
)
char
=
chr
(
i
)
data
=
[
data
=
[
# Properties
# Properties
str
(
self
.
db
.
digit
(
char
,
-
1
)),
str
(
self
.
db
.
digit
(
char
,
-
1
)),
...
@@ -194,7 +194,7 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
...
@@ -194,7 +194,7 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
# its numeric value should be the same.
# its numeric value should be the same.
count
=
0
count
=
0
for
i
in
xrange
(
0x10000
):
for
i
in
xrange
(
0x10000
):
c
=
uni
chr
(
i
)
c
=
chr
(
i
)
dec
=
self
.
db
.
decimal
(
c
,
-
1
)
dec
=
self
.
db
.
decimal
(
c
,
-
1
)
if
dec
!=
-
1
:
if
dec
!=
-
1
:
self
.
assertEqual
(
dec
,
self
.
db
.
numeric
(
c
))
self
.
assertEqual
(
dec
,
self
.
db
.
numeric
(
c
))
...
@@ -207,7 +207,7 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
...
@@ -207,7 +207,7 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
# its numeric value should be the same.
# its numeric value should be the same.
count
=
0
count
=
0
for
i
in
xrange
(
0x10000
):
for
i
in
xrange
(
0x10000
):
c
=
uni
chr
(
i
)
c
=
chr
(
i
)
dec
=
self
.
db
.
digit
(
c
,
-
1
)
dec
=
self
.
db
.
digit
(
c
,
-
1
)
if
dec
!=
-
1
:
if
dec
!=
-
1
:
self
.
assertEqual
(
dec
,
self
.
db
.
numeric
(
c
))
self
.
assertEqual
(
dec
,
self
.
db
.
numeric
(
c
))
...
...
Lib/urllib.py
View file @
84fc66dd
...
@@ -1158,7 +1158,7 @@ def unquote(s):
...
@@ -1158,7 +1158,7 @@ def unquote(s):
except
KeyError
:
except
KeyError
:
res
[
i
]
=
'%'
+
item
res
[
i
]
=
'%'
+
item
except
UnicodeDecodeError
:
except
UnicodeDecodeError
:
res
[
i
]
=
uni
chr
(
int
(
item
[:
2
],
16
))
+
item
[
2
:]
res
[
i
]
=
chr
(
int
(
item
[:
2
],
16
))
+
item
[
2
:]
return
""
.
join
(
res
)
return
""
.
join
(
res
)
def
unquote_plus
(
s
):
def
unquote_plus
(
s
):
...
...
Objects/stringobject.c
View file @
84fc66dd
...
@@ -4009,7 +4009,7 @@ static PyObject *str_iter(PyObject *seq);
...
@@ -4009,7 +4009,7 @@ static PyObject *str_iter(PyObject *seq);
PyTypeObject
PyString_Type
=
{
PyTypeObject
PyString_Type
=
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
PyObject_HEAD_INIT
(
&
PyType_Type
)
0
,
0
,
"str"
,
"str
8
"
,
sizeof
(
PyStringObject
),
sizeof
(
PyStringObject
),
sizeof
(
char
),
sizeof
(
char
),
string_dealloc
,
/* tp_dealloc */
string_dealloc
,
/* tp_dealloc */
...
...
Objects/unicodeobject.c
View file @
84fc66dd
...
@@ -7954,7 +7954,7 @@ static PyObject *unicode_iter(PyObject *seq);
...
@@ -7954,7 +7954,7 @@ static PyObject *unicode_iter(PyObject *seq);
PyTypeObject
PyUnicode_Type
=
{
PyTypeObject
PyUnicode_Type
=
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
PyObject_HEAD_INIT
(
&
PyType_Type
)
0
,
/* ob_size */
0
,
/* ob_size */
"
unicode
"
,
/* tp_name */
"
str
"
,
/* tp_name */
sizeof
(
PyUnicodeObject
),
/* tp_size */
sizeof
(
PyUnicodeObject
),
/* tp_size */
0
,
/* tp_itemsize */
0
,
/* tp_itemsize */
/* Slots */
/* Slots */
...
...
Python/bltinmodule.c
View file @
84fc66dd
...
@@ -380,28 +380,6 @@ PyDoc_STRVAR(filter_doc,
...
@@ -380,28 +380,6 @@ PyDoc_STRVAR(filter_doc,
"function is None, return the items that are true. If sequence is a tuple
\n
"
"function is None, return the items that are true. If sequence is a tuple
\n
"
"or string, return the same type, else return a list."
);
"or string, return the same type, else return a list."
);
static
PyObject
*
builtin_chr
(
PyObject
*
self
,
PyObject
*
args
)
{
long
x
;
char
s
[
1
];
if
(
!
PyArg_ParseTuple
(
args
,
"l:chr"
,
&
x
))
return
NULL
;
if
(
x
<
0
||
x
>=
256
)
{
PyErr_SetString
(
PyExc_ValueError
,
"chr() arg not in range(256)"
);
return
NULL
;
}
s
[
0
]
=
(
char
)
x
;
return
PyString_FromStringAndSize
(
s
,
1
);
}
PyDoc_STRVAR
(
chr_doc
,
"chr(i) -> character
\n
\
\n
\
Return a string of one character with ordinal i; 0 <= i < 256."
);
#ifdef Py_USING_UNICODE
#ifdef Py_USING_UNICODE
static
PyObject
*
static
PyObject
*
...
@@ -416,7 +394,7 @@ builtin_unichr(PyObject *self, PyObject *args)
...
@@ -416,7 +394,7 @@ builtin_unichr(PyObject *self, PyObject *args)
}
}
PyDoc_STRVAR
(
unichr_doc
,
PyDoc_STRVAR
(
unichr_doc
,
"
uni
chr(i) -> Unicode character
\n
\
"chr(i) -> Unicode character
\n
\
\n
\
\n
\
Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff."
);
Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff."
);
#endif
#endif
...
@@ -2270,7 +2248,7 @@ static PyMethodDef builtin_methods[] = {
...
@@ -2270,7 +2248,7 @@ static PyMethodDef builtin_methods[] = {
{
"all"
,
builtin_all
,
METH_O
,
all_doc
},
{
"all"
,
builtin_all
,
METH_O
,
all_doc
},
{
"any"
,
builtin_any
,
METH_O
,
any_doc
},
{
"any"
,
builtin_any
,
METH_O
,
any_doc
},
{
"callable"
,
builtin_callable
,
METH_O
,
callable_doc
},
{
"callable"
,
builtin_callable
,
METH_O
,
callable_doc
},
{
"chr"
,
builtin_unichr
,
METH_VARARGS
,
chr_doc
},
{
"chr"
,
builtin_unichr
,
METH_VARARGS
,
uni
chr_doc
},
{
"cmp"
,
builtin_cmp
,
METH_VARARGS
,
cmp_doc
},
{
"cmp"
,
builtin_cmp
,
METH_VARARGS
,
cmp_doc
},
{
"compile"
,
(
PyCFunction
)
builtin_compile
,
METH_VARARGS
|
METH_KEYWORDS
,
compile_doc
},
{
"compile"
,
(
PyCFunction
)
builtin_compile
,
METH_VARARGS
|
METH_KEYWORDS
,
compile_doc
},
{
"delattr"
,
builtin_delattr
,
METH_VARARGS
,
delattr_doc
},
{
"delattr"
,
builtin_delattr
,
METH_VARARGS
,
delattr_doc
},
...
@@ -2376,6 +2354,7 @@ _PyBuiltin_Init(void)
...
@@ -2376,6 +2354,7 @@ _PyBuiltin_Init(void)
SETBUILTIN
(
"slice"
,
&
PySlice_Type
);
SETBUILTIN
(
"slice"
,
&
PySlice_Type
);
SETBUILTIN
(
"staticmethod"
,
&
PyStaticMethod_Type
);
SETBUILTIN
(
"staticmethod"
,
&
PyStaticMethod_Type
);
SETBUILTIN
(
"str"
,
&
PyUnicode_Type
);
SETBUILTIN
(
"str"
,
&
PyUnicode_Type
);
SETBUILTIN
(
"str8"
,
&
PyString_Type
);
SETBUILTIN
(
"super"
,
&
PySuper_Type
);
SETBUILTIN
(
"super"
,
&
PySuper_Type
);
SETBUILTIN
(
"tuple"
,
&
PyTuple_Type
);
SETBUILTIN
(
"tuple"
,
&
PyTuple_Type
);
SETBUILTIN
(
"type"
,
&
PyType_Type
);
SETBUILTIN
(
"type"
,
&
PyType_Type
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment