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
ba91b9fd
Commit
ba91b9fd
authored
May 19, 2004
by
Armin Rigo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Applying SF patch #949329 on behalf of Raymond Hettinger.
parent
16581c86
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
34 deletions
+34
-34
Lib/stringprep.py
Lib/stringprep.py
+8
-7
Tools/unicode/mkstringprep.py
Tools/unicode/mkstringprep.py
+26
-27
No files found.
Lib/stringprep.py
View file @
ba91b9fd
...
@@ -5,7 +5,7 @@ There are two kinds of tables: sets, for which a member test is provided,
...
@@ -5,7 +5,7 @@ There are two kinds of tables: sets, for which a member test is provided,
and mappings, for which a mapping function is provided.
and mappings, for which a mapping function is provided.
"""
"""
import
unicodedata
,
sets
import
unicodedata
assert
unicodedata
.
unidata_version
==
'3.2.0'
assert
unicodedata
.
unidata_version
==
'3.2.0'
...
@@ -16,7 +16,7 @@ def in_table_a1(code):
...
@@ -16,7 +16,7 @@ def in_table_a1(code):
return
(
c
&
0xFFFF
)
not
in
(
0xFFFE
,
0xFFFF
)
return
(
c
&
0xFFFF
)
not
in
(
0xFFFE
,
0xFFFF
)
b1_set
=
set
s
.
Set
([
173
,
847
,
6150
,
6155
,
6156
,
6157
,
8203
,
8204
,
8205
,
8288
,
65279
]
+
range
(
65024
,
65040
))
b1_set
=
set
([
173
,
847
,
6150
,
6155
,
6156
,
6157
,
8203
,
8204
,
8205
,
8288
,
65279
]
+
range
(
65024
,
65040
))
def
in_table_b1
(
code
):
def
in_table_b1
(
code
):
return
ord
(
code
)
in
b1_set
return
ord
(
code
)
in
b1_set
...
@@ -217,7 +217,7 @@ def in_table_c11_c12(code):
...
@@ -217,7 +217,7 @@ def in_table_c11_c12(code):
def
in_table_c21
(
code
):
def
in_table_c21
(
code
):
return
ord
(
code
)
<
128
and
unicodedata
.
category
(
code
)
==
"Cc"
return
ord
(
code
)
<
128
and
unicodedata
.
category
(
code
)
==
"Cc"
c22_specials
=
set
s
.
Set
([
1757
,
1807
,
6158
,
8204
,
8205
,
8232
,
8233
,
65279
]
+
range
(
8288
,
8292
)
+
range
(
8298
,
8304
)
+
range
(
65529
,
65533
)
+
range
(
119155
,
119163
))
c22_specials
=
set
([
1757
,
1807
,
6158
,
8204
,
8205
,
8232
,
8233
,
65279
]
+
range
(
8288
,
8292
)
+
range
(
8298
,
8304
)
+
range
(
65529
,
65533
)
+
range
(
119155
,
119163
))
def
in_table_c22
(
code
):
def
in_table_c22
(
code
):
c
=
ord
(
code
)
c
=
ord
(
code
)
if
c
<
128
:
return
False
if
c
<
128
:
return
False
...
@@ -244,22 +244,22 @@ def in_table_c5(code):
...
@@ -244,22 +244,22 @@ def in_table_c5(code):
return
unicodedata
.
category
(
code
)
==
"Cs"
return
unicodedata
.
category
(
code
)
==
"Cs"
c6_set
=
set
s
.
Set
(
range
(
65529
,
65534
))
c6_set
=
set
(
range
(
65529
,
65534
))
def
in_table_c6
(
code
):
def
in_table_c6
(
code
):
return
ord
(
code
)
in
c6_set
return
ord
(
code
)
in
c6_set
c7_set
=
set
s
.
Set
(
range
(
12272
,
12284
))
c7_set
=
set
(
range
(
12272
,
12284
))
def
in_table_c7
(
code
):
def
in_table_c7
(
code
):
return
ord
(
code
)
in
c7_set
return
ord
(
code
)
in
c7_set
c8_set
=
set
s
.
Set
([
832
,
833
,
8206
,
8207
]
+
range
(
8234
,
8239
)
+
range
(
8298
,
8304
))
c8_set
=
set
([
832
,
833
,
8206
,
8207
]
+
range
(
8234
,
8239
)
+
range
(
8298
,
8304
))
def
in_table_c8
(
code
):
def
in_table_c8
(
code
):
return
ord
(
code
)
in
c8_set
return
ord
(
code
)
in
c8_set
c9_set
=
set
s
.
Set
([
917505
]
+
range
(
917536
,
917632
))
c9_set
=
set
([
917505
]
+
range
(
917536
,
917632
))
def
in_table_c9
(
code
):
def
in_table_c9
(
code
):
return
ord
(
code
)
in
c9_set
return
ord
(
code
)
in
c9_set
...
@@ -270,3 +270,4 @@ def in_table_d1(code):
...
@@ -270,3 +270,4 @@ def in_table_d1(code):
def
in_table_d2
(
code
):
def
in_table_d2
(
code
):
return
unicodedata
.
bidirectional
(
code
)
==
"L"
return
unicodedata
.
bidirectional
(
code
)
==
"L"
Tools/unicode/mkstringprep.py
View file @
ba91b9fd
import
re
,
unicodedata
,
sys
,
sets
import
re
,
unicodedata
,
sys
from
sets
import
Set
if
sys
.
maxunicode
==
65535
:
if
sys
.
maxunicode
==
65535
:
raise
RuntimeError
,
"need UCS-4 Python"
raise
RuntimeError
,
"need UCS-4 Python"
...
@@ -40,10 +39,10 @@ def compact_set(l):
...
@@ -40,10 +39,10 @@ def compact_set(l):
single
.
append
(
prev
)
single
.
append
(
prev
)
tuple
=
" + "
.
join
([
"range(%d,%d)"
%
t
for
t
in
tuple
])
tuple
=
" + "
.
join
([
"range(%d,%d)"
%
t
for
t
in
tuple
])
if
not
single
:
if
not
single
:
return
"set
s.Set
(%s)"
%
tuple
return
"set(%s)"
%
tuple
if
not
tuple
:
if
not
tuple
:
return
"set
s.Set
(%s)"
%
repr
(
single
)
return
"set(%s)"
%
repr
(
single
)
return
"set
s.Set
(%s + %s)"
%
(
repr
(
single
),
tuple
)
return
"set(%s + %s)"
%
(
repr
(
single
),
tuple
)
############## Read the tables in the RFC #######################
############## Read the tables in the RFC #######################
...
@@ -114,7 +113,7 @@ There are two kinds of tables: sets, for which a member test is provided,
...
@@ -114,7 +113,7 @@ There are two kinds of tables: sets, for which a member test is provided,
and mappings, for which a mapping function is provided.
and mappings, for which a mapping function is provided.
\
"
\
"
\
"
\
"
\
"
\
"
import unicodedata
, sets
import unicodedata
"""
"""
print
"assert unicodedata.unidata_version == %s"
%
repr
(
unicodedata
.
unidata_version
)
print
"assert unicodedata.unidata_version == %s"
%
repr
(
unicodedata
.
unidata_version
)
...
@@ -124,14 +123,14 @@ print "assert unicodedata.unidata_version == %s" % repr(unicodedata.unidata_vers
...
@@ -124,14 +123,14 @@ print "assert unicodedata.unidata_version == %s" % repr(unicodedata.unidata_vers
name
,
table
=
tables
[
0
]
name
,
table
=
tables
[
0
]
del
tables
[
0
]
del
tables
[
0
]
assert
name
==
"A.1"
assert
name
==
"A.1"
table
=
S
et
(
table
.
keys
())
table
=
s
et
(
table
.
keys
())
Cn
=
S
et
(
gen_category
([
"Cn"
]))
Cn
=
s
et
(
gen_category
([
"Cn"
]))
# FDD0..FDEF are process internal codes
# FDD0..FDEF are process internal codes
Cn
-=
S
et
(
range
(
0xFDD0
,
0xFDF0
))
Cn
-=
s
et
(
range
(
0xFDD0
,
0xFDF0
))
# not a character
# not a character
Cn
-=
S
et
(
range
(
0xFFFE
,
0x110000
,
0x10000
))
Cn
-=
s
et
(
range
(
0xFFFE
,
0x110000
,
0x10000
))
Cn
-=
S
et
(
range
(
0xFFFF
,
0x110000
,
0x10000
))
Cn
-=
s
et
(
range
(
0xFFFF
,
0x110000
,
0x10000
))
# assert table == Cn
# assert table == Cn
...
@@ -251,8 +250,8 @@ name, table = tables[0]
...
@@ -251,8 +250,8 @@ name, table = tables[0]
del
tables
[
0
]
del
tables
[
0
]
assert
name
==
"C.1.2"
assert
name
==
"C.1.2"
# table =
S
et(table.keys())
# table =
s
et(table.keys())
# Zs =
Set(gen_category(["Zs"])) - S
et([0x20])
# Zs =
set(gen_category(["Zs"])) - s
et([0x20])
# assert Zs == table
# assert Zs == table
print
"""
print
"""
...
@@ -268,9 +267,9 @@ name, table_c21 = tables[0]
...
@@ -268,9 +267,9 @@ name, table_c21 = tables[0]
del
tables
[
0
]
del
tables
[
0
]
assert
name
==
"C.2.1"
assert
name
==
"C.2.1"
Cc
=
S
et
(
gen_category
([
"Cc"
]))
Cc
=
s
et
(
gen_category
([
"Cc"
]))
Cc_ascii
=
Cc
&
S
et
(
range
(
128
))
Cc_ascii
=
Cc
&
s
et
(
range
(
128
))
table_c21
=
S
et
(
table_c21
.
keys
())
table_c21
=
s
et
(
table_c21
.
keys
())
assert
Cc_ascii
==
table_c21
assert
Cc_ascii
==
table_c21
print
"""
print
"""
...
@@ -285,7 +284,7 @@ del tables[0]
...
@@ -285,7 +284,7 @@ del tables[0]
assert
name
==
"C.2.2"
assert
name
==
"C.2.2"
Cc_nonascii
=
Cc
-
Cc_ascii
Cc_nonascii
=
Cc
-
Cc_ascii
table_c22
=
S
et
(
table_c22
.
keys
())
table_c22
=
s
et
(
table_c22
.
keys
())
assert
len
(
Cc_nonascii
-
table_c22
)
==
0
assert
len
(
Cc_nonascii
-
table_c22
)
==
0
specials
=
list
(
table_c22
-
Cc_nonascii
)
specials
=
list
(
table_c22
-
Cc_nonascii
)
...
@@ -308,8 +307,8 @@ name, table = tables[0]
...
@@ -308,8 +307,8 @@ name, table = tables[0]
del
tables
[
0
]
del
tables
[
0
]
assert
name
==
"C.3"
assert
name
==
"C.3"
Co
=
S
et
(
gen_category
([
"Co"
]))
Co
=
s
et
(
gen_category
([
"Co"
]))
assert
S
et
(
table
.
keys
())
==
Co
assert
s
et
(
table
.
keys
())
==
Co
print
"""
print
"""
def in_table_c3(code):
def in_table_c3(code):
...
@@ -322,10 +321,10 @@ name, table = tables[0]
...
@@ -322,10 +321,10 @@ name, table = tables[0]
del
tables
[
0
]
del
tables
[
0
]
assert
name
==
"C.4"
assert
name
==
"C.4"
nonchar
=
S
et
(
range
(
0xFDD0
,
0xFDF0
)
+
nonchar
=
s
et
(
range
(
0xFDD0
,
0xFDF0
)
+
range
(
0xFFFE
,
0x110000
,
0x10000
)
+
range
(
0xFFFE
,
0x110000
,
0x10000
)
+
range
(
0xFFFF
,
0x110000
,
0x10000
))
range
(
0xFFFF
,
0x110000
,
0x10000
))
table
=
S
et
(
table
.
keys
())
table
=
s
et
(
table
.
keys
())
assert
table
==
nonchar
assert
table
==
nonchar
print
"""
print
"""
...
@@ -341,8 +340,8 @@ name, table = tables[0]
...
@@ -341,8 +340,8 @@ name, table = tables[0]
del
tables
[
0
]
del
tables
[
0
]
assert
name
==
"C.5"
assert
name
==
"C.5"
Cs
=
S
et
(
gen_category
([
"Cs"
]))
Cs
=
s
et
(
gen_category
([
"Cs"
]))
assert
S
et
(
table
.
keys
())
==
Cs
assert
s
et
(
table
.
keys
())
==
Cs
print
"""
print
"""
def in_table_c5(code):
def in_table_c5(code):
...
@@ -410,8 +409,8 @@ name, table = tables[0]
...
@@ -410,8 +409,8 @@ name, table = tables[0]
del
tables
[
0
]
del
tables
[
0
]
assert
name
==
"D.1"
assert
name
==
"D.1"
RandAL
=
S
et
(
gen_bidirectional
([
"R"
,
"AL"
]))
RandAL
=
s
et
(
gen_bidirectional
([
"R"
,
"AL"
]))
assert
S
et
(
table
.
keys
())
==
RandAL
assert
s
et
(
table
.
keys
())
==
RandAL
print
"""
print
"""
def in_table_d1(code):
def in_table_d1(code):
...
@@ -423,8 +422,8 @@ name, table = tables[0]
...
@@ -423,8 +422,8 @@ name, table = tables[0]
del
tables
[
0
]
del
tables
[
0
]
assert
name
==
"D.2"
assert
name
==
"D.2"
L
=
S
et
(
gen_bidirectional
([
"L"
]))
L
=
s
et
(
gen_bidirectional
([
"L"
]))
assert
S
et
(
table
.
keys
())
==
L
assert
s
et
(
table
.
keys
())
==
L
print
"""
print
"""
def in_table_d2(code):
def in_table_d2(code):
...
...
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