Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4b963d9

Browse files
[po] auto sync
1 parent 16de4df commit 4b963d9

7 files changed

Lines changed: 1228 additions & 1122 deletions

File tree

.stat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"translation": "92.33%", "updated_at": "2023-11-17T05:55:47Z"}
1+
{"translation": "92.27%", "updated_at": "2023-11-17T14:56:09Z"}

howto/isolating-extensions.po

Lines changed: 149 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ msgid ""
1414
msgstr ""
1515
"Project-Id-Version: Python 3.12\n"
1616
"Report-Msgid-Bugs-To: \n"
17-
"POT-Creation-Date: 2023-08-25 22:29+0000\n"
17+
"POT-Creation-Date: 2023-11-17 14:14+0000\n"
1818
"PO-Revision-Date: 2022-11-05 19:48+0000\n"
1919
"Last-Translator: Freesand Leo <[email protected]>, 2023\n"
2020
"Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n"
@@ -518,41 +518,146 @@ msgstr ""
518518

519519
#: ../../howto/isolating-extensions.rst:342
520520
msgid ""
521-
"Please refer to the :ref:`the documentation <type-structs>` of "
522-
":c:macro:`Py_TPFLAGS_HAVE_GC` and :c:member:`~PyTypeObject.tp_traverse` for "
523-
"additional considerations."
521+
"Please refer to the the documentation of :c:macro:`Py_TPFLAGS_HAVE_GC` and "
522+
":c:member:`~PyTypeObject.tp_traverse` for additional considerations."
524523
msgstr ""
525-
"请参阅 :c:macro:`Py_TPFLAGS_HAVE_GC` 和 :c:member:`~PyTypeObject.tp_traverse` 的 "
526-
":ref:`文档 <type-structs>` 来了解更多相关问题的考量。"
527524

528525
#: ../../howto/isolating-extensions.rst:346
529526
msgid ""
530-
"If your traverse function delegates to the ``tp_traverse`` of its base class"
531-
" (or another type), ensure that ``Py_TYPE(self)`` is visited only once. Note"
532-
" that only heap type are expected to visit the type in ``tp_traverse``."
527+
"The API for defining heap types grew organically, leaving it somewhat "
528+
"awkward to use in its current state. The following sections will guide you "
529+
"through common issues."
533530
msgstr ""
534-
"如果你的遍历函数委托给了其基类(或另一个类型)的 ``tp_traverse``,请确保 ``Py_TYPE(self)`` 只被访问一次。 "
535-
"请注意只有堆类型会被预期访问 ``tp_traverse`` 中的类型。"
536531

537-
#: ../../howto/isolating-extensions.rst:350
532+
#: ../../howto/isolating-extensions.rst:352
533+
msgid "``tp_traverse`` in Python 3.8 and lower"
534+
msgstr ""
535+
536+
#: ../../howto/isolating-extensions.rst:354
537+
msgid ""
538+
"The requirement to visit the type from ``tp_traverse`` was added in Python "
539+
"3.9. If you support Python 3.8 and lower, the traverse function must *not* "
540+
"visit the type, so it must be more complicated::"
541+
msgstr ""
542+
543+
#: ../../howto/isolating-extensions.rst:366
544+
msgid ""
545+
"Unfortunately, :c:data:`Py_Version` was only added in Python 3.11. As a "
546+
"replacement, use:"
547+
msgstr ""
548+
549+
#: ../../howto/isolating-extensions.rst:369
550+
msgid ":c:macro:`PY_VERSION_HEX`, if not using the stable ABI, or"
551+
msgstr ""
552+
553+
#: ../../howto/isolating-extensions.rst:370
554+
msgid ""
555+
":py:data:`sys.version_info` (via :c:func:`PySys_GetObject` and "
556+
":c:func:`PyArg_ParseTuple`)."
557+
msgstr ""
558+
559+
#: ../../howto/isolating-extensions.rst:375
560+
msgid "Delegating ``tp_traverse``"
561+
msgstr ""
562+
563+
#: ../../howto/isolating-extensions.rst:377
564+
msgid ""
565+
"If your traverse function delegates to the "
566+
":c:member:`~PyTypeObject.tp_traverse` of its base class (or another type), "
567+
"ensure that ``Py_TYPE(self)`` is visited only once. Note that only heap type"
568+
" are expected to visit the type in ``tp_traverse``."
569+
msgstr ""
570+
571+
#: ../../howto/isolating-extensions.rst:382
538572
msgid "For example, if your traverse function includes::"
539573
msgstr "举例来说,如果你的遍历函数包括::"
540574

