Update test_codecencodings_cn from v3.14.3

This commit is contained in:
CPython Developers
2026-02-15 14:30:45 +09:00
committed by Lee Dogeon
parent cf21e2da10
commit 5c280d070d
32 changed files with 730 additions and 0 deletions

9
Lib/test/cjkencodings/big5-utf8.txt vendored Normal file
View File

@@ -0,0 +1,9 @@
如何在 Python 中使用既有的 C library?
 在資訊科技快速發展的今天, 開發及測試軟體的速度是不容忽視的
課題. 為加快開發及測試的速度, 我們便常希望能利用一些已開發好的
library, 並有一個 fast prototyping 的 programming language 可
供使用. 目前有許許多多的 library 是以 C 寫成, 而 Python 是一個
fast prototyping 的 programming language. 故我們希望能將既有的
C library 拿到 Python 的環境中測試及整合. 其中最主要也是我們所
要討論的問題就是:

9
Lib/test/cjkencodings/big5.txt vendored Normal file
View File

@@ -0,0 +1,9 @@
如何在 Python 中使用既有的 C library?
 在資訊科技快速發展的今天, 開發及測試軟體的速度是不容忽視的
課題. 為加快開發及測試的速度, 我們便常希望能利用一些已開發好的
library, 並有一個 fast prototyping 的 programming language 可
供使用. 目前有許許多多的 library 是以 C 寫成, 而 Python 是一個
fast prototyping 的 programming language. 故我們希望能將既有的
C library 拿到 Python 的環境中測試及整合. 其中最主要也是我們所
要討論的問題就是:

View File

@@ -0,0 +1,2 @@
𠄌Ě鵮罓洆
ÊÊ̄ê êê̄

2
Lib/test/cjkencodings/big5hkscs.txt vendored Normal file
View File

@@ -0,0 +1,2 @@
ˆEˆ\ŠsÚ<E280B9>Ø
ˆfˆbˆ§ ˆ§ˆ£

9
Lib/test/cjkencodings/cp949-utf8.txt vendored Normal file
View File

@@ -0,0 +1,9 @@
똠방각하 펲시콜라
㉯㉯납!! 因九月패믤릔궈 ⓡⓖ훀¿¿¿ 긍뒙 ⓔ뎨 ㉯. .
亞영ⓔ능횹 . . . . 서울뤄 뎐학乙 家훀 ! ! !ㅠ.ㅠ
흐흐흐 ㄱㄱㄱ☆ㅠ_ㅠ 어릨 탸콰긐 뎌응 칑九들乙 ㉯드긐
설릌 家훀 . . . . 굴애쉌 ⓔ궈 ⓡ릘㉱긐 因仁川女中까즼
와쒀훀 ! ! 亞영ⓔ 家능궈 ☆上관 없능궈능 亞능뒈훀 글애듴
ⓡ려듀九 싀풔숴훀 어릨 因仁川女中싁⑨들앜!! ㉯㉯납♡ ⌒⌒*

9
Lib/test/cjkencodings/cp949.txt vendored Normal file
View File

@@ -0,0 +1,9 @@
稪寞陝ビ <20>衛屬塭
阱阱陶!! 孻朐篘彐埝醩掬 佺來麗000 晤<> 供絨 阱. .
銢艙供棟<EFBFBD> . . . . 憮選瘀 粟ピ錟 坅麗 ! ! !壬.壬
⺮⺮⺮ 丑丑丑≧壬_壬 橫<> 攣攜<E694A3> 筑擬 疲朐菟錟 阱萄<E998B1>
撲郄 坅麗 . . . . 掉擁餎 供掬 佺𡺉阬<F0A1BA89> 孻嬬藿澇齌梱<E9BD8C>
諦冀麗 ! ! 銢艙供 坅棟掬 ≧葞婦 橈棟掬棟 銢棟華麗 旋擁氽
佺溥菽朐 煳ジ膜麗 橫<> 孻嬬藿澇齌𠫂剁菟脗!! 阱阱陶Ⅴ ÷÷*

View File

@@ -0,0 +1,8 @@
Python の開発は、1990 年ごろから開始されています。
開発者の Guido van Rossum は教育用のプログラミング言語「ABC」の開発に参加していましたが、ABC は実用上の目的にはあまり適していませんでした。
このため、Guido はより実用的なプログラミング言語の開発を開始し、英国 BBS 放送のコメディ番組「モンティ パイソン」のファンである Guido はこの言語を「Python」と名づけました。
このような背景から生まれた Python の言語設計は、「シンプル」で「習得が容易」という目標に重点が置かれています。
多くのスクリプト系言語ではユーザの目先の利便性を優先して色々な機能を言語要素として取り入れる場合が多いのですが、Python ではそういった小細工が追加されることはあまりありません。
言語自体の機能は最小限に押さえ、必要な機能は拡張モジュールとして追加する、というのが Python のポリシーです。
ノか゚ ト゚ トキ喝塀 𡚴𪎌 麀齁𩛰

View File

@@ -0,0 +1,8 @@
Python の開発は、1990 年ごろから開始されています。
開発者の Guido van Rossum は教育用のプログラミング言語「ABC」の開発に参加していましたが、ABC は実用上の目的にはあまり適していませんでした。
このため、Guido はより実用的なプログラミング言語の開発を開始し、英国 BBS 放送のコメディ番組「モンティ パイソン」のファンである Guido はこの言語を「Python」と名づけました。
このような背景から生まれた Python の言語設計は、「シンプル」で「習得が容易」という目標に重点が置かれています。
多くのスクリプト系言語ではユーザの目先の利便性を優先して色々な機能を言語要素として取り入れる場合が多いのですが、Python ではそういった小細工が追加されることはあまりありません。
言語自体の機能は最小限に押さえ、必要な機能は拡張モジュールとして追加する、というのが Python のポリシーです。
<EFBFBD> <20> トキ<E38388><E382AD> <20><> <20><><EFBFBD>

