@@ -11,7 +11,7 @@ msgid ""
11
11
msgstr ""
12
12
"Project-Id-Version : Python 3.12\n "
13
13
"Report-Msgid-Bugs-To : \n "
14
- "POT-Creation-Date : 2024-09-13 14:48 +0000\n "
14
+ "POT-Creation-Date : 2024-10-04 14:53 +0000\n "
15
15
"PO-Revision-Date : 2024-05-11 00:32+0000\n "
16
16
"
Last-Translator :
Rafael Fontenelle <[email protected] >, 2024\n "
17
17
"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -636,7 +636,7 @@ msgid ""
636
636
"raised in this case."
637
637
msgstr "如果 *value* 为 ``NULL`` 则返回 ``-1``。 在此情况下调用它必须附带一个异常。"
638
638
639
- #: ../../c-api/module.rst:500 ../../c-api/module.rst:549
639
+ #: ../../c-api/module.rst:500 ../../c-api/module.rst:557
640
640
msgid "Example usage::"
641
641
msgstr "用法示例::"
642
642
@@ -666,7 +666,7 @@ msgstr ""
666
666
" return res;\n"
667
667
" }"
668
668
669
- #: ../../c-api/module.rst:514 ../../c-api/module.rst:567
669
+ #: ../../c-api/module.rst:514 ../../c-api/module.rst:575
670
670
msgid ""
671
671
"The example can also be written without checking explicitly if *obj* is "
672
672
"``NULL``::"
@@ -692,21 +692,35 @@ msgstr ""
692
692
" return res;\n"
693
693
" }"
694
694
695
- #: ../../c-api/module.rst:526 ../../c-api/module.rst:583
695
+ #: ../../c-api/module.rst:526 ../../c-api/module.rst:591
696
696
msgid ""
697
697
"Note that ``Py_XDECREF()`` should be used instead of ``Py_DECREF()`` in this"
698
698
" case, since *obj* can be ``NULL``."
699
699
msgstr ""
700
700
"注意在此情况下应当使用 ``Py_XDECREF()`` 而不是 ``Py_DECREF()``,因为 *obj* 可能为 ``NULL``。"
701
701
702
- #: ../../c-api/module.rst:534
702
+ #: ../../c-api/module.rst:529
703
+ msgid ""
704
+ "The number of different *name* strings passed to this function should be "
705
+ "kept small, usually by only using statically allocated strings as *name*. "
706
+ "For names that aren't known at compile time, prefer calling "
707
+ ":c:func:`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` directly. For "
708
+ "more details, see :c:func:`PyUnicode_InternFromString`, which may be used "
709
+ "internally to create a key object."
710
+ msgstr ""
711
+ "传给该函数的不同 *name* 字符串应当保持在较少的数量,通常是通过仅使用静态分配的字符串作为 *name* 来做到这一点。 "
712
+ "对于编译时未知的名称,建议直接调用 :c:func:`PyUnicode_FromString` 和 "
713
+ ":c:func:`PyObject_SetAttr`。 更多相关细节,请参阅 "
714
+ ":c:func:`PyUnicode_InternFromString`,它可在内部用于创建键对象。"
715
+
716
+ #: ../../c-api/module.rst:542
703
717
msgid ""
704
718
"Similar to :c:func:`PyModule_AddObjectRef`, but steals a reference to "
705
719
"*value* on success (if it returns ``0``)."
706
720
msgstr ""
707
721
"类似于 :c:func:`PyModule_AddObjectRef`,但会在成功时偷取一个对 *value* 的引用(如果它返回 ``0`` 值)。"
708
722
709
- #: ../../c-api/module.rst:537
723
+ #: ../../c-api/module.rst:545
710
724
msgid ""
711
725
"The new :c:func:`PyModule_AddObjectRef` function is recommended, since it is"
712
726
" easy to introduce reference leaks by misusing the "
@@ -715,19 +729,19 @@ msgstr ""
715
729
"推荐使用新的 :c:func:`PyModule_AddObjectRef` 函数,因为误用 :c:func:`PyModule_AddObject` "
716
730
"函数很容易导致引用泄漏。"
717
731
718
- #: ../../c-api/module.rst:543
732
+ #: ../../c-api/module.rst:551
719
733
msgid ""
720
734
"Unlike other functions that steal references, ``PyModule_AddObject()`` only "
721
735
"releases the reference to *value* **on success**."
722
736
msgstr "与其他窃取引用的函数不同,``PyModule_AddObject()`` 只在 **成功** 时释放对 *value* 的引用。"
723
737
724
- #: ../../c-api/module.rst:546
738
+ #: ../../c-api/module.rst:554
725
739
msgid ""
726
740
"This means that its return value must be checked, and calling code must "
727
741
":c:func:`Py_DECREF` *value* manually on error."
728
742
msgstr "这意味着必须检查它的返回值,调用方必须在发生错误时手动为*value*调用 :c:func:`Py_DECREF`。"
729
743
730
- #: ../../c-api/module.rst:551
744
+ #: ../../c-api/module.rst:559
731
745
msgid ""
732
746
"static int\n"
733
747
"add_spam(PyObject *module, int value)\n"
@@ -746,7 +760,7 @@ msgid ""
746
760
"}"
747
761
msgstr ""
748
762
749
- #: ../../c-api/module.rst:570
763
+ #: ../../c-api/module.rst:578
750
764
msgid ""
751
765
"static int\n"
752
766
"add_spam(PyObject *module, int value)\n"
@@ -762,7 +776,7 @@ msgid ""
762
776
"}"
763
777
msgstr ""
764
778
765
- #: ../../c-api/module.rst:589
779
+ #: ../../c-api/module.rst:597
766
780
msgid ""
767
781
"Add an integer constant to *module* as *name*. This convenience function "
768
782
"can be used from the module's initialization function. Return ``-1`` with an"
@@ -771,7 +785,15 @@ msgstr ""
771
785
"将一个整数常量作为 *name* 添加到 *module* 中。 这个便捷函数可在模块的初始化函数中使用。 当发生错误时将返回 ``-1`` "
772
786
"并设置一个异常,成功时则返回 ``0``。"
773
787
774
- #: ../../c-api/module.rst:596
788
+ #: ../../c-api/module.rst:601
789
+ msgid ""
790
+ "This is a convenience function that calls :c:func:`PyLong_FromLong` and "
791
+ ":c:func:`PyModule_AddObjectRef`; see their documentation for details."
792
+ msgstr ""
793
+ "这是一个调用 :c:func:`PyLong_FromLong` 和 :c:func:`PyModule_AddObjectRef` "
794
+ "的便捷函数;请参阅其文档了解详情。"
795
+
796
+ #: ../../c-api/module.rst:607
775
797
msgid ""
776
798
"Add a string constant to *module* as *name*. This convenience function can "
777
799
"be used from the module's initialization function. The string *value* must "
@@ -781,7 +803,16 @@ msgstr ""
781
803
"将一个字符串常量作为 *name* 添加到 *module* 中。 这个便捷函数可在模块初始化函数中使用。 字符串 *value* 必须以 "
782
804
"``NULL`` 结尾。 当发生错误时将返回 ``-1``,成功时则返回 ``0``。"
783
805
784
- #: ../../c-api/module.rst:604
806
+ #: ../../c-api/module.rst:612
807
+ msgid ""
808
+ "This is a convenience function that calls "
809
+ ":c:func:`PyUnicode_InternFromString` and :c:func:`PyModule_AddObjectRef`; "
810
+ "see their documentation for details."
811
+ msgstr ""
812
+ "这是一个调用 :c:func:`PyUnicode_InternFromString` 和 "
813
+ ":c:func:`PyModule_AddObjectRef` 的便捷函数;请参阅其文档了解详情。"
814
+
815
+ #: ../../c-api/module.rst:619
785
816
msgid ""
786
817
"Add an int constant to *module*. The name and the value are taken from "
787
818
"*macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int "
@@ -792,11 +823,11 @@ msgstr ""
792
823
"AF_INET)`` 将值为 *AF_INET* 的整数常量 *AF_INET* 添加到 *module* 中。 当发生错误时将抬 ``-1`` "
793
824
"并设置一个异常,成功时将返回 ``0``。"
794
825
795
- #: ../../c-api/module.rst:612
826
+ #: ../../c-api/module.rst:627
796
827
msgid "Add a string constant to *module*."
797
828
msgstr "将一个字符串常量添加到*module*模块中。"
798
829
799
- #: ../../c-api/module.rst:616
830
+ #: ../../c-api/module.rst:631
800
831
msgid ""
801
832
"Add a type object to *module*. The type object is finalized by calling "
802
833
"internally :c:func:`PyType_Ready`. The name of the type object is taken from"
@@ -807,25 +838,25 @@ msgstr ""
807
838
":c:member:`~PyTypeObject.tp_name` 在点号之后的部分。 当发生错误时将返回 ``-1`` 并设置一个异常,成功时将返回 "
808
839
"``0``。"
809
840
810
- #: ../../c-api/module.rst:626
841
+ #: ../../c-api/module.rst:641
811
842
msgid "Module lookup"
812
843
msgstr "查找模块"
813
844
814
- #: ../../c-api/module.rst:628
845
+ #: ../../c-api/module.rst:643
815
846
msgid ""
816
847
"Single-phase initialization creates singleton modules that can be looked up "
817
848
"in the context of the current interpreter. This allows the module object to "
818
849
"be retrieved later with only a reference to the module definition."
819
850
msgstr "单阶段初始化创建可以在当前解释器上下文中被查找的单例模块。这使得仅通过模块定义的引用,就可以检索模块对象。"
820
851
821
- #: ../../c-api/module.rst:632
852
+ #: ../../c-api/module.rst:647
822
853
msgid ""
823
854
"These functions will not work on modules created using multi-phase "
824
855
"initialization, since multiple such modules can be created from a single "
825
856
"definition."
826
857
msgstr "这些函数不适用于通过多阶段初始化创建的模块,因为可以从一个模块定义创建多个模块对象。"
827
858
828
- #: ../../c-api/module.rst:637
859
+ #: ../../c-api/module.rst:652
829
860
msgid ""
830
861
"Returns the module object that was created from *def* for the current "
831
862
"interpreter. This method requires that the module object has been attached "
@@ -836,18 +867,18 @@ msgstr ""
836
867
"返回当前解释器中由 *def* 创建的模块对象。此方法要求模块对象此前已通过 :c:func:`PyState_AddModule` "
837
868
"函数附加到解释器状态中。如果找不到相应的模块对象,或模块对象还未附加到解释器状态,返回 ``NULL``。"
838
869
839
- #: ../../c-api/module.rst:644
870
+ #: ../../c-api/module.rst:659
840
871
msgid ""
841
872
"Attaches the module object passed to the function to the interpreter state. "
842
873
"This allows the module object to be accessible via "
843
874
":c:func:`PyState_FindModule`."
844
875
msgstr "将传给函数的模块对象附加到解释器状态。 这将允许通过 :c:func:`PyState_FindModule` 来访问该模块对象。"
845
876
846
- #: ../../c-api/module.rst:647
877
+ #: ../../c-api/module.rst:662
847
878
msgid "Only effective on modules created using single-phase initialization."
848
879
msgstr "仅在使用单阶段初始化创建的模块上有效。"
849
880
850
- #: ../../c-api/module.rst:649
881
+ #: ../../c-api/module.rst:664
851
882
msgid ""
852
883
"Python calls ``PyState_AddModule`` automatically after importing a module, "
853
884
"so it is unnecessary (but harmless) to call it from module initialization "
@@ -861,15 +892,15 @@ msgstr ""
861
892
"显式的调用仅在模块自己的初始化代码后继调用了 ``PyState_FindModule`` 的情况下才是必要的。 "
862
893
"此函数主要是为了实现替代导入机制(或是通过直接调用它,或是通过引用它的实现来获取所需的状态更新详情)。"
863
894
864
- #: ../../c-api/module.rst:657 ../../c-api/module.rst:668
895
+ #: ../../c-api/module.rst:672 ../../c-api/module.rst:683
865
896
msgid "The caller must hold the GIL."
866
897
msgstr "调用时必须携带GIL。"
867
898
868
- #: ../../c-api/module.rst:659
899
+ #: ../../c-api/module.rst:674
869
900
msgid "Return ``-1`` with an exception set on error, ``0`` on success."
870
901
msgstr "出错时返回 ``-1`` 并设置一个异常,成功时返回 ``0``。"
871
902
872
- #: ../../c-api/module.rst:665
903
+ #: ../../c-api/module.rst:680
873
904
msgid ""
874
905
"Removes the module object created from *def* from the interpreter state. "
875
906
"Return ``-1`` with an exception set on error, ``0`` on success."
0 commit comments