What's New In Python 3.3¶
ãã®èšäºã§ã¯ 3.2 ãšæ¯èŒãã Python 3.3 ã®æ°æ©èœã解説ããŸãã Python 3.3 ã¯2012幎9æ29æ¥ã«ãªãªãŒã¹ãããŸãããå šè©³çŽ°ã«ã€ããŠã¯ 倿Žå±¥æŽ ãã芧ãã ããã
åè
PEP 398 - Python 3.3 ãªãªãŒã¹ã¹ã±ãžã¥ãŒã«
æŠèŠ -- ãªãªãŒã¹ãã€ã©ã€ã¶
æ°ããªææ³æ©èœ:
ãžã§ãã¬ãŒã¿ã®å§è². ã®ããã®æ°ãã
yield fromåŒstrãªããžã§ã¯ãåãã®u'unicode'ææ³ã®åé©çš
æ°ããªã©ã€ãã©ãªã¢ãžã¥ãŒã«:
faulthandler(äœæ°Žæºã®ã¯ã©ãã·ã¥ã®ãããã°ãè£å©ãã)ipaddress(IPã¢ãã¬ã¹ãšãã¹ã¯ã衚ã髿°Žæºãªããžã§ã¯ã)lzma(XZ / LZMA ã¢ã«ãŽãªãºã ã䜿çšããããŒã¿å§çž®)unittest.mock(ãã¹ãåãã«ã·ã¹ãã ã®äžéšãã¢ãã¯ãªããžã§ã¯ãã§çœ®ãæãã)venv(人æ°ã®virtualenvããã±ãŒãžã®ãããªãPython virtual environments)
æ°ããªçµã¿èŸŒã¿æ©èœ:
I/O äŸå€éå±€ ã®æçŽã
å®è£ ã®æ¹å:
ã€ã³ããŒãæ©æ§ ãã
importlibãå ã«æžãæãããã³ã³ãã¯ã㪠ãŠãã³ãŒãæåå.
ããã³ã³ãã¯ããª å±æ§èŸæž.
ã©ã€ãã©ãªã¢ãžã¥ãŒã«ã®å€§å¹ ãªæ¹å:
decimal ã¢ãžã¥ãŒã«ã®Cã«ããé«éå
email ã¢ãžã¥ãŒã«ã§ã®ããè¯ããŠãã³ãŒãåŠç (æ«å®ç)
ã»ãã¥ãªãã£ã®æ¹å:
ããã·ã¥ã®ã©ã³ãã åãããã©ã«ãã§æå¹ã«ãªããŸããã
以éã¯ãŠãŒã¶åãã®å€æŽã®å æ¬çãªãªã¹ãã«ãªã£ãŠããŸãã
PEP 405: ä»®æ³ç°å¢Â¶
ä»®æ³ç°å¢ (virtual environment) ã¯éé¢ãããPythonç°å¢ãäœæããæå©ããããŸãã
äžæ¹ã§ä¿å®ã容æã«ããããã«ãã·ã¹ãã å
šäœã®ã€ã³ã¹ããŒã«ãå
±æããŸãã
ä»®æ³ç°å¢ã¯ããèªèº«ã® site packages (ã€ãŸãããŒã«ã«ã«ã€ã³ã¹ããŒã«ãããã©ã€ãã©ãª) ãæã¡ã€ã€ãä»»æã§ã·ã¹ãã å
šäœã® site packages ãšåé¢ã§ããŸãã
ãã®ã³ã³ã»ãããšå®è£
ã¯ã人æ°ã®ãµãŒãããŒãã£ããã±ãŒãžã§ãã virtualenv ãå
ã«ããŠããŸãããã€ã³ã¿ããªã¿ã³ã¢ãšã®çµ±åã«ããæ©æµãåããŠããŸãã
ãã® PEP ã¯ããã°ã©ã ããã®ã¢ã¯ã»ã¹çšã® venv ã¢ãžã¥ãŒã«ãšãã³ãã³ãã©ã€ã³ããã®ã¢ã¯ã»ã¹ãšç®¡çåãã® pyvenv ã¹ã¯ãªããã远å ããŸããPythonã€ã³ã¿ããªã¿ã¯ä»®æ³ç°å¢ã®ãã£ã¬ã¯ããªããªãŒã®ååšã瀺ã pyvenv.cfg ããã§ãã¯ããŸãã
åè
- PEP 405 - Python Virtual Environments
PEP written by Carl Meyer; implementation by Carl Meyer and Vinay Sajip
PEP 420: æé»çãªåå空éããã±ãŒãžÂ¶
__init__.py ããŒã«ãŒãã¡ã€ã«ãå¿
èŠãšããªãããã±ãŒãžãã£ã¬ã¯ããªãšãè€æ°ã®ã¢ãžã¥ãŒã«ãã¹ããã€ãã£ãã§ãµããŒãããŸã(PEP 420 ã«èšèŒãããæ§ã
ãªãµãŒãããŒãã£ã§ã®åå空éã®ã¢ãããŒãã«åœ±é¿ãããŠããŸã)
åè
- PEP 420 - Implicit Namespace Packages
PEP written by Eric V. Smith; implementation by Eric V. Smith and Barry Warsaw
PEP 3118: æ°ããªã¡ã¢ãªãã¥ãŒã®å®è£ ãšãããã¡ãããã³ã«ã®ããã¥ã¡ã³ã¶
PEP 3118 ã®å®è£ ãå€§å¹ ã«æ¹åãããŸããã
æ°ãã memoryview å®è£ ããPy_buffer æ§é äœå ã«ãã£ãŒã«ããåçã«ã¢ãã±ãŒãããéã«å€æ°ã®ã¯ã©ãã·ã¥ã®å ±åããããããŠããå šãŠã®æææš©åé¡ãã©ã€ãã¿ã€ã åé¡ãå æ¬çã«è§£æ±ºããŸãããå ããŠãäžé£ç¶ãããã¯å€æ¬¡å ã®å ¥åã«å¯ŸããŠã¯ã©ãã·ã¥ããã誀ã£ãçµæãè¿ããŠãã倿°ã®é¢æ°ãä¿®æ£ãããŸããã
memoryview ãªããžã§ã¯ãã«ã PEP-3118 æºæ ã® getbufferproc() ã远å ãããŠããŸã (蚳泚: ãããã¡ãªããžã§ã¯ãæ§é äœ (buffer object structure) åç §)ãããã¯ã³ã³ã·ã¥ãŒãã®èŠæ±åããã§ãã¯ããŸããå€ãã®æ°æ©èœã远å ãããŠããããããã®ã»ãšãã©ãäžé£ç¶é åãšãµããªãã»ãããæã€é åã«å®å šãªäžè¬åããããããã®ã§ãã
ããã¥ã¡ã³ã ãæŽæ°ããããšãã¹ããŒã¿(æäŸåŽ)ãšã³ã³ã·ã¥ãŒã(å©çšåŽ)äž¡æ¹ã«ã€ããŠã®è²¬åãããæç¢ºã«è©³çްåããŠããŸãã ãããã¡èŠæ±ã®ãã©ã° ããåºæ¬ãã©ã°ãšçµåããã©ã°ã§ã°ã«ãŒãåããããŠããŸããäžé£ç¶é åãšå€æ¬¡å ã® NumPy ã¹ã¿ã€ã«è¡åã®ã¡ã¢ãªã¬ã€ã¢ãŠãã«ã€ããŠèª¬æãããŠããŸãã
ãã£ãŒãã£ãŒÂ¶
struct ã¢ãžã¥ãŒã«ã®æ§æã®å šãŠã® native æžåŒæå®æå ããµããŒãããããã«ãªããŸãã ('@' ãã¬ãã£ã¯ã¹ãä»ããŠããŠãè¯ãã§ã)ã (蚳泚:
formatåç §ã)ããã€ãã®å¶éã¯ãããŸããã
cast()ã¡ãœããã§ãã©ãŒããã倿Žãš C-contiguous é åã®åœ¢ç¶ (shape) ã®å€æŽãè¡ãããšãåºæ¥ãŸããä»»æã®é ååã§å€æ¬¡å ã®ãªã¹ã衚çŸããµããŒããããããã«ãªã£ãŠããŸãã
ä»»æã®é ååã§å€æ¬¡å ã®æ¯èŒããµããŒããããããã«ãªã£ãŠããŸãã
'B', 'b', 'c' ããããã®ãã©ãŒãããã® hashable 㪠(èªã¿åºãå°çšã®) åã®1次å ã¡ã¢ãªãã¥ãŒããŸãã hashable ã§ãã (Contributed by Antoine Pitrou in bpo-13411.)
Arbitrary slicing of any 1-D arrays type is supported. For example, it is now possible to reverse a memoryview in O(1) by using a negative step.
API ã®å€æŽÂ¶
æå€§
次å ã¯å ¬åŒã« 64 ã«å¶éãããŠããŸãã空ã®
shape, 空ã®strides, 空ã®suboffsetsã衚çŸããã®ã«ä»¥åã¯NoneãçšããŠããŸãããä»ã§ã¯ããã¯ç©ºã®ã¿ãã«ã§ãããã©ãŒããã 'B' (unsigned bytes) ã§ã® memoryview èŠçŽ ãžã®ã¢ã¯ã»ã¹ã¯æŽæ°ãè¿ãããã«ãªããŸãã (struct ã¢ãžã¥ãŒã«ã§ã®æ§æã«åŸã£ãŠããŸã)ãbytes ãªããžã§ã¯ããæ¬²ãããã°ãŸããã¥ãŒã 'c' ã§
cast()ããªããã°ãªããŸãããmemoryview ã©ããã®æ¯èŒã¯è¢«æŒç®å¯Ÿè±¡ã®è«çæ§é ã䜿ã£ãŠè¡ãããã«ãªãããŸããå šãŠã®é åèŠçŽ ã¯å€ã§æ¯èŒãããŸããstruct ã¢ãžã¥ãŒã«ã®æ§æã®å šãŠã®ãã©ãŒãããæåã§ãµããŒããããŸããèªèåºæ¥ãªããã©ãŒãããæåã§ã®ãã¥ãŒã¯ä»ã§ãèš±ãããŠããŸããããã¥ãŒã®æãäžèº«ã«ãããããã¯åžžã«çãããªããšãããŸãã
ã»ãã®å€æŽã«ã€ããŠã¯ã ãã«ããªãã³ã« C API ã®å€æŽ ãš C ã³ãŒãã®ç§»æ€ ãåç §ããŠãã ããã
(Contributed by Stefan Krah in bpo-10181.)
åè
PEP 3118 - Revising the Buffer Protocol
PEP 393: æååã®æè»ãªè¡šçŸÂ¶
Unicode æåååããè€æ°ã®å éšè¡šçŸ (1ã2 ãŸã㯠4 ãã€ãã§è¡šçŸããã Unicode åºæ°(ordinal) ã®æå€§å€äŸå) ãã衚çŸãããæååå ã§ãµããŒãããããã«å€æŽãããŸãã (蚳泚: 以åãŸã§ã¯ Python ã®ãã«ãæã«åºå®ã§æ±ºããŠããŸãã)ããã®ããšã¯å šãŠã®ã·ã¹ãã ã«ãããŠãäžè¬ã®ã±ãŒã¹ã§ã¯ç©ºéå¹çã®è¯ã衚çŸãããªããã UCS-4 ãžã®ãã«ã¢ã¯ã»ã¹ãäžããŸããæ¢åã® API ãšã®äºææ§ã®ããã«è€æ°ã®è¡šçŸã䞊è¡ã§ååšããããšã«ãªããŸãããåŸã ã«ãã®äºææ§ã¯ãªããããŠããã¯ãã§ãã
Python åŽã«ã¯ãã®å€æŽã«ããäžéœåã¯äœããªãã¯ãã§ãã
C API åŽã§ã¯ PEP 393 ã¯å®å šã«åŸæ¹äºæã§ããã¬ã¬ã·ãŒãª API ã¯æäœ 5 å¹Žã¯æ®ãããã¯ãã§ããã¬ã¬ã·ãŒ API ã䜿ãã¢ããªã±ãŒã·ã§ã³ã¯ã¡ã¢ãªåæžã®å¹èœãå®å šã«ã¯åŸãããªããããããã¯ææªã®å Žåã«ã¯å°ãäœèšãªã¡ã¢ãªã䜿ããããããŸããããã㯠Python ãããããã®æååã®äºã€ã®ããŒãžã§ã³ (ã¬ã¬ã·ãŒãªãã©ãŒããããšæ°ããå¹ççãªæ ŒçŽæ¹æ³) ãç¶æããå¿ èŠããããããããªãããã§ã
æ©èœæ§Â¶
PEP 393 ã§ãªããã倿Žã¯ä»¥äžã®éãã§ã:
Python ã¯ä»ãé BMP é¢ã®æåãå«ã Unicode ã³ãŒããã€ã³ãã®å®å šãªç¯å² (ã€ãŸã
U+0000ããU+10FFFFãŸã§) ãåžžã«ãµããŒãããŸããnarrow ãã«ã / wide ãã«ããšããåºå¥ã¯ä»ã§ã¯ååšããŠããªããããPython ã¯ä»ã§ã¯ãã€ã§ããã€ãŠã® wide ãã«ãã®ããã«æ¯ãèããWindows ã§ãããã¯äŸå€ã§ã¯ãããŸãããnarrow ãã«ããšã®æ±ºå¥ã¯ãããã«ä»ãç©ã ã£ãåé¡ã解決ããŸãããäŸãã°:
len()ã¯ä»ã§ã¯é BMP 颿åã«ã€ããŠå¿ ã 1 ãè¿ããŸããã€ãŸãlen('\U0010FFFF') == 1ã§ã;ãµãã²ãŒããã¢ãæååãªãã©ã«å ã§åçµåãããããšã¯ãããŸãããã€ãŸã
'\uDBFF\uDFFF' != '\U0010FFFF'ã§ã;é BMP 颿åãæãã€ã³ãã¯ã¹ãã¹ã©ã€ã¹ã¯æåŸ éãã®å€ãè¿ããŸããã€ãŸã
'\U0010FFFF'[0]ã¯ä»ã§ã¯'\uDBFF'ã§ã¯ãªã'\U0010FFFF'ãè¿ããŸã;ã»ãã®å šãŠã®æšæºã©ã€ãã©ãªé¢æ°ãä»ã§ã¯æ£ããé BMP ã³ãŒããã€ã³ããåŠçããŸãã
sys.maxunicodeã®å€ã¯ä»ããã€ã§ã1114111(åå é²ã§0x10FFFF) ã§ããåŸæ¹äºææ§ã®ããã« C API ã®PyUnicode_GetMax()颿°ã¯ä»ã§ã0xFFFFã0x10FFFFã®ã©ã¡ãããè¿ãããã«ãªã£ãŠã¯ããŸãããæ°ãã Unicode API ãšãšãã«ã¯äœ¿ã£ãŠã¯ãããŸãã (see bpo-13054)ã./configureã¹ã¯ãªããã®ãã©ã°--with-wide-unicodeã¯åé€ãããŸããã
æ§èœããã³ãªãœãŒã¹äœ¿çšé¶
Unicode æååã®èšæ¶åãµã€ãºãæååå ã®ã³ãŒããã€ã³ãæå€§å€ã«äŸåããããã«ãªã£ããšããããšã§ã:
çŽç²ãª ASCII ãš Latin1 æåå (
U+0000-U+00FF) ã¯ã³ãŒããã€ã³ãããšã« 1 ãã€ããå ããŸã;BMP æåå (
U+0000-U+FFFF) ã¯ã³ãŒããã€ã³ãããšã« 2 ãã€ããå ããŸã;é BMP æåå (
U+10000-U+10FFFF) ã¯ã³ãŒããã€ã³ãããšã« 4 ãã€ããå ããŸãã
çµå±ã®ãšããã»ãšãã©ã®ã¢ããªã±ãŒã·ã§ã³ã«ãšã£ãŠã®ããã®å¹èœã¯ãæååèšæ¶ã®ããã®ã¡ã¢ãªäœ¿çšéãæ¿æžããããšã§ãããã¯ä»¥åã® wide unicode ãã«ããšæ¯èŒããŠé¡èã§ããããã¯å€ãã®å Žåãã€ã³ã¿ãŒãã·ã§ãã«ãªæèã§ãã£ãŠããªãçŽç²ãª ASCII ã䜿ãããã§ãããããšã«é¢ä¿ããããŸãã(ãšããã®ãå€ãã®æååã人éåãã§ãªãèšèªãšããŠæ ŒçŽãããããã§ããäŸãã° XML ãã©ã°ã¡ã³ãã HTTP ããããJSON ãšã³ã³ãŒããããããŒã¿ããªã©ãªã©ã)åãçç±ããã倧ããªã¢ããªã±ãŒã·ã§ã³ã§ CPU ãã£ãã·ã¥æŽ»çšå¹çãé«ããã§ãããããšãæåŸ åºæ¥ãŸããPython 3.3 ã®ã¡ã¢ãªäœ¿çšã¯ Python 3.2 ã® 2 åãã 3 åå°ããããŸããPython 2.7 ãããå°ãè¯ãããšã Django ãã³ãããŒã¯ã§ããã£ãŠããŸã (詳现㯠PEP ãã¿ãŠãã ãã)ã
åè
- PEP 393 - æååã®æè»ãªè¡šçŸ (Flexible String Representation)
PEP written by Martin von Löwis; implementation by Torsten Becker and Martin von Löwis.
PEP 397: Windows ã® Python ã©ã³ãã£Â¶
Python 3.3 ã® Windows ã€ã³ã¹ããŒã©ããã©ã³ãã£ã¢ããªã±ãŒã·ã§ã³ã® py ãã€ã³ã¹ããŒã«ããããã«ãªããŸããããã㯠Python ãããŒãžã§ã³ã«äŸåããªãæ¹æ³ã§èµ·åããã®ã«äœ¿ãããŸãã
ã©ã³ãã£ã¯ *.py ãã¡ã€ã«ãããã«ã¯ãªãã¯ãããšæé»ã®ãã¡ã«åŒã³åºãããŸããã·ã¹ãã ã«ã€ã³ã¹ããŒã«ãããŠããã®ãåäžã® Python ããŒãžã§ã³ã§ããã°ããã®ããŒãžã§ã³ããã¡ã€ã«ã®å®è¡ã«äœ¿ãããŸããè€æ°ããŒãžã§ã³ãã€ã³ã¹ããŒã«ãããŠããã°ããã©ã«ãã§ã¯ææ°ããŒãžã§ã³ã䜿ãããŸãããPython ã¹ã¯ãªããå
ã§ Unix ã¹ã¿ã€ã«ã®ãshebang è¡ ( #! )ããå«ããããšã§ãªãŒãã©ã€ãåºæ¥ãŸãã
ã©ã³ãã£ã¯æç€ºçã«ã³ãã³ãã©ã€ã³ãã py ã¢ããªã±ãŒã·ã§ã³ãšããŠäœ¿ãããšãåºæ¥ãŸãã py ã®å®è¡ã¯æé»ã«ã¹ã¯ãªãããèµ·åããããŒãžã§ã³éžæã®ã«ãŒã«ã«åŸããŸãããäžããã³ãã³ãã©ã€ã³åŒæ°ã«ããçã£ãããŒãžã§ã³ãéžæåºæ¥ãŸã (ããšãã° -3 㯠Python 2 ãã€ã³ã¹ããŒã«ãããŠããéã« Python 3 ãèŠæ±ãã -2.6 ã¯ãã£ãšæ°ããããŒãžã§ã³ãã€ã³ã¹ããŒã«ãããŠããå Žåã«ç¹å®ã®å€ãããŒãžã§ã³ãèŠæ±ããŸã)ã
ã©ã³ãã£ã«å ããWindows ã€ã³ã¹ããŒã©ã«ã¯æ°ããã€ã³ã¹ããŒã«ãã Python ãã·ã¹ãã ã® PATH ã«è¿œå ãããªãã·ã§ã³ãå«ãŸããããã«ãªããŸããã (Contributed by Brian Curtin in bpo-3561.)
åè
- PEP 397 - Python Launcher for Windows
PEP written by Mark Hammond and Martin v. Löwis; implementation by Vinay Sajip.
ã©ã³ãã£ã®ããã¥ã¡ã³ã: Python install manager
ã€ã³ã¹ããŒã© PATH ã®èª¿æŽ: Python install manager
PEP 3151: OS ããã³ IO äŸå€éå±€ã®æçŽã¶
OS ãšã©ãŒãéåºããäŸå€ã®éå±€ãåçŽåãããç²åºŠãäžããããŸããã
You don't have to worry anymore about choosing the appropriate exception
type between OSError, IOError, EnvironmentError,
WindowsError, mmap.error, socket.error or
select.error. All these exception types are now only one:
OSError. The other names are kept as aliases for compatibility
reasons.
ãŸããç¹å®ã®ãšã©ãŒæ¡ä»¶ãææããã®ã容æã«ãªããŸããã
errno 屿§ (ãŸã㯠args[0]) ã®ç¹å®ã®å®æ°ã errno ã¢ãžã¥ãŒã«ãã調ã¹ã代ããã«ãé©å㪠OSError 掟çã¯ã©ã¹ãææããããšãåºæ¥ãŸãã
å©çšå¯èœãªæŽŸçã¯ã©ã¹ã¯ä»¥äžã®éãã§ã:
ConnectionError èªèº«ã«ã¯çްããªæŽŸçã¯ã©ã¹ããããŸã:
æ°ããªäŸå€ã®ãããã§ errno ã®äžè¬çãªäœ¿ãæ¹ãé¿ããããšãåºæ¥ãŸãã
äŸãã°ãPython 3.2 åãã«æžããã以äžã®ã³ãŒã:
from errno import ENOENT, EACCES, EPERM
try:
with open("document.txt") as f:
content = f.read()
except IOError as err:
if err.errno == ENOENT:
print("document.txt file is missing")
elif err.errno in (EACCES, EPERM):
print("You are not allowed to read document.txt")
else:
raise
㯠errno ãã€ã³ããŒããããæåã§äŸå€å±æ§ã調ã¹ããããã«æžãããšãåºæ¥ãŸã:
try:
with open("document.txt") as f:
content = f.read()
except FileNotFoundError:
print("document.txt file is missing")
except PermissionError:
print("You are not allowed to read document.txt")
åè
- PEP 3151 - Reworking the OS and IO Exception Hierarchy
PEP written and implemented by Antoine Pitrou
PEP 380: ãµããžã§ãã¬ãŒã¿ãžã®å§è²æ§æÂ¶
PEP 380 㯠yield from åŒã远å ããŸãããã㯠ãžã§ãã¬ãŒã¿ ã«ããã®æäœã®äžéšãã»ãã®ãžã§ãã¬ãŒã¿ã«å§è²ããããã®åŒã§ããããã«ãã£ãŠ yield ãå«ãã§ããã³ãŒãã®ã»ã¯ã·ã§ã³ãã»ãã®ãžã§ãã¬ãŒã¿ã«ç§»ååºæ¥ãã§ããããå ããŠãµããžã§ãã¬ãŒã¿ã¯å€ã䌎ã£ãŠæ»ãããšãåºæ¥ããã®æ»ãå€ã¯å§è²ããåŽã®ãžã§ãã¬ãŒã¿ã§äœ¿ããŸãã
yield from åŒããã¶ã€ã³ãããäž»ããåæ©ã¯ãµããžã§ãã¬ãŒã¿ãžã®å§è²ãšããŠäœ¿ãããšã§ã¯ãããŸãããå®éã«ã¯ä»»æã®ãµãã€ãã¬ãŒã¿ã«å§è²ããããšãåºæ¥ãŸãã
åçŽãªã€ãã¬ãŒã¿ã«å¯ŸããŠã yield from iterable ã¯æ¬è³ªçã«ã¯ for item in iterable: yield item ãžã®åãªãéèšæ³ã§ã:
>>> def g(x):
... yield from range(x, 0, -1)
... yield from range(x)
...
>>> list(g(5))
[5, 4, 3, 2, 1, 0, 1, 2, 3, 4]
ã§ããæ®éã®ã«ãŒããšã¯éã£ãŠ yield from ã§ã¯ãµããžã§ãã¬ãŒã¿ã¯ãåŒã³åºãåŽã¹ã³ãŒããã send() ãããã throw() ãããå€ãçŽæ¥åãåãããšãã§ãããŸããå€åŽã®ãžã§ãã¬ãŒã¿ã«æçµçãªå€ãè¿ããŸã:
>>> def accumulate():
... tally = 0
... while 1:
... next = yield
... if next is None:
... return tally
... tally += next
...
>>> def gather_tallies(tallies):
... while 1:
... tally = yield from accumulate()
... tallies.append(tally)
...
>>> tallies = []
>>> acc = gather_tallies(tallies)
>>> next(acc) # Ensure the accumulator is ready to accept values
>>> for i in range(4):
... acc.send(i)
...
>>> acc.send(None) # Finish the first tally
>>> for i in range(5):
... acc.send(i)
...
>>> acc.send(None) # Finish the second tally
>>> tallies
[6, 10]
ãã®å€æŽãæšãé²ããäžçªæ¬è³ªã«ãã£ããã®ã¯ãããšã send ã¡ãœããã throw ã¡ãœãããšãšãã«äœ¿ãããããšãåæã«èšèšããããžã§ãã¬ãŒã¿ã§ãã£ãŠãã倧ããªé¢æ°ãè€æ°ã®ãµã颿°ã«åå²ããã®ãšåããããã«ããžã§ãã¬ãŒã¿ãç°¡åã«è€æ°ã®ãµããžã§ãã¬ãŒã¿ã«åå²åºæ¥ãããã«ããããšã§ããã
åè
- PEP 380 - ãµããžã§ãã¬ãŒã¿ãžã®å§è²æ§æ
PEP written by Greg Ewing; implementation by Greg Ewing, integrated into 3.3 by Renaud Blanch, Ryan Kelly and Nick Coghlan; documentation by Zbigniew JÄdrzejewski-Szmek and Nick Coghlan
PEP 409: äŸå€ã³ã³ããã¹ãã®æå¶Â¶
PEP 409 ã¯ããã§ã€ã³ãããäŸå€ã³ã³ããã¹ãã®è¡šç€ºãç¡å¹ã«ããããã®æ°æ§æãå°å ¥ããŸããããã䜿ãã°äŸå€ç¿»èš³ããŠæãçŽããããªã¢ããªã±ãŒã·ã§ã³ã§ããšã©ãŒã¡ãã»ãŒãžãããããããããããšãåºæ¥ãŸã:
>>> class D:
... def __init__(self, extra):
... self._extra_attributes = extra
... def __getattr__(self, attr):
... try:
... return self._extra_attributes[attr]
... except KeyError:
... raise AttributeError(attr) from None
...
>>> D({}).x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 8, in __getattr__
AttributeError: x
å
ãšãªãèŠå äŸå€ãæå¶ãã from None ãåŸçœ®ããªããã°ãããšã®äŸå€ã¯ããã©ã«ãã§è¡šç€ºãããŸã:
>>> class C:
... def __init__(self, extra):
... self._extra_attributes = extra
... def __getattr__(self, attr):
... try:
... return self._extra_attributes[attr]
... except KeyError:
... raise AttributeError(attr)
...
>>> C({}).x
Traceback (most recent call last):
File "<stdin>", line 6, in __getattr__
KeyError: 'x'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 8, in __getattr__
AttributeError: x
æå¶ããããšã§ãããã°èœåã倱ããããšããããã§ã¯ãªããŠãå ã ã®äŸå€ã³ã³ããã¹ãã¯å©çšå¯èœãªãŸãŸã§ãã(äŸãã°ä»åšããã©ã€ãã©ãªãæçãªèåŸã®è©³çްãäžé©åã«é ããŠããŸã£ãŠãããªã©ãå¿ èŠãªå Žåã¯ããã§ãããã)
>>> try:
... D({}).x
... except AttributeError as exc:
... print(repr(exc.__context__))
...
KeyError('x',)
åè
- PEP 409 - äŸå€ã³ã³ããã¹ãã®æå¶
PEP written by Ethan Furman; implemented by Ethan Furman and Nick Coghlan.
PEP 414: æç€ºçãªãŠãã³ãŒããªãã©ã«Â¶
Unicode ãæèãã Python ã¢ããªã±ãŒã·ã§ã³ã Python 2 ã§ Unicode ãªãã©ã«ãå€çšããŠãããšããŠã Python 3 ãžã®ç§»è¡ã容æã«ããããã«ãPython 3.3 ã§ã¯æååãªãã©ã«ãžã® "u" å眮ãåã³ãµããŒãããããšã«ããŸããããã®å眮㯠Python 3 èªèº«ã§ã¯äœãã®æå³ãæã¡ã¯ãããPython 3 ãžã®ç§»è¡ã«ãããŠçŽç²ãªæ©æ¢°ç倿ŽãèŠããäºé
ãåã«æžããããã ãã®ããã«æäŸãããŸããéçºè
ã¯ãã£ãšéèŠãªæå³çå€æŽ (ããšãã°ãã€ããªãšããã¹ãã®å³å¯ãªåºå¥) ã«éäžãã¹ããªã®ã§ãã
åè
- PEP 414 - æç€ºçãªãŠãã³ãŒããªãã©ã«
PEP written by Armin Ronacher.
PEP 3155: ã¯ã©ã¹ãšé¢æ°ã®æ£èŠå¶
Functions and class objects have a new __qualname__
attribute representing
the "path" from the module top-level to their definition. For global functions
and classes, this is the same as __name__.
For other functions and classes,
it provides better information about where they were actually defined, and
how they might be accessible from the global scope.
(æçžãããŠããªã) ã¡ãœããã§ã®äŸ:
>>> class C:
... def meth(self):
... pass
...
>>> C.meth.__name__
'meth'
>>> C.meth.__qualname__
'C.meth'
å ¥ãåã®ã¯ã©ã¹ã§ã®äŸ:
>>> class C:
... class D:
... def meth(self):
... pass
...
>>> C.D.__name__
'D'
>>> C.D.__qualname__
'C.D'
>>> C.D.meth.__name__
'meth'
>>> C.D.meth.__qualname__
'C.D.meth'
å ¥ãåã®é¢æ°ã®äŸ:
>>> def outer():
... def inner():
... pass
... return inner
...
>>> outer().__name__
'inner'
>>> outer().__qualname__
'outer.<locals>.inner'
ããããªããžã§ã¯ãã®æåå衚çŸãããã®æ°ãããŠããæ£ç¢ºãªæ å ±ãå«ãããã«å€æŽãããŠããŸã:
>>> str(C.D)
"<class '__main__.C.D'>"
>>> str(C.D.meth)
'<function C.D.meth at 0x7f46b9fe31e0>'
åè
- PEP 3155 - ã¯ã©ã¹ãšé¢æ°ã®æ£èŠå (qualified name)
PEP written and implemented by Antoine Pitrou.
PEP 412: ããŒå ±æèŸæžÂ¶
ãªããžã§ã¯ã屿§ãèšæ¶ããã®ã«äœ¿ãããèŸæžããå éšèšæ¶åã®äžéš (ããŒãšããã«å¯Ÿå¿ããããã·ã¥å€) ãäºãã«å ±æåºæ¥ãããã«ãªããŸãããããã«ãããçµã¿èŸŒã¿ã§ãªãåã®ã€ã³ã¹ã¿ã³ã¹ãããããäœãããã°ã©ã ã®ã¡ã¢ãªæ¶è²»ãå°ãªããªããŸãã
åè
- PEP 412 - ããŒå ±æèŸæž
PEP written and implemented by Mark Shannon.
PEP 362: 颿°ã·ã°ããã£ãªããžã§ã¯ã¶
æ°ãã«è¿œå ããã颿° inspect.signature() ã¯ãPython åŒã³åºãå¯èœãªããžã§ã¯ã (callable) ã調ã¹ãããšãç°¡åã§çŽæ¥çãªãã®ã«ããŠãããŸããå¹
åºã callable ããµããŒãããŠããŸã:ãã³ã¬ãŒããããŠãããã©ããã«ããã颿°ãã¯ã©ã¹ã functools.partial() ãªããžã§ã¯ããæ°ãã«è¿œå ãããã¯ã©ã¹çŸ€ inspect.Signature, inspect.Parameter, inspect.BoundArguments ã¯ãã¢ãããŒã·ã§ã³ãããã©ã«ãå€ããã©ã¡ãŒã¿ã®çš®é¡ãæçžãããŠããåŒæ°ãªã©ã®ãããªåŒã³åºãã·ã°ããã£ã«ã€ããŠã®æ
å ±ãä¿æããããã«ãã£ãŠããã³ã¬ãŒã¿ãæžããããããã¯åŒã³åºãã·ã°ããã£ãåŒæ°ãæ€èšŒãããæ¹èšãããããã³ãŒããæžãããšããéåžžã«åçŽã«ãªããŸãã
åè
- PEP 362: - 颿°ã·ã°ããã£ãªããžã§ã¯ã
PEP written by Brett Cannon, Yury Selivanov, Larry Hastings, Jiwon Seo; implemented by Yury Selivanov.
PEP 421: sys.implementation ã®è¿œå ¶
sys ã¢ãžã¥ãŒã«ã«æ°èŠå±æ§ã远å ãããããã¯çŸåšåäœäžã®ã€ã³ã¿ãŒããªã¿å®è£
ã«åºæã®è©³çްãå
¬éããŸãããã® sys.implementation 屿§ã®æå§ãã®éåãšããŠã name, version, hexversion, cache_tag ãå®çŸ©ãããŠããŸãã
sys.implementation ã®çæã¯ãæšæºã©ã€ãã©ãªã«ãã£ãŠå©çšãããå®è£
åºæã®æ
å ±ãäžã€ã®åå空éã§äžå
管çããããšã«ãããŸãããã®ããšã«ããç°ãªã Python å®è£
ãåäžã®æšæºã©ã€ãã©ãªã®ã³ãŒãããŒã¹ãå
±æããããšãããã£ãšãã£ãšç°¡åã«ãªããŸãã仿ç¹ã§ã®åæç¶æ
ã§ã¯ sys.implementation ã¯å®è£
åºæããŒã¿ã®ããäžéšãä¿æããŠããã ãã§ããæšæºã©ã€ãã©ãªã®ç§»æ€æ§ããã£ãšé«ããªãããã«ãåŸã
ã«ãã®æ¯çãå€ãã£ãŠããã§ãããã
æšæºã©ã€ãã©ãªã®ç§»æ€æ§ãæ¹åããäžäŸã cache_tag ã§ããPython 3.3 以é㯠sys.implementation.cache_tag ã PEP 3147 ããµããŒãããããã« importlib ã«ãã䜿ãããŸããçµã¿èŸŒã¿ã®ã€ã³ããŒãã·ã¹ãã ã®ããã« importlib ã䜿ãå
šãŠã® Python å®è£
ããã¢ãžã¥ãŒã«ã®ãã£ãã·ã¥ã®æ¯ãèããå¶åŸ¡ããã®ã« cache_tag ãå©çšã§ããŸãã
SimpleNamespace¶
sys.implementation ã®å®çŸã«äŒŽã£ãŠ Python ã«æ°ããªå types.SimpleNamespace ãå°å
¥ãããããšãšãªããŸããã dict ã®ãããªãããã³ã°ããŒã¹ã®åå空éãšã¯å¯Ÿç
§çã«ã SimpleNamespace 㯠object ã®ãããªå±æ§ããŒã¹ã§ããã§ãã object ãšã¯éã£ãŠ SimpleNamespace ã€ã³ã¹ã¿ã³ã¹ã¯æžã蟌ã¿å¯èœã§ããã€ãŸãæ®éã®å±æ§ã¢ã¯ã»ã¹ãéããŠåå空éã«è¿œå ãããåé€ãããä¿®æ£ãããã§ããŸãã
åè
- PEP 421 - sys.implementation ã®è¿œå
PEP written and implemented by Eric Snow.
ã€ã³ããŒãå®è£ ãšããŠã® importlib ã®äœ¿çšÂ¶
bpo-2377 - Replace __import__ w/ importlib.__import__
bpo-13959 - Re-implement parts of imp in pure Python
bpo-14605 - Make import machinery explicit
bpo-14646 - Require loaders set __loader__ and __package__
__import__() 颿°ã importlib.__import__() ã«ãã£ãŠå®çŸããããã«ããŸããããã㯠PEP 302 ã®ãç¬¬äºæ®µéããå®äºããããã®ã§ãããã®å€æŽã«ã¯è€æ°ã®æ©æµããããŸãããŸãæåã«ããã¯ã€ã³ããŒãã®æ©æ§ããC ã³ãŒãã®å¥¥æ·±ãã§æé»ã«ç§å¯è£ã«è¡ãã®ã§ã¯ãªããããéæåããŸãããã®ããšã§ãPython 3.3 ããµããŒãããå
šãŠã® Python VM ã§åäžã®å®è£
ãçšããããšãåºæ¥ãããã«ãªããã€ã³ããŒãã®ã»ãã³ãã£ã¯ã¹ã«ããã VM åºæã®éžè±ãšæ±ºå¥ããå©ããšããªããŸãããããŠããã¯ã€ã³ããŒãæ©æ§ã®ä¿å®ããã容æãšããå°æ¥èµ·ããããé²åãä¿ããŸãã
äžè¬ã®ãŠãŒã¶ã«ãšã£ãŠã¯ãã»ãã³ãã£ã¯ã¹ã«ãããŠç®ã«èŠããå€åã¯ãªãã¯ãã§ãã仿ç¹ã§ã€ã³ããŒããæäœãããã€ã³ããŒãåŒã³åºããããã°ã©ã çã«è¡ã£ãŠããå Žåã¯ããã®ããã¥ã¡ã³ãã® Python ã³ãŒãã®ç§»æ€ ã§ã«ããŒããŠããã³ãŒãã®ä¿®æ£ãå¿ èŠã«ãªããããããŸããã
æ°ã㪠API¶
ãã®å€æŽã«ããäžçªå€§ããªæ©æµã®äžã€ã¯ãã€ã³ããŒãæã®åäœã«äœãä»åšããã®ãã«ã€ããŠé²ã«ãªã£ãããšã§ããã€ãŸããã€ãŠã¯æ§ã
ãªã€ã³ããŒã¿ãæé»ã§è¡ã£ãŠããããšããä»ã§ã¯å®å
šã« importlib ããã±ãŒãžã®äžéšãšããŠå
¬éãããŠããŸãã
The abstract base classes defined in importlib.abc have been expanded
to properly delineate between meta path finders
and path entry finders by introducing
importlib.abc.MetaPathFinder and
importlib.abc.PathEntryFinder, respectively. The old ABC of
importlib.abc.Finder is now only provided for backwards-compatibility
and does not enforce any method requirements.
In terms of finders, importlib.machinery.FileFinder exposes the
mechanism used to search for source and bytecode files of a module. Previously
this class was an implicit member of sys.path_hooks.
ããŒã (loader) ã«ã€ããŠã¯ãæ°èŠã®æœè±¡åºåºã¯ã©ã¹ importlib.abc.FileLoader ããã¢ãžã¥ãŒã«ã®ã³ãŒããæ ŒçŽããæ©æ§ãšããŠã®ãã¡ã€ã«ã·ã¹ãã ã䜿ãããŒããæžãå©ããšãªããŸãããœãŒã¹ãã¡ã€ã«ã®ããŒã (importlib.machinery.SourceFileLoader)ããœãŒã¹ãæããªããã€ãã³ãŒãã®ããã®ããŒã (importlib.machinery.SourcelessFileLoader)ããããŠæ¡åŒµã¢ãžã¥ãŒã«ã®ããã®ããŒã (importlib.machinery.ExtensionFileLoader) ãä»ã§ã¯çŽæ¥çã«å©çšåºæ¥ãŸãã
ImportError ã«ã¯å±æ§ name ãš path ã远å ãããŠãããã«ã¯æäŸãã¹ãé¢é£ããŒã¿ãããå Žåã«ã»ãããããŸããã€ã³ããŒã倱ææã®ã¡ãã»ãŒãžãããããŸã§ã®ããã«ã¢ãžã¥ãŒã«åã®æ«å°Ÿã ããäžããã®ã§ã¯ãªããã¢ãžã¥ãŒã«ã®å®å
šåãæäŸããããã«ãªããŸããã
The importlib.invalidate_caches() function will now call the method with
the same name on all finders cached in sys.path_importer_cache to help
clean up any stored state as necessary.
ç®ã«èŠããå€å¶
æœåšçã«å¿ èŠãšãªããããããªãã³ãŒãä¿®æ£ã«ã€ããŠã¯ã Python ã³ãŒãã®ç§»æ€ ã»ã¯ã·ã§ã³ãåç §ããŠãã ããã
importlib ã«ãã£ãŠå
¬éããããã®ãæ¡ãã£ãããšã«ãããã€ã³ããŒãã«ã€ããŠã®ã»ãã®ç®ã«èŠããå€åããããŸããæå€§ã®å€å㯠sys.meta_path ãš sys.path_hooks ããã€ã³ããŒãã§äœ¿ããã meta path finder ãš path entry hook ã®å
šãŠãæ ŒçŽããããã«ãªã£ãããšã§ãã以åã¯ãã¡ã€ã³ãã¯çŽæ¥çã«å
¬éãããã®ã§ã¯ãªããã€ã³ããŒãã® C ã³ãŒãå
ã«æé»ã®ãã®ãšããŠé ãããŠããŸããããã®ããšã«ãã£ãŠãä»ã§ã¯æãã°èŠä»¶ã«åããããã¡ã€ã³ããåãé€ãããé åºãå€ããããšãã£ãããšãç°¡åã«è¡ããããã«ãªã£ãŠããŸãã
ããäžã€ã®å€åã¯ãã¢ãžã¥ãŒã«çææã«äœ¿ãããããŒããæ ŒçŽãã __loader__ 屿§ããå
šãŠã®ã¢ãžã¥ãŒã«ãæã€ããã«ãªã£ãããšã§ãã PEP 302 ã¯ããŒãã®å®è£
ã«ãããŠãã®å±æ§ãã»ããããããšãå¿
é ãšããããæŽæ°ãããŸãããã§ãã®ã§ä»åŸãµãŒãããŒãã£ã®ããŒããæŽæ°ãããã°ããã®å±æ§ã®ååšã«äŸååºæ¥ãããã«ãªããŸããã§ãããã®ãšããæ¥ããŸã§ã¯ãã€ã³ããŒãåŠçãã¢ãžã¥ãŒã«ã®ããŒãã®åŸåŠçãšããŠã»ããããŸãã
ããã«ããŒãã PEP 366 ããã® __package__ 屿§ãèšå®ããããšãæåŸ
åºæ¥ãããã«ãªããŸãããç¹°ãè¿ãã«ãªããŸããã€ã³ããŒãåŠçèªèº«ãæ¢ã«ãããå
šãŠã®ããŒãã§ importlib ããè¡ã£ãŠããŠããŸããã€ã³ããŒãåŠçèªèº«ããã®å±æ§ãããŒãã®åŸåŠçãšããŠã»ããããŠããŸãã
None is now inserted into sys.path_importer_cache when no finder
can be found on sys.path_hooks. Since imp.NullImporter is not
directly exposed on sys.path_hooks it could no longer be relied upon to
always be available to use as a value representing no finder found.
å šãŠã®ã»ãã®å€æŽã¯ãPython 3.3 ãžã®ã³ãŒãã®æŽæ°ã®éã«èæ ®ãã¹ãã»ãã³ãã£ã¯ã¹ã®å€æŽã«é¢ä¿ããŠããŸããã§ãã®ã§ãããã«ã€ããŠããã®ããã¥ã¡ã³ãã® Python ã³ãŒãã®ç§»æ€ ã»ã¯ã·ã§ã³ãèªãã¹ãã§ãã
(Implementation by Brett Cannon)
ãã®ä»ã®èšèªå€æŽÂ¶
Python èšèªã³ã¢ã«å°ããªå€æŽãããã€ãè¡ãããŸãã:
Added support for Unicode name aliases and named sequences. Both
unicodedata.lookup()and'\N{...}'now resolve name aliases, andunicodedata.lookup()resolves named sequences too.(Contributed by Ezio Melotti in bpo-12753.)
Unicode ããŒã¿ããŒã¹ã UCD ããŒãžã§ã³ 6.1.0 ã«ã¢ããã°ã¬ãŒãããŸããã
range()ãªããžã§ã¯ãã©ããã®ç倿§æ¯èŒããããããã® range ãªããžã§ã¯ãã«ãã£ãŠçæãããã·ãŒã±ã³ã¹ã®ç倿§ãåæ ããŠè¡ãããããã«ãªããŸãã (bpo-13201)ãbytesãšbytearrayãªããžã§ã¯ãã®ã¡ãœããcount(),find(),rfind(),index(),rindex()ãã第äžåŒæ°ã« 0 ãã 255 ã®æŽæ°ãåãä»ããããã«ãªããŸããã(Contributed by Petri Lehtinen in bpo-12170.)
bytesãšbytearrayãªããžã§ã¯ãã®ã¡ãœããrjust(),ljust(),center()ããfillåŒæ°ãšããŠbytearrayãåãä»ããããã«ãªããŸãã (Contributed by Petri Lehtinen in bpo-12380.)ãNew methods have been added to
listandbytearray:copy()andclear()(bpo-10516). Consequently,MutableSequencenow also defines aclear()method (bpo-11388).raw bytes ãªãã©ã«ãšããŠ
br"..."ã ãã§ãªãrb"..."ãšãæžããããã«ãªããŸããã(Contributed by Antoine Pitrou in bpo-13748.)
dict.setdefault()ãäžããããããŒã®ã«ãã¯ã¢ãããäžåºŠããè¡ããªãããã«ãªã£ãã®ã§ãçµã¿èŸŒã¿åã§ã®ããã®äœ¿çšã¯ã¢ãããã¯ã«ãªããŸãã(蚳泚: å€éšèгå¯å¯èœãªå€åã§èª¬æãããšã以åã¯ãã®åŒã³åºãããããŒã®2åã® __hash__ã__eq__ åŒã³åºããåŒãèµ·ãããŠãããã®ãã1åã«ãªã£ãã)(Contributed by Filip GruszczyÅski in bpo-13521.)
颿°åŒã³åºãã颿°ã·ã°ããã£ã«åèŽããªãå Žåã®ãšã©ãŒã¡ãã»ãŒãžãããªãæ¹åãããŸããã
(Contributed by Benjamin Peterson.)
现ç²åºŠã®ã€ã³ããŒãããã¯Â¶
Previous versions of CPython have always relied on a global import lock.
This led to unexpected annoyances, such as deadlocks when importing a module
would trigger code execution in a different thread as a side-effect.
Clumsy workarounds were sometimes employed, such as the
PyImport_ImportModuleNoBlock() C API function.
Python 3.3 ã§ã¯ã¢ãžã¥ãŒã«ã®ã€ã³ããŒãã§ã¯ãã¢ãžã¥ãŒã«åäœã§ã®ããã¯ãæ¡çšããŠããŸãããã®ããšã«ãã£ãŠè€æ°ã¹ã¬ããããã®æå®ã¢ãžã¥ãŒã«ã®ã€ã³ããŒã㯠(ã¢ãžã¥ãŒã«ãäžå®å šãªåæåã®ãŸãŸæãããã®ãé²ãã§) æ£ããçŽååãããŠãåè¿°ã®é çã®çš®ã¯åãé€ãããŠããŸãã
(Contributed by Antoine Pitrou in bpo-9260.)
çµã¿èŸŒã¿ã®é¢æ°ãšå¶
open()gets a new opener parameter: the underlying file descriptor for the file object is then obtained by calling opener with (file, flags). It can be used to use custom flags likeos.O_CLOEXECfor example. The'x'mode was added: open for exclusive creation, failing if the file already exists.print(): flush ããŒã¯ãŒãåŒæ°ã远å ãããŸãããflush ããŒã¯ãŒãåŒæ°ãçã®å Žåã¹ããªãŒã ã¯åŒ·å¶çã«ãã©ãã·ã¥ãããŸããhash(): ããã·ã¥ã®ã©ã³ãã åãããã©ã«ãã§æå¹ã«ãªããŸãããobject.__hash__()ãšç°å¢å€æ°PYTHONHASHSEEDãåç §ããŠãã ãããstråã«casefold()ã¡ãœããã远å ãããŸãããæååã® casefold ãããã³ããŒãè¿ããŸããcasefold ãããæååã¯ã倧æåå°æåã«é¢ä¿ãªããããã«äœ¿ããŸããäŸãã°'Ã'.casefold()ã¯'ss'ãè¿ããŸããã·ãŒã±ã³ã¹ã«ã€ããŠã®ããã¥ã¡ã³ããå€§å¹ ã«æžãæããŸããããã€ããªã®ã·ãŒã±ã³ã¹ãšããã¹ãã®ã·ãŒã±ã³ã¹ã«ã€ããŠã®åºå¥ã«ã€ããŠããè¯ã説æãå ãããŸããåã ã®çµã¿èŸŒã¿ã·ãŒã±ã³ã¹ã«é¢ããŠåå¥ã®ããã¥ã¡ã³ããæäŸããŠããŸã (bpo-4966)ã
æ°ããªã¢ãžã¥ãŒã«Â¶
faulthandler¶
This new debug module faulthandler contains functions to dump Python tracebacks explicitly,
on a fault (a crash like a segmentation fault), after a timeout, or on a user
signal. Call faulthandler.enable() to install fault handlers for the
SIGSEGV, SIGFPE, SIGABRT,
SIGBUS, and SIGILL signals.
You can also enable them at startup by setting the PYTHONFAULTHANDLER
environment variable or by using -X faulthandler command line option.
Linuxã§ã®ã»ã°ã¡ã³ããŒã·ã§ã³ãã©ãŒã«ãæã®äŸ:
$ python -q -X faulthandler
>>> import ctypes
>>> ctypes.string_at(0)
Fatal Python error: Segmentation fault
Current thread 0x00007fb899f39700:
File "/home/python/cpython/Lib/ctypes/__init__.py", line 486 in string_at
File "<stdin>", line 1 in <module>
Segmentation fault
ipaddress¶
æ°èŠã¢ãžã¥ãŒã« ipaddress ã¯ãIPv4/IPv6 ã¢ãã¬ã¹ããããã¯ãŒã¯ãã€ã³ã¿ãŒãã§ãŒã¹ (ããªãã¡åºæã® IP ãµããããã§é¢é£ä»ãããã IP ã¢ãã¬ã¹) ã衚çŸãããªããžã§ã¯ããçæãããå å·¥ãããããããã®éå
·ç«ãŠãæäŸããŸãã
(Contributed by Google and Peter Moody in PEP 3144.)
lzma¶
The newly added lzma module provides data compression and decompression
using the LZMA algorithm, including support for the .xz and .lzma
file formats.
(Contributed by Nadeem Vawda and Per Ãyvind Karlsen in bpo-6715.)
æ¹è¯ãããã¢ãžã¥ãŒã«Â¶
abc¶
Improved support for abstract base classes containing descriptors composed with
abstract methods. The recommended approach to declaring abstract descriptors is
now to provide __isabstractmethod__ as a dynamically updated
property. The built-in descriptors have been updated accordingly.
@abc.abstractpropertyhas been deprecated, use@propertywith@abc.abstractmethodinstead.@abc.abstractclassmethodhas been deprecated, use@classmethodwith@abc.abstractmethodinstead.@abc.abstractstaticmethodhas been deprecated, use@staticmethodwith@abc.abstractmethodinstead.
(Contributed by Darren Dale in bpo-11610.)
abc.ABCMeta.register() ãç»é²ããããµãã¯ã©ã¹ãè¿ãããã«ãªããŸãããã€ãŸãã¯ã©ã¹ãã³ã¬ãŒã¿ãšããŠäœ¿ãããšãã§ããããã«ãªã£ããšããããšã§ã (bpo-10868)ã
array¶
The array module supports the long long type using q and
Q type codes.
(Contributed by Oren Tirosh and Hirokazu Yamamoto in bpo-1172711.)
base64¶
base64 ã¢ãžã¥ãŒã«ã®ã¢ãã³ãªã€ã³ã¿ãŒãã§ã€ã¹ã®ã»ãã®ãã³ãŒã颿°ããASCII æåã®ã¿ã§æ§æããã Unicode æååãåãä»ããããã«ãªããŸãããããšãã° base64.b64decode('YWJj') 㯠b'abc' ãè¿ããŸãã (Contributed by Catalin Iacob in bpo-13641.)
binascii¶
a2b_ 颿°ãããã€ããªãªããžã§ã¯ãã ãã§ãªã ASCII æåã®ã¿ã§æ§æããã Unicode æååãå
¥åãšããŠåãä»ããããã«ãªããŸããã (Contributed by Antoine Pitrou in bpo-13637.)
bz2¶
bz2 ã¢ãžã¥ãŒã«ãæåããæžãçŽãããŸããããã®éçšã§æ°æ©èœãããã€ã远å ãããŸããã
æ°ããª
bz2.open()颿°: bzip2 ã§å§çž®ããããã¡ã€ã«ããã€ããªãããã¹ãã¢ãŒãã§éããŸããbz2.BZ2Fileããã³ã³ã¹ãã©ã¯ã¿ã® fileobj åŒæ°ã§ãä»»æã®ãã¡ã€ã«æ§ãªããžã§ã¯ãã®èªã¿æžããåºæ¥ãããã«ãªããŸããã(Contributed by Nadeem Vawda in bpo-5863.)
bz2.BZ2Fileãšbz2.decompress()ã (pbzip2 ããŒã«ã§çæããããããª) ãã«ãã¹ããªãŒã ã®å ¥åãå±éåºæ¥ãããã«ãªããŸãããåæã«bz2.BZ2Fileã¯ã'a'(远èš) ã¢ãŒãã䜿ã£ãŠãã®ã¿ã€ãã®å§çž®ãã¡ã€ã«ãäœãã®ã«äœ¿ããããã«ãªããŸããã(Contributed by Nir Aides in bpo-1625.)
bz2.BZ2Filenow implements all of theio.BufferedIOBaseAPI, except for thedetach()andtruncate()methods.
codecs¶
mbcs ã³ãŒããã¯ããå
šãŠã® Windows ããŒãžã§ã³ã§ãšã©ãŒãã³ãã© replace ãš ignore ãæ£ããåŠçããããã«æžãæããããŸããã mbcs ã³ãŒããã¯ã¯ä»¥åã¯ããšã³ã³ãŒãã§ã¯ replace ã®ã¿ããã³ãŒãã§ã¯ ignore ã®ã¿ã§ããããããã«ããå
šãŠã®ãšã©ãŒãã³ãã©ããµããŒããããŸãã
æ°ãã« Windows ã®ã¿çšã®ã³ãŒãã㯠cp65001 ã远å ãããŸãã (bpo-13216)ããã㯠Windows ã³ãŒãããŒãž 65001 (Windows UTF-8, CP_UTF8) ã§ããäŸãã°ããã¯ã³ã³ãœãŒã«åºåã®ã³ãŒãããŒãžã (äŸãã° chcp 65001 ã³ãã³ãã䜿ã£ãŠ) cp65001 ã«ã»ãããããŠããå Žåã« sys.stdout ã§äœ¿ãããŸãã
ãã«ããã€ã CJK ãã³ãŒãã®ååæãé«éã«ãªããŸãããããã¯äžæ£ãªãã€ãã·ãŒã±ã³ã¹ãæåã®ãã€ãã§ããã°ç¡èŠããã ãã§ããäŸãã° b'\xff\n'.decode('gb2312', 'replace') ã¯æå眮ãæãã®ã®ã¡ã« \n ãè¿ãããã«ãªã£ãŠããŸãã
挞å¢ç CJK ã³ãŒããã¯ã®ãšã³ã³ãŒãã¯ä»¥å㯠encode() ã¡ãœããåŒã³åºãã®ãã³ã«ãªã»ããããŠããŸãããããªã»ããããªããªããŸãããäŸãã°:
>>> import codecs
>>> encoder = codecs.getincrementalencoder('hz')('strict')
>>> b''.join(encoder.encode(x) for x in '\u52ff\u65bd\u65bc\u4eba\u3002 Bye.')
b'~{NpJ)l6HK!#~} Bye.'
ãã®äŸã®å Žåã¯ä»¥åã® Python ã§ã¯ b'~{Np~}~{J)~}~{l6~}~{HK~}~{!#~} Bye.' ãšãªã£ãŠããŸããã
unicode_internal ã³ãŒããã¯ã¯éæšå¥šãšãªããŸããã
collections¶
æ°ãã«è¿œå ãããã¯ã©ã¹ ChainMap ã¯ãè€æ°ã®ãããã³ã°ãã²ãšãŸãšãŸãã«æ±ããããã«ããŸãã (Written by Raymond Hettinger for bpo-11089, made public in bpo-11297.)
æœè±¡åºåºã¯ã©ã¹çŸ€ã¯æ°ããã¢ãžã¥ãŒã« collections.abc ã«ç§»åããŸãããæœè±¡ã³ã¬ã¯ã·ã§ã³ãšå
·è±¡ã³ã¬ã¯ã·ã§ã³ãèå¥ããããããããã§ãããããã€ã³ããŒãããŠããæ¢åã®ã³ãŒããç¶æããããã«ã ABC ã®å¥å矀ã collections ã¢ãžã¥ãŒã«å
ã«æ®ãããŠããŸãã (bpo-11085)
Counter ã¯ã©ã¹ããåé
+ æŒç®åãåé
- æŒç®åãã€ã³ãã¬ã€ã¹æŒç®åã® +=, -=, |=, &= ããµããŒãããããã«ãªããŸããã(Contributed by Raymond Hettinger in bpo-13121.)
contextlib¶
ã³ã³ããã¹ããããŒãžã£ãããã°ã©ã çã«æäœããããšãšããããšé¡äŒŒã®ã¯ãªãŒã³ã¢ããã®æ©èœæ§ã«ã€ããŠãExitStack ãä»åŸã¯ç¢ºããªåºç€ãæäŸããŸãããã€ãŠã® (éæšå¥šãšãªãåé€ããã) contextlib.nested API ãšã¯éã£ãŠããã®æ°ãã API ã¯ãã³ã³ããã¹ããããŒãžã£ããªãœãŒã¹ã (ããšãã°ãã¡ã€ã«ãªããžã§ã¯ããªã©ã) __init__ ã¡ãœããã§ç²åŸããã®ããããã㯠(ããšãã° threading ã¢ãžã¥ãŒã«ããã®åæãªããžã§ã¯ãã) __enter__ ã¡ãœããã§ç²åŸããã®ããšã¯ç¡é¢ä¿ã«æ£ããåäœããããã«èšèšãããŸããã
crypt¶
Addition of salt and modular crypt format (hashing method) and the mksalt()
function to the crypt module.
curses¶
If the
cursesmodule is linked to the ncursesw library, use Unicode functions when Unicode strings or characters are passed (e.g.waddwstr()), and bytes functions otherwise (e.g.waddstr()).Unicode æååããšã³ã³ãŒãããã®ã«
utf-8ã§ã¯ãªã locale ã®ãšã³ã³ãŒãã£ã³ã°ã䜿ãããã«ãªããŸããã(---蚳泚: bpo-12567 ã«å¯Ÿå¿ãã説æãšæããŸãããšããã°ãã㯠ã¯ã€ãæåãåãåããªã C 颿°ã«æž¡ã éã« Unicode ããšã³ã³ãŒãããéã®è©±ããã®ãšãã«ä»¥åã¯æé»ã§utf-8ã§ãšã³ã³ãŒãããŠããã®ã¯ã誀ãã§ããããšããããšã®ããã§ãã ---)curses.windowã¯ã©ã¹ã«å±æ§curses.window.encodingã远å ãããŸãããcurses.windowã¯ã©ã¹ã«get_wch()ã¡ãœããã远å ãããŸãããããã¯ã¯ã€ãæåãäžã€ååŸããŸããcursesã¢ãžã¥ãŒã«ã«é¢æ°unget_wch()ã远å ãããŸãããããã¯ã¯ã€ãæåãããã·ã¥ããæ¬¡ã«get_wch()ãåŒã³åºããæã«ãã®å€ãè¿ãããã«ããŸãã
(Contributed by Iñigo Serna in bpo-6755.) (---蚳泚: æåã®2ã€ã¯ãããã bpo-12567 --)
datetime¶
naive ãª
datetimeã€ã³ã¹ã¿ã³ã¹ãš aware ãªdatetimeã€ã³ã¹ã¿ã³ã¹ã®ç䟡æ¯èŒã§ãTypeErrorãæããã«Falseãè¿ãããã«ãªããŸããã (bpo-15006).æ°èŠã¡ãœãã
datetime.datetime.timestamp():datetimeã€ã³ã¹ã¿ã³ã¹ã«å¯Ÿå¿ãã POSIX ã¿ã€ã ã¹ã¿ã³ããè¿ããŸããdatetime.datetime.strftime()ã¡ãœããã 1000 幎ãããåã®æžåŒåããµããŒãããŸããã(---蚳泚: What's New in Python 3.2 ã§ã®å€æŽãåç §ããŠã¿ãŠãã ããã---)datetime.datetime.astimezone()ã¡ãœãããåŒæ°ãªãã§åŒã³åºããããã«ãªããŸããããã㯠datetime ã€ã³ã¹ã¿ã³ã¹ãã·ã¹ãã ã®ã¿ã€ã ãŸãŒã³ã«å€æããŸãã
decimal¶
- bpo-7652 - decimal ç®è¡æŒç®ã®ãé«éãªãã€ãã£ã å®è£ ã®çµ±å
C-module and libmpdec written by Stefan Krah.
The new C version of the decimal module integrates the high speed libmpdec library for arbitrary precision correctly rounded decimal floating-point arithmetic. libmpdec conforms to IBM's General Decimal Arithmetic Specification.
Performance gains range from 10x for database applications to 100x for numerically intensive applications. These numbers are expected gains for standard precisions used in decimal floating-point arithmetic. Since the precision is user configurable, the exact figures may vary. For example, in integer bignum arithmetic the differences can be significantly higher.
The following table is meant as an illustration. Benchmarks are available at https://www.bytereef.org/mpdecimal/quickstart.html.
decimal.py
_decimal
speedup
pi
42.02s
0.345s
120x
telco
172.19s
5.68s
30x
psycopg
3.57s
0.29s
12x
ãã£ãŒãã£ãŒÂ¶
FloatOperationã·ã°ãã« ã«ãããfloat ãš Decimal ã®æ··åã®å³å¯ãªã»ãã³ãã£ã¯ã¹ãæå¹ã«åºæ¥ãŸãã(---蚳泚: 䜿çšäŸã Quick-start tutorial ã«ãããŸãã---)If Python is compiled without threads, the C version automatically disables the expensive thread local context machinery. In this case, the variable
HAVE_THREADSis set toFalse.
API ã®å€æŽÂ¶
C ã¢ãžã¥ãŒã«ã¯ãã·ã³ã¢ãŒããã¯ãã£ã«äŸåãã以äžã®ã³ã³ããã¹ãã®å¶éãæã¡ãŸã:
In the context templates (
DefaultContext,BasicContextandExtendedContext) the magnitude ofEmaxandEminhas changed to999999.decimal.py ã®
Decimalã³ã³ã¹ãã©ã¯ã¿ã¯äžèšã®ã³ã³ããã¹ãå¶éã«ç¡ç¥ã§ãä»»æã®ææ°ãç²ŸåºŠã§æ£ç¢ºã«å€æããããšããŸããC çã¯å éšã®å¶éãæã£ãŠããŸãã®ã§ã次ã®èŠåã䜿ãããŸã: å¯èœãªãã°å€ã¯æ£ç¢ºã«å€æãããããã§ãªãå ŽåInvalidOperationãéåºãããŠçµæã NaN ãšãªããŸããåŸè ã®ã±ãŒã¹ã¯äžžããããã¯äžæ£ç¢ºãªå€ãåŸãããã«create_decimal()ã䜿ãããšã§ãã€ã§ãå¯èœã§ãã(---蚳泚: ãããã«ãã衚çŸã§ããã³ã³ããã¹ãã§ InvalidOperation ããã©ããããŠããã°çµæã NaN ã§åãåããŠ(ããã§ãªããã° InvalidOperation ãæããããŠ)ããã®å¶åŸ¡ã¯ create_decimal ã§æç€ºçã«è¡ããããšããããšãèšã£ãŠããŸãã---)The power function in decimal.py is always correctly rounded. In the C version, it is defined in terms of the correctly rounded
exp()andln()functions, but the final result is only "almost always correctly rounded".C çã§ã¯ã·ã°ãã«ãå«ãèŸæžã¯
MutableMappingã§ããé床çãªçç±ã«ããflagsãštrapsã¯ã³ã³ããã¹ããåæåãããæç¹ã§ã®MutableMappingãåç §ãç¶ããŸããæ°ããªã·ã°ãã«èŸæžãflagsã«trapså²ãåœãŠãã°æ°ããå€ã§æŽæ°ã¯ããããã®ã®ãã³ã³ããã¹ãã¯ãããå³èŸºã®èŸæžãåç §ããŸãããContextã pickle åãããšãããŸã§ãšã¯ç°ãªãåºåãããŸãããã㯠Python çãš C çã§å ±éã®äº€æãã©ãŒããããå®çŸããããã§ããContextã³ã³ã¹ãã¿ã¯ã¿ã®åŒæ°é ãrepr()ã§ã®è¡šç€ºé ã«åãããã«æ¹ããããŸãããquantize()ã¡ãœããã®watchexpãã©ã¡ãŒã¿ãéæšå¥šãšãªããŸããã
email¶
ããªã·ãŒãã¬ãŒã ã¯ãŒã¯Â¶
email ããã±ãŒãžã« policy ãã¬ãŒã ã¯ãŒã¯ã远å ãããŸããã Policy ã¯ã email ããã±ãŒãžãã©ã®ããã«æ¯èãã®ããå¶åŸ¡ããããã®å€æ°ã®ã¡ãœãããšããããã£ãæã€ãªããžã§ã¯ãã§ããPython 3.3 ã®ããã®æåã®ããªã·ãŒã¯ Compat32 ã§ããã㯠Python 3.2 ã® email ããã±ãŒãžãšã®åŸæ¹äºææ§ãæäŸããŸãã policy ã¯ã parser ã«ãã£ãŠ email ã¡ãã»ãŒãžãè§£æãããéãããã㯠Message ãªããžã§ã¯ããçæããéãããã㯠generator ãçšã㊠email ãã·ãªã¢ã©ã€ãºããéã«æå®åºæ¥ãŸãããªãŒãã©ã€ãããªãéãã¯ã parser ã«æž¡ãããããªã·ãŒã¯å
šãŠã® Message ãªããžã§ã¯ããš parser ãçæãããµããªããžã§ã¯ãã«åŒãç¶ãããŸããããã©ã«ãã§ã¯ generator ã¯ãã·ãªã¢ã©ã€ãºããããšãã Message ãªããžã§ã¯ãã®ããªã·ãŒã䜿ããŸããããã©ã«ãã®ããªã·ãŒã¯ compat32 ã§ãã
ãã¹ãŠã® policy ãªããžã§ã¯ãã§å®è£
ãããå¶åŸ¡ã®æå°éã®ã»ããã¯ä»¥äžã§ã:
max_line_length |
|
linesep |
|
cte_type |
|
raise_on_defect |
|
æ°ããªèšå®å€ãæã€æ°ããããªã·ãŒã€ã³ã¹ã¿ã³ã¹ã¯ãããªã·ãŒãªããžã§ã¯ãã® clone() ã¡ãœããã䜿ã£ãŠäœãããŸãã clone ã¯ä»»æã®äžèšå¶åŸ¡å€ãããŒã¯ãŒãåŒæ°ãšããŠåãåããŸãããã®åŒã³åºãã§æå®ãããªãå¶åŸ¡ã¯ããã©ã«ãã®ãŸãŸæ®ãããŸããã§ãã®ã§ linesep æååãšã㊠\r\n ã䜿ãããªã·ãŒããã®ããã«ããŠäœããŸã:
mypolicy = compat32.clone(linesep='\r\n')
ããªã·ãŒã¯ãããªãã®ã¢ããªã±ãŒã·ã§ã³ãå¿
èŠãšãããã©ãŒãããã§ã¡ãã»ãŒãžãçæããã®ãç°¡åã«ããŠãããŸãã generator ãåŒã³åºãå
šãŠã®å Žæã§ linesep='\r\n' ãæå®ããã®ãå¿ããªãããã«ãã代ããã«ãããªãã®ããã°ã©ã ã Message ãªããžã§ã¯ããäœæããããã«äœ¿ã parser ããã㯠Message ãããªã·ãŒãèŠæ±ããäžç®æã ãã§æå®ããã°è¯ãã®ã§ãããã¡ããäžæ¹ã§ã¯ã¡ãã»ãŒãžãè€æ°ã®åœ¢åŒã§çæããå¿
èŠãããã°ã generator åŒã³åºãã®ãã³ã«ãã©ã¡ãŒã¿ã§æå®ããå¿
èŠããããŸãããããã¯ãããªãåºæã®ã±ãŒã¹ã®ããã«ã«ã¹ã¿ã ãªããªã·ãŒãäœã£ãŠã generator äœæã®éã«ãããæž¡ãããšãåºæ¥ãŸãã
æ°èŠããã API ã䌎ã£ãæ«å®ããªã·ãŒÂ¶
ããªã·ãŒãã¬ãŒã ã¯ãŒã¯ååã§ããŸã£ãããã£ãŠäŸ¡å€ããããã®ã§ã¯ãããŸããããã®å°å ¥ã®äž»ããåæ©ã¯ãããã䜿ããªãã³ãŒãã«å¯ŸããŠã®åŸæ¹äºæãå£ããªãããæ¹ã§ãemail ããã±ãŒãžã«æ°æ©èœãå®çŸããæ°ããããªã·ãŒãäœããããã«ããããšã§ããããã®æ°ããããªã·ãŒã¯æ°èŠ API ãå°å ¥ãããã®ãªã®ã§ãç§ãã¡ã¯ãããã Python 3.3 ã§ã® æ«å®ããªã·ãŒ ãšããŠãªãªãŒã¹ããŸãããã³ã¢éçºè ãå¿ èŠãšå€æããã°ãåŸæ¹äºææ§ãç Žå£ãã (ã³ãŒãã®ç Žæ£ãããå«ã) 倿Žãèµ·ããããŸãã
ãã®æ°èŠããªã·ãŒã¯ EmailPolicy ã®ã€ã³ã¹ã¿ã³ã¹ (蚳泚: email.policy.default ã email.policy.SMTP ãªã©) ã§ããããã«ã¯ä»¥äžã®å¶åŸ¡ã远å ãããŠããŸã:
refold_source |
|
header_factory |
|
header_factory ãããã®æ°èŠããªã·ãŒã«ããæäŸãããæ°æ©èœã®èŠã§ãããã®æ°èŠããªã·ãŒã®äžã€ã䜿ããããšã Message ãªããžã§ã¯ãããæœåºããããã¹ãŠã®ããã㯠header_factory ã§çæããããªããžã§ã¯ãã§ããããŸãã Message ã«ããããã»ããããå Žåã®ãã€ã§ãããã㯠header_factory ã§çæããããªããžã§ã¯ãã«ãªããŸãããã¹ãŠã®ãã®çš®ã®ããããªããžã§ã¯ãã¯ããããåãšååã® name 屿§ãæã¡ãŸããã¢ãã¬ã¹ããããšæ¥ä»ãããã¯ããããã®è§£ææžã¿æ¥ä»ã«ã¢ã¯ã»ã¹åºæ¥ãããã远å ã®å±æ§çŸ€ãæã¡ãŸãã以äžã®ããã«äœ¿ããŸã:
>>> m = Message(policy=SMTP)
>>> m['To'] = 'Ãric <foo@example.com>'
>>> m['to']
'Ãric <foo@example.com>'
>>> m['to'].addresses
(Address(display_name='Ãric', username='foo', domain='example.com'),)
>>> m['to'].addresses[0].username
'foo'
>>> m['to'].addresses[0].display_name
'Ãric'
>>> m['Date'] = email.utils.localtime()
>>> m['Date'].datetime
datetime.datetime(2012, 5, 25, 21, 39, 24, 465484, tzinfo=datetime.timezone(datetime.timedelta(-1, 72000), 'EDT'))
>>> m['Date']
'Fri, 25 May 2012 21:44:27 -0400'
>>> print(m)
To: =?utf-8?q?=C3=89ric?= <foo@example.com>
Date: Fri, 25 May 2012 21:44:27 -0400
Unicode ã® display name ããã¡ãã»ãŒãžãã·ãªã¢ã©ã€ãºãããéã«èªåçã« utf-8 (蚳泚: å®è¡äŸã®å Žåã¯ãã® MIME ããããšã³ã³ãŒãã) ã§ãšã³ã³ãŒãããããããã«çŽæ¥ã¢ã¯ã»ã¹ãããš Unicode ã§è¿ãããšã«æ°ä»ããšæããŸããã€ãŸã email.header ã® decode_header() 颿°ã make_header() 颿°ãåãæ±ãå¿
èŠæ§ãåãé€ããŠãããŠããŸãã
ã¢ãã¬ã¹ãéšåããçµã¿ç«ãŠãããšãåºæ¥ãŸã:
>>> m['cc'] = [Group('pals', [Address('Bob', 'bob', 'example.com'),
... Address('Sally', 'sally', 'example.com')]),
... Address('Bonzo', addr_spec='bonz@laugh.com')]
>>> print(m)
To: =?utf-8?q?=C3=89ric?= <foo@example.com>
Date: Fri, 25 May 2012 21:44:27 -0400
cc: pals: Bob <bob@example.com>, Sally <sally@example.com>;, Bonzo <bonz@laugh.com>
Unicode ãžãã³ãŒãããã®ã¯èªåã§è¡ãããŸã:
>>> m2 = message_from_string(str(m))
>>> m2['to']
'Ãric <foo@example.com>'
ã¡ãã»ãŒãžè§£æã®éãã°ã«ãŒããšåã
ã®ã¢ãã¬ã¹ã«ã¢ã¯ã»ã¹ããã®ã«ããããªããžã§ã¯ãã® addresses 屿§ãš groups 屿§ã䜿ããŸã:
>>> m2['cc'].addresses
(Address(display_name='Bob', username='bob', domain='example.com'), Address(display_name='Sally', username='sally', domain='example.com'), Address(display_name='Bonzo', username='bonz', domain='laugh.com'))
>>> m2['cc'].groups
(Group(display_name='pals', addresses=(Address(display_name='Bob', username='bob', domain='example.com'), Address(display_name='Sally', username='sally', domain='example.com')), Group(display_name=None, addresses=(Address(display_name='Bonzo', username='bonz', domain='laugh.com'),))
èŠããã«æ°èŠããªã·ãŒã®ã©ããäžã€ã䜿ãããšã¯ããããæäœããã®ãããªãã®ã«ããŠããããšããããšã§ã: ããªãã®ã¢ããªã±ãŒã·ã§ã³ã¯ Unicode æååã§ãä»äºãããemail ããã±ãŒãžã¯ Unicode ã®ãšã³ã³ãŒã/ãã³ãŒããééçã«è¡ã£ãŠ RFC æšæº Content Transfer Encoding ãšã®çžäºå€æããã£ãŠã®ããããšã
ãã®ä»ã®APIã®å€æŽÂ¶
BytesHeaderParser ã parser ã¢ãžã¥ãŒã«ã«è¿œå ãããŸããããã㯠HeaderParser ãè£è¶³ãããã®ã§ããããŸãã bytes API ãå®å
šã«ãã (蚳泚: What's New in Python 3.2 ã§ã® email ã®å€æŽå
容åç
§) ãã®ã§ãã
æ°ãããŠãŒãã£ãªãã£é¢æ°:
format_datetime():datetimeãäžãããš email ãããã§äœ¿ãããæžåŒã§ãã©ãŒãããããæååãçæããŸããparsedate_to_datetime(): email ãããããã®æ¥ä»æååãæž¡ããšã aware ãªããŸã㯠naive ãªdatetimeã«å€æããŸãããªãã»ããã-0000ã®å Žåã« naive ã§è¿ããŸããlocaltime(): åŒæ°ãªãã§åŒã³åºããšãããŒã«ã«timezoneã䜿ã£ã aware ãªdatetimeãšããŠçŸåšããŒã«ã«æéãè¿ããŸããaware ãªdatetimeãæž¡ããŠåŒã³åºããšãããŒã«ã«timezoneã䜿ã£ã aware ãªdatetimeã«å€æããŸãã
ftplib¶
ftplib.FTPã«æ°ããããŒã¯ãŒãåŒæ°source_addressã远å ãããŸããã(host, port)ã®åœ¢ã§æå®ããããã¯å€ã«åãããœã±ãããäœæããéã«bind()åŒã³åºãå ã§ã®ãœãŒã¹ã¢ãã¬ã¹ãšããŠçšããããŸãã (Contributed by Giampaolo Rodolà in bpo-8594.)FTP_TLSã¯ã©ã¹ã«ãå¶åŸ¡ãã£ãã«ãå¹³æã«æ»ãããã®ccc()颿°ã远å ãããŸãããããã¯ãåºå®ããŒãã§éãããšãªãéã»ãã¥ã¢ FTP ã§ NAT ãåŠçããæ¹æ³ãç¥ã£ãŠãããã¡ã€ã¢ãŠã©ãŒã«ãå©çšããã®ã«æçšãšãªãããŸãã(Contributed by Giampaolo Rodolà in bpo-12139.)æ°èŠã¡ãœãã
ftplib.FTP.mlsd()ã¯æ©æ¢°ã§èªãããã£ã¬ã¯ããªãªã¹ãã£ã³ã°ã®ãã©ãŒããããæäŸããftplib.FTP.nlst()ãšftplib.FTP.dir()ã«åã£ãŠä»£ãããã®ãšãªããŸããã(Contributed by Giampaolo Rodolà in bpo-11072.)
functools¶
The @functools.lru_cache decorator now accepts a typed keyword
argument (that defaults to False to ensure that it caches values of
different types that compare equal in separate cache slots. (Contributed
by Raymond Hettinger in bpo-13227.)
gc¶
ã¬ãŒããŒãžã³ã¬ã¯ã¿ãååååŸã«åŒã³åºãã³ãŒã«ããã¯ãç»é²åºæ¥ãããã«ãªããŸãããæ°èŠå±æ§ callbacks ãªã¹ãã«ç»é²ããŸãã
hmac¶
ã¿ã€ãã³ã°è§£æã«ãããã€ãžã§ã¹ãã«å¯Ÿãã ãµã€ããã£ã³ãã«æ»æ ããã®é²åŸ¡ã®ããã«ã compare_digest() 颿°ã远å ãããŸããã(Contributed by Nick Coghlan and Christian Heimes in bpo-15061.)
http¶
http.server.BaseHTTPRequestHandler ããããããããã¡ããããã«ãªãã end_headers() åŒã³åºãæã«äžåºŠã«å
šãŠããŸãšããŠæžãåºãããã«ãªããŸãããæ°èŠã®ã¡ãœãã flush_headers() ã¯ãéç©ããããããéä¿¡ããå Žåã®ç®¡çã«çŽæ¥äœ¿ãããšãåºæ¥ãŸãã(Contributed by Andrew Schaaf in bpo-3709.)
http.server ãæ£åœãª HTML 4.01 strict åºåãçæããããã«ãªããŸããã (Contributed by Ezio Melotti in bpo-13295.)
http.client.HTTPResponse ã«ã¡ãœãã readinto() ã远å ãããŸãããã€ãŸããã®ã¯ã©ã¹ã io.RawIOBase ã®ããã«æ±ãããšããããšã§ãã (Contributed by John Kuhn in bpo-13464.)
html¶
html.parser.HTMLParser is now able to parse broken markup without
raising errors, therefore the strict argument of the constructor and the
HTMLParseError exception are now deprecated.
The ability to parse broken markup is the result of a number of bug fixes that
are also available on the latest bug fix releases of Python 2.7/3.2.
(Contributed by Ezio Melotti in bpo-15114, and bpo-14538,
bpo-13993, bpo-13960, bpo-13358, bpo-1745761,
bpo-755670, bpo-13357, bpo-12629, bpo-1200313,
bpo-670664, bpo-13273, bpo-12888, bpo-7311.)
html.entities ã¢ãžã¥ãŒã«ã«ãHTML5 ååä»ãæååç
§ãš Unicode æå(å) ãšã察å¿ä»ãã html5 èŸæžã远å ãããŸãã (äŸ: html5['gt;'] == '>')ããã®èŸæžã¯æ¢ã« HTMLParser ã䜿ã£ãŠããŸãã (Contributed by Ezio Melotti in bpo-11113 and bpo-15156.)
imaplib¶
IMAP4_SSL ã³ã³ã¹ãã©ã¯ã¿ã SSLContext ãã©ã¡ãŒã¿ãåãåãããã«ãªããŸãããããã¯ã»ãã¥ã¢ãªãã£ãã«ã®ãã©ã¡ãŒã¿ãå¶åŸ¡ããŸãã
(Contributed by Sijin Joseph in bpo-8808.)
inspect¶
getclosurevars() 颿°ã远å ãããŸããããã®é¢æ°ã¯ãæå®ãã颿°ã®é¢æ°æ¬äœããåç
§ãããŠããçŸåšæçžãããŠããå
šãŠã®ååãšããããååã解決ãããå Žæ (蚳泚: globals, builtins ãªã©) ãå ±åããŸããããã«ãããã¹ããŒããã«ãªã¯ããŒãžã£ã«äŸåããã³ãŒãããã¹ãããã®ã«ãæ£ããå
éšç¶æ
ãæ€èšŒããã®ã容æã«ãªããŸãã
(Contributed by Meador Inge and Nick Coghlan in bpo-13062.)
getgeneratorlocals() 颿°ã远å ãããŸããããã®é¢æ°ã¯ãæå®ãããžã§ãã¬ãŒã¿ã®ã¹ã¿ãã¯ãã¬ãŒã å
ã®ããŒã«ã«å€æ°ã®ãçŸåšæçžãããŠãããã®ãå ±åããŸããããã«ããããžã§ãã¬ãŒã¿ããã¹ãããã®ã«ãæ£ããå
éšç¶æ
ãæ€èšŒããã®ã容æã«ãªããŸãã
(Contributed by Meador Inge in bpo-15153.)
io¶
open() 颿°ã«æä»çäœæã«äœ¿çšããæ°ã㪠'x' ã¢ãŒãã远å ãããŸããããã¡ã€ã«ãæ¢ã«ååšããå Žå㯠FileExistsError ãéåºããŸãã
C11 fopen() ã® 'x' ã¢ãŒãã«åºã¥ããŠããŸãã
(Contributed by David Townshend in bpo-12760.)
The constructor of the TextIOWrapper class has a new
write_through optional argument. If write_through is True, calls to
write() are guaranteed not to be buffered: any data
written on the TextIOWrapper object is immediately handled to its
underlying binary buffer.
itertools¶
accumulate() ããŠãŒã¶æäŸäºé
颿°ãæž¡ãããã®ãªãã·ã§ãã«åŒæ° func ãåãä»ããããã«ãªããŸããã
logging¶
basicConfig() 颿°ããªãã·ã§ãã«ãª handlers åŒæ°ããµããŒãããããã«ãªããŸãããããã¯ã«ãŒããã¬ãŒã«è¿œå ãããã³ãã©çŸ€ã® ã€ãã©ãã« ã§ãã
A class level attribute append_nul has
been added to SysLogHandler to allow control of the
appending of the NUL (\000) byte to syslog records, since for some
daemons it is required while for others it is passed through to the log.
math¶
math ã¢ãžã¥ãŒã«ã«æ°ããªé¢æ° log2() ã远å ãããŸãããx ã® 2 ãåºãšãã察æ°ãè¿ããŸãã
(Written by Mark Dickinson in bpo-11888.)
mmap¶
read() ã¡ãœããã®ä»ã®ãã¡ã€ã«ã©ã€ã¯ãªãªããžã§ã¯ããšã®äºææ§ãå¢ããŸãããåŒæ°ãçç¥ãããã None ã®å Žåã«ããã¡ã€ã«ã®çŸåšäœçœ®ãããããã³ã°ã®æ«å°ŸãŸã§ã®ãã€ãåãè¿ãããã«ãªã£ãŠããŸãã(Contributed by Petri Lehtinen in bpo-12021.)
multiprocessing¶
颿° multiprocessing.connection.wait() ã远å ãããŸãããããã¯è€æ°ã® (æ¥ç¶ããœã±ããããã€ãã®ãããª) ãªããžã§ã¯ããã¿ã€ã ã¢ãŠãä»ãã§ããŒãªã³ã°ããŸãã(Contributed by Richard Oudkerk in bpo-12328.)
multiprocessing.connection.Connection objects can now be transferred
over multiprocessing connections.
(Contributed by Richard Oudkerk in bpo-4892.)
multiprocessing.Process ãããŒã¯ãŒãåŒæ° daemon ãåãããã«ãªããŸãããããã¯èŠªããã»ã¹ãã daemon ãã©ã°ãç¶æ¿ããããã©ã«ãã®æ¯ãèãããªãŒãã©ã€ãããŸã (bpo-6064)ã
屿§ multiprocessing.Process.sentinel ã远å ãããŸããããããçšããããšã§ããµãããã OS ããªããã£ã (äŸãã° POSIX ã·ã¹ãã ã§ã® select) ã䜿ã£ãäžæ¬ã§ã®è€æ° Process ãªããžã§ã¯ãåŸ
ã¡ãå¯èœã§ãã
map() ãš itertools.starmap() ãšã®é¢ä¿ãšåããæ¢åã® multiprocessing.pool.Pool.map() ãš map_async() ã«å¯Ÿå¿ãã multiprocessing.pool.Pool.starmap() ãš starmap_async() ã远å ãããŸããã (Contributed by Hynek Schlawack in bpo-12708.)
nntplib¶
The nntplib.NNTP class now supports the context management protocol to
unconditionally consume socket.error exceptions and to close the NNTP
connection when done:
>>> from nntplib import NNTP
>>> with NNTP('news.gmane.org') as n:
... n.group('gmane.comp.python.committers')
...
('211 1755 1 1755 gmane.comp.python.committers', 1755, 1, 1755, 'gmane.comp.python.committers')
>>>
(Contributed by Giampaolo Rodolà in bpo-9795.)
os¶
The
osmodule has a newpipe2()function that makes it possible to create a pipe withO_CLOEXECorO_NONBLOCKflags set atomically. This is especially useful to avoid race conditions in multi-threaded programs.osã¢ãžã¥ãŒã«ã«sendfile()颿°ã远å ãããŸãããããã¯ãããã¡ã€ã« (ãŸãã¯ãœã±ãã) èšè¿°åããã®ã³ããŒããå¹ççãªããŒãã³ããŒãã§è¡ããŸããããŒãã³ããŒããšããèšãåãã¯ãããã¯äºã€ã®èšè¿°åéã§ã®ããŒã¿ã®ã³ããŒå šãŠãå®å šã«ã«ãŒãã«ã«ãã£ãŠè¡ãããããšããäºå®ã«ã€ããŠæããŠããŸããããŒã¿ã³ããŒã«ãŠãŒã¶ç©ºéã®ãããã¡ã¯äœ¿ãããŸãããsendfile()ã¯äŸãã°ãã¡ã€ã«ã®ããŠã³ããŒãã®ãããªããã£ã¹ã¯äžã®ãã¡ã€ã«ãšãããã¯ãŒã¯ãœã±ããéã§ã®å¹ççãªããŒã¿ã³ããŒã«äœ¿ãããšãåºæ¥ãŸãã(Patch submitted by Ross Lagerwall and Giampaolo Rodolà in bpo-10882.)
ã·ã³ããªãã¯ãªã³ã¯æ»æãäžæãã¡ã€ã«ãäžæãã£ã¬ã¯ããªã«ãŸã€ããåé¡ã®ãããªç«¶åç¶æ ãé¿ããã«ã¯ããã¡ã€ã«åã®ä»£ããã«ãã¡ã€ã«èšè¿°åãæäœããããšãããä¿¡é Œåºæ¥ãŸã (ãããŠé«éã§ããããŸã)ã Python 3.3 ã¯ãã¡ã€ã«èšè¿°åã§åäœããããæ¢å颿°ã®åŒ·åãšæ°èŠé¢æ°ã®è¿œå ãè¡ãªããŸããã (bpo-4761, bpo-10755 and bpo-14626)
osã¢ãžã¥ãŒã«ã®æ°èŠé¢æ°fwalk()ã¯walk()ãšäŒŒãŠããŸãããããã¯èšªåãããã£ã¬ã¯ããªãæããã¡ã€ã«èšè¿°åã yield ããŸããããã¯ç¹ã«ã·ã³ããªãã¯ãªã³ã¯ã®ç«¶åãé¿ããããã«æçšã§ããThe following functions get new optional dir_fd (paths relative to directory descriptors) and/or follow_symlinks (not following symlinks):
access(),chflags(),chmod(),chown(),link(),lstat(),mkdir(),mkfifo(),mknod(),open(),readlink(),remove(),rename(),replace(),rmdir(),stat(),symlink(),unlink(),utime(). Platform support for using these parameters can be checked via the setsos.supports_dir_fdandos.supports_follow_symlinks.颿°
chdir(),chmod(),chown(),execve(),listdir(),pathconf(),exists(),stat(),statvfs(),utime()ãããã¹åŒæ°ãšããŠãã¡ã€ã«èšè¿°åããµããŒãããããã«ãªããŸãããããããã©ãããã©ãŒã ããµããŒããããã©ããã¯os.supports_fdã調ã¹ãããšã§ããããŸãã
access()ãããŒã¯ãŒãåŒæ°effective_idsãåãåãããã«ãªããŸãããããã¯å® uid/gid ã®ä»£ããã«å®å¹ uid/gid ã䜿ã£ãŠã¢ã¯ã»ã¹ãã§ãã¯ãè¡ãããã«æ¯ãèãã倿ŽããŸããããããã©ãããã©ãŒã ããµããŒããããã©ããã¯supports_effective_idsã調ã¹ãããšã§ããããŸããosã¢ãžã¥ãŒã«ã« 2 ã€ã®é¢æ°ã远å ãããŸãããgetpriority()ãšsetpriority()ã§ãããããã¯ããã»ã¹ã®ãã€ã¹å€/åªå 床 (niceness/priority) ãos.nice()ãšäŒŒãæ¹æ³ã§ååŸã»èšå®ããŸãããçŸåšããã»ã¹ã ãã®ãã®ã ãã§ã¯ãªãå šãŠã®ããã»ã¹ã«å¯ŸããŠäœ¿ããããæ¡åŒµãããŠããŸãã(Patch submitted by Giampaolo Rodolà in bpo-10784.)
æ°èŠé¢æ°
os.replace()ã¯å€æŽå ã®äžæžãã«ãããŠã¯ãã¹ãã©ãããã©ãŒã ãªæ¹æ³ã§ãã¡ã€ã«å倿Žãè¡ããŸããæ¢åã®os.rename()ã§ã¯ã倿Žå ãæ¢åã®ãã¡ã€ã«ã®å Žåã« POSIX ã§ã¯äžæžããWindows ã§ã¯ãšã©ãŒãšãªããŸãã(Contributed by Antoine Pitrou in bpo-8828.)stat ç³»é¢æ° (
stat(),fstat(),lstat()) ããã¡ã€ã«ã®ã¿ã€ã ã¹ã¿ã³ãã®ããç§ç²ŸåºŠãèªã¿åããããã«ãªããŸããããããšå¯Ÿãšãªãutime()ããã¡ã€ã«ã®ã¿ã€ã ã¹ã¿ã³ããããç§ç²ŸåºŠã§æžãåºããããã«ãªããŸããã (Contributed by Larry Hastings in bpo-14127.)æ°èŠé¢æ°
os.get_terminal_size()ã¯ãã¡ã€ã«èšè¿°åãæ¥ç¶ããŠããã¿ãŒããã«ãŠã£ã³ããŠã®ãµã€ãºãååŸããŸããshutil.get_terminal_size()ãåç §ããŠäžããã (Contributed by Zbigniew JÄdrzejewski-Szmek in bpo-13609.)
Linux æ¡åŒµå±æ§ããµããŒãããããã®æ°ããªé¢æ° (bpo-12720):
getxattr(),listxattr(),removexattr(),setxattr().ã¹ã±ãžã¥ãŒã©ã«å¯Ÿããæ°ããªã€ã³ã¿ãŒãã§ã€ã¹ãããã颿°ã¯ããã»ã¹ã«å¯Ÿãã OS ã«ãã CPU æéå²ãåœãŠãå¶åŸ¡ããŸããæ°èŠé¢æ°:
sched_get_priority_max(),sched_get_priority_min(),sched_getaffinity(),sched_getparam(),sched_getscheduler(),sched_rr_get_interval(),sched_setaffinity(),sched_setparam(),sched_setscheduler(),sched_yield(),ãã¡ã€ã«ã·ã¹ãã ãå¶åŸ¡ããæ°ããªé¢æ°:
posix_fadvise(): ããŒã¿ãžã¢ã¯ã»ã¹ããææãããã¿ãŒã³ãæå®ããŠå®£èšããŸããããã«ããã«ãŒãã«ãæé©åãè¡ããããã«ãªããŸããposix_fallocate(): ãã¡ã€ã«ãå²ãåœãŠãã«ååãªãã£ã¹ã¯ã¹ããŒã¹ã確ä¿ããŸããsync(): ãã£ã¹ã¯ãžã®å šãŠã®æžã蟌ã¿ã匷å¶ããŸãã
远å ãããæ°ã㪠POSIX 颿°:
lockf(): ãªãŒãã³ããããã¡ã€ã«èšè¿°åã«å¯ŸããŠãPOSIX ããã¯ã®é©çšããã¹ããè§£é€ãè¡ããŸããpread(): ãã¡ã€ã«èšè¿°åã®æå®ãªãã»ããäœçœ®ããèªã¿èŸŒã¿ãŸãããã¡ã€ã«ãªãã»ããã¯å€åããŸãããpwrite(): ãã¡ã€ã«èšè¿°åã«å¯Ÿããæå®ãªãã»ããäœçœ®ããæžãåºããŸãããã¡ã€ã«ãªãã»ããã¯å€åããŸãããreadv(): ãã¡ã€ã«èšè¿°åããããŒã¿ãèªã¿ããã§è€æ°ã®æžã蟌ã¿å¯èœãªãããã¡ã«æžã蟌ã¿ãŸããtruncate(): path ã«å¯Ÿå¿ãããã¡ã€ã«ãããµã€ãºãæå€§ã§ length ãã€ãã«ãªãããåãè©°ããŸããwaitid(): äžã€ä»¥äžã®åããã»ã¹ã®å®äºãåŸ ã¡ãŸããwritev(): buffers ã®å 容ããã¡ã€ã«èšè¿°åãžæžãåºããŸãã buffer ã¯ä»»æã®ãããã¡ã®ã·ãŒã±ã³ã¹ã§ããgetgrouplist()(bpo-9344): æå®ãããŠãŒã¶ãå±ããã°ã«ãŒã ID ã®ãªã¹ããè¿ããŸãã
times()ããã³uname(): æ»ãå€ã®åãã¿ãã«ãã屿§åã®ã€ããã¿ãã«ã©ã€ã¯ãªããžã§ã¯ãã«å€æŽãããŸãããããã€ãã®ãã©ãããã©ãŒã ã«ãããŠã
lseek()颿°ã§äœ¿ã远å ã®å®æ°ããµããŒãããããã«ãªããŸãããos.SEEK_HOLEãos.SEEK_DATAãªã©ã§ããNew constants
RTLD_LAZY,RTLD_NOW,RTLD_GLOBAL,RTLD_LOCAL,RTLD_NODELETE,RTLD_NOLOAD, andRTLD_DEEPBINDare available on platforms that support them. These are for use with thesys.setdlopenflags()function, and supersede the similar constants defined inctypesandDLFCN. (Contributed by Victor Stinner in bpo-13226.)ã¯ãã¹ãã©ãããã©ãŒã ã®ãµããŒããç°¡åã«ããããã«ãé Windows ç°å¢ã§ã
os.symlink()ãããŒã¯ãŒãåŒæ°target_is_directoryãåãä»ããããã«ãªããŸãã (åã«ç¡èŠããŸã)ã
pdb¶
Tab ããŒã§ã®è£å®ãã³ãã³ãåã ãã§ãªããã®åŒæ°ã«å¯ŸããŠã䜿ããããã«ãªããŸãããäŸãã° break ã³ãã³ãã«å¯ŸããŠã¯ã颿°ããã¡ã€ã«åãè£å®ãããŸãã
(Contributed by Georg Brandl in bpo-14210)
pickle¶
pickle.Pickler ãªããžã§ã¯ãã« pickler ããšã®ãªãã¯ã·ã§ã³é¢æ°ãèšå®ããããªãã·ã§ãã«ãª dispatch_table 屿§ã远å ãããŸããã
(Contributed by Richard Oudkerk in bpo-14166.)
pydoc¶
The Tk GUI and the serve() function have been removed from the
pydoc module: pydoc -g and serve() have been deprecated
in Python 3.2.
re¶
str æ£èŠè¡šçŸã \u ããã³ \U ãšã¹ã±ãŒãããµããŒãããŸããã
(Contributed by Serhiy Storchaka in bpo-3665.)
sched¶
run()ã blocking ãã©ã¡ãŒã¿ãåãããã«ãªããŸããã ãããåœã«ã»ãããããšããã®ã¡ãœããã¯æ¢ã«å®è¡äºå®æéã«ãªã£ãŠããã€ãã³ã (ããããã°) ãå®è¡ããŠããã«æ»ããŸãã ããã¯schedulerãéããããã³ã°ãªã¢ããªã±ãŒã·ã§ã³ã§äœ¿ãããå Žåã«æçšã§ãã (Contributed by Giampaolo Rodolà in bpo-13449.) (---蚳泚: åæã®è¡šçŸããããã«ããã§ãããããã¯blocking=Falseæã¯ã¹ã±ãžã¥ãŒã«ãããæéã«ãªã£ãŠããã¿ã¹ã¯ãããã°é垞㯠delayfunc ãåŒã³åºããšãããããããã«ãäžçªæ©ã次ã®äºå®æéã«éããã¿ã¹ã¯ã®äºå®æéãŸã§ã®æéå·®ãè¿ããŸãã---)schedulerã¯ã©ã¹ããã«ãã¹ã¬ããç°å¢ã§å®å šã«äœ¿ããããã«ãªããŸããã (Contributed by Josiah Carlson and Giampaolo Rodolà in bpo-8684.)schedulerã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿ã§ã®ãã©ã¡ãŒã¿ timefunc ãš delayfunc ãçç¥å¯èœã«ãªããŸãããããããããã©ã«ãã§é ã«time.time(),time.sleep()ã䜿ãããŸãã (Contributed by Chris Clark in bpo-13245.)enter()ãšenterabs()ã® argument ãã©ã¡ãŒã¿ãçç¥å¯èœã«ãªããŸããã (Contributed by Chris Clark in bpo-13245.)enter()ãšenterabs()ã kwargs ãã©ã¡ãŒã¿ãåãä»ããããã«ãªããŸããã (Contributed by Chris Clark in bpo-13245.)
select¶
Solaris ãšãã®æŽŸçãã©ãããã©ãŒã ã«ãããŠãæ°èŠã¯ã©ã¹ select.devpoll ã远å ãããŸãããããã¯ãã€ããã©ãŒãã³ã¹ãªéåæãœã±ããã /dev/poll çµç±ã§æäŸãããã®ã§ãã (Contributed by Jesús Cea Avión in bpo-6397.)
shlex¶
The previously undocumented helper function quote from the
pipes modules has been moved to the shlex module and
documented. quote() properly escapes all characters in a string
that might be otherwise given special meaning by the shell.
shutil¶
æ°ããªé¢æ°:
disk_usage(): ãã£ã¹ã¯ã®å©çšç¶æ³ã«ã€ããŠãããŒã¿ã«ã䜿çšäžã空ãã®å®¹éãè¿ããŸãã (Contributed by Giampaolo Rodolà in bpo-12442.)chown(): æå®ããã path ã®ãŠãŒã¶ãã°ã«ãŒãã®äž¡æ¹ãããã¯äžæ¹ã倿ŽããŸãããŠãŒã¶ãã°ã«ãŒãã¯ååãããã¯æ°å€ã§ã® ID (uid, gid) ã§æå®ããŸãã(Contributed by Sandro Tosi in bpo-12191.)shutil.get_terminal_size(): ã€ã³ã¿ããªã¿ãæ¥ç¶ããŠããã¿ãŒããã«ãŠã£ã³ããŠã®ãµã€ãºãååŸããŸãã (Contributed by Zbigniew JÄdrzejewski-Szmek in bpo-13609.)
copy2()ãšcopystat()ããã¡ã€ã«ã®ã¿ã€ã ã¹ã¿ã³ãããããããµããŒããããã©ãããã©ãŒã ã§ã¯ããç§ç²ŸåºŠãç¶æããããã«ãªããŸããããŸããLinux ã§ã¯ãããã¯ãæ¡åŒµå±æ§ (extended attributes)ããã³ããŒããããã«ãªããŸããã (Contributed by Larry Hastings in bpo-14127 and bpo-15238.)ããã€ãã®é¢æ°ããªãã·ã§ãã«ãª
symlinksåŒæ°ãåãããã«ãªããŸããããããçã®å Žåãã·ã³ããªãã¯ãªã³ã¯ã®æãå ã解決ããã®ã§ã¯ãªãã·ã³ããªãã¯ãã®ãã®ã«å¯ŸããŠã®æäœãããŸã (ããããããšãå¿ èŠã§ããã°ã·ã³ããªãã¯ãªã³ã¯äœæãããŸã)ã(Contributed by Hynek Schlawack in bpo-12715.)ãã¡ã€ã«ã·ã¹ãã ããŸããã£ããã¡ã€ã«ã®ã³ããŒã®éã«ã
move()ãã·ã³ããªãã¯ãªã³ã¯ã POSIX ã®moveã³ãã³ããè¡ãã®ãšåãããæ¹ã§æ±ãããã«ãªããŸãããã€ãŸãã¿ãŒã²ããã®ãã¡ã€ã«ã®äžèº«ãã³ããŒããã®ã§ã¯ãªãã·ã³ããªãã¯ãªã³ã¯ãåäœæããŸãã(Contributed by Jonathan Niehof in bpo-9993.) ãŸããmove()ã¯dståŒæ°ãæ»ãå€ãšããŠè¿ãããã«ãªããŸãããos.open()ãšos.unlink()ãæ°ãã©ã¡ãŒã¿dir_fdããµããŒãããŠãããã©ãããã©ãŒã ã§ã¯ãrmtree()ã¯ä»ã§ã¯ ã·ã³ããªãã¯ãªã³ã¯æ»æã«èæ§ãæã¡ãŸãã (Contributed by Martin von Löwis and Hynek Schlawack in bpo-4489.)
signal¶
signalã¢ãžã¥ãŒã«ã«æ°èŠé¢æ°ã远å ãããŸãã:pthread_sigmask(): ãããåŒã³åºãã¹ã¬ããã«ã»ãããããŠããã·ã°ãã«ãã¹ã¯ãåãåºããã倿ŽãããããŸã (Contributed by Jean-Paul Calderone in bpo-8407);pthread_kill(): ã¹ã¬ããã«ã·ã°ãã«ãéããŸã;sigpending(): ä¿çäžã®ã·ã°ãã«ã調ã¹ãŸã;sigwait(): ã·ã°ãã«ãåŸ ã¡ãŸã;sigwaitinfo(): ã·ã°ãã«ãåŸ ã¡ãŸãããããã«ã€ããŠã®è©³çްæ å ±ãè¿ããŸã;sigtimedwait():sigwaitinfo()ãšäŒŒãŠããŸããã¿ã€ã ã¢ãŠãæå®ã§ããŸãã
ã·ã°ãã«ãã³ãã©ã¯ wakeup ãã¡ã€ã«èšè¿°åã«ä»¥åã¯
\0ãæžã蟌ãã§ããŸããããã·ã°ãã«çªå·ã 1 ãã€ãæŽæ°ãšããŠæžã蟌ãããã«ããŸãããããã«ãããäžã€ä»¥äžã®ã·ã°ãã«ãåŸ ã£ãäžã§ã©ã®ã·ã°ãã«ãçºçããã®ãããšãã調ã¹ããšãã£ãããšãåºæ¥ãŸããsignal.signal()ãšsignal.siginterrupt()㯠RuntimeError ã§ã¯ãªãOSErrorãæããããã«ãªããŸãã: OSError 㯠errno 屿§ãæã£ãŠããŸãã
smtpd¶
The smtpd module now supports RFC 5321 (extended SMTP) and RFC 1870
(size extension). Per the standard, these extensions are enabled if and only
if the client initiates the session with an EHLO command.
(Initial ELHO support by Alberto Trevino. Size extension by Juhana
Jauhiainen. Substantial additional work on the patch contributed by Michele
Orrù and Dan Boswell. bpo-8739)
smtplib¶
ã¯ã©ã¹ SMTP, SMTP_SSL, LMTP ã«æ°ããããŒã¯ãŒãåŒæ° source_address ã远å ãããŸããã (host, port) ã®åœ¢ã§æå®ããããã¯å€ã«åãããœã±ãããäœæããéã« bind() åŒã³åºãå
ã§ã®ãœãŒã¹ã¢ãã¬ã¹ãšããŠçšããããŸãã(Contributed by Paulo Scardine in bpo-11281.)
SMTP ãã³ã³ããã¹ã管çãããã³ã«ããµããŒãããããã«ãªã£ãã®ã§ SMTP ã®ã€ã³ã¹ã¿ã³ã¹ã with æã§äœ¿ããŸãã (Contributed by Giampaolo Rodolà in bpo-11289.)
SMTP_SSL ã³ã³ã¹ãã©ã¯ã¿ãš starttls() ã¡ãœããã SSLContext ãã©ã¡ãŒã¿ãåãåãããã«ãªããŸãããããã¯ã»ãã¥ã¢ãªãã£ãã«ã®ãã©ã¡ãŒã¿ãå¶åŸ¡ããŸãã (Contributed by Kasun Herath in bpo-8809.)
socket¶
socketã¯ã©ã¹ããåæãšãªããã©ãããã©ãŒã ããµããŒãããŠããã°åŸå±çãªããŒã¿ãåŠçãã远å ã®ã¡ãœãããå ¬éããŸãã:(Contributed by David Watson in bpo-6560, based on an earlier patch by Heiko Wundram)
socketã¯ã©ã¹ã Linux ã§ (https://lwn.net/Articles/253425) PF_CAN ãããã³ã«ãã¡ã㪠(https://en.wikipedia.org/wiki/Socketcan) ããµããŒãããŸããã(Contributed by Matthias Fuchs, updated by Tiago Gonçalves in bpo-10141.)
The
socketclass now supports the PF_RDS protocol family (https://en.wikipedia.org/wiki/Reliable_Datagram_Sockets and https://oss.oracle.com/projects/rds).socketã¯ã©ã¹ã OS X ã§PF_SYSTEMãããã³ã«ãã¡ããªããµããŒãããããã«ãªããŸããã (Contributed by Michael Goderbauer in bpo-13777.)New function
sethostname()allows the hostname to be set on Unix systems if the calling process has sufficient privileges. (Contributed by Ross Lagerwall in bpo-10866.)
socketserver¶
BaseServer ããªãŒãã©ã€ãå¯èœãª service_actions() ã¡ãœãããæã€ããã«ãªãããã㯠serve_forever() ã«ãããµãŒãã¹ã«ãŒãå
ã§åŒã³åºãããŸãã ForkingMixIn ãããããŸã³ãåããåããã»ã¹ã®ã¯ãªãŒã³ã¢ããã«äœ¿ã£ãŠããŸãã (Contributed by Justin Warkentin in bpo-11109.)
sqlite3¶
sqlite3.Connection ã®æ°èŠã®ã¡ãœãã set_trace_callback() ã䜿ããš sqlite3 ã«ããåŠçããããã¹ãŠã® sql ã³ãã³ãã®è¶³è·¡ (ãã¬ãŒã¹) ããã£ããã£åºæ¥ãŸãã(Contributed by Torsten Landschoff in bpo-11688.)
ssl¶
sslã¢ãžã¥ãŒã«ã«æ°ãã« 2 ã€ã®ä¹±æ°çæé¢æ°ã远å ãããŸãã:RAND_bytes(): æå·åŠçã«åŒ·åºãªæ¬äŒŒä¹±æ°ãã€ãåãçæããŸããRAND_pseudo_bytes(): generate pseudo-random bytes.
(Contributed by Victor Stinner in bpo-12049.)
sslã¢ãžã¥ãŒã«ãããç²åºŠã®çްããäŸå€éå±€ãå ¬éããããã«ãªããããã«ããæ§ã ãªçš®é¡ã®ãšã©ãŒã調ã¹ãããšã容æã«ãªããŸãã (Contributed by Antoine Pitrou in bpo-11183.)load_cert_chain()ã password åŒæ°ãåãä»ããããã«ãªããŸãããããã¯ç§å¯éµãæå·åãããŠããå Žåã«äœ¿ãããŸãã (Contributed by Adam Simpkins in bpo-12803.)ãã£ãã£ãŒã»ãã«ãã³éµå ±æã®ãéåžžã®ãã®ãšæ¥åæ²ç·ããŒã¹ã®ãã®äž¡æ¹ã
load_dh_params()ã¡ãœãããšset_ecdh_curve()ã¡ãœãããéããŠãµããŒããããããã«ãªããŸããã(Contributed by Antoine Pitrou in bpo-13626 and bpo-13627.)SSL ãœã±ããã«æ°èŠã¡ãœãã
get_channel_binding()ã远å ãããŸããããã㯠SCRAM-SHA-1-PLUS (蚳泚: RFC 5802 ãªã©åç §) ã®ãããªããçš®ã®èªèšŒã¡ã«ããºã ã®å®è£ ã§æ¡åŒµãããããšãæ³å®ãããã®ã§ãã(Contributed by Jacek Konieczny in bpo-12551.)You can query the SSL compression algorithm used by an SSL socket, thanks to its new
compression()method. The new attributeOP_NO_COMPRESSIONcan be used to disable compression. (Contributed by Antoine Pitrou in bpo-13634.)ssl.SSLContext.set_npn_protocols()ã«ãã Next Protocol Negotiation æ¡åŒµã®ãµããŒãã远å ãããŸããã (Contributed by Colin Marc in bpo-14204.)屿§
libraryãšreasonã远å ãããã®ã§ãSSL ã®ãšã©ãŒã¯ä»¥åãããã£ãšç°¡åã«èª¿ã¹ãããšãåºæ¥ãããã«ãªããŸããã(Contributed by Antoine Pitrou in bpo-14837.)get_server_certificate()颿°ã IPv6 ããµããŒãããããã«ãªããŸããã (Contributed by Charles-François Natali in bpo-11811.)New attribute
OP_CIPHER_SERVER_PREFERENCEallows setting SSLv3 server sockets to use the server's cipher ordering preference rather than the client's (bpo-13635).
stat¶
ããã¥ã¡ã³ããããŠããªãã£ã tarfile.filemode 颿°ã stat.filemode() ã«ç§»åãããŸãããããã¯ãã¡ã€ã«ã¢ãŒãã '-rwxrwxrwx' 圢åŒã®æååã«å€æããã®ã«äœ¿ããŸãã
(Contributed by Giampaolo Rodolà in bpo-14807.)
struct¶
The struct module now supports ssize_t and size_t via the
new codes n and N, respectively. (Contributed by Antoine Pitrou
in bpo-3163.)
subprocess¶
POSIX ãã©ãããã©ãŒã ã«ãããŠãã³ãã³ãæååãšã㊠bytes ãªããžã§ã¯ããæž¡ããããã«ãªããŸããã (Contributed by Victor Stinner in bpo-8513.)
A new constant DEVNULL allows suppressing output in a
platform-independent fashion. (Contributed by Ross Lagerwall in
bpo-5870.)
sys¶
sys ã¢ãžã¥ãŒã«ã«ãã¹ã¬ããã®å®è£
ã«é¢ããæ
å ±ãæ ŒçŽããã ååä»ãã¿ãã« ãä¿æãã thread_info ã远å ãããŸããã (bpo-11223)
tarfile¶
tarfile ã lzma ã¢ãžã¥ãŒã«ã«ãã lzma ãšã³ã³ãŒãã£ã³ã°ããµããŒãããããã«ãªããŸãã (Contributed by Lars GustÀbel in bpo-5689.)ã
tempfile¶
tempfile.SpooledTemporaryFile's truncate() method now accepts
a size parameter. (Contributed by Ryan Kelly in bpo-9957.)
textwrap¶
textwrap ã¢ãžã¥ãŒã«ã« indent() ã远å ãããŸãããããã¯ããã¹ãã®ãããã¯å
ã®éžæè¡ã«å
±éã®ãã¬ãã£ã¯ã¹ã远å ããç°¡åãªæ¹æ³ã«ãªããŸãã(bpo-13857)
threading¶
ãããããã€ãŠã€ã³ã¹ã¿ã³ã¹ãè¿ããã¡ã¯ããªé¢æ°ã§ãã£ã threading.Condition, threading.Semaphore, threading.BoundedSemaphore, threading.Event, threading.Timer ãã¯ã©ã¹ã«ãªã£ãã®ã§ããµãã¯ã©ã¹ååºæ¥ãããã«ãªããŸããã (Contributed by Ãric Araujo in bpo-10968.)
threading.Thread ã³ã³ã¹ãã©ã¯ã¿ãããŒã¯ãŒãåŒæ° daemon ãåãããã«ãªããŸãããããã¯èŠªã¹ã¬ãããã daemon ãã©ã°ãç¶æ¿ããããã©ã«ãã®æ¯ãèãããªãŒãã©ã€ãããŸã (bpo-6064)ã
ãã€ãŠã®éå
¬é颿° _thread.get_ident ãå
¬é颿° threading.get_ident() ãšããŠå©çšå¯èœãšãªã£ãŠããŸããããã¯æšæºã©ã€ãã©ãªã«ãããŠå€æ°ã® _thread ã¢ãžã¥ãŒã«ãžã®çŽæ¥ã¢ã¯ã»ã¹ãåãé€ãçµæã«ãªããŸããã _thread.get_ident ã䜿ã£ãŠãããµãŒãããŒãã£ã®ã³ãŒããåãããã«ãæ°ããå
¬éåãããã€ã³ã¿ãŒãã§ã€ã¹ã«ä¹ãæããã¹ãã§ãã
time¶
PEP 418 ã time ã¢ãžã¥ãŒã«ã«æ°ããªé¢æ°ã远å ããŸãã:
get_clock_info(): ã¯ããã¯ã®æ å ±ãååŸããŸããmonotonic(): å調ãªã¯ãã㯠(éè¡ããªã)ãã·ã¹ãã ã¯ããã¯ã®æŽæ°ã®åœ±é¿ãåããŸãããperf_counter(): çæéã®èšæž¬ã®ããã«å©çšå¯èœãªæé«ã®è§£å床ãæã€ããã©ãŒãã³ã¹ã«ãŠã³ã¿ã§ããprocess_time(): çŸåšã®ããã»ã¹ã® system ãš user CPU æéã®åã§ãã
ãã®ä»ã®æ°ããªé¢æ°:
clock_getres(),clock_gettime()andclock_settime()functions withCLOCK_xxxconstants. (Contributed by Victor Stinner in bpo-10278.)
ã¯ãã¹ãã©ãããã©ãŒã éã§ã®äžè²«æ§ãæ¹åããããã«ã sleep() ãè² ã®å€ãæž¡ããš ValueError ãæããããã«å€æŽãããŠããŸãã以åãã POSIX ã·ã¹ãã ã§ã¯ãšã©ãŒã§ããããWindows ã®å Žåã«ç¡éã« sleep ããŠããŸããã
types¶
æ°èŠã¯ã©ã¹ types.MappingProxyType ã®è¿œå : èªã¿åºãå°çšã®ãããã³ã°ã®ãããã·ã§ãã (bpo-14386)
æ°èŠé¢æ° types.new_class() ãš types.prepare_class() 㯠PEP 3115 æºæ ã®åçãªåã®çæãµããŒããæäŸããŸãã(bpo-14588)
unittest¶
ã¡ãœãã assertRaises(), assertRaisesRegex(), assertWarns(), assertWarnsRegex() ããã³ã³ããã¹ããããŒãžã£ãšããŠäœ¿ãããéã«ããŒã¯ãŒãåŒæ° msg ãåãä»ããããã«ãªããŸããã (Contributed by Ezio Melotti and Winston Ewert in bpo-10775.)
unittest.TestCase.run() ã TestResult ãªããžã§ã¯ããè¿ãããã«ãªããŸããã
urllib¶
Request ã¯ã©ã¹ã get_method() ã§äœ¿ããã method åŒæ°ãåãä»ããããã«ãªããŸãããããã¯ã©ã® HTTP ã¡ãœããã䜿ãããã¹ãããæå®ããŸããäŸãã°ä»¥äžã¯ 'HEAD' ãªã¯ãšã¹ããéä¿¡ããŸã:
>>> urlopen(Request('https://www.python.org', method='HEAD'))
webbrowser¶
webbrowser ã¢ãžã¥ãŒã«ãããã«å€ãã® "browsers" ããµããŒãããŸãã: Google Chrome (ããŒãžã§ã³ãš OS äŸåã§ååã chrome, chromium, chrome-browser, ããã㯠chromium-browser) ãšãæ±çšã®ã©ã³ã㣠xdg-open (FreeDesktop.org ãããžã§ã¯ãã®ãã®) ãš gvfs-open (GNOME 3 ã®ããã©ã«ã URI ãã³ãã©)ã (The former contributed by Arnaud Calmettes in bpo-13620, the latter by Matthias Klose in bpo-14493.)
xml.etree.ElementTree¶
The xml.etree.ElementTree module now imports its C accelerator by
default; there is no longer a need to explicitly import
xml.etree.cElementTree (this module stays for backwards compatibility,
but is now deprecated). In addition, the iter family of methods of
Element has been optimized (rewritten in C).
The module's documentation has also been greatly improved with added examples
and a more detailed reference.
zlib¶
New attribute zlib.Decompress.eof makes it possible to distinguish
between a properly formed compressed stream and an incomplete or truncated one.
(Contributed by Nadeem Vawda in bpo-12646.)
New attribute zlib.ZLIB_RUNTIME_VERSION reports the version string of
the underlying zlib library that is loaded at runtime. (Contributed by
Torsten Landschoff in bpo-12306.)
æé©å¶
倧ããªæ§èœåäžããããŸãã:
PEP 393 ã«ãããUnicode æååã«å¯Ÿããæäœãæé©åãããŸãã:
ã¡ã¢ãªãããããªã³ãã¯ããã¹ãã«äŸåã㊠1/2 ãã 1/4 ã«ãªããŸãã
ASCII æååã UTF-8 ã«ãšã³ã³ãŒãããã®ã«æåããšã³ã³ãŒãããå¿ èŠã¯ãªããªããŸãããUTF-8 衚çŸã¯ ASCII 衚çŸãšå ±æãããŸã
UTF-8 ãšã³ã³ãŒããæé©åãããŸãã
åäžã® ASCII æåãç¹°ãè¿ã㊠ASCII æååã®éšååãåŸãã®ã¯ 4 åéããªããŸãã
UTF-8 ã2åãã4åéããªããŸãããUTF-16 ã®ãšã³ã³ãŒãã£ã³ã°ãæå€§ã§10åéããªããŸããã
(Contributed by Serhiy Storchaka, bpo-14624, bpo-14738 and bpo-15026.)
ãã«ããªãã³ã« C API ã®å€æŽÂ¶
Python ã®ãã«ãéçšãš C API ã®å€æŽã¯ä»¥äžã®éãã§ã:
æ°ãã PEP 3118 é¢é£ã®é¢æ°:
PEP 393 ã«ãã远å ãããæ°ã㪠Unicode åããã¯ãã颿°:
髿°Žæº API:
äœæ°Žæº API:
æ§é äœ
PyASCIIObjectãšPyCompactUnicodeObjectPyUnicode_DATA,PyUnicode_1BYTE_DATA,PyUnicode_2BYTE_DATA,PyUnicode_4BYTE_DATAPyUnicode_KINDwithPyUnicode_Kindenum:PyUnicode_WCHAR_KIND,PyUnicode_1BYTE_KIND,PyUnicode_2BYTE_KIND,PyUnicode_4BYTE_KIND
PyArg_ParseTupleãcãã©ãŒããããšããŠbytearrayã蚱容ããããã«ãªããŸãã (bpo-12380)ã
éæšå¥šÂ¶
ãµããŒããããªããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ¶
ä¿å®ããè ãããªããã OS/2 ãªãã³ã« VMS ã¯ãã¯ããµããŒããããŸããã
ä¿å®ã®è² æ
ã®ãã WIndows 2000 ããã³ COMSPEC ã command.com ã«èšå®ããŠãã Windows ãã©ãããã©ãŒã ã¯ãã¯ããµããŒããããŸããã
3.2 ã§éæšå¥šã ã£ã OSF ã®ãµããŒããå®å šã«åé€ãããŸããã
éæšå¥šã® Python ã¢ãžã¥ãŒã«ã颿°ãã¡ãœãã¶
object åãã®ãã®ã®
object.__format__()ã«ç©ºã§ãªãæååãæž¡ãããšã¯éæšå¥šãšãªããŸãããPython 3.4 ã§ã¯ããã¯TypeErrorãšãªããŸã (bpo-9856)ãPEP 393 ã«ããã
unicode_internalã³ãŒããã¯ã¯éæšå¥šãšãªããŸãããUTF-8, UTF-16 (utf-16-leãŸãã¯utf-16-be), ããã㯠UTF-32 (utf-32-leãŸãã¯utf-32-be) ã䜿ã£ãŠãã ãããftplib.FTP.nlst()ããã³ftplib.FTP.dir():ftplib.FTP.mlsd()ã䜿ã£ãŠãã ããplatform.popen(): use thesubprocessmodule. Check especially the Replacing Older Functions with the subprocess Module section (bpo-11377).bpo-13374:
osã¢ãžã¥ãŒã«ã«ãã Windows ã®ãã€ãå API ã¯éæšå¥šãšãªããŸãããANSI ã³ãŒãããŒãžã«äŸåããªãããã«ããŠãããããã¡ã€ã«åããµããŒãããããã«ããã€ãåæååã®ãã¡ã€ã«åã§ã¯ãªã Unicode ãã¡ã€ã«åã䜿ã£ãŠãã ãããbpo-13988: The
xml.etree.cElementTreemodule is deprecated. The accelerator is used automatically whenever available.The behaviour of
time.clock()depends on the platform: use the newtime.perf_counter()ortime.process_time()function instead, depending on your requirements, to have a well defined behaviour.The
os.stat_float_times()function is deprecated.abcã¢ãžã¥ãŒã«:@abc.abstractpropertyhas been deprecated, use@propertywith@abc.abstractmethodinstead.@abc.abstractclassmethodhas been deprecated, use@classmethodwith@abc.abstractmethodinstead.@abc.abstractstaticmethodhas been deprecated, use@staticmethodwith@abc.abstractmethodinstead.
importlibããã±ãŒãž:ãã€ãã³ãŒããã¡ã€ã«ãšããŠã®
importlib.abc.SourceLoader.path_stats()ã«ããã³ã³ãã€ã«æç¹ã®ä¿®æ£æå»ãšãœãŒã¹ãã¡ã€ã«ãµã€ãºã®äž¡æ¹ãæ ŒçŽããããã«ãªã£ãã®ã§ãimportlib.abc.SourceLoader.path_mtime()ã¯éæšå¥šãšãªããŸããã
C API ã®éæšå¥šã®é¢æ°ãªãã³ã«å¶
PEP 393 ã§ Py_UNICODE ã¯éæšå¥šã«ãªããPython 4 ã§åé€ãããŸãããã®åã䜿çšããŠããå
šãŠã®é¢æ°ã¯éæšå¥šã§ãã
Unicode functions and methods using Py_UNICODE and
Py_UNICODE* types:
PyUnicode_FromUnicode: usePyUnicode_FromWideChar()orPyUnicode_FromKindAndData()PyUnicode_AS_UNICODE,PyUnicode_AsUnicode(),PyUnicode_AsUnicodeAndSize(): usePyUnicode_AsWideCharString()PyUnicode_AS_DATA: usePyUnicode_DATAwithPyUnicode_READandPyUnicode_WRITEPyUnicode_GET_SIZE,PyUnicode_GetSize(): usePyUnicode_GET_LENGTHorPyUnicode_GetLength()PyUnicode_GET_DATA_SIZE: usePyUnicode_GET_LENGTH(str) * PyUnicode_KIND(str)(only work on ready strings)PyUnicode_AsUnicodeCopy(): usePyUnicode_AsUCS4Copy()orPyUnicode_AsWideCharString()PyUnicode_GetMax()
Py_UNICODE* æååãæäœãã颿°ãªãã³ã«ãã¯ã:
Py_UNICODE_strlen(): usePyUnicode_GetLength()orPyUnicode_GET_LENGTHPy_UNICODE_strcat(): usePyUnicode_CopyCharacters()orPyUnicode_FromFormat()Py_UNICODE_strcpy(),Py_UNICODE_strncpy(),Py_UNICODE_COPY(): usePyUnicode_CopyCharacters()orPyUnicode_Substring()Py_UNICODE_strcmp(): usePyUnicode_Compare()Py_UNICODE_strncmp(): usePyUnicode_Tailmatch()Py_UNICODE_strchr(),Py_UNICODE_strrchr(): usePyUnicode_FindChar()Py_UNICODE_FILL(): usePyUnicode_Fill()Py_UNICODE_MATCH
ãšã³ã³ãŒã:
PyUnicode_Encode(): usePyUnicode_AsEncodedObject()PyUnicode_EncodeUTF7()PyUnicode_EncodeUTF8(): usePyUnicode_AsUTF8()orPyUnicode_AsUTF8String()PyUnicode_EncodeUTF32()PyUnicode_EncodeUTF16()PyUnicode_EncodeUnicodeEscape()usePyUnicode_AsUnicodeEscapeString()PyUnicode_EncodeRawUnicodeEscape()usePyUnicode_AsRawUnicodeEscapeString()PyUnicode_EncodeLatin1(): usePyUnicode_AsLatin1String()PyUnicode_EncodeASCII(): usePyUnicode_AsASCIIString()PyUnicode_EncodeCharmap()PyUnicode_TranslateCharmap()PyUnicode_EncodeMBCS(): usePyUnicode_AsMBCSString()orPyUnicode_EncodeCodePage()(withCP_ACPcode_page)PyUnicode_EncodeDecimal(),PyUnicode_TransformDecimalToASCII()
éæšå¥šã®æ©èœÂ¶
array ã¢ãžã¥ãŒã«ã® 'u' æžåŒåã³ãŒãã¯éæšå¥šãšãªããŸãããPython 4 ã§ã¯ã»ãã® (Py_UNICODE) API ãšäžç·ã«åé€ãããã§ãããã
Python 3.3 ãžã®ç§»æ€Â¶
ãã®ã»ã¯ã·ã§ã³ã§ã¯åè¿°ã®å€æŽãšãã°ãã£ãã¯ã¹ã«ããå¿ èŠãšãªããããããªãã³ãŒãã®å€æŽãåæããŸã:
Python ã³ãŒãã®ç§»æ€Â¶
ããã·ã¥ã®ã©ã³ãã åãããã©ã«ãã§æå¹ã«ãªããŸããããããç¡å¹ã«ããã«ã¯ç°å¢å€æ°
PYTHONHASHSEEDã0ã«ã»ããããŠäžãããobject.__hash__()ã¡ãœãããåç §ããŠäžãããbpo-12326: Linux ã§ã¯ã
sys.platformã¯ãã¯ãã¡ãžã£ãŒããŒãžã§ã³çªå·ãå«ã¿ãŸããã ããã¯ä»ã§ã¯åžžã« 'linux' ã§ãã以åã¯ãã㯠Python ã®ãã«ãã«äœ¿ããã Linux ããŒãžã§ã³ã«äŸåãã'linux2'ã'linux3'ã§ãããsys.platform == 'linux2'ãªã©ãšããã®ã§ã¯ãªããsys.platform.startswith('linux')ãšããããå€ã Python ããŒãžã§ã³ã®ãµããŒããäžèŠã§ããã°çŽæ¥çã«sys.platform == 'linux'ãšããŠäžãããbpo-13847, bpo-14180:
timeããã³datetime: ã¿ã€ã ã¹ã¿ã³ããç¯å²å€ã®å Žåã«ãValueErrorã§ã¯ãªãOverflowErrorãéåºããããã«ãªããŸããããŸããC 颿°ã®gmtime()ãããã¯localtime()ã倱æããå Žåã«ã¯OSErrorãéåºããããã«ãªããŸãããã€ã³ããŒãã§äœ¿ãããããã©ã«ãã®ãã¡ã€ã³ãããç¹å®ã®ãã£ã¬ã¯ããªã«äœãå«ãŸããã®ãã«ã€ããŠã®ãã£ãã·ã¥ãå©çšããããã«ãªã£ãŠããŸããå®è¡äžã« Python ãœãŒã¹ãã¡ã€ã«ããã€ãã³ãŒããã¡ã€ã«ãäœã£ããããã£ãã·ã¥ãã¯ãªã¢ããŠãã¡ã€ã³ããæ°ããäœããããã¡ã€ã«ã«æ°ä»ããããã«ã
importlib.invalidate_caches()ãåŒã¶å¿ èŠãããããšã«æ³šæããŠãã ãããImportErrorãã€ã³ããŒãã詊ã¿ãã¢ãžã¥ãŒã«åãšããŠå®å šåã䜿ãããã«ãªã£ãŠããŸããImportError ã®ã¡ãã»ãŒãžããã§ãã¯ãã doctest ã¯ãã¢ãžã¥ãŒã«åããã®æ«å°Ÿã®ååã§ã¯ãªãå®å šãªååã䜿ãããã«æŽæ°ããå¿ èŠããããŸãã__import__()ã®åŒæ° index ã®ããã©ã«ãã -1 ã§ã¯ãªã 0 ãšãªãããŸãããã¯ãè² ã®å€ã¯ãµããŒããããŸãããããã©ã«ãå€ã -1 ã§æ®ãããã®ã¯(蚳泚: ã€ãŸã絶察ãçžå¯Ÿã€ã³ããŒãã®äž¡æ¹ã詊ã¿ãããã«ããã®ã¯) PEP 328 ãå®è£ ããéã®é倱ã§ããã絶察ã€ã³ããŒãã«å ç«ã£ãŠçžå¯Ÿã€ã³ããŒããå®è¡ããæ¯ãèãããŸã å¿ èŠãªã®ã§ããã°ãindex ã 1 ã«ããŠçžå¯Ÿã€ã³ããŒããå®è¡ããŠããã®åŸã§ index 0 ã®ã€ã³ããŒããããããã«ããŠãã ããããããªã®ã§ããã__import__()ãçŽæ¥åŒã³åºãã®ã§ã¯ãªããimportlib.import_module()ã䜿ãããšãæãŸããããæ¹ã§ãã__import__()ã® index ã«ããããã¬ãã«ã¢ãžã¥ãŒã«ã«å¯Ÿã㊠0 ã§ãªã 1 ãäžããããšã¯ä»ã§ã¯èš±ãããŸãããäŸãã°__import__('sys', level=1)ã¯ãšã©ãŒã§ããBecause
sys.meta_pathandsys.path_hooksnow have finders on them by default, you will most likely want to uselist.insert()instead oflist.append()to add to those lists.Because
Noneis now inserted intosys.path_importer_cache, if you are clearing out entries in the dictionary of paths that do not have a finder, you will need to remove keys paired with values ofNoneandimp.NullImporterto be backwards-compatible. This will lead to extra overhead on older versions of Python that re-insertNoneintosys.path_importer_cachewhere it represents the use of implicit finders, but semantically it should not change anything.importlib.abc.Finderno longer specifies afind_module()abstract method that must be implemented. If you were relying on subclasses to implement that method, make sure to check for the method's existence first. You will probably want to check forfind_loader()first, though, in the case of working with path entry finders.pkgutilã¯ãå éšçã«importlibã䜿ãããã«å€æŽãããŸããããã®ããšã¯ã PEP 302 ã€ã³ããŒããšãã¥ã¬ãŒã·ã§ã³ã®å€ãæ¯ãèããæ¬ç©ã®ã€ã³ããŒãã·ã¹ãã ã®æ¯ãèãã«åãããã®ã«å€±æããŠããæ°å€ãã®ç¹æ®ã±ãŒã¹ã®åé¡ãåãé€ããŸããã€ã³ããŒããšãã¥ã¬ãŒã·ã§ã³ãã®ãã®ã¯ãŸã ååšããŸãããä»ã§ã¯éæšå¥šã§ããpkgutil.iter_importers()颿°ãšpkgutil.walk_packages()颿°ã¯æšæºã€ã³ããŒãããã¯ãç¹å¥ã«æ±ãã®ã§ããã¡ã€ã³ãã®iter_modules()ã¡ãœããã¯æšæºã§ã¯ãªãã«ãé¢ãããããŸã ãµããŒããããŸããemail.header.decode_header()ã«ãã£ãŠãªãããè§£æã«é·ãéååšããŠãã RFC éæºæ ã®ãã° (bpo-1079) ãä¿®æ£ãããŸããããšã³ã³ãŒãããããããã Unicode ã«å€æããããã®æšæºçãªã€ãã£ãªã (str(make_header(decode_header(h))) ã䜿ãã³ãŒãããã¯å€åã¯ã¿ããŸãããã§ããã decode_header ããè¿ãããåã ã®ã¿ãã«èŠçŽ ãèŠãŠããã³ãŒãã§ã¯ãASCIIã»ã¯ã·ã§ã³ã®ååŸã®ç©ºçœãASCIIå ã«å«ãŸããããã«ãªã£ãããšãããããŸããmake_headerã¯å ¥åæååã«æ¢ã«ååšããŠããªããã°ASCIIéASCIIã»ã¯ã·ã§ã³éã«ä»¥åãšåãã空çœã远å ããã®ã§ãmake_headerã䜿ã£ãŠããããæ§ç¯ããã³ãŒãã¯å€æŽãªãã§åäœããã¯ãã§ããemail.utils.formataddr()ã¯é ASCII ã® display name ã«å¯Ÿãæ£ãã content transfer encoding ã®æ±ããããããã«ãªã£ãŠããŸãããã€ãŠã®ããã©ãŒãããåŸæååå ã«é ASCII Unicode ãç¶æããŠããŸã誀ã£ãæ¯ãèãã«äŸåãããã¹ãŠã®ã³ãŒãã¯ã倿Žã®å¿ èŠããããŸãã (bpo-1690608)poplib.POP3.quit()ã¡ãœãããã»ãã®å šãŠã®poplibã®ã¡ãœãããšåãããä»ã§ã¯ãããã³ã«ãšã©ãŒãéåºãåŸãŸããquitãpoplib.error_protoãšã©ãŒãéåºããªãããšãããŠã«ããŠããã³ãŒãã¯ãquitã§ã®ãšã©ãŒãç¹å®ã®ã¢ããªã±ãŒã·ã§ã³ã«ãšã£ãŠåé¡ãšãªãããã§ããã°ãä¿®æ£ã®å¿ èŠããããããããŸãã (bpo-11291)ãPython 2.4 ããéæšå¥šãšãªã£ãŠããã
email.parser.Parserãžã®strictåŒæ°ã¯ã€ãã«åé€ãããŸãããéæšå¥šãšãªã£ãŠããã¡ãœãã
unittest.TestCase.assertSameElementsã¯åé€ãããŸãããéæšå¥šãšãªã£ãŠãã倿°
time.accept2dyearã¯åé€ãããŸãããéæšå¥šãšãªã£ãŠãã
Context._clamp屿§ãdecimalã¢ãžã¥ãŒã«ããåé€ãããŸããã以åã«æ¢ã«ããã¯å ¬é屿§clampã«çœ®ãæããããŠããŸãã (bpo-8540 åç §)ãææžåãããŠããªãã£ãå éšãã«ãã¯ã©ã¹
SSLFakeFileãsmtplibã¢ãžã¥ãŒã«ããåé€ãããŸããããã®æ©èœã¯ãã£ãšä»¥åããsocket.socket.makefile()ã«ãã£ãŠçŽæ¥çã«æäŸãããŠããŸããWindows ã§ã¯
time.sleep()ã«è² å€ãäžããå Žåã«ç¡éã«ç ã£ãŠããŸããããä»ã§ã¯ããã¯äŸå€ãéåºããŸããPOSIX ã§ã¯ããã¯ä»¥åããåžžã«äŸå€ã§ããThe
ast.__version__constant has been removed. If you need to make decisions affected by the AST version, usesys.version_infoto make the decision.threadingã¢ãžã¥ãŒã«ã®ãéå ¬éã¯ã©ã¹ããµãã¯ã©ã¹åãããã¡ã¯ããªé¢æ°ãè¿åããŠããã³ãŒãã¯ãä»ã§ã¯å ¬éã¯ã©ã¹ã«ãªã£ãã®ã§ä¿®æ£ã®å¿ èŠããããŸããthreading ã¢ãžã¥ãŒã«å ã®ææžåãããŠããªãã£ããããã°æ©æ§ãåé€ããŠã³ãŒããåçŽåããŸããããã®ããšã補åã³ãŒãã«åœ±é¿ããããšããã£ãŠã¯ãªããŸãããããããšé£æºããŠããã¢ããªã±ãŒã·ã§ã³ãããã°ãã¬ãŒã ã¯ãŒã¯ã®ã±ãŒã¹ãããããã®ã§ãèšåããŠãããŸã (bpo-13550)ã
C ã³ãŒãã®ç§»æ€Â¶
In the course of changes to the buffer API the undocumented
smalltablemember of thePy_bufferstructure has been removed and the layout of thePyMemoryViewObjecthas changed.memoryobject.hãããã¯object.hã§ã®é¢ä¿ããéšåã«äŸåããå šãŠã®æ¡åŒµã¯ãåãã«ããå¿ èŠã§ããPEP 393 ã«ããã
Py_UNICODEåãšãã®åã䜿ãå šãŠã®é¢æ°ã¯éæšå¥šãšãªããŸãã (ãã ãæäœ 5 幎ã¯å©çšå¯èœãªãŸãŸä¿ãããŸã)ãUnicode ãªããžã§ã¯ãã®æ§ç¯ãšã¢ã¯ã»ã¹ã«äœæ°Žæº Unicode API ããããŸã§äœ¿ã£ãŠããŠã PEP 393 ã«ãã£ãŠæäŸãããã¡ã¢ãªãããããªã³ãåæžã®æ©æµãåããããã°ãæ°ãã Unicode API ã«ä¹ãæããå¿ èŠããããŸããäžæ¹ã§
PyUnicode_Concat()ãPyUnicode_Join()ãããã¯PyUnicode_FromFormat()ãšãã£ã髿°Žæºé¢æ°ã®ã¿ã䜿ã£ãŠããã®ã§ããã°ãããªãã®ã³ãŒãã¯èªåçã«æ°ãã Unicode 衚çŸã«äŸ¿ä¹ã§ããŸããPyImport_GetMagicNumber()ã¯å€±ææã«-1ãè¿ãããã«ãªããŸããã__import__()ã® level åŒæ°ã«è² å€ãæž¡ãããšã¯ãã¯ãæå¹ã§ã¯ãªãã®ã§ã察å¿ããPyImport_ImportModuleLevel()ã§ãåãã§ãããã®ããšã¯PyImport_ImportModuleEx()ã«äœ¿ããã level ã®å€ã-1ã§ã¯ãªã0ã䜿ãããã«ãªã£ãããšãæå³ããŠããŸãã
C æ¡åŒµã®ãã«ã¶
C æ¡åŒµã®ãã¡ã€ã«åãšããŠèªããããç¯å²ãçããããŸãããæ» å€ã«äœ¿ãããŠããªãã£ãåœåã¯åããããããŸãã: POSIX ã§ã¯ã
xxxmodule.so,xxxmodule.abi3.so,xxxmodule.cpython-*.soåœåã¯ä»åŸxxxã¢ãžã¥ãŒã«ã®å®è£ ãšã¯èªèãããŸããããããŸã§ãã®ãããªãã¡ã€ã«ãäœã£ãŠããã®ã§ããã°ãå¥ã®åœåã«ä¹ãæããŠãã ãã (ã€ãŸãmoduleæååããã¡ã€ã«åããåãé€ããŠãã ãã)ã(implemented in bpo-14040.)
ã³ãã³ãã©ã€ã³ã¹ã€ããã®å€æŽÂ¶
-Qã³ãã³ãã©ã€ã³ã¹ã€ãããšããã«é¢ä¿ãããã®ã¯åé€ãããŸãããsys.flags.division_warningããã§ãã¯ããŠããã³ãŒãã¯ä¿®æ£ããå¿ èŠããããŸãã(bpo-10998, contributed by Ãric Araujo.)
-Sã¹ã€ããä»ãã§ python ãéå§ãããšãimport siteãã¢ãžã¥ãŒã«æ€çŽ¢ãã¹ã«ãµã€ãåºæã®ãã¹ã远å ããªããªããŸãã以åã®ããŒãžã§ã³ã§ã¯ãããããŠããŸããã(bpo-11591, contributed by Carl Meyer with editions by Ãric Araujo.)