541-
#: ../../howto/isolating-extensions.rst:354
575+
#: ../../howto/isolating-extensions.rst:386
542576
msgid "...and ``base`` may be a static type, then it should also include::"
543577
msgstr "... 并且 ``base`` 可能是一个静态类型,则它也应当包括::"
544578

545-
#: ../../howto/isolating-extensions.rst:362
579+
#: ../../howto/isolating-extensions.rst:396
580+
msgid ""
581+
"It is not necessary to handle the type's reference count in "
582+
":c:member:`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_clear`."
583+
msgstr ""
584+
585+
#: ../../howto/isolating-extensions.rst:401
586+
msgid "Defining ``tp_dealloc``"
587+
msgstr ""
588+
589+
#: ../../howto/isolating-extensions.rst:403
590+
msgid ""
591+
"If your type has a custom :c:member:`~PyTypeObject.tp_dealloc` function, it "
592+
"needs to:"
593+
msgstr ""
594+
595+
#: ../../howto/isolating-extensions.rst:406
546596
msgid ""
547-
"It is not necessary to handle the type's reference count in ``tp_new`` and "
548-
"``tp_clear``."
549-
msgstr "不需要在 ``tp_new`` 和 ``tp_clear`` 中处理该类型的引用计数。"
597+
"call :c:func:`PyObject_GC_UnTrack` before any fields are invalidated, and"
598+
msgstr ""
599+
600+
#: ../../howto/isolating-extensions.rst:407
601+
msgid "decrement the reference count of the type."
602+
msgstr ""
550603

551-
#: ../../howto/isolating-extensions.rst:367
604+
#: ../../howto/isolating-extensions.rst:409
605+
msgid ""
606+
"To keep the type valid while ``tp_free`` is called, the type's refcount "
607+
"needs to be decremented *after* the instance is deallocated. For example::"
608+
msgstr ""
609+
610+
#: ../../howto/isolating-extensions.rst:421
611+
msgid ""
612+
"The default ``tp_dealloc`` function does this, so if your type does *not* "
613+
"override ``tp_dealloc`` you don't need to add it."
614+
msgstr ""
615+
616+
#: ../../howto/isolating-extensions.rst:427
617+
msgid "Not overriding ``tp_free``"
618+
msgstr ""
619+
620+
#: ../../howto/isolating-extensions.rst:429
621+
msgid ""
622+
"The :c:member:`~PyTypeObject.tp_free` slot of a heap type must be set to "
623+
":c:func:`PyObject_GC_Del`. This is the default; do not override it."
624+
msgstr ""
625+
626+
#: ../../howto/isolating-extensions.rst:435
627+
msgid "Avoiding ``PyObject_New``"
628+
msgstr ""
629+
630+
#: ../../howto/isolating-extensions.rst:437
631+
msgid "GC-tracked objects need to be allocated using GC-aware functions."
632+
msgstr ""
633+
634+
#: ../../howto/isolating-extensions.rst:439
635+
msgid "If you use use :c:func:`PyObject_New` or :c:func:`PyObject_NewVar`:"
636+
msgstr ""
637+
638+
#: ../../howto/isolating-extensions.rst:441
639+
msgid ""
640+
"Get and call type's :c:member:`~PyTypeObject.tp_alloc` slot, if possible. "
641+
"That is, replace ``TYPE *o = PyObject_New(TYPE, typeobj)`` with::"
642+
msgstr ""
643+
644+
#: ../../howto/isolating-extensions.rst:446
645+
msgid ""
646+
"Replace ``o = PyObject_NewVar(TYPE, typeobj, size)`` with the same, but use "
647+
"size instead of the 0."
648+
msgstr ""
649+
650+
#: ../../howto/isolating-extensions.rst:449
651+
msgid ""
652+
"If the above is not possible (e.g. inside a custom ``tp_alloc``), call "
653+
":c:func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`::"
654+
msgstr ""
655+
656+
#: ../../howto/isolating-extensions.rst:458
552657
msgid "Module State Access from Classes"
553658
msgstr "类对模块状态的访问"
554659