7
Lib/test/cjkencodings/euc_jp-utf8.txt vendored Normal file
View File

@@ -0,0 +1,7 @@
Python の開発は、1990 年ごろから開始されています。
開発者の Guido van Rossum は教育用のプログラミング言語「ABC」の開発に参加していましたが、ABC は実用上の目的にはあまり適していませんでした。
このため、Guido はより実用的なプログラミング言語の開発を開始し、英国 BBS 放送のコメディ番組「モンティ パイソン」のファンである Guido はこの言語を「Python」と名づけました。
このような背景から生まれた Python の言語設計は、「シンプル」で「習得が容易」という目標に重点が置かれています。
多くのスクリプト系言語ではユーザの目先の利便性を優先して色々な機能を言語要素として取り入れる場合が多いのですが、Python ではそういった小細工が追加されることはあまりありません。
言語自体の機能は最小限に押さえ、必要な機能は拡張モジュールとして追加する、というのが Python のポリシーです。

7
Lib/test/cjkencodings/euc_jp.txt vendored Normal file
View File

@@ -0,0 +1,7 @@
Python の開発は、1990 年ごろから開始されています。
開発者の Guido van Rossum は教育用のプログラミング言語「ABC」の開発に参加していましたが、ABC は実用上の目的にはあまり適していませんでした。
このため、Guido はより実用的なプログラミング言語の開発を開始し、英国 BBS 放送のコメディ番組「モンティ パイソン」のファンである Guido はこの言語を「Python」と名づけました。
このような背景から生まれた Python の言語設計は、「シンプル」で「習得が容易」という目標に重点が置かれています。
多くのスクリプト系言語ではユーザの目先の利便性を優先して色々な機能を言語要素として取り入れる場合が多いのですが、Python ではそういった小細工が追加されることはあまりありません。
言語自体の機能は最小限に押さえ、必要な機能は拡張モジュールとして追加する、というのが Python のポリシーです。

7
Lib/test/cjkencodings/euc_kr-utf8.txt vendored Normal file
View File

@@ -0,0 +1,7 @@
◎ 파이썬(Python)은 배우기 쉽고, 강력한 프로그래밍 언어입니다. 파이썬은
효율적인 고수준 데이터 구조와 간단하지만 효율적인 객체지향프로그래밍을
지원합니다. 파이썬의 우아(優雅)한 문법과 동적 타이핑, 그리고 인터프리팅
환경은 파이썬을 스크립팅과 여러 분야에서와 대부분의 플랫폼에서의 빠른
애플리케이션 개발을 할 수 있는 이상적인 언어로 만들어줍니다.
☆첫가끝: 날아라 쓔쓔쓩~ 닁큼! 뜽금없이 전홥니다. 뷁. 그런거 읎다.

7
Lib/test/cjkencodings/euc_kr.txt vendored Normal file
View File

@@ -0,0 +1,7 @@
◎ 파이썬(Python)은 배우기 쉽고, 강력한 프로그래밍 언어입니다. 파이썬은
효율적인 고수준 데이터 구조와 간단하지만 효율적인 객체지향프로그래밍을
지원합니다. 파이썬의 우아(優雅)한 문법과 동적 타이핑, 그리고 인터프리팅
환경은 파이썬을 스크립팅과 여러 분야에서와 대부분의 플랫폼에서의 빠른
애플리케이션 개발을 할 수 있는 이상적인 언어로 만들어줍니다.
☆첫가끝: 날아라 ㅤㅆㅠㅤㅤㅆㅠㅤ쓩~ ㅤㄴㅢㅇ큼! ㅤㄸㅡㅇ금없이 전ㅤㅎㅘㅂ니다. ㅤㅂㅞㄺ. 그런거 ㅤㅇㅡㅄ다.

15
Lib/test/cjkencodings/gb18030-utf8.txt vendored Normal file
View File

@@ -0,0 +1,15 @@
Python派森语言是一种功能强大而完善的通用型计算机程序设计语言
已经具有十多年的发展历史,成熟且稳定。这种语言具有非常简捷而清晰
的语法特点,适合完成各种高层任务,几乎可以在所有的操作系统中
运行。这种语言简单而强大,适合各种人士学习使用。目前,基于这
种语言的相关技术正在飞速的发展,用户数量急剧扩大,相关的资源非常多。
如何在 Python 中使用既有的 C library?
 在資訊科技快速發展的今天, 開發及測試軟體的速度是不容忽視的
課題. 為加快開發及測試的速度, 我們便常希望能利用一些已開發好的
library, 並有一個 fast prototyping 的 programming language 可
供使用. 目前有許許多多的 library 是以 C 寫成, 而 Python 是一個
fast prototyping 的 programming language. 故我們希望能將既有的
C library 拿到 Python 的環境中測試及整合. 其中最主要也是我們所
要討論的問題就是:
파이썬은 강력한 기능을 지닌 범용 컴퓨터 프로그래밍 언어다.

15
Lib/test/cjkencodings/gb18030.txt vendored Normal file
View File

