44# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
55#
66# Translators:
7- # Freesand Leo <[email protected] >, 202187# ppcfish <[email protected] >, 202198# Alpha Du <[email protected] >, 20219+ # Dai Xu <[email protected] >, 202110+ # Freesand Leo <[email protected] >, 20211011#
1112#, fuzzy
1213msgid ""
@@ -15,7 +16,7 @@ msgstr ""
1516"Report-Msgid-Bugs-To : \n "
1617"POT-Creation-Date : 2021-06-29 12:56+0000\n "
1718"PO-Revision-Date : 2021-06-28 01:04+0000\n "
18- "Last-Translator : Alpha Du <alphanow@gmail .com>, 2021\n "
19+ "Last-Translator : Freesand Leo <yuqinju@163 .com>, 2021\n "
1920"Language-Team : Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n "
2021"MIME-Version : 1.0\n "
2122"Content-Type : text/plain; charset=UTF-8\n "
@@ -34,40 +35,42 @@ msgid ""
3435"the default if the code is correct; new warnings are only emitted when an "
3536"issue is detected."
3637msgstr ""
37- "Python "
38- "开发模式引入了额外的运行时检查,由于成本太高,所以默认情况下是不启用的。如果代码是正确的,它不应该比默认情况的更加详细;只有在检测到问题的时候才会发出新的警告 。"
38+ "开发模式下的 Python "
39+ "加入了额外的运行时检查,由于开销太大,并非默认启用的。如果代码能够正确执行,默认的调试级别足矣,不应再提高了;仅当觉察到问题时再提升警告触发的级别 。"
3940
4041#: ../../library/devmode.rst:13
4142msgid ""
4243"It can be enabled using the :option:`-X dev <-X>` command line option or by "
4344"setting the :envvar:`PYTHONDEVMODE` environment variable to ``1``."
4445msgstr ""
45- "它可以通过 :option:`-X dev <-X>` 命令行选项或通过设置 :envvar:`PYTHONDEVMODE` 环境变量为 ``1`` "
46- "来启用 。"
46+ "使用 :option:`-X dev <-X>` 命令行参数或将环境变量 :envvar:`PYTHONDEVMODE` 置为 ``1`` "
47+ ",可以启用开发模式 。"
4748
4849#: ../../library/devmode.rst:16
4950msgid "See also :ref:`Python debug build <debug-build>`."
5051msgstr "另请参考 :ref:`Python debug build <debug-build>` 。"
5152
5253#: ../../library/devmode.rst:19
5354msgid "Effects of the Python Development Mode"
54- msgstr ""
55+ msgstr "Python 开发模式的效果 "
5556
5657#: ../../library/devmode.rst:21
5758msgid ""
5859"Enabling the Python Development Mode is similar to the following command, "
5960"but with additional effects described below::"
60- msgstr ""
61+ msgstr "启用 Python 开发模式后的效果,与以下命令类似,不过还有下面的额外效果: "
6162
6263#: ../../library/devmode.rst:26
6364msgid "Effects of the Python Development Mode:"
64- msgstr ""
65+ msgstr "Python 开发模式的效果: "
6566
6667#: ../../library/devmode.rst:28
6768msgid ""
6869"Add ``default`` :ref:`warning filter <describing-warning-filters>`. The "
6970"following warnings are shown:"
7071msgstr ""
72+ "加入 ``default`` :ref:`warning filter <describing-warning-filters>` "
73+ "。下述警告信息将会显示出来:"
7174
7275#: ../../library/devmode.rst:31
7376msgid ":exc:`DeprecationWarning`"
@@ -90,99 +93,114 @@ msgid ""
9093"Normally, the above warnings are filtered by the default :ref:`warning "
9194"filters <describing-warning-filters>`."
9295msgstr ""
96+ "通常上述警告是由默认的 :ref:`warning filters <describing-warning-filters>` 负责处理的。"
9397
9498#: ../../library/devmode.rst:39
9599msgid ""
96100"It behaves as if the :option:`-W default <-W>` command line option is used."
97- msgstr ""
101+ msgstr "效果类似于采用了 :option:`-W default <-W>` 命令行参数。 "
98102
99103#: ../../library/devmode.rst:41
100104msgid ""
101105"Use the :option:`-W error <-W>` command line option or set the "
102106":envvar:`PYTHONWARNINGS` environment variable to ``error`` to treat warnings"
103107" as errors."
104108msgstr ""
109+ "使用命令行参数 :option:`-W error <-W>` 或将环境变量 :envvar:`PYTHONWARNINGS` 设为 "
110+ "``error``,可将警告视为错误。"
105111
106112#: ../../library/devmode.rst:45
107113msgid "Install debug hooks on memory allocators to check for:"
108- msgstr ""
114+ msgstr "在内存分配程序中安装调试钩子,用以查看: "
109115
110116#: ../../library/devmode.rst:47
111117msgid "Buffer underflow"
112- msgstr ""
118+ msgstr "缓冲区下溢 "
113119
114120#: ../../library/devmode.rst:48
115121msgid "Buffer overflow"
116- msgstr ""
122+ msgstr "缓冲区上溢 "
117123
118124#: ../../library/devmode.rst:49
119125msgid "Memory allocator API violation"
120- msgstr ""
126+ msgstr "内存分配 API 冲突 "
121127
122128#: ../../library/devmode.rst:50
123129msgid "Unsafe usage of the GIL"
124- msgstr ""
130+ msgstr "不安全的 GIL 调用 "
125131
126132#: ../../library/devmode.rst:52
127133msgid "See the :c:func:`PyMem_SetupDebugHooks` C function."
128- msgstr ""
134+ msgstr "参见 C 函数 :c:func:`PyMem_SetupDebugHooks` 。 "
129135
130136#: ../../library/devmode.rst:54
131137msgid ""
132138"It behaves as if the :envvar:`PYTHONMALLOC` environment variable is set to "
133139"``debug``."
134- msgstr ""
140+ msgstr "效果如同将环境变量 :envvar:`PYTHONMALLOC` 设为 ``debug``。 "
135141
136142#: ../../library/devmode.rst:57
137143msgid ""
138144"To enable the Python Development Mode without installing debug hooks on "
139145"memory allocators, set the :envvar:`PYTHONMALLOC` environment variable to "
140146"``default``."
141147msgstr ""
148+ "若要启用 Python 开发模式,却又不要在内存分配程序中安装调试钩子,请将 环境变量 :envvar:`PYTHONMALLOC` 设为 "
149+ "``default``。"
142150
143151#: ../../library/devmode.rst:61
144152msgid ""
145153"Call :func:`faulthandler.enable` at Python startup to install handlers for "
146154"the :const:`SIGSEGV`, :const:`SIGFPE`, :const:`SIGABRT`, :const:`SIGBUS` and"
147155" :const:`SIGILL` signals to dump the Python traceback on a crash."
148156msgstr ""
157+ "在启动 Python 时调用 :func:`faulthandler.enable` ,会安装 :const:`SIGSEGV` 、 "
158+ ":const:`SIGFPE` 、 :const:`SIGABRT` 、 :const:`SIGBUS` 和 :const:`SIGILL` "
159+ "信号的处理程序,以便在程序崩溃时将 Python 跟踪信息转储下来。"
149160
150161#: ../../library/devmode.rst:65
151162msgid ""
152163"It behaves as if the :option:`-X faulthandler <-X>` command line option is "
153164"used or if the :envvar:`PYTHONFAULTHANDLER` environment variable is set to "
154165"``1``."
155166msgstr ""
167+ "其行为如同使用了 :option:`-X faulthandler <-X>` 命令行选项或将 :envvar:`PYTHONFAULTHANDLER`"
168+ " 环境变量设为 ``1``。"
156169
157170#: ../../library/devmode.rst:69
158171msgid ""
159172"Enable :ref:`asyncio debug mode <asyncio-debug-mode>`. For example, "
160173":mod:`asyncio` checks for coroutines that were not awaited and logs them."
161174msgstr ""
175+ "启用 :ref:`asyncio debug mode <asyncio-debug-mode>`。比如 :mod:`asyncio` "
176+ "会检查没有等待的协程并记录下来。"
162177
163178#: ../../library/devmode.rst:72
164179msgid ""
165180"It behaves as if the :envvar:`PYTHONASYNCIODEBUG` environment variable is "
166181"set to ``1``."
167- msgstr ""
182+ msgstr "效果如同将环境变量 :envvar:`PYTHONASYNCIODEBUG` 设为 ``1``。 "
168183
169184#: ../../library/devmode.rst:75
170185msgid ""
171186"Check the *encoding* and *errors* arguments for string encoding and decoding"
172187" operations. Examples: :func:`open`, :meth:`str.encode` and "
173188":meth:`bytes.decode`."
174189msgstr ""
190+ "检查字符串编码和解码函数的 *encoding* 和 *errors* 参数。例如: :func:`open` 、 :meth:`str.encode`"
191+ " 和 :meth:`bytes.decode`。"
175192
176193#: ../../library/devmode.rst:79
177194msgid ""
178195"By default, for best performance, the *errors* argument is only checked at "
179196"the first encoding/decoding error and the *encoding* argument is sometimes "
180197"ignored for empty strings."
181198msgstr ""
199+ "为了获得最佳性能,默认只会在第一次编码/解码错误时才会检查 *errors* 参数,有时 *encoding* 参数为空字符串时还会被忽略。"
182200
183201#: ../../library/devmode.rst:83
184202msgid "The :class:`io.IOBase` destructor logs ``close()`` exceptions."
185- msgstr ""
203+ msgstr ":class:`io.IOBase` 的析构函数会记录 ``close()`` 触发的异常。 "
186204
187205#: ../../library/devmode.rst:84
188206msgid ""
@@ -200,62 +218,69 @@ msgid ""
200218"and a buffer overflow error logs the traceback where the memory block was "
201219"allocated."
202220msgstr ""
221+ "Python 开发模式下,默认不会启用 :mod:`tracemalloc` 模块,因为其性能和内存开销太大。启用 :mod:`tracemalloc`"
222+ " 模块后,能够提供有关错误来源的一些额外信息。例如,:exc:`ResourceWarning` "
223+ "记录了资源分配的跟踪信息,而缓冲区溢出错误记录了内存块分配的跟踪信息。"
203224
204225#: ../../library/devmode.rst:94
205226msgid ""
206227"The Python Development Mode does not prevent the :option:`-O` command line "
207228"option from removing :keyword:`assert` statements nor from setting "
208229":const:`__debug__` to ``False``."
209230msgstr ""
231+ "Python 开发模式不会阻止命令行参数 :option:`-O` 删除 :keyword:`assert` 语句,也不会阻止将 "
232+ ":const:`__debug__` 设为 ``False``。"
210233
211234#: ../../library/devmode.rst:98
212235msgid ""
213236"The Python Development Mode can only be enabled at the Python startup. Its "
214237"value can be read from :data:`sys.flags.dev_mode <sys.flags>`."
215238msgstr ""
239+ "Python 开发模式只能在 Python 启动时启用。其参数值可从 :data:`sys.flags.dev_mode <sys.flags>` "
240+ "读取。"
216241
217242#: ../../library/devmode.rst:101
218243msgid "The :class:`io.IOBase` destructor now logs ``close()`` exceptions."
219- msgstr ""
244+ msgstr "现在, :class:`io.IOBase` 的析构函数会记录 ``close()`` 触发的异常。 "
220245
221246#: ../../library/devmode.rst:104
222247msgid ""
223248"The *encoding* and *errors* arguments are now checked for string encoding "
224249"and decoding operations."
225- msgstr ""
250+ msgstr "现在,字符串编码和解码操作时会检查 *encoding* 和 *errors* 参数。 "
226251
227252#: ../../library/devmode.rst:110
228253msgid "ResourceWarning Example"
229- msgstr ""
254+ msgstr "ResourceWarning 示例 "
230255
231256#: ../../library/devmode.rst:112
232257msgid ""
233258"Example of a script counting the number of lines of the text file specified "
234259"in the command line::"
235- msgstr ""
260+ msgstr "以下示例将统计由命令行指定的文本文件的行数: "
236261
237262#: ../../library/devmode.rst:126
238263msgid ""
239264"The script does not close the file explicitly. By default, Python does not "
240265"emit any warning. Example using README.txt, which has 269 lines:"
241- msgstr ""
266+ msgstr "上述代码没有显式关闭文件。默认情况下,Python 不会触发任何警告。下面用 README.txt 文件测试下,有 269 行: "
242267
243268#: ../../library/devmode.rst:134
244269msgid ""
245270"Enabling the Python Development Mode displays a :exc:`ResourceWarning` "
246271"warning:"
247- msgstr ""
272+ msgstr "启用 Python 开发模式后,则会显示一条 :exc:`ResourceWarning` 警告: "
248273
249274#: ../../library/devmode.rst:144
250275msgid ""
251276"In addition, enabling :mod:`tracemalloc` shows the line where the file was "
252277"opened:"
253- msgstr ""
278+ msgstr "启用 :mod:`tracemalloc` 后,则还会显示打开文件的那行代码: "
254279
255280#: ../../library/devmode.rst:159
256281msgid ""
257282"The fix is to close explicitly the file. Example using a context manager::"
258- msgstr ""
283+ msgstr "修正方案就是显式关闭文件。下面用上下文管理器作为示例: "
259284
260285#: ../../library/devmode.rst:167
261286msgid ""
@@ -264,24 +289,28 @@ msgid ""
264289"CPython, but it is even worse in PyPy. Closing resources explicitly makes an"
265290" application more deterministic and more reliable."
266291msgstr ""
292+ "未能显式关闭资源,会让资源打开时长远超预期;在退出 Python 时可能会导致严重问题。这在 CPython 中比较糟糕,但在 PyPy "
293+ "中会更糟。显式关闭资源能让应用程序更加稳定可靠。"
267294
268295#: ../../library/devmode.rst:174
269296msgid "Bad file descriptor error example"
270- msgstr ""
297+ msgstr "文件描述符错误示例 "
271298
272299#: ../../library/devmode.rst:176
273300msgid "Script displaying the first line of itself::"
274- msgstr ""
301+ msgstr "显示自身的第一行代码: "
275302
276303#: ../../library/devmode.rst:189
277304msgid "By default, Python does not emit any warning:"
278- msgstr ""
305+ msgstr "默认情况下,Python 不会触发任何警告: "
279306
280307#: ../../library/devmode.rst:196
281308msgid ""
282309"The Python Development Mode shows a :exc:`ResourceWarning` and logs a \" Bad "
283310"file descriptor\" error when finalizing the file object:"
284311msgstr ""
312+ "在 Python 开发模式下,会在析构文件对象时显示 :exc:`ResourceWarning` 并记录 “Bad file descriptor” "
313+ "错误。"
285314
286315#: ../../library/devmode.rst:212
287316msgid ""
@@ -291,9 +320,11 @@ msgid ""
291320"worst case scenario, closing it twice can lead to a crash (see "
292321":issue:`18748` for an example)."
293322msgstr ""
323+ "``os.close(fp.fileno())`` 会关闭文件描述符。当文件对象析构函数试图再次关闭文件描述符时会失败,并触发 ``Bad file "
324+ "descriptor`` 错误。每个文件描述符只允许关闭一次。在最坏的情况下,关闭两次会导致程序崩溃(示例可参见 :issue:`18748` )。"
294325
295326#: ../../library/devmode.rst:218
296327msgid ""
297328"The fix is to remove the ``os.close(fp.fileno())`` line, or open the file "
298329"with ``closefd=False``."
299- msgstr ""
330+ msgstr "修正方案是删除 ``os.close(fp.fileno())`` 这一行,或者打开文件时带上 ``closefd=False`` 参数。 "
0 commit comments