555-
#: ../../howto/isolating-extensions.rst:369
660+
#: ../../howto/isolating-extensions.rst:460
556661
msgid ""
557662
"If you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, "
558663
"you can call :c:func:`PyType_GetModule` to get the associated module, and "
@@ -562,17 +667,17 @@ msgstr ""
562667
":c:func:`PyType_GetModule` 来获取关联的模块,然后调用 :c:func:`PyModule_GetState` "
563668
"来获取模块的状态。to get the module's state."
564669

565-
#: ../../howto/isolating-extensions.rst:373
670+
#: ../../howto/isolating-extensions.rst:464
566671
msgid ""
567672
"To save a some tedious error-handling boilerplate code, you can combine "
568673
"these two steps with :c:func:`PyType_GetModuleState`, resulting in::"
569674
msgstr "要省略一些繁琐的错误处理样板代码,你可以使用 :c:func:`PyType_GetModuleState` 来合并这两步,得到::"
570675

571-
#: ../../howto/isolating-extensions.rst:383
676+
#: ../../howto/isolating-extensions.rst:474
572677
msgid "Module State Access from Regular Methods"
573678
msgstr "常规方法对模块状态的访问"
574679

575-
#: ../../howto/isolating-extensions.rst:385
680+
#: ../../howto/isolating-extensions.rst:476
576681
msgid ""
577682
"Accessing the module-level state from methods of a class is somewhat more "
578683
"complicated, but is possible thanks to API introduced in Python 3.9. To get "
@@ -582,14 +687,14 @@ msgstr ""
582687
"从一个类的方法访问模块层级的状态在某些方面会更为复杂,但通过 Python 3.9 所引入的 API 这是可能做到的。 为了获取状态,你需要首先获取 "
583688
"*定义的类*,然后从中获取模块状态。"
584689

585-
#: ../../howto/isolating-extensions.rst:390
690+
#: ../../howto/isolating-extensions.rst:481
586691
msgid ""
587692
"The largest roadblock is getting *the class a method was defined in*, or "
588693
"that method's \"defining class\" for short. The defining class can have a "
589694
"reference to the module it is part of."
590695
msgstr "最大的障碍是获取 *方法定义所在的类*,简称为方法“定义的类”。 定义的类可以拥有一个指向作为其组成部分的方法的引用。"
591696

592-
#: ../../howto/isolating-extensions.rst:394
697+
#: ../../howto/isolating-extensions.rst:485
593698
msgid ""
594699
"Do not confuse the defining class with :c:expr:`Py_TYPE(self)`. If the "
595700
"method is called on a *subclass* of your type, ``Py_TYPE(self)`` will refer "
@@ -598,15 +703,15 @@ msgstr ""
598703
"不要混淆定义的类和 :c:expr:`Py_TYPE(self)`。 如果方法是在你的类型的一个 *子类* 上被调用的,则 "
599704
"``Py_TYPE(self)`` 将指向该子类,它可能是在另一个模块中定义的。"
600705

601-
#: ../../howto/isolating-extensions.rst:399
706+
#: ../../howto/isolating-extensions.rst:490
602707
msgid ""
603708
"The following Python code can illustrate the concept. "
604709
"``Base.get_defining_class`` returns ``Base`` even if ``type(self) == Sub``:"
605710
msgstr ""
606711
"下面的 Python 代码可以演示这一概念。 ``Base.get_defining_class`` 将返回 ``Base``,即使 "
607712
"``type(self) == Sub``:"
608713

