@@ -236,7 +236,7 @@ msgid ""
236236"returns ``NULL``, so a wrapper function around a system call can write "
237237"``return PyErr_SetFromErrno(type);`` when the system call returns an error."
238238msgstr ""
239- "这是个方便的函数 ,当 C 库函数返回错误并设置 :c:data:`errno` 时,这个函数会触发异常。它构造一个元组对象,其第一项是整数值 "
239+ "这是个便捷函数 ,当 C 库函数返回错误并设置 :c:data:`errno` 时,这个函数会触发异常。它构造一个元组对象,其第一项是整数值 "
240240":c:data:`errno`,第二项是相应的错误消息(从 :c:func:`strerror` 获取),然后调用 "
241241"``PyErr_SetObject(type, object)``。在 Unix 上,当 :c:data:`errno` 值是 "
242242":const:`EINTR` ,即中断的系统调用时,这个函数会调用 :c:func:`PyErr_CheckSignals` "
@@ -260,8 +260,8 @@ msgid ""
260260"second filename object, for raising errors when a function that takes two "
261261"filenames fails."
262262msgstr ""
263- "类似于 :c:func:`PyErr_SetFromErrnoWithFilenameObject` "
264- ",但接受第二个文件名对象,用于当一个接受两个文件名的函数失败时触发错误 。"
263+ "类似于 :c:func:`PyErr_SetFromErrnoWithFilenameObject` ,但接受第二个 filename "
264+ "对象,用于当一个接受两个 filename 的函数失败时触发错误 。"
265265
266266#: ../../c-api/exceptions.rst:184
267267msgid ""
@@ -284,6 +284,11 @@ msgid ""
284284"calls ``PyErr_SetObject(PyExc_WindowsError, object)``. This function always "
285285"returns ``NULL``."
286286msgstr ""
287+ "这是触发 :exc:`WindowsError` 的便捷函数。如果 *lerr* 为 :c:data:`0` ,则改用调用 "
288+ ":c:func:`GetLastError` 返回的错误代码。它调用 Win32 函数 :c:func:`FormatMessage` 来检索 "
289+ "*ierr* 或 :c:func:`GetLastError` 给定的错误代码的 Windows 描述,然后构造一个元组对象,其第一项是 *ierr* "
290+ "值,第二项是相应的错误信息(从 :c:func:`FormatMessage` 获取),然后调用 "
291+ "``PyErr_SetObject(PyExc_WindowsError, object)`` 。该函数永远返回 ``NULL`` 。"
287292
288293#: ../../c-api/exceptions.rst:200 ../../c-api/exceptions.rst:208
289294#: ../../c-api/exceptions.rst:217 ../../c-api/exceptions.rst:225
@@ -295,32 +300,37 @@ msgstr ":ref:`可用性 <availability>`: Windows。"
295300msgid ""
296301"Similar to :c:func:`PyErr_SetFromWindowsErr`, with an additional parameter "
297302"specifying the exception type to be raised."
298- msgstr ""
303+ msgstr "类似于 :c:func:`PyErr_SetFromWindowsErr` ,额外的参数指定要触发的异常类型。 "
299304
300305#: ../../c-api/exceptions.rst:213
301306msgid ""
302307"Similar to :c:func:`PyErr_SetFromWindowsErrWithFilenameObject`, but the "
303308"filename is given as a C string. *filename* is decoded from the filesystem "
304309"encoding (:func:`os.fsdecode`)."
305310msgstr ""
311+ "类似于 :c:func:`PyErr_SetFromWindowsErrWithFilenameObject` ,但是 filename 是以 C "
312+ "字符串形式给出的。 *filename* 是从文件系统编码(:func:`os.fsdecode`)解码出来的。"
306313
307314#: ../../c-api/exceptions.rst:222
308315msgid ""
309316"Similar to :c:func:`PyErr_SetFromWindowsErrWithFilenameObject`, with an "
310317"additional parameter specifying the exception type to be raised."
311318msgstr ""
319+ "类似于 :c:func:`PyErr_SetFromWindowsErrWithFilenameObject` ,额外参数指定要触发的异常类型。"
312320
313321#: ../../c-api/exceptions.rst:230
314322msgid ""
315323"Similar to :c:func:`PyErr_SetExcFromWindowsErrWithFilenameObject`, but "
316324"accepts a second filename object."
317325msgstr ""
326+ "类似于 :c:func:`PyErr_SetExcFromWindowsErrWithFilenameObject` ,但是接受第二个 filename"
327+ " 对象。"
318328
319329#: ../../c-api/exceptions.rst:240
320330msgid ""
321331"Similar to :c:func:`PyErr_SetFromWindowsErrWithFilename`, with an additional"
322332" parameter specifying the exception type to be raised."
323- msgstr ""
333+ msgstr "类似于 :c:func:`PyErr_SetFromWindowsErrWithFilename` ,额外参数指定要触发的异常类型。 "
324334
325335#: ../../c-api/exceptions.rst:248
326336msgid ""
@@ -329,6 +339,8 @@ msgid ""
329339"be ``NULL``, will be set as the :exc:`ImportError`'s respective ``name`` and"
330340" ``path`` attributes."
331341msgstr ""
342+ "这是触发 :exc:`ImportError` 的便捷函数。 *msg* 将被设为异常的消息字符串。 *name* 和 *path* ,(都可以为 "
343+ "``NULL`` ),将用来被设置 :exc:`ImportError` 对应的属性 ``name`` 和 ``path``。"
332344
333345#: ../../c-api/exceptions.rst:258
334346msgid ""
@@ -337,18 +349,22 @@ msgid ""
337349"attributes, which make the exception printing subsystem think the exception "
338350"is a :exc:`SyntaxError`."
339351msgstr ""
352+ "设置当前异常的文件,行和偏移信息。如果当前异常不是 :exc:`SyntaxError` ,则它设置额外的属性,使异常打印子系统认为异常是 "
353+ ":exc:`SyntaxError`。"
340354
341355#: ../../c-api/exceptions.rst:268
342356msgid ""
343357"Like :c:func:`PyErr_SyntaxLocationObject`, but *filename* is a byte string "
344358"decoded from the filesystem encoding (:func:`os.fsdecode`)."
345359msgstr ""
360+ "与 :c:func:`PyErr_SyntaxLocationObject` 类似,只是 *filename* 是从文件系统编码( "
361+ ":func:`os.fsdecode` )解码出的一个字节字符串。"
346362
347363#: ../../c-api/exceptions.rst:276
348364msgid ""
349365"Like :c:func:`PyErr_SyntaxLocationEx`, but the col_offset parameter is "
350366"omitted."
351- msgstr ""
367+ msgstr "与 :c:func:`PyErr_SyntaxLocationEx` 类似,但省略了参数 col_offset。 "
352368
353369#: ../../c-api/exceptions.rst:282
354370msgid ""
@@ -357,10 +373,12 @@ msgid ""
357373"function) was invoked with an illegal argument. It is mostly for internal "
358374"use."
359375msgstr ""
376+ "这是 ``PyErr_SetString(PyExc_SystemError, message)`` 的缩写,其中 *message* "
377+ "表示使用了非法参数调用内部操作(例如,Python/C API 函数)。它主要用于内部使用。"
360378
361379#: ../../c-api/exceptions.rst:289
362380msgid "Issuing warnings"
363- msgstr "警告 "
381+ msgstr "发出警告 "
364382
365383#: ../../c-api/exceptions.rst:291
366384msgid ""
@@ -377,6 +395,12 @@ msgid ""
377395"normal exception handling (for example, :c:func:`Py_DECREF` owned references"
378396" and return an error value)."
379397msgstr ""
398+ "这些函数可以从 C 代码中发出警告。它们仿照了由 Python 模块 :mod:`warnings` 导出的那些函数。它们通常向 "
399+ "*sys.stderr* "
400+ "打印一条警告信息;当然,用户也有可能已经指定将警告转换为错误,在这种情况下,它们将触发异常。也有可能由于警告机制出现问题,使得函数触发异常。如果没有触发异常,返回值为"
401+ " ``0`` ;如果触发异常,返回值为 "
402+ "``-1``。(无法确定是否实际打印了警告信息,也无法确定异常触发的原因。这是故意为之)。如果触发了异常,调用者应该进行正常的异常处理(例如,:c:func:`Py_DECREF`"
403+ " 持有引用并返回一个错误值)。"
380404
381405#: ../../c-api/exceptions.rst:306
382406msgid ""
@@ -387,6 +411,9 @@ msgid ""
387411"stack frame. A *stack_level* of 1 is the function calling "
388412":c:func:`PyErr_WarnEx`, 2 is the function above that, and so forth."
389413msgstr ""
414+ "发出一个警告信息。参数 *category* 是一个警告类别(见下面)或 ``NULL`` ; *message* 是一个 UTF-8 编码的字符串。 "
415+ "*stack_level* 是一个给出栈帧数量的正数;警告将从该栈帧中当前正在执行的代码行发出。 *stack_level* 为 1 的是调用 "
416+ ":c:func:`PyErr_WarnEx` 的函数,2 是在此之上的函数,以此类推。"
390417
391418#: ../../c-api/exceptions.rst:313
392419msgid ""
@@ -396,13 +423,17 @@ msgid ""
396423"Python warning categories are available as global variables whose names are "
397424"enumerated at :ref:`standardwarningcategories`."
398425msgstr ""
426+ "警告类别必须是 :c:data:`PyExc_Warning` 的子类, :c:data:`PyExc_Warning` 是 "
427+ ":c:data:`PyExc_Exception` 的子类;默认警告类别是 :c:data:`PyExc_RuntimeWarning` 。标准 "
428+ "Python 警告类别作为全局变量可用,所有其名称见 :ref:`standardwarningcategories` 。"
399429
400430#: ../../c-api/exceptions.rst:319
401431msgid ""
402432"For information about warning control, see the documentation for the "
403433":mod:`warnings` module and the :option:`-W` option in the command line "
404434"documentation. There is no C API for warning control."
405435msgstr ""
436+ "有关警告控制的信息,参见模块文档 :mod:`warnings` 和命令行文档中的 :option:`-W` 选项。没有用于警告控制的 C API。"
406437
407438#: ../../c-api/exceptions.rst:325
408439msgid ""
0 commit comments