@@ -0,0 +1,15 @@
Python派森语言是一种功能强大而完善的通用型计算机程序设计语言
已经具有十多年的发展历史,成熟且稳定。这种语言具有非常简捷而清晰
的语法特点,适合完成各种高层任务,几乎可以在所有的操作系统中
运行。这种语言简单而强大,适合各种人士学习使用。目前,基于这
种语言的相关技术正在飞速的发展,用户数量急剧扩大,相关的资源非常多。
如何在 Python 中使用既有的 C library?
 在資訊科技快速發展的今天, 開發及測試軟體的速度是不容忽視的
課題. 為加快開發及測試的速度, 我們便常希望能利用一些已開發好的
library, 並有一個 fast prototyping 的 programming language 可
供使用. 目前有許許多多的 library 是以 C 寫成, 而 Python 是一個
fast prototyping 的 programming language. 故我們希望能將既有的
C library 拿到 Python 的環境中測試及整合. 其中最主要也是我們所
要討論的問題就是:
파이썬은 강력한 기능을 지닌 범용 컴퓨터 프로그래밍 언어다.

6
Lib/test/cjkencodings/gb2312-utf8.txt vendored Normal file
View File

@@ -0,0 +1,6 @@
Python派森语言是一种功能强大而完善的通用型计算机程序设计语言
已经具有十多年的发展历史,成熟且稳定。这种语言具有非常简捷而清晰
的语法特点,适合完成各种高层任务,几乎可以在所有的操作系统中
运行。这种语言简单而强大,适合各种人士学习使用。目前,基于这
种语言的相关技术正在飞速的发展,用户数量急剧扩大,相关的资源非常多。

6
Lib/test/cjkencodings/gb2312.txt vendored Normal file
View File

@@ -0,0 +1,6 @@
Python派森语言是一种功能强大而完善的通用型计算机程序设计语言
已经具有十多年的发展历史,成熟且稳定。这种语言具有非常简捷而清晰
的语法特点,适合完成各种高层任务,几乎可以在所有的操作系统中
运行。这种语言简单而强大,适合各种人士学习使用。目前,基于这
种语言的相关技术正在飞速的发展,用户数量急剧扩大,相关的资源非常多。

14
Lib/test/cjkencodings/gbk-utf8.txt vendored Normal file
View File

@@ -0,0 +1,14 @@
Python派森语言是一种功能强大而完善的通用型计算机程序设计语言
已经具有十多年的发展历史,成熟且稳定。这种语言具有非常简捷而清晰
的语法特点,适合完成各种高层任务,几乎可以在所有的操作系统中
运行。这种语言简单而强大,适合各种人士学习使用。目前,基于这
种语言的相关技术正在飞速的发展,用户数量急剧扩大,相关的资源非常多。
如何在 Python 中使用既有的 C library?
 在資訊科技快速發展的今天, 開發及測試軟體的速度是不容忽視的
課題. 為加快開發及測試的速度, 我們便常希望能利用一些已開發好的
library, 並有一個 fast prototyping 的 programming language 可
供使用. 目前有許許多多的 library 是以 C 寫成, 而 Python 是一個
fast prototyping 的 programming language. 故我們希望能將既有的
C library 拿到 Python 的環境中測試及整合. 其中最主要也是我們所
要討論的問題就是:

14
Lib/test/cjkencodings/gbk.txt vendored Normal file
View File

@@ -0,0 +1,14 @@
Python派森语言是一种功能强大而完善的通用型计算机程序设计语言
已经具有十多年的发展历史,成熟且稳定。这种语言具有非常简捷而清晰
的语法特点,适合完成各种高层任务,几乎可以在所有的操作系统中
运行。这种语言简单而强大,适合各种人士学习使用。目前,基于这
种语言的相关技术正在飞速的发展,用户数量急剧扩大,相关的资源非常多。
如何在 Python 中使用既有的 C library?
 在資訊科技快速發展的今天, 開發及測試軟體的速度是不容忽視的
課題. 為加快開發及測試的速度, 我們便常希望能利用一些已開發好的
library, 並有一個 fast prototyping 的 programming language 可
供使用. 目前有許許多多的 library 是以 C 寫成, 而 Python 是一個
fast prototyping 的 programming language. 故我們希望能將既有的
C library 拿到 Python 的環境中測試及整合. 其中最主要也是我們所
要討論的問題就是:

2
Lib/test/cjkencodings/hz-utf8.txt vendored Normal file
View File

@@ -0,0 +1,2 @@
This sentence is in ASCII.
The next sentence is in GB.己所不欲勿施於人。Bye.

2
Lib/test/cjkencodings/hz.txt vendored Normal file
View File