609-
#: ../../howto/isolating-extensions.rst:415
714+
#: ../../howto/isolating-extensions.rst:506
610715
msgid ""
611716
"For a method to get its \"defining class\", it must use the "
612717
":ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS <METH_METHOD-"
@@ -617,25 +722,25 @@ msgstr ""
617722
"<METH_METHOD-METH_FASTCALL-METH_KEYWORDS>` :c:type:`调用惯例 <PyMethodDef>` "
618723
"以及相应的 :c:type:`PyCMethod` 签名::"
619724

620-
#: ../../howto/isolating-extensions.rst:427
725+
#: ../../howto/isolating-extensions.rst:518
621726
msgid ""
622727
"Once you have the defining class, call :c:func:`PyType_GetModuleState` to "
623728
"get the state of its associated module."
624729
msgstr "一旦你得到了定义的类,即可调用 :c:func:`PyType_GetModuleState` 来获取它所关联的模块的状态。"
625730

626-
#: ../../howto/isolating-extensions.rst:430
731+
#: ../../howto/isolating-extensions.rst:521
627732
msgid "For example::"
628733
msgstr "例如:"
629734

630-
#: ../../howto/isolating-extensions.rst:458
735+
#: ../../howto/isolating-extensions.rst:549
631736
msgid "Module State Access from Slot Methods, Getters and Setters"
632737
msgstr "槽位方法、读取方法和设置方法对模块状态的访问"
633738

634-
#: ../../howto/isolating-extensions.rst:462
739+
#: ../../howto/isolating-extensions.rst:553
635740
msgid "This is new in Python 3.11."
636741
msgstr "这是 Python 3.11 的新增特性。"
637742

638-
#: ../../howto/isolating-extensions.rst:470
743+
#: ../../howto/isolating-extensions.rst:561
639744
msgid ""
640745
"Slot methods—the fast C equivalents for special methods, such as "
641746
":c:member:`~PyNumberMethods.nb_add` for :py:attr:`~object.__add__` or "
@@ -649,7 +754,7 @@ msgstr ""
649754
"具有不允许传入定义类的非常简单的 API,这不同于 :c:type:`PyCMethod`。 同样的机制也适用于通过 "
650755
":c:type:`PyGetSetDef` 定义的读取方法和设置方法。"
651756

652-
#: ../../howto/isolating-extensions.rst:477
757+
#: ../../howto/isolating-extensions.rst:568
653758
msgid ""
654759
"To access the module state in these cases, use the "
655760
":c:func:`PyType_GetModuleByDef` function, and pass in the module definition."
@@ -659,7 +764,7 @@ msgstr ""
659764
"要在这些场景下访问模块状态,请使用 :c:func:`PyType_GetModuleByDef` 函数,并传入模块定义。 一旦你得到该模块,即可调用 "
660765
":c:func:`PyModule_GetState` 来获取状态::"
661766

662-
#: ../../howto/isolating-extensions.rst:488
767+
#: ../../howto/isolating-extensions.rst:579
663768
msgid ""
664769
":c:func:`!PyType_GetModuleByDef` works by searching the :term:`method "
665770
"resolution order` (i.e. all superclasses) for the first superclass that has "
@@ -668,7 +773,7 @@ msgstr ""
668773
":c:func:`!PyType_GetModuleByDef` 的作用方式是通过搜索 :term:`method resolution order` "
669774
"(即所有超类) 来找到具有相应模块的第一个超类。"
670775

671-
#: ../../howto/isolating-extensions.rst:494
776+
#: ../../howto/isolating-extensions.rst:585
672777
msgid ""
673778
"In very exotic cases (inheritance chains spanning multiple modules created "
674779
"from the same definition), :c:func:`!PyType_GetModuleByDef` might not return"
@@ -678,18 +783,18 @@ msgstr ""
678783
"在非常特别的情况下(继承链跨越由同样定义创建的多个模块),:c:func:`!PyType_GetModuleByDef` "
679784
"可能不会返回真正定义方法的类。 但是,它总是会返回一个具有同样定义的模块,这将确保具有兼容的 C 内存布局。"
680785

