@@ -1714,6 +1714,26 @@ msgid ""
1714
1714
"b'X7899 warehouse Reserve cog '\n"
1715
1715
"b'L6988 receiving Primary sprocket'"
1716
1716
msgstr ""
1717
+ ">>> REC_LEN, LOC_START, LOC_LEN = 34, 7, 11\n"
1718
+ "\n"
1719
+ ">>> def change_location(buffer, record_number, location):\n"
1720
+ "... start = record_number * REC_LEN + LOC_START\n"
1721
+ "... buffer[start: start+LOC_LEN] = location\n"
1722
+ "\n"
1723
+ ">>> import io\n"
1724
+ "\n"
1725
+ ">>> byte_stream = io.BytesIO(\n"
1726
+ "... b'G3805 storeroom Main chassis '\n"
1727
+ "... b'X7899 shipping Reserve cog '\n"
1728
+ "... b'L6988 receiving Primary sprocket'\n"
1729
+ "... )\n"
1730
+ ">>> buffer = byte_stream.getbuffer()\n"
1731
+ ">>> change_location(buffer, 1, b'warehouse ')\n"
1732
+ ">>> change_location(buffer, 0, b'showroom ')\n"
1733
+ ">>> print(byte_stream.getvalue())\n"
1734
+ "b'G3805 showroom Main chassis '\n"
1735
+ "b'X7899 warehouse Reserve cog '\n"
1736
+ "b'L6988 receiving Primary sprocket'"
1717
1737
1718
1738
#: ../../whatsnew/3.2.rst:1146
1719
1739
msgid "(Contributed by Antoine Pitrou in :issue:`5506`.)"
@@ -2406,6 +2426,28 @@ msgid ""
2406
2426
"... description='xz compression'\n"
2407
2427
"... )"
2408
2428
msgstr ""
2429
+ ">>> import shutil, pprint\n"
2430
+ "\n"
2431
+ ">>> os.chdir('mydata') # 改至源目录\n"
2432
+ ">>> f = shutil.make_archive('/var/backup/mydata',\n"
2433
+ "... 'zip') # 将当前目录归档\n"
2434
+ ">>> f # 显示归档文件名\n"
2435
+ "'/var/backup/mydata.zip'\n"
2436
+ ">>> os.chdir('tmp') # 改至解包目录\n"
2437
+ ">>> shutil.unpack_archive('/var/backup/mydata.zip') # 恢复数据\n"
2438
+ "\n"
2439
+ ">>> pprint.pprint(shutil.get_archive_formats()) # 显示已知格式\n"
2440
+ "[('bztar',\" bzip2'ed tar-file\" ),\n"
2441
+ " ('gztar',\" gzip'ed tar-file\" ),\n"
2442
+ " ('tar', 'uncompressed tar file'),\n"
2443
+ " ('zip', 'ZIP file')]\n"
2444
+ "\n"
2445
+ ">>> shutil.register_archive_format( # 注册新的归档格式\n"
2446
+ "... name='xz',\n"
2447
+ "... function=xz.compress, # 可调用的归档函数\n"
2448
+ "... extra_args=[('level', 8)], # 函数的参数\n"
2449
+ "... description='xz compression'\n"
2450
+ "... )"
2409
2451
2410
2452
#: ../../whatsnew/3.2.rst:1595
2411
2453
msgid "sqlite3"
@@ -3914,6 +3956,8 @@ msgid ""
3914
3956
"``'mbcs'``) and the ``'surrogateescape'`` error handler on all operating "
3915
3957
"systems."
3916
3958
msgstr ""
3959
+ "默认情况下,:mod:`tarfile` 在 Windows 上使用 ``'utf-8'`` 编码格式 (而不是 ``'mbcs'``) "
3960
+ "并在所有操作系统上使用 ``'surrogateescape'`` 错误处理器。"
3917
3961
3918
3962
#: ../../whatsnew/3.2.rst:2461
3919
3963
msgid "Documentation"
@@ -4030,6 +4074,9 @@ msgid ""
4030
4074
"<https://www.mercurial-scm.org/wiki/QuickStart>`_ or the `Guide to Mercurial"
4031
4075
" Workflows <https://www.mercurial-scm.org/guide>`_."
4032
4076
msgstr ""
4077
+ "要学习使用新的版本控制系统,请参阅 `Quick Start <https://www.mercurial-"
4078
+ "scm.org/wiki/QuickStart>`_ 或 `Guide to Mercurial Workflows "
4079
+ "<https://www.mercurial-scm.org/guide>`_。"
4033
4080
4034
4081
#: ../../whatsnew/3.2.rst:2528
4035
4082
msgid "Build and C API Changes"
@@ -4044,6 +4091,8 @@ msgid ""
4044
4091
"The *idle*, *pydoc* and *2to3* scripts are now installed with a version-"
4045
4092
"specific suffix on ``make altinstall`` (:issue:`10679`)."
4046
4093
msgstr ""
4094
+ "现在 *idle*, *pydoc* 和 *2to3* 脚本的安装将在 ``make altinstall`` 中附带特定版本的后缀 "
4095
+ "(:issue:`10679`)。"
4047
4096
4048
4097
#: ../../whatsnew/3.2.rst:2535
4049
4098
msgid ""
@@ -4384,6 +4433,8 @@ msgid ""
4384
4433
":mod:`http.client`. Such support is still present on the server side (in "
4385
4434
":mod:`http.server`)."
4386
4435
msgstr ""
4436
+ "对旧式 HTTP 0.9 的支持已从 :mod:`urllib.request` 和 :mod:`http.client` 中移除。 "
4437
+ "此项支持仍然存在于服务器端(在 :mod:`http.server` 中)。"
4387
4438
4388
4439
#: ../../whatsnew/3.2.rst:2729
4389
4440
msgid "(Contributed by Antoine Pitrou, :issue:`10711`.)"
@@ -4394,6 +4445,8 @@ msgid ""
4394
4445
"SSL sockets in timeout mode now raise :exc:`socket.timeout` when a timeout "
4395
4446
"occurs, rather than a generic :exc:`~ssl.SSLError`."
4396
4447
msgstr ""
4448
+ "超时模式下的 SSL 套接字现在如发生超时则会引发 :exc:`socket.timeout`,而不是一般性的 "
4449
+ ":exc:`~ssl.SSLError`。"
4397
4450
4398
4451
#: ../../whatsnew/3.2.rst:2734
4399
4452
msgid "(Contributed by Antoine Pitrou, :issue:`10272`.)"
@@ -4406,13 +4459,18 @@ msgid ""
4406
4459
"state aware APIs (such as :c:func:`PyEval_SaveThread` and "
4407
4460
":c:func:`PyEval_RestoreThread`) should be used instead."
4408
4461
msgstr ""
4462
+ "有误导性的 :c:func:`!PyEval_AcquireLock` 和 :c:func:`!PyEval_ReleaseLock` 已正式被弃用。 "
4463
+ "应当改用可感知线程状态的 API (如 :c:func:`PyEval_SaveThread` 和 "
4464
+ ":c:func:`PyEval_RestoreThread`)。"
4409
4465
4410
4466
#: ../../whatsnew/3.2.rst:2741
4411
4467
msgid ""
4412
4468
"Due to security risks, :func:`!asyncore.handle_accept` has been deprecated, "
4413
4469
"and a new function, :func:`!asyncore.handle_accepted`, was added to replace "
4414
4470
"it."
4415
4471
msgstr ""
4472
+ "由于存在安全风险,:func:`!asyncore.handle_accept` 已被弃用,新增了一个函数 "
4473
+ ":func:`!asyncore.handle_accepted` 用来替代它。"
4416
4474
4417
4475
#: ../../whatsnew/3.2.rst:2744
4418
4476
msgid "(Contributed by Giampaolo Rodola in :issue:`6706`.)"
@@ -4423,3 +4481,5 @@ msgid ""
4423
4481
"Due to the new :term:`GIL` implementation, :c:func:`!PyEval_InitThreads` "
4424
4482
"cannot be called before :c:func:`Py_Initialize` anymore."
4425
4483
msgstr ""
4484
+ "由于新的 :term:`GIL` 实现的限制,:c:func:`!PyEval_InitThreads` 不再可以在 "
4485
+ ":c:func:`Py_Initialize` 之前被调用。"