@@ -0,0 +1,2 @@
This sentence is in ASCII.
The next sentence is in GB.~{<:Ky2;S{#,NpJ)l6HK!#~}Bye.

View File

@@ -0,0 +1,7 @@
Python の開発は、1990 年ごろから開始されています。
開発者の Guido van Rossum は教育用のプログラミング言語「ABC」の開発に参加していましたが、ABC は実用上の目的にはあまり適していませんでした。
このため、Guido はより実用的なプログラミング言語の開発を開始し、英国 BBS 放送のコメディ番組「モンティ パイソン」のファンである Guido はこの言語を「Python」と名づけました。
このような背景から生まれた Python の言語設計は、「シンプル」で「習得が容易」という目標に重点が置かれています。
多くのスクリプト系言語ではユーザの目先の利便性を優先して色々な機能を言語要素として取り入れる場合が多いのですが、Python ではそういった小細工が追加されることはあまりありません。
言語自体の機能は最小限に押さえ、必要な機能は拡張モジュールとして追加する、というのが Python のポリシーです。

7
Lib/test/cjkencodings/iso2022_jp.txt vendored Normal file
View File

@@ -0,0 +1,7 @@
Python $B$N3+H/$O!"(B1990 $BG/$4$m$+$i3+;O$5$l$F$$$^$9!#(B
$B3+H/<T$N(B Guido van Rossum $B$O650iMQ$N%W%m%0%i%_%s%08@8l!V(BABC$B!W$N3+H/$K;22C$7$F$$$^$7$?$,!"(BABC $B$O<BMQ>e$NL\E*$K$O$"$^$jE,$7$F$$$^$;$s$G$7$?!#(B
$B$3$N$?$a!"(BGuido $B$O$h$j<BMQE*$J%W%m%0%i%_%s%08@8l$N3+H/$r3+;O$7!"1Q9q(B BBS $BJ|Aw$N%3%a%G%#HVAH!V%b%s%F%#(B $B%Q%$%=%s!W$N%U%!%s$G$"$k(B Guido $B$O$3$N8@8l$r!V(BPython$B!W$HL>$E$1$^$7$?!#(B
$B$3$N$h$&$JGX7J$+$i@8$^$l$?(B Python $B$N8@8l@_7W$O!"!V%7%s%W%k!W$G!V=,F@$,MF0W!W$H$$$&L\I8$K=EE@$,CV$+$l$F$$$^$9!#(B
$BB?$/$N%9%/%j%W%H7O8@8l$G$O%f!<%6$NL\@h$NMxJX@-$rM%@h$7$F?'!9$J5!G=$r8@8lMWAG$H$7$F<h$jF~$l$k>l9g$,B?$$$N$G$9$,!"(BPython $B$G$O$=$&$$$C$?>.:Y9)$,DI2C$5$l$k$3$H$O$"$^$j$"$j$^$;$s!#(B
$B8@8l<+BN$N5!G=$O:G>.8B$K2!$5$(!"I,MW$J5!G=$O3HD%%b%8%e!<%k$H$7$FDI2C$9$k!"$H$$$&$N$,(B Python $B$N%]%j%7!<$G$9!#(B

View File

@@ -0,0 +1,7 @@
◎ 파이썬(Python)은 배우기 쉽고, 강력한 프로그래밍 언어입니다. 파이썬은
효율적인 고수준 데이터 구조와 간단하지만 효율적인 객체지향프로그래밍을
지원합니다. 파이썬의 우아(優雅)한 문법과 동적 타이핑, 그리고 인터프리팅
환경은 파이썬을 스크립팅과 여러 분야에서와 대부분의 플랫폼에서의 빠른
애플리케이션 개발을 할 수 있는 이상적인 언어로 만들어줍니다.
☆첫가끝: 날아라 쓩~ 큼! 금없이 전니다. 그런거 다.

7
Lib/test/cjkencodings/iso2022_kr.txt vendored Normal file
View File

@@ -0,0 +1,7 @@
$)C!] FD@L=c(Python)@: 9h?l1b =10m, 0-7BGQ GA7N1W7!9V >p>n@T4O4Y. FD@L=c@:
H?@2@{@N 0m<vAX 5%@LEM 18A6?M 0#4\GOAv88 H?@2@{@N 04C<AvGbGA7N1W7!9V@;
Av?xGU4O4Y. FD@L=c@G ?l>F(iPd:)GQ 9.9}0z 5?@{ E8@LGN, 1W8.0m @NEMGA8.FC
H/0f@: FD@L=c@; =:E)83FC0z ?)7/ :P>_?!<-?M 4k:N:P@G GC7'F{?!<-@G :|8%
>VGC8.DI@L<G 039_@; GR <v @V4B @L;s@{@N >p>n7N 885i>nA]4O4Y.
!YC90!3!: 3/>F6s >1~ E-! 1]>x@L @|4O4Y. 1W710E 4Y.

9
Lib/test/cjkencodings/johab-utf8.txt vendored Normal file
View File

@@ -0,0 +1,9 @@
똠방각하 펲시콜라
㉯㉯납!! 因九月패믤릔궈 ⓡⓖ훀¿¿¿ 긍뒙 ⓔ뎨 ㉯. .
亞영ⓔ능횹 . . . . 서울뤄 뎐학乙 家훀 ! ! !ㅠ.ㅠ
흐흐흐 ㄱㄱㄱ☆ㅠ_ㅠ 어릨 탸콰긐 뎌응 칑九들乙 ㉯드긐
설릌 家훀 . . . . 굴애쉌 ⓔ궈 ⓡ릘㉱긐 因仁川女中까즼
와쒀훀 ! ! 亞영ⓔ 家능궈 ☆上관 없능궈능 亞능뒈훀 글애듴
ⓡ려듀九 싀풔숴훀 어릨 因仁川女中싁⑨들앜!! ㉯㉯납♡ ⌒⌒*

9
Lib/test/cjkencodings/johab.txt vendored Normal file
View File

@@ -0,0 +1,9 @@
苘已Ê̄胊 狖砥觼𦡞
傱傱𨤳!! 鎤<><EFBFBD><E79EBA><EFBFBD>𦛚 嗍嗄烚棬棬棬 𢶤𣙀 嗀<> 傱. .
<EFBFBD><硬嗀𢘛烞 . . . . 矜<>鱝 胆胕譇 <20>;烚 ! ! !䰲.䰲
羖羖羖 ㇁㇁㇁揓䰲_䰲 氮<> 龰鰻𡀞 𦳑暈 <20><>𡟙譇 傱㻡𡀞
祇鞴 <20>;烚 . . . . <20><>捏 嗀𦛚 嗍<>僉𡀞 鎤鎟霯薤鶅蘏<E9B685>
聒瓷烚 ! ! <20><硬嗀 <20>;𢘛𦛚 揓篨䤑 渭𢘛𦛚𢘛 <20><𢘛𩤯烚 𤷫<>𨯧
嗍犏嫎<EFBFBD> <20>峞恣烚 氮<> 鎤鎟霯薤鶅<E896A4>堽𡟙揀!! 傱傱𨤳棌 摡摡*

View File

@@ -0,0 +1,7 @@
Python の開発は、1990 年ごろから開始されています。
開発者の Guido van Rossum は教育用のプログラミング言語「ABC」の開発に参加していましたが、ABC は実用上の目的にはあまり適していませんでした。
このため、Guido はより実用的なプログラミング言語の開発を開始し、英国 BBS 放送のコメディ番組「モンティ パイソン」のファンである Guido はこの言語を「Python」と名づけました。
このような背景から生まれた Python の言語設計は、「シンプル」で「習得が容易」という目標に重点が置かれています。
多くのスクリプト系言語ではユーザの目先の利便性を優先して色々な機能を言語要素として取り入れる場合が多いのですが、Python ではそういった小細工が追加されることはあまりありません。
言語自体の機能は最小限に押さえ、必要な機能は拡張モジュールとして追加する、というのが Python のポリシーです。

7
Lib/test/cjkencodings/shift_jis.txt vendored Normal file
View File

@@ -0,0 +1,7 @@
Python の開発は、1990 年ごろから開始されています。
開発者の Guido van Rossum は教育用のプログラミング言語「ABC」の開発に参加していましたが、ABC は実用上の目的にはあまり適していませんでした。
このため、Guido はより実用的なプログラミング言語の開発を開始し、英国 BBS 放送のコメディ番組「モンティ パイソン」のファンである Guido はこの言語を「Python」と名づけました。
このような背景から生まれた Python の言語設計は、「シンプル」で「習得が容易」という目標に重点が置かれています。
多くのスクリプト系言語ではユーザの目先の利便性を優先して色々な機能を言語要素として取り入れる場合が多いのですが、Python ではそういった小細工が追加されることはあまりありません。
言語自体の機能は最小限に押さえ、必要な機能は拡張モジュールとして追加する、というのが Python のポリシーです。

View File

@@ -0,0 +1,8 @@
Python の開発は、1990 年ごろから開始されています。
開発者の Guido van Rossum は教育用のプログラミング言語「ABC」の開発に参加していましたが、ABC は実用上の目的にはあまり適していませんでした。
このため、Guido はより実用的なプログラミング言語の開発を開始し、英国 BBS 放送のコメディ番組「モンティ パイソン」のファンである Guido はこの言語を「Python」と名づけました。
このような背景から生まれた Python の言語設計は、「シンプル」で「習得が容易」という目標に重点が置かれています。
多くのスクリプト系言語ではユーザの目先の利便性を優先して色々な機能を言語要素として取り入れる場合が多いのですが、Python ではそういった小細工が追加されることはあまりありません。
言語自体の機能は最小限に押さえ、必要な機能は拡張モジュールとして追加する、というのが Python のポリシーです。
ノか゚ ト゚ トキ喝塀 𡚴𪎌 麀齁𩛰

View File

@@ -0,0 +1,8 @@
Python の開発は、1990 年ごろから開始されています。
開発者の Guido van Rossum は教育用のプログラミング言語「ABC」の開発に参加していましたが、ABC は実用上の目的にはあまり適していませんでした。
このため、Guido はより実用的なプログラミング言語の開発を開始し、英国 BBS 放送のコメディ番組「モンティ パイソン」のファンである Guido はこの言語を「Python」と名づけました。
このような背景から生まれた Python の言語設計は、「シンプル」で「習得が容易」という目標に重点が置かれています。
多くのスクリプト系言語ではユーザの目先の利便性を優先して色々な機能を言語要素として取り入れる場合が多いのですが、Python ではそういった小細工が追加されることはあまりありません。
言語自体の機能は最小限に押さえ、必要な機能は拡張モジュールとして追加する、というのが Python のポリシーです。
<EFBFBD> <20> トキ<E38388><E382AD> <20><> <20><>

400
Lib/test/multibytecodec_support.py vendored Normal file
View File

@@ -0,0 +1,400 @@
#
# multibytecodec_support.py
# Common Unittest Routines for CJK codecs
#
import codecs
import os
import re
import sys
import unittest
from http.client import HTTPException
from test import support
from io import BytesIO
class TestBase:
encoding = '' # codec name
codec = None # codec tuple (with 4 elements)
tstring = None # must set. 2 strings to test StreamReader
codectests = None # must set. codec test tuple
roundtriptest = 1 # set if roundtrip is possible with unicode
has_iso10646 = 0 # set if this encoding contains whole iso10646 map
xmlcharnametest = None # string to test xmlcharrefreplace
unmappedunicode = '\udeee' # a unicode code point that is not mapped.
def setUp(self):
if self.codec is None:
self.codec = codecs.lookup(self.encoding)
self.encode = self.codec.encode
self.decode = self.codec.decode
self.reader = self.codec.streamreader
self.writer = self.codec.streamwriter
self.incrementalencoder = self.codec.incrementalencoder
self.incrementaldecoder = self.codec.incrementaldecoder
def test_chunkcoding(self):
tstring_lines = []
for b in self.tstring:
lines = b.split(b"\n")
last = lines.pop()
assert last == b""
lines = [line + b"\n" for line in lines]
tstring_lines.append(lines)
for native, utf8 in zip(*tstring_lines):
u = self.decode(native)[0]
self.assertEqual(u, utf8.decode('utf-8'))
if self.roundtriptest:
self.assertEqual(native, self.encode(u)[0])
def test_errorhandle(self):
for source, scheme, expected in self.codectests:
if isinstance(source, bytes):
func = self.decode
else:
func = self.encode
if expected:
result = func(source, scheme)[0]
if func is self.decode:
self.assertTrue(type(result) is str, type(result))
self.assertEqual(result, expected,
'%a.decode(%r, %r)=%a != %a'
% (source, self.encoding, scheme, result,
expected))
else:
self.assertTrue(type(result) is bytes, type(result))
self.assertEqual(result, expected,
'%a.encode(%r, %r)=%a != %a'
% (source, self.encoding, scheme, result,
expected))
else:
self.assertRaises(UnicodeError, func, source, scheme)
def test_xmlcharrefreplace(self):
if self.has_iso10646:
self.skipTest('encoding contains full ISO 10646 map')
s = "\u0b13\u0b23\u0b60 nd eggs"
self.assertEqual(
self.encode(s, "xmlcharrefreplace")[0],
b"&#2835;&#2851;&#2912; nd eggs"
)
def test_customreplace_encode(self):
if self.has_iso10646:
self.skipTest('encoding contains full ISO 10646 map')
from html.entities import codepoint2name
def xmlcharnamereplace(exc):
if not isinstance(exc, UnicodeEncodeError):
raise TypeError("don't know how to handle %r" % exc)
l = []
for c in exc.object[exc.start:exc.end]:
if ord(c) in codepoint2name:
l.append("&%s;" % codepoint2name[ord(c)])
else:
l.append("&#%d;" % ord(c))
return ("".join(l), exc.end)
codecs.register_error("test.xmlcharnamereplace", xmlcharnamereplace)
if self.xmlcharnametest:
sin, sout = self.xmlcharnametest
else:
sin = "\xab\u211c\xbb = \u2329\u1234\u232a"
sout = b"&laquo;&real;&raquo; = &lang;&#4660;&rang;"
self.assertEqual(self.encode(sin,
"test.xmlcharnamereplace")[0], sout)
def test_callback_returns_bytes(self):
def myreplace(exc):
return (b"1234", exc.end)
codecs.register_error("test.cjktest", myreplace)
enc = self.encode("abc" + self.unmappedunicode + "def", "test.cjktest")[0]
self.assertEqual(enc, b"abc1234def")
def test_callback_wrong_objects(self):
def myreplace(exc):
return (ret, exc.end)
codecs.register_error("test.cjktest", myreplace)
for ret in ([1, 2, 3], [], None, object()):
self.assertRaises(TypeError, self.encode, self.unmappedunicode,
'test.cjktest')
def test_callback_long_index(self):
def myreplace(exc):
return ('x', int(exc.end))
codecs.register_error("test.cjktest", myreplace)
self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh',
'test.cjktest'), (b'abcdxefgh', 9))
def myreplace(exc):
return ('x', sys.maxsize + 1)
codecs.register_error("test.cjktest", myreplace)
self.assertRaises(IndexError, self.encode, self.unmappedunicode,
'test.cjktest')
def test_callback_None_index(self):
def myreplace(exc):
return ('x', None)
codecs.register_error("test.cjktest", myreplace)
self.assertRaises(TypeError, self.encode, self.unmappedunicode,
'test.cjktest')
def test_callback_backward_index(self):
def myreplace(exc):
if myreplace.limit > 0:
myreplace.limit -= 1
return ('REPLACED', 0)
else:
return ('TERMINAL', exc.end)
myreplace.limit = 3
codecs.register_error("test.cjktest", myreplace)
self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh',
'test.cjktest'),
(b'abcdREPLACEDabcdREPLACEDabcdREPLACEDabcdTERMINALefgh', 9))
def test_callback_forward_index(self):
def myreplace(exc):
return ('REPLACED', exc.end + 2)
codecs.register_error("test.cjktest", myreplace)
self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh',
'test.cjktest'), (b'abcdREPLACEDgh', 9))
def test_callback_index_outofbound(self):
def myreplace(exc):
return ('TERM', 100)
codecs.register_error("test.cjktest", myreplace)
self.assertRaises(IndexError, self.encode, self.unmappedunicode,
'test.cjktest')
def test_incrementalencoder(self):
UTF8Reader = codecs.getreader('utf-8')
for sizehint in [None] + list(range(1, 33)) + \
[64, 128, 256, 512, 1024]:
istream = UTF8Reader(BytesIO(self.tstring[1]))
ostream = BytesIO()
encoder = self.incrementalencoder()
while 1:
if sizehint is not None:
data = istream.read(sizehint)
else:
data = istream.read()
if not data:
break
e = encoder.encode(data)
ostream.write(e)
self.assertEqual(ostream.getvalue(), self.tstring[0])
def test_incrementaldecoder(self):
UTF8Writer = codecs.getwriter('utf-8')
for sizehint in [None, -1] + list(range(1, 33)) + \
[64, 128, 256, 512, 1024]:
istream = BytesIO(self.tstring[0])
ostream = UTF8Writer(BytesIO())
decoder = self.incrementaldecoder()
while 1:
data = istream.read(sizehint)
if not data:
break
else:
u = decoder.decode(data)
ostream.write(u)
self.assertEqual(ostream.getvalue(), self.tstring[1])
def test_incrementalencoder_error_callback(self):
inv = self.unmappedunicode
e = self.incrementalencoder()
self.assertRaises(UnicodeEncodeError, e.encode, inv, True)
e.errors = 'ignore'
self.assertEqual(e.encode(inv, True), b'')
e.reset()
def tempreplace(exc):
return ('called', exc.end)
codecs.register_error('test.incremental_error_callback', tempreplace)
e.errors = 'test.incremental_error_callback'
self.assertEqual(e.encode(inv, True), b'called')
# again
e.errors = 'ignore'
self.assertEqual(e.encode(inv, True), b'')
def test_streamreader(self):
UTF8Writer = codecs.getwriter('utf-8')
for name in ["read", "readline", "readlines"]:
for sizehint in [None, -1] + list(range(1, 33)) + \
[64, 128, 256, 512, 1024]:
istream = self.reader(BytesIO(self.tstring[0]))
ostream = UTF8Writer(BytesIO())
func = getattr(istream, name)
while 1:
data = func(sizehint)
if not data:
break
if name == "readlines":
ostream.writelines(data)
else:
ostream.write(data)
self.assertEqual(ostream.getvalue(), self.tstring[1])
def test_streamwriter(self):
readfuncs = ('read', 'readline', 'readlines')
UTF8Reader = codecs.getreader('utf-8')
for name in readfuncs:
for sizehint in [None] + list(range(1, 33)) + \
[64, 128, 256, 512, 1024]:
istream = UTF8Reader(BytesIO(self.tstring[1]))
ostream = self.writer(BytesIO())
func = getattr(istream, name)
while 1:
if sizehint is not None:
data = func(sizehint)
else:
data = func()
if not data:
break
if name == "readlines":
ostream.writelines(data)
else:
ostream.write(data)
self.assertEqual(ostream.getvalue(), self.tstring[0])
def test_streamwriter_reset_no_pending(self):
# Issue #23247: Calling reset() on a fresh StreamWriter instance
# (without pending data) must not crash
stream = BytesIO()
writer = self.writer(stream)
writer.reset()
def test_incrementalencoder_del_segfault(self):
e = self.incrementalencoder()
with self.assertRaises(AttributeError):
del e.errors
def test_null_terminator(self):
# see gh-101828
text = "フルーツ"
try:
text.encode(self.encoding)
except UnicodeEncodeError:
text = "Python is cool"
encode_w_null = (text + "\0").encode(self.encoding)
encode_plus_null = text.encode(self.encoding) + "\0".encode(self.encoding)
self.assertTrue(encode_w_null.endswith(b'\x00'))
self.assertEqual(encode_w_null, encode_plus_null)
encode_w_null_2 = (text + "\0" + text + "\0").encode(self.encoding)
encode_plus_null_2 = encode_plus_null + encode_plus_null
self.assertEqual(encode_w_null_2.count(b'\x00'), 2)
self.assertEqual(encode_w_null_2, encode_plus_null_2)
class TestBase_Mapping(unittest.TestCase):
pass_enctest = []
pass_dectest = []
supmaps = []
codectests = []
def setUp(self):
try:
self.open_mapping_file().close() # test it to report the error early
except (OSError, HTTPException):
self.skipTest("Could not retrieve "+self.mapfileurl)
def open_mapping_file(self):
return support.open_urlresource(self.mapfileurl, encoding="utf-8")
def test_mapping_file(self):
if self.mapfileurl.endswith('.xml'):
self._test_mapping_file_ucm()
else:
self._test_mapping_file_plain()
def _test_mapping_file_plain(self):
def unichrs(s):
return ''.join(chr(int(x, 16)) for x in s.split('+'))
urt_wa = {}
with self.open_mapping_file() as f:
for line in f:
if not line:
break
data = line.split('#')[0].split()
if len(data) != 2:
continue
if data[0][:2] != '0x':
self.fail(f"Invalid line: {line!r}")
csetch = bytes.fromhex(data[0][2:])
if len(csetch) == 1 and 0x80 <= csetch[0]:
continue
unich = unichrs(data[1])
if ord(unich) == 0xfffd or unich in urt_wa:
continue
urt_wa[unich] = csetch
self._testpoint(csetch, unich)
def _test_mapping_file_ucm(self):
with self.open_mapping_file() as f:
ucmdata = f.read()
uc = re.findall('<a u="([A-F0-9]{4})" b="([0-9A-F ]+)"/>', ucmdata)
for uni, coded in uc:
unich = chr(int(uni, 16))
codech = bytes.fromhex(coded)
self._testpoint(codech, unich)
def test_mapping_supplemental(self):
for mapping in self.supmaps:
self._testpoint(*mapping)
def _testpoint(self, csetch, unich):
if (csetch, unich) not in self.pass_enctest:
self.assertEqual(unich.encode(self.encoding), csetch)
if (csetch, unich) not in self.pass_dectest:
self.assertEqual(str(csetch, self.encoding), unich)
def test_errorhandle(self):
for source, scheme, expected in self.codectests:
if isinstance(source, bytes):
func = source.decode
else:
func = source.encode
if expected:
if isinstance(source, bytes):
result = func(self.encoding, scheme)
self.assertTrue(type(result) is str, type(result))
self.assertEqual(result, expected,
'%a.decode(%r, %r)=%a != %a'
% (source, self.encoding, scheme, result,
expected))
else:
result = func(self.encoding, scheme)
self.assertTrue(type(result) is bytes, type(result))
self.assertEqual(result, expected,
'%a.encode(%r, %r)=%a != %a'
% (source, self.encoding, scheme, result,
expected))
else:
self.assertRaises(UnicodeError, func, self.encoding, scheme)
def load_teststring(name):
dir = os.path.join(os.path.dirname(__file__), 'cjkencodings')
with open(os.path.join(dir, name + '.txt'), 'rb') as f:
encoded = f.read()
with open(os.path.join(dir, name + '-utf8.txt'), 'rb') as f:
utf8 = f.read()
return encoded, utf8