681-
#: ../../howto/isolating-extensions.rst:502
786+
#: ../../howto/isolating-extensions.rst:593
682787
msgid "Lifetime of the Module State"
683788
msgstr "模块状态的生命期"
684789

685-
#: ../../howto/isolating-extensions.rst:504
790+
#: ../../howto/isolating-extensions.rst:595
686791
msgid ""
687792
"When a module object is garbage-collected, its module state is freed. For "
688793
"each pointer to (a part of) the module state, you must hold a reference to "
689794
"the module object."
690795
msgstr "当一个模块对象被当作垃圾回收时,它的模块状态将被释放。 对于每个指向(一部分)模块状态的指针来说,你必须持有一个对模块对象的引用。"
691796

692-
#: ../../howto/isolating-extensions.rst:508
797+
#: ../../howto/isolating-extensions.rst:599
693798
msgid ""
694799
"Usually this is not an issue, because types created with "
695800
":c:func:`PyType_FromModuleAndSpec`, and their instances, hold a reference to"
@@ -700,15 +805,15 @@ msgstr ""
700805
"通常这不会有问题,因为使用 :c:func:`PyType_FromModuleAndSpec` 创建的类型,以及它们的实例,都持有对模块的引用。 "
701806
"但是,当你从其他地方,例如对外部库的回调引用模块状态时必须小心谨慎。"
702807

703-
#: ../../howto/isolating-extensions.rst:517
808+
#: ../../howto/isolating-extensions.rst:608
704809
msgid "Open Issues"
705810
msgstr "未解决的问题"
706811

707-
#: ../../howto/isolating-extensions.rst:519
812+
#: ../../howto/isolating-extensions.rst:610
708813
msgid "Several issues around per-module state and heap types are still open."
709814
msgstr "围绕模块级状态和堆类型仍然存在一些未解决的问题。"
710815

711-
#: ../../howto/isolating-extensions.rst:521
816+
#: ../../howto/isolating-extensions.rst:612
712817
msgid ""
713818
"Discussions about improving the situation are best held on the `capi-sig "
714819
"mailing list <https://mail.python.org/mailman3/lists/capi-"
@@ -717,11 +822,11 @@ msgstr ""
717822
"改善此状况最好的讨论是在 `capi-sig 邮件列表 <https://mail.python.org/mailman3/lists/capi-"
718823
"sig.python.org/>`__ 进行的。"
719824

720-
#: ../../howto/isolating-extensions.rst:526
825+
#: ../../howto/isolating-extensions.rst:617
721826
msgid "Per-Class Scope"
722827
msgstr "类级作用域"
723828

724-
#: ../../howto/isolating-extensions.rst:528
829+
#: ../../howto/isolating-extensions.rst:619
725830
msgid ""
726831
"It is currently (as of Python 3.11) not possible to attach state to "
727832
"individual *types* without relying on CPython implementation details (which "
@@ -731,11 +836,11 @@ msgstr ""
731836
"目前(即 Python 3.11)还无法将状态关联到单个 *类型* 而不依赖于 CPython 实现细节(这在未来可能发生改变 — "
732837
"或许,会怪异地允许采用适当的类级作用域解决方案)。"
733838

734-
#: ../../howto/isolating-extensions.rst:535
839+
#: ../../howto/isolating-extensions.rst:626
735840
msgid "Lossless Conversion to Heap Types"
736841
msgstr "无损转换为堆类型"
737842

738-
#: ../../howto/isolating-extensions.rst:537
843+
#: ../../howto/isolating-extensions.rst:628
739844
msgid ""
740845
"The heap type API was not designed for \"lossless\" conversion from static "
741846
"types; that is, creating a type that works exactly like a given static type."

0 commit comments

Comments
 (0)