77msgstr ""
88"Project-Id-Version : Python 3.13\n "
99"Report-Msgid-Bugs-To : \n "
10- "POT-Creation-Date : 2025-08-18 00:18 +0000\n "
10+ "POT-Creation-Date : 2025-08-27 00:15 +0000\n "
1111"PO-Revision-Date : 2023-04-24 20:49+0800\n "
1212"Last-Translator : Adrian Liaw <adrianliaw2000@gmail.com>\n "
1313"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -2874,23 +2874,33 @@ msgstr ""
28742874
28752875#: ../../c-api/init.rst:2399
28762876msgid ""
2877- "Critical sections avoid deadlocks by implicitly suspending active critical "
2878- "sections and releasing the locks during calls to :c:func:"
2879- "`PyEval_SaveThread`. When :c:func:`PyEval_RestoreThread` is called, the most "
2880- "recent critical section is resumed, and its locks reacquired. This means "
2881- "the critical section API provides weaker guarantees than traditional locks "
2882- "-- they are useful because their behavior is similar to the :term:`GIL`."
2877+ "Critical sections are intended to be used for custom types implemented in C-"
2878+ "API extensions. They should generally not be used with built-in types like :"
2879+ "class:`list` and :class:`dict` because their public C-APIs already use "
2880+ "critical sections internally, with the notable exception of :c:func:"
2881+ "`PyDict_Next`, which requires critical section to be acquired externally."
28832882msgstr ""
28842883
28852884#: ../../c-api/init.rst:2406
28862885msgid ""
2886+ "Critical sections avoid deadlocks by implicitly suspending active critical "
2887+ "sections, hence, they do not provide exclusive access such as provided by "
2888+ "traditional locks like :c:type:`PyMutex`. When a critical section is "
2889+ "started, the per-object lock for the object is acquired. If the code "
2890+ "executed inside the critical section calls C-API functions then it can "
2891+ "suspend the critical section thereby releasing the per-object lock, so other "
2892+ "threads can acquire the per-object lock for the same object."
2893+ msgstr ""
2894+
2895+ #: ../../c-api/init.rst:2414
2896+ msgid ""
28872897"The functions and structs used by the macros are exposed for cases where C "
28882898"macros are not available. They should only be used as in the given macro "
28892899"expansions. Note that the sizes and contents of the structures may change in "
28902900"future Python versions."
28912901msgstr ""
28922902
2893- #: ../../c-api/init.rst:2413
2903+ #: ../../c-api/init.rst:2421
28942904msgid ""
28952905"Operations that need to lock two objects at once must use :c:macro:"
28962906"`Py_BEGIN_CRITICAL_SECTION2`. You *cannot* use nested critical sections to "
@@ -2899,11 +2909,11 @@ msgid ""
28992909"lock more than two objects at once."
29002910msgstr ""
29012911
2902- #: ../../c-api/init.rst:2419
2912+ #: ../../c-api/init.rst:2427
29032913msgid "Example usage::"
29042914msgstr "範例用法: ::"
29052915
2906- #: ../../c-api/init.rst:2421
2916+ #: ../../c-api/init.rst:2429
29072917msgid ""
29082918"static PyObject *\n"
29092919"set_field(MyObject *self, PyObject *value)\n"
@@ -2923,7 +2933,7 @@ msgstr ""
29232933" Py_RETURN_NONE;\n"
29242934"}"
29252935
2926- #: ../../c-api/init.rst:2430
2936+ #: ../../c-api/init.rst:2438
29272937msgid ""
29282938"In the above example, :c:macro:`Py_SETREF` calls :c:macro:`Py_DECREF`, which "
29292939"can call arbitrary code through an object's deallocation function. The "
@@ -2933,18 +2943,18 @@ msgid ""
29332943"`PyEval_SaveThread`."
29342944msgstr ""
29352945
2936- #: ../../c-api/init.rst:2438
2946+ #: ../../c-api/init.rst:2446
29372947msgid ""
29382948"Acquires the per-object lock for the object *op* and begins a critical "
29392949"section."
29402950msgstr ""
29412951
2942- #: ../../c-api/init.rst:2441 ../../c-api/init.rst:2455
2943- #: ../../c-api/init.rst:2470 ../../c-api/init.rst:2484
2952+ #: ../../c-api/init.rst:2449 ../../c-api/init.rst:2463
2953+ #: ../../c-api/init.rst:2478 ../../c-api/init.rst:2492
29442954msgid "In the free-threaded build, this macro expands to::"
29452955msgstr ""
29462956
2947- #: ../../c-api/init.rst:2443
2957+ #: ../../c-api/init.rst:2451
29482958msgid ""
29492959"{\n"
29502960" PyCriticalSection _py_cs;\n"
@@ -2954,34 +2964,34 @@ msgstr ""
29542964" PyCriticalSection _py_cs;\n"
29552965" PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))"
29562966
2957- #: ../../c-api/init.rst:2447 ../../c-api/init.rst:2476
2967+ #: ../../c-api/init.rst:2455 ../../c-api/init.rst:2484
29582968msgid "In the default build, this macro expands to ``{``."
29592969msgstr ""
29602970
2961- #: ../../c-api/init.rst:2453
2971+ #: ../../c-api/init.rst:2461
29622972msgid "Ends the critical section and releases the per-object lock."
29632973msgstr ""
29642974
2965- #: ../../c-api/init.rst:2457
2975+ #: ../../c-api/init.rst:2465
29662976msgid ""
29672977" PyCriticalSection_End(&_py_cs);\n"
29682978"}"
29692979msgstr ""
29702980" PyCriticalSection_End(&_py_cs);\n"
29712981"}"
29722982
2973- #: ../../c-api/init.rst:2460 ../../c-api/init.rst:2489
2983+ #: ../../c-api/init.rst:2468 ../../c-api/init.rst:2497
29742984msgid "In the default build, this macro expands to ``}``."
29752985msgstr ""
29762986
2977- #: ../../c-api/init.rst:2466
2987+ #: ../../c-api/init.rst:2474
29782988msgid ""
29792989"Acquires the per-objects locks for the objects *a* and *b* and begins a "
29802990"critical section. The locks are acquired in a consistent order (lowest "
29812991"address first) to avoid lock ordering deadlocks."
29822992msgstr ""
29832993
2984- #: ../../c-api/init.rst:2472
2994+ #: ../../c-api/init.rst:2480
29852995msgid ""
29862996"{\n"
29872997" PyCriticalSection2 _py_cs2;\n"
@@ -2991,11 +3001,11 @@ msgstr ""
29913001" PyCriticalSection2 _py_cs2;\n"
29923002" PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))"
29933003
2994- #: ../../c-api/init.rst:2482
3004+ #: ../../c-api/init.rst:2490
29953005msgid "Ends the critical section and releases the per-object locks."
29963006msgstr ""
29973007
2998- #: ../../c-api/init.rst:2486
3008+ #: ../../c-api/init.rst:2494
29993009msgid ""
30003010" PyCriticalSection2_End(&_py_cs2);\n"
30013011"}"
0 commit comments