@@ -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 : 2023-11-10 14:13 +0000\n "
14
+ "POT-Creation-Date : 2023-11-17 14:14 +0000\n "
15
15
"PO-Revision-Date : 2022-11-05 19:48+0000\n "
16
16
"Last-Translator : tomo, 2022\n "
17
17
"Language-Team : Japanese (https://app.transifex.com/python-doc/teams/5390/ "
@@ -449,108 +449,217 @@ msgstr ""
449
449
450
450
#: ../../howto/isolating-extensions.rst:342
451
451
msgid ""
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."
455
454
msgstr ""
456
455
457
456
#: ../../howto/isolating-extensions.rst:346
458
457
msgid ""
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 ."
462
461
msgstr ""
463
462
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 "
466
465
msgstr ""
467
466
468
467
#: ../../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
469
507
msgid "...and ``base`` may be a static type, then it should also include::"
470
508
msgstr ""
471
509
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
473
582
msgid ""
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`:: "
476
585
msgstr ""
477
586
478
- #: ../../howto/isolating-extensions.rst:367
587
+ #: ../../howto/isolating-extensions.rst:458
479
588
msgid "Module State Access from Classes"
480
589
msgstr ""
481
590
482
- #: ../../howto/isolating-extensions.rst:369
591
+ #: ../../howto/isolating-extensions.rst:460
483
592
msgid ""
484
593
"If you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, "
485
594
"you can call :c:func:`PyType_GetModule` to get the associated module, and "
486
595
"then :c:func:`PyModule_GetState` to get the module's state."
487
596
msgstr ""
488
597
489
- #: ../../howto/isolating-extensions.rst:373
598
+ #: ../../howto/isolating-extensions.rst:464
490
599
msgid ""
491
600
"To save a some tedious error-handling boilerplate code, you can combine "
492
601
"these two steps with :c:func:`PyType_GetModuleState`, resulting in::"
493
602
msgstr ""
494
603
495
- #: ../../howto/isolating-extensions.rst:383
604
+ #: ../../howto/isolating-extensions.rst:474
496
605
msgid "Module State Access from Regular Methods"
497
606
msgstr ""
498
607
499
- #: ../../howto/isolating-extensions.rst:385
608
+ #: ../../howto/isolating-extensions.rst:476
500
609
msgid ""
501
610
"Accessing the module-level state from methods of a class is somewhat more "
502
611
"complicated, but is possible thanks to API introduced in Python 3.9. To get "
503
612
"the state, you need to first get the *defining class*, and then get the "
504
613
"module state from it."
505
614
msgstr ""
506
615
507
- #: ../../howto/isolating-extensions.rst:390
616
+ #: ../../howto/isolating-extensions.rst:481
508
617
msgid ""
509
618
"The largest roadblock is getting *the class a method was defined in*, or "
510
619
"that method's \" defining class\" for short. The defining class can have a "
511
620
"reference to the module it is part of."
512
621
msgstr ""
513
622
514
- #: ../../howto/isolating-extensions.rst:394
623
+ #: ../../howto/isolating-extensions.rst:485
515
624
msgid ""
516
625
"Do not confuse the defining class with :c:expr:`Py_TYPE(self)`. If the "
517
626
"method is called on a *subclass* of your type, ``Py_TYPE(self)`` will refer "
518
627
"to that subclass, which may be defined in different module than yours."
519
628
msgstr ""
520
629
521
- #: ../../howto/isolating-extensions.rst:399
630
+ #: ../../howto/isolating-extensions.rst:490
522
631
msgid ""
523
632
"The following Python code can illustrate the concept. ``Base."
524
633
"get_defining_class`` returns ``Base`` even if ``type(self) == Sub``:"
525
634
msgstr ""
526
635
527
- #: ../../howto/isolating-extensions.rst:415
636
+ #: ../../howto/isolating-extensions.rst:506
528
637
msgid ""
529
638
"For a method to get its \" defining class\" , it must use the :ref:"
530
639
"`METH_METHOD | METH_FASTCALL | METH_KEYWORDS <METH_METHOD-METH_FASTCALL-"
531
640
"METH_KEYWORDS>` :c:type:`calling convention <PyMethodDef>` and the "
532
641
"corresponding :c:type:`PyCMethod` signature::"
533
642
msgstr ""
534
643
535
- #: ../../howto/isolating-extensions.rst:427
644
+ #: ../../howto/isolating-extensions.rst:518
536
645
msgid ""
537
646
"Once you have the defining class, call :c:func:`PyType_GetModuleState` to "
538
647
"get the state of its associated module."
539
648
msgstr ""
540
649
541
- #: ../../howto/isolating-extensions.rst:430
650
+ #: ../../howto/isolating-extensions.rst:521
542
651
msgid "For example::"
543
652
msgstr "例えば::"
544
653
545
- #: ../../howto/isolating-extensions.rst:458
654
+ #: ../../howto/isolating-extensions.rst:549
546
655
msgid "Module State Access from Slot Methods, Getters and Setters"
547
656
msgstr ""
548
657
549
- #: ../../howto/isolating-extensions.rst:462
658
+ #: ../../howto/isolating-extensions.rst:553
550
659
msgid "This is new in Python 3.11."
551
660
msgstr ""
552
661
553
- #: ../../howto/isolating-extensions.rst:470
662
+ #: ../../howto/isolating-extensions.rst:561
554
663
msgid ""
555
664
"Slot methods—the fast C equivalents for special methods, such as :c:member:"
556
665
"`~PyNumberMethods.nb_add` for :py:attr:`~object.__add__` or :c:member:"
@@ -560,40 +669,40 @@ msgid ""
560
669
"`PyGetSetDef`."
561
670
msgstr ""
562
671
563
- #: ../../howto/isolating-extensions.rst:477
672
+ #: ../../howto/isolating-extensions.rst:568
564
673
msgid ""
565
674
"To access the module state in these cases, use the :c:func:"
566
675
"`PyType_GetModuleByDef` function, and pass in the module definition. Once "
567
676
"you have the module, call :c:func:`PyModule_GetState` to get the state::"
568
677
msgstr ""
569
678
570
- #: ../../howto/isolating-extensions.rst:488
679
+ #: ../../howto/isolating-extensions.rst:579
571
680
msgid ""
572
681
":c:func:`!PyType_GetModuleByDef` works by searching the :term:`method "
573
682
"resolution order` (i.e. all superclasses) for the first superclass that has "
574
683
"a corresponding module."
575
684
msgstr ""
576
685
577
- #: ../../howto/isolating-extensions.rst:494
686
+ #: ../../howto/isolating-extensions.rst:585
578
687
msgid ""
579
688
"In very exotic cases (inheritance chains spanning multiple modules created "
580
689
"from the same definition), :c:func:`!PyType_GetModuleByDef` might not return "
581
690
"the module of the true defining class. However, it will always return a "
582
691
"module with the same definition, ensuring a compatible C memory layout."
583
692
msgstr ""
584
693
585
- #: ../../howto/isolating-extensions.rst:502
694
+ #: ../../howto/isolating-extensions.rst:593
586
695
msgid "Lifetime of the Module State"
587
696
msgstr ""
588
697
589
- #: ../../howto/isolating-extensions.rst:504
698
+ #: ../../howto/isolating-extensions.rst:595
590
699
msgid ""
591
700
"When a module object is garbage-collected, its module state is freed. For "
592
701
"each pointer to (a part of) the module state, you must hold a reference to "
593
702
"the module object."
594
703
msgstr ""
595
704
596
- #: ../../howto/isolating-extensions.rst:508
705
+ #: ../../howto/isolating-extensions.rst:599
597
706
msgid ""
598
707
"Usually this is not an issue, because types created with :c:func:"
599
708
"`PyType_FromModuleAndSpec`, and their instances, hold a reference to the "
@@ -602,38 +711,38 @@ msgid ""
602
711
"libraries."
603
712
msgstr ""
604
713
605
- #: ../../howto/isolating-extensions.rst:517
714
+ #: ../../howto/isolating-extensions.rst:608
606
715
msgid "Open Issues"
607
716
msgstr ""
608
717
609
- #: ../../howto/isolating-extensions.rst:519
718
+ #: ../../howto/isolating-extensions.rst:610
610
719
msgid "Several issues around per-module state and heap types are still open."
611
720
msgstr ""
612
721
613
- #: ../../howto/isolating-extensions.rst:521
722
+ #: ../../howto/isolating-extensions.rst:612
614
723
msgid ""
615
724
"Discussions about improving the situation are best held on the `capi-sig "
616
725
"mailing list <https://mail.python.org/mailman3/lists/capi-sig.python.org/"
617
726
">`__."
618
727
msgstr ""
619
728
620
- #: ../../howto/isolating-extensions.rst:526
729
+ #: ../../howto/isolating-extensions.rst:617
621
730
msgid "Per-Class Scope"
622
731
msgstr ""
623
732
624
- #: ../../howto/isolating-extensions.rst:528
733
+ #: ../../howto/isolating-extensions.rst:619
625
734
msgid ""
626
735
"It is currently (as of Python 3.11) not possible to attach state to "
627
736
"individual *types* without relying on CPython implementation details (which "
628
737
"may change in the future—perhaps, ironically, to allow a proper solution for "
629
738
"per-class scope)."
630
739
msgstr ""
631
740
632
- #: ../../howto/isolating-extensions.rst:535
741
+ #: ../../howto/isolating-extensions.rst:626
633
742
msgid "Lossless Conversion to Heap Types"
634
743
msgstr ""
635
744
636
- #: ../../howto/isolating-extensions.rst:537
745
+ #: ../../howto/isolating-extensions.rst:628
637
746
msgid ""
638
747
"The heap type API was not designed for \" lossless\" conversion from static "
639
748
"types; that is, creating a type that works exactly like a given static type."
0 commit comments