5
5
#
6
6
# Translators:
7
7
# Rafael Fontenelle <rffontenelle@gmail.com>, 2025
8
+ # Freesand Leo <yuqinju@163.com>, 2025
8
9
#
9
10
#, fuzzy
10
11
msgid ""
@@ -13,7 +14,7 @@ msgstr ""
13
14
"Report-Msgid-Bugs-To : \n "
14
15
"POT-Creation-Date : 2025-05-30 14:58+0000\n "
15
16
"PO-Revision-Date : 2025-05-08 05:09+0000\n "
16
- "Last-Translator : Rafael Fontenelle <rffontenelle@gmail .com>, 2025\n "
17
+ "Last-Translator : Freesand Leo <yuqinju@163 .com>, 2025\n "
17
18
"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
18
19
"MIME-Version : 1.0\n "
19
20
"Content-Type : text/plain; charset=UTF-8\n "
@@ -392,34 +393,38 @@ msgid ""
392
393
"You can also define a new exception that is unique to your module. The "
393
394
"simplest way to do this is to declare a static global object variable at the"
394
395
" beginning of the file::"
395
- msgstr ""
396
+ msgstr "你也可以定义你的模块独有的新异常。 做到这点的最简单方式是在文件的开头声明一个静态全局对象变量:: "
396
397
397
398
#: ../../extending/extending.rst:210
398
399
msgid "static PyObject *SpamError = NULL;"
399
- msgstr ""
400
+ msgstr "static PyObject *SpamError = NULL; "
400
401
401
402
#: ../../extending/extending.rst:212
402
403
msgid ""
403
404
"and initialize it by calling :c:func:`PyErr_NewException` in the module's "
404
405
":c:data:`Py_mod_exec` function (:c:func:`!spam_module_exec`)::"
405
406
msgstr ""
407
+ "并通过在模块的 :c:data:`Py_mod_exec` 函数 (:c:func:`!spam_module_exec`) 中调用 "
408
+ ":c:func:`PyErr_NewException` 来初始化它::"
406
409
407
410
#: ../../extending/extending.rst:215
408
411
msgid "SpamError = PyErr_NewException(\" spam.error\" , NULL, NULL);"
409
- msgstr ""
412
+ msgstr "SpamError = PyErr_NewException( \" spam.error \" , NULL, NULL); "
410
413
411
414
#: ../../extending/extending.rst:217
412
415
msgid ""
413
416
"Since :c:data:`!SpamError` is a global variable, it will be overwitten every"
414
417
" time the module is reinitialized, when the :c:data:`Py_mod_exec` function "
415
418
"is called."
416
419
msgstr ""
420
+ "由于 :c:data:`!SpamError` 是一个全局变量,它将在模块每次重新初始化时被覆盖,即当 :c:data:`Py_mod_exec` "
421
+ "函数被调用时。"
417
422
418
423
#: ../../extending/extending.rst:220
419
424
msgid ""
420
425
"For now, let's avoid the issue: we will block repeated initialization by "
421
426
"raising an :py:exc:`ImportError`::"
422
- msgstr ""
427
+ msgstr "对于现在,让我们来避免这个问题:我们将通过引发 :py:exc:`ImportError` 来阻止重复的初始化:: "
423
428
424
429
#: ../../extending/extending.rst:223
425
430
msgid ""
@@ -459,6 +464,41 @@ msgid ""
459
464
" return PyModuleDef_Init(&spam_module);\n"
460
465
"}"
461
466
msgstr ""
467
+ "static PyObject *SpamError = NULL;\n"
468
+ "\n"
469
+ "static int\n"
470
+ "spam_module_exec(PyObject *m)\n"
471
+ "{\n"
472
+ " if (SpamError != NULL) {\n"
473
+ " PyErr_SetString(PyExc_ImportError,\n"
474
+ " \" cannot initialize spam module more than once\" );\n"
475
+ " return -1;\n"
476
+ " }\n"
477
+ " SpamError = PyErr_NewException(\" spam.error\" , NULL, NULL);\n"
478
+ " if (PyModule_AddObjectRef(m, \" SpamError\" , SpamError) < 0) {\n"
479
+ " return -1;\n"
480
+ " }\n"
481
+ "\n"
482
+ " return 0;\n"
483
+ "}\n"
484
+ "\n"
485
+ "static PyModuleDef_Slot spam_module_slots[] = {\n"
486
+ " {Py_mod_exec, spam_module_exec},\n"
487
+ " {0, NULL}\n"
488
+ "};\n"
489
+ "\n"
490
+ "static struct PyModuleDef spam_module = {\n"
491
+ " .m_base = PyModuleDef_HEAD_INIT,\n"
492
+ " .m_name = \" spam\" ,\n"
493
+ " .m_size = 0, // non-negative\n"
494
+ " .m_slots = spam_module_slots,\n"
495
+ "};\n"
496
+ "\n"
497
+ "PyMODINIT_FUNC\n"
498
+ "PyInit_spam(void)\n"
499
+ "{\n"
500
+ " return PyModuleDef_Init(&spam_module);\n"
501
+ "}"
462
502
463
503
#: ../../extending/extending.rst:259
464
504
msgid ""
0 commit comments