96
Lib/test/test_codecencodings_cn.py vendored Normal file
View File

@@ -0,0 +1,96 @@
#
# test_codecencodings_cn.py
# Codec encoding tests for PRC encodings.
#
from test import multibytecodec_support
import unittest
class Test_GB2312(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'gb2312'
tstring = multibytecodec_support.load_teststring('gb2312')
codectests = (
# invalid bytes
(b"abc\x81\x81\xc1\xc4", "strict", None),
(b"abc\xc8", "strict", None),
(b"abc\x81\x81\xc1\xc4", "replace", "abc\ufffd\ufffd\u804a"),
(b"abc\x81\x81\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\u804a\ufffd"),
(b"abc\x81\x81\xc1\xc4", "ignore", "abc\u804a"),
(b"\xc1\x64", "strict", None),
)
class Test_GBK(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'gbk'
tstring = multibytecodec_support.load_teststring('gbk')
codectests = (
# invalid bytes
(b"abc\x80\x80\xc1\xc4", "strict", None),
(b"abc\xc8", "strict", None),
(b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ufffd\u804a"),
(b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\u804a\ufffd"),
(b"abc\x80\x80\xc1\xc4", "ignore", "abc\u804a"),
(b"\x83\x34\x83\x31", "strict", None),
("\u30fb", "strict", None),
)
class Test_GB18030(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'gb18030'
tstring = multibytecodec_support.load_teststring('gb18030')
codectests = (
# invalid bytes
(b"abc\x80\x80\xc1\xc4", "strict", None),
(b"abc\xc8", "strict", None),
(b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ufffd\u804a"),
(b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ufffd\u804a\ufffd"),
(b"abc\x80\x80\xc1\xc4", "ignore", "abc\u804a"),
(b"abc\x84\x39\x84\x39\xc1\xc4", "replace", "abc\ufffd9\ufffd9\u804a"),
("\u30fb", "strict", b"\x819\xa79"),
(b"abc\x84\x32\x80\x80def", "replace", 'abc\ufffd2\ufffd\ufffddef'),
(b"abc\x81\x30\x81\x30def", "strict", 'abc\x80def'),
(b"abc\x86\x30\x81\x30def", "replace", 'abc\ufffd0\ufffd0def'),
# issue29990
(b"\xff\x30\x81\x30", "strict", None),
(b"\x81\x30\xff\x30", "strict", None),
(b"abc\x81\x39\xff\x39\xc1\xc4", "replace", "abc\ufffd\x39\ufffd\x39\u804a"),
(b"abc\xab\x36\xff\x30def", "replace", 'abc\ufffd\x36\ufffd\x30def'),
(b"abc\xbf\x38\xff\x32\xc1\xc4", "ignore", "abc\x38\x32\u804a"),
)
has_iso10646 = True
class Test_HZ(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'hz'
tstring = multibytecodec_support.load_teststring('hz')
codectests = (
# test '~\n' (3 lines)
(b'This sentence is in ASCII.\n'
b'The next sentence is in GB.~{<:Ky2;S{#,~}~\n'
b'~{NpJ)l6HK!#~}Bye.\n',
'strict',
'This sentence is in ASCII.\n'
'The next sentence is in GB.'
'\u5df1\u6240\u4e0d\u6b32\uff0c\u52ff\u65bd\u65bc\u4eba\u3002'
'Bye.\n'),
# test '~\n' (4 lines)
(b'This sentence is in ASCII.\n'
b'The next sentence is in GB.~\n'
b'~{<:Ky2;S{#,NpJ)l6HK!#~}~\n'
b'Bye.\n',
'strict',
'This sentence is in ASCII.\n'
'The next sentence is in GB.'
'\u5df1\u6240\u4e0d\u6b32\uff0c\u52ff\u65bd\u65bc\u4eba\u3002'
'Bye.\n'),
# invalid bytes
(b'ab~cd', 'replace', 'ab\uFFFDcd'),
(b'ab\xffcd', 'replace', 'ab\uFFFDcd'),
(b'ab~{\x81\x81\x41\x44~}cd', 'replace', 'ab\uFFFD\uFFFD\u804Acd'),
(b'ab~{\x41\x44~}cd', 'replace', 'ab\u804Acd'),
(b"ab~{\x79\x79\x41\x44~}cd", "replace", "ab\ufffd\ufffd\u804acd"),
# issue 30003
('ab~cd', 'strict', b'ab~~cd'), # escape ~
(b'~{Dc~~:C~}', 'strict', None), # ~~ only in ASCII mode
(b'~{Dc~\n:C~}', 'strict', None), # ~\n only in ASCII mode
)
if __name__ == "__main__":
unittest.main()