@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version : Python 3.12\n "
1313"Report-Msgid-Bugs-To : \n "
14- "POT-Creation-Date : 2023-11-10 14:13 +0000\n "
14+ "POT-Creation-Date : 2023-11-17 14:14 +0000\n "
1515"PO-Revision-Date : 2022-11-05 19:48+0000\n "
1616"Last-Translator : tomo, 2022\n "
1717"Language-Team : Japanese (https://app.transifex.com/python-doc/teams/5390/ "
@@ -449,108 +449,217 @@ msgstr ""
449449
450450#: ../../howto/isolating-extensions.rst:342
451451msgid ""
452- "Please refer to the :ref:`the documentation <type-structs>` of :c:macro:"
453- "`Py_TPFLAGS_HAVE_GC` and :c:member:`~PyTypeObject.tp_traverse` for "
454- "additional considerations."
452+ "Please refer to the the documentation of :c:macro:`Py_TPFLAGS_HAVE_GC` and :"
453+ "c:member:`~PyTypeObject.tp_traverse` for additional considerations."
455454msgstr ""
456455
457456#: ../../howto/isolating-extensions.rst:346
458457msgid ""
459- "If your traverse function delegates to the ``tp_traverse`` of its base class "
460- "(or another type), ensure that ``Py_TYPE(self)`` is visited only once. Note "
461- "that only heap type are expected to visit the type in ``tp_traverse`` ."
458+ "The API for defining heap types grew organically, leaving it somewhat "
459+ "awkward to use in its current state. The following sections will guide you "
460+ "through common issues ."
462461msgstr ""
463462
464- #: ../../howto/isolating-extensions.rst:350
465- msgid "For example, if your traverse function includes:: "
463+ #: ../../howto/isolating-extensions.rst:352
464+ msgid "``tp_traverse`` in Python 3.8 and lower "
466465msgstr ""
467466
468467#: ../../howto/isolating-extensions.rst:354
468+ msgid ""
469+ "The requirement to visit the type from ``tp_traverse`` was added in Python "
470+ "3.9. If you support Python 3.8 and lower, the traverse function must *not* "
471+ "visit the type, so it must be more complicated::"
472+ msgstr ""
473+
474+ #: ../../howto/isolating-extensions.rst:366
475+ msgid ""
476+ "Unfortunately, :c:data:`Py_Version` was only added in Python 3.11. As a "
477+ "replacement, use:"
478+ msgstr ""
479+
480+ #: ../../howto/isolating-extensions.rst:369
481+ msgid ":c:macro:`PY_VERSION_HEX`, if not using the stable ABI, or"
482+ msgstr ""
483+
484+ #: ../../howto/isolating-extensions.rst:370
485+ msgid ""
486+ ":py:data:`sys.version_info` (via :c:func:`PySys_GetObject` and :c:func:"
487+ "`PyArg_ParseTuple`)."
488+ msgstr ""
489+
490+ #: ../../howto/isolating-extensions.rst:375
491+ msgid "Delegating ``tp_traverse``"
492+ msgstr ""
493+
494+ #: ../../howto/isolating-extensions.rst:377
495+ msgid ""
496+ "If your traverse function delegates to the :c:member:`~PyTypeObject."
497+ "tp_traverse` of its base class (or another type), ensure that "
498+ "``Py_TYPE(self)`` is visited only once. Note that only heap type are "
499+ "expected to visit the type in ``tp_traverse``."
500+ msgstr ""
501+
502+ #: ../../howto/isolating-extensions.rst:382
503+ msgid "For example, if your traverse function includes::"
504+ msgstr ""
505+
506+ #: ../../howto/isolating-extensions.rst:386
469507msgid "...and ``base`` may be a static type, then it should also include::"
470508msgstr ""
471509
472- #: ../../howto/isolating-extensions.rst:362
510+ #: ../../howto/isolating-extensions.rst:396
511+ msgid ""
512+ "It is not necessary to handle the type's reference count in :c:member:"
513+ "`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_clear`."
514+ msgstr ""
515+
516+ #: ../../howto/isolating-extensions.rst:401
517+ msgid "Defining ``tp_dealloc``"
518+ msgstr ""
519+
520+ #: ../../howto/isolating-extensions.rst:403
521+ msgid ""
522+ "If your type has a custom :c:member:`~PyTypeObject.tp_dealloc` function, it "
523+ "needs to:"
524+ msgstr ""
525+
526+ #: ../../howto/isolating-extensions.rst:406
527+ msgid ""
528+ "call :c:func:`PyObject_GC_UnTrack` before any fields are invalidated, and"
529+ msgstr ""
530+
531+ #: ../../howto/isolating-extensions.rst:407
532+ msgid "decrement the reference count of the type."
533+ msgstr ""
534+
535+ #: ../../howto/isolating-extensions.rst:409
536+ msgid ""
537+ "To keep the type valid while ``tp_free`` is called, the type's refcount "
538+ "needs to be decremented *after* the instance is deallocated. For example::"
539+ msgstr ""
540+
541+ #: ../../howto/isolating-extensions.rst:421
542+ msgid ""
543+ "The default ``tp_dealloc`` function does this, so if your type does *not* "
544+ "override ``tp_dealloc`` you don't need to add it."
545+ msgstr ""
546+
547+ #: ../../howto/isolating-extensions.rst:427
548+ msgid "Not overriding ``tp_free``"
549+ msgstr ""
550+
551+ #: ../../howto/isolating-extensions.rst:429
552+ msgid ""
553+ "The :c:member:`~PyTypeObject.tp_free` slot of a heap type must be set to :c:"
554+ "func:`PyObject_GC_Del`. This is the default; do not override it."
555+ msgstr ""
556+
557+ #: ../../howto/isolating-extensions.rst:435
558+ msgid "Avoiding ``PyObject_New``"
559+ msgstr ""
560+
561+ #: ../../howto/isolating-extensions.rst:437
562+ msgid "GC-tracked objects need to be allocated using GC-aware functions."
563+ msgstr ""
564+
565+ #: ../../howto/isolating-extensions.rst:439
566+ msgid "If you use use :c:func:`PyObject_New` or :c:func:`PyObject_NewVar`:"
567+ msgstr ""
568+
569+ #: ../../howto/isolating-extensions.rst:441
570+ msgid ""
571+ "Get and call type's :c:member:`~PyTypeObject.tp_alloc` slot, if possible. "
572+ "That is, replace ``TYPE *o = PyObject_New(TYPE, typeobj)`` with::"
573+ msgstr ""
574+
575+ #: ../../howto/isolating-extensions.rst:446
576+ msgid ""
577+ "Replace ``o = PyObject_NewVar(TYPE, typeobj, size)`` with the same, but use "
578+ "size instead of the 0."
579+ msgstr ""
580+
581+ #: ../../howto/isolating-extensions.rst:449
473582msgid ""
474- "It is not necessary to handle the type's reference count in ``tp_new`` and "
475- "``tp_clear``. "
583+ "If the above is not possible (e.g. inside a custom ``tp_alloc``), call :c: "
584+ "func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`:: "
476585msgstr ""
477586
478- #: ../../howto/isolating-extensions.rst:367
587+ #: ../../howto/isolating-extensions.rst:458
479588msgid "Module State Access from Classes"
480589msgstr ""
481590
482- #: ../../howto/isolating-extensions.rst:369
591+ #: ../../howto/isolating-extensions.rst:460
483592msgid ""
484593"If you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, "
485594"you can call :c:func:`PyType_GetModule` to get the associated module, and "
486595"then :c:func:`PyModule_GetState` to get the module's state."
487596msgstr ""
488597
489- #: ../../howto/isolating-extensions.rst:373
598+ #: ../../howto/isolating-extensions.rst:464
490599msgid ""
491600"To save a some tedious error-handling boilerplate code, you can combine "
492601"these two steps with :c:func:`PyType_GetModuleState`, resulting in::"
493602msgstr ""
494603
495- #: ../../howto/isolating-extensions.rst:383
604+ #: ../../howto/isolating-extensions.rst:474
496605msgid "Module State Access from Regular Methods"
497606msgstr ""
498607
499- #: ../../howto/isolating-extensions.rst:385
608+ #: ../../howto/isolating-extensions.rst:476
500609msgid ""
501610"Accessing the module-level state from methods of a class is somewhat more "
502611"complicated, but is possible thanks to API introduced in Python 3.9. To get "
503612"the state, you need to first get the *defining class*, and then get the "
504613"module state from it."
505614msgstr ""
506615
507- #: ../../howto/isolating-extensions.rst:390
616+ #: ../../howto/isolating-extensions.rst:481
508617msgid ""
509618"The largest roadblock is getting *the class a method was defined in*, or "
510619"that method's \" defining class\" for short. The defining class can have a "
511620"reference to the module it is part of."
512621msgstr ""
513622
514- #: ../../howto/isolating-extensions.rst:394
623+ #: ../../howto/isolating-extensions.rst:485
515624msgid ""
516625"Do not confuse the defining class with :c:expr:`Py_TYPE(self)`. If the "
517626"method is called on a *subclass* of your type, ``Py_TYPE(self)`` will refer "
518627"to that subclass, which may be defined in different module than yours."
519628msgstr ""
520629
521- #: ../../howto/isolating-extensions.rst:399
630+ #: ../../howto/isolating-extensions.rst:490
522631msgid ""
523632"The following Python code can illustrate the concept. ``Base."
524633"get_defining_class`` returns ``Base`` even if ``type(self) == Sub``:"
525634msgstr ""
526635
527- #: ../../howto/isolating-extensions.rst:415
636+ #: ../../howto/isolating-extensions.rst:506
528637msgid ""
529638"For a method to get its \" defining class\" , it must use the :ref:"
530639"`METH_METHOD | METH_FASTCALL | METH_KEYWORDS <METH_METHOD-METH_FASTCALL-"
531640"METH_KEYWORDS>` :c:type:`calling convention <PyMethodDef>` and the "
532641"corresponding :c:type:`PyCMethod` signature::"
533642msgstr ""
534643
535- #: ../../howto/isolating-extensions.rst:427
644+ #: ../../howto/isolating-extensions.rst:518
536645msgid ""
537646"Once you have the defining class, call :c:func:`PyType_GetModuleState` to "
538647"get the state of its associated module."
539648msgstr ""
540649
541- #: ../../howto/isolating-extensions.rst:430
650+ #: ../../howto/isolating-extensions.rst:521
542651msgid "For example::"
543652msgstr "例えば::"
544653
545- #: ../../howto/isolating-extensions.rst:458
654+ #: ../../howto/isolating-extensions.rst:549
546655msgid "Module State Access from Slot Methods, Getters and Setters"
547656msgstr ""
548657
549- #: ../../howto/isolating-extensions.rst:462
658+ #: ../../howto/isolating-extensions.rst:553
550659msgid "This is new in Python 3.11."
551660msgstr ""
552661
553- #: ../../howto/isolating-extensions.rst:470
662+ #: ../../howto/isolating-extensions.rst:561
554663msgid ""
555664"Slot methods—the fast C equivalents for special methods, such as :c:member:"
556665"`~PyNumberMethods.nb_add` for :py:attr:`~object.__add__` or :c:member:"
@@ -560,40 +669,40 @@ msgid ""
560669"`PyGetSetDef`."
561670msgstr ""
562671
563- #: ../../howto/isolating-extensions.rst:477
672+ #: ../../howto/isolating-extensions.rst:568
564673msgid ""
565674"To access the module state in these cases, use the :c:func:"
566675"`PyType_GetModuleByDef` function, and pass in the module definition. Once "
567676"you have the module, call :c:func:`PyModule_GetState` to get the state::"
568677msgstr ""
569678
570- #: ../../howto/isolating-extensions.rst:488
679+ #: ../../howto/isolating-extensions.rst:579
571680msgid ""
572681":c:func:`!PyType_GetModuleByDef` works by searching the :term:`method "
573682"resolution order` (i.e. all superclasses) for the first superclass that has "
574683"a corresponding module."
575684msgstr ""
576685
577- #: ../../howto/isolating-extensions.rst:494
686+ #: ../../howto/isolating-extensions.rst:585
578687msgid ""
579688"In very exotic cases (inheritance chains spanning multiple modules created "
580689"from the same definition), :c:func:`!PyType_GetModuleByDef` might not return "
581690"the module of the true defining class. However, it will always return a "
582691"module with the same definition, ensuring a compatible C memory layout."
583692msgstr ""
584693
585- #: ../../howto/isolating-extensions.rst:502
694+ #: ../../howto/isolating-extensions.rst:593
586695msgid "Lifetime of the Module State"
587696msgstr ""
588697
589- #: ../../howto/isolating-extensions.rst:504
698+ #: ../../howto/isolating-extensions.rst:595
590699msgid ""
591700"When a module object is garbage-collected, its module state is freed. For "
592701"each pointer to (a part of) the module state, you must hold a reference to "
593702"the module object."
594703msgstr ""
595704
596- #: ../../howto/isolating-extensions.rst:508
705+ #: ../../howto/isolating-extensions.rst:599
597706msgid ""
598707"Usually this is not an issue, because types created with :c:func:"
599708"`PyType_FromModuleAndSpec`, and their instances, hold a reference to the "
@@ -602,38 +711,38 @@ msgid ""
602711"libraries."
603712msgstr ""
604713
605- #: ../../howto/isolating-extensions.rst:517
714+ #: ../../howto/isolating-extensions.rst:608
606715msgid "Open Issues"
607716msgstr ""
608717
609- #: ../../howto/isolating-extensions.rst:519
718+ #: ../../howto/isolating-extensions.rst:610
610719msgid "Several issues around per-module state and heap types are still open."
611720msgstr ""
612721
613- #: ../../howto/isolating-extensions.rst:521
722+ #: ../../howto/isolating-extensions.rst:612
614723msgid ""
615724"Discussions about improving the situation are best held on the `capi-sig "
616725"mailing list <https://mail.python.org/mailman3/lists/capi-sig.python.org/"
617726">`__."
618727msgstr ""
619728
620- #: ../../howto/isolating-extensions.rst:526
729+ #: ../../howto/isolating-extensions.rst:617
621730msgid "Per-Class Scope"
622731msgstr ""
623732
624- #: ../../howto/isolating-extensions.rst:528
733+ #: ../../howto/isolating-extensions.rst:619
625734msgid ""
626735"It is currently (as of Python 3.11) not possible to attach state to "
627736"individual *types* without relying on CPython implementation details (which "
628737"may change in the future—perhaps, ironically, to allow a proper solution for "
629738"per-class scope)."
630739msgstr ""
631740
632- #: ../../howto/isolating-extensions.rst:535
741+ #: ../../howto/isolating-extensions.rst:626
633742msgid "Lossless Conversion to Heap Types"
634743msgstr ""
635744
636- #: ../../howto/isolating-extensions.rst:537
745+ #: ../../howto/isolating-extensions.rst:628
637746msgid ""
638747"The heap type API was not designed for \" lossless\" conversion from static "
639748"types; that is, creating a type that works exactly like a given static type."
0 commit comments