Skip to content

Commit f221102

Browse files
github-actions[bot]mattwang44
authored andcommitted
sync with cpython b82b12bc
1 parent 8c0fd99 commit f221102

File tree

2 files changed

+62
-51
lines changed

2 files changed

+62
-51
lines changed

c-api/module.po

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: Python 3.14\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2025-11-27 00:14+0000\n"
10+
"POT-Creation-Date: 2026-01-28 00:16+0000\n"
1111
"PO-Revision-Date: 2018-05-23 14:32+0000\n"
1212
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
1313
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -784,7 +784,12 @@ msgid ""
784784
"``PyModule_FromDefAndSpec``)."
785785
msgstr ""
786786

787-
#: ../../c-api/module.rst:682
787+
#: ../../c-api/module.rst:678
788+
#, fuzzy
789+
msgid "Return ``0`` on success. Return ``-1`` with an exception set on error."
790+
msgstr "在失敗時回傳 ``NULL`` 並設定例外。"
791+
792+
#: ../../c-api/module.rst:685
788793
msgid ""
789794
"Indicate that *module* does or does not support running without the global "
790795
"interpreter lock (GIL), using one of the values from :c:macro:`Py_mod_gil`. "
@@ -796,26 +801,26 @@ msgid ""
796801
"on error, ``0`` on success."
797802
msgstr ""
798803

799-
#: ../../c-api/module.rst:696
804+
#: ../../c-api/module.rst:699
800805
msgid "Module lookup (single-phase initialization)"
801806
msgstr ""
802807

803-
#: ../../c-api/module.rst:698
808+
#: ../../c-api/module.rst:701
804809
msgid ""
805810
"The legacy :ref:`single-phase initialization <single-phase-initialization>` "
806811
"initialization scheme creates singleton modules that can be looked up in the "
807812
"context of the current interpreter. This allows the module object to be "
808813
"retrieved later with only a reference to the module definition."
809814
msgstr ""
810815

811-
#: ../../c-api/module.rst:703
816+
#: ../../c-api/module.rst:706
812817
msgid ""
813818
"These functions will not work on modules created using multi-phase "
814819
"initialization, since multiple such modules can be created from a single "
815820
"definition."
816821
msgstr ""
817822

818-
#: ../../c-api/module.rst:708
823+
#: ../../c-api/module.rst:711
819824
msgid ""
820825
"Returns the module object that was created from *def* for the current "
821826
"interpreter. This method requires that the module object has been attached "
@@ -824,18 +829,18 @@ msgid ""
824829
"to the interpreter state yet, it returns ``NULL``."
825830
msgstr ""
826831

827-
#: ../../c-api/module.rst:715
832+
#: ../../c-api/module.rst:718
828833
msgid ""
829834
"Attaches the module object passed to the function to the interpreter state. "
830835
"This allows the module object to be accessible via :c:func:"
831836
"`PyState_FindModule`."
832837
msgstr ""
833838

834-
#: ../../c-api/module.rst:718
839+
#: ../../c-api/module.rst:721
835840
msgid "Only effective on modules created using single-phase initialization."
836841
msgstr ""
837842

838-
#: ../../c-api/module.rst:720
843+
#: ../../c-api/module.rst:723
839844
msgid ""
840845
"Python calls ``PyState_AddModule`` automatically after importing a module "
841846
"that uses :ref:`single-phase initialization <single-phase-initialization>`, "
@@ -847,21 +852,21 @@ msgid ""
847852
"state updates)."
848853
msgstr ""
849854

850-
#: ../../c-api/module.rst:729
855+
#: ../../c-api/module.rst:732
851856
msgid ""
852857
"If a module was attached previously using the same *def*, it is replaced by "
853858
"the new *module*."
854859
msgstr ""
855860

856-
#: ../../c-api/module.rst:732 ../../c-api/module.rst:743
861+
#: ../../c-api/module.rst:735 ../../c-api/module.rst:746
857862
msgid "The caller must have an :term:`attached thread state`."
858863
msgstr ""
859864

860-
#: ../../c-api/module.rst:734
865+
#: ../../c-api/module.rst:737
861866
msgid "Return ``-1`` with an exception set on error, ``0`` on success."
862867
msgstr "成功時回傳 ``0``,在失敗時回傳 ``-1`` 並設定例外。"
863868

864-
#: ../../c-api/module.rst:740
869+
#: ../../c-api/module.rst:743
865870
msgid ""
866871
"Removes the module object created from *def* from the interpreter state. "
867872
"Return ``-1`` with an exception set on error, ``0`` on success."

library/contextvars.po

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ msgid ""
44
msgstr ""
55
"Project-Id-Version: Python 3.14\n"
66
"Report-Msgid-Bugs-To: \n"
7-
"POT-Creation-Date: 2026-01-27 00:17+0000\n"
7+
"POT-Creation-Date: 2026-01-28 00:16+0000\n"
88
"PO-Revision-Date: 2025-07-30 22:06+0800\n"
99
"Last-Translator: \n"
1010
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -211,32 +211,38 @@ msgstr ""
211211
"# 在重設呼叫之後,var 又沒有值了,所以\n"
212212
"# var.get() 會引發 LookupError。"
213213

214-
#: ../../library/contextvars.rst:125
214+
#: ../../library/contextvars.rst:122
215+
msgid "The same *token* cannot be used twice."
216+
msgstr ""
217+
218+
#: ../../library/contextvars.rst:127
219+
#, fuzzy
215220
msgid ""
216221
"*Token* objects are returned by the :meth:`ContextVar.set` method. They can "
217222
"be passed to the :meth:`ContextVar.reset` method to revert the value of the "
218-
"variable to what it was before the corresponding *set*."
223+
"variable to what it was before the corresponding *set*. A single token "
224+
"cannot reset a context variable more than once."
219225
msgstr ""
220226
"*Token* 物件由 :meth:`ContextVar.set` 方法回傳,可以傳遞給 :meth:`ContextVar."
221227
"reset` 方法,用以將變數的值還原為相對應的 *set* 之前的值。"
222228

223-
#: ../../library/contextvars.rst:130
229+
#: ../../library/contextvars.rst:132
224230
msgid ""
225231
"Tokens support the :ref:`context manager protocol <context-managers>` to "
226232
"automatically reset context variables. See :meth:`ContextVar.set`."
227233
msgstr ""
228234

229-
#: ../../library/contextvars.rst:135
235+
#: ../../library/contextvars.rst:137
230236
msgid "Added support for usage as a context manager."
231237
msgstr "新增對用作情境管理器的支援。"
232238

233-
#: ../../library/contextvars.rst:139
239+
#: ../../library/contextvars.rst:141
234240
msgid ""
235241
"A read-only property. Points to the :class:`ContextVar` object that created "
236242
"the token."
237243
msgstr "唯讀屬性。 指向建立 token 的 :class:`ContextVar` 物件。"
238244

239-
#: ../../library/contextvars.rst:144
245+
#: ../../library/contextvars.rst:146
240246
msgid ""
241247
"A read-only property. Set to the value the variable had before the :meth:"
242248
"`ContextVar.set` method call that created the token. It points to :attr:"
@@ -245,34 +251,34 @@ msgstr ""
245251
"唯讀屬性。 值為變數在呼叫 :meth:`ContextVar.set` 方法之前的值。如果變數在呼叫"
246252
"前沒有設定,則指向 :attr:`Token.MISSING`。"
247253

248-
#: ../../library/contextvars.rst:151
254+
#: ../../library/contextvars.rst:153
249255
msgid "A marker object used by :attr:`Token.old_value`."
250256
msgstr "由 :attr:`Token.old_value` 使用的標記物件。"
251257

252-
#: ../../library/contextvars.rst:155
258+
#: ../../library/contextvars.rst:157
253259
msgid "Manual Context Management"
254260
msgstr "手動情境管理"
255261

256-
#: ../../library/contextvars.rst:159
262+
#: ../../library/contextvars.rst:161
257263
msgid "Returns a copy of the current :class:`~contextvars.Context` object."
258264
msgstr "回傳目前 :class:`~contextvars.Context` 物件的複本(copy)。"
259265

260-
#: ../../library/contextvars.rst:161
266+
#: ../../library/contextvars.rst:163
261267
msgid ""
262268
"The following snippet gets a copy of the current context and prints all "
263269
"variables and their values that are set in it::"
264270
msgstr ""
265271
"以下程式碼片段會取得目前情境的複本,並顯示在其中設定的所有變數及其值:::"
266272

267-
#: ../../library/contextvars.rst:164
273+
#: ../../library/contextvars.rst:166
268274
msgid ""
269275
"ctx: Context = copy_context()\n"
270276
"print(list(ctx.items()))"
271277
msgstr ""
272278
"ctx: Context = copy_context()\n"
273279
"print(list(ctx.items()))"
274280

275-
#: ../../library/contextvars.rst:167
281+
#: ../../library/contextvars.rst:169
276282
msgid ""
277283
"The function has an *O*\\ (1) complexity, i.e. works equally fast for "
278284
"contexts with a few context variables and for contexts that have a lot of "
@@ -281,19 +287,19 @@ msgstr ""
281287
"這個函式具有 *O*\\ (1) 的複雜度,也就是說,對於只有少許情境變數的情境和有大量"
282288
"情境變數的情境,速度都一樣快。"
283289

284-
#: ../../library/contextvars.rst:174
290+
#: ../../library/contextvars.rst:176
285291
msgid "A mapping of :class:`ContextVars <ContextVar>` to their values."
286292
msgstr ":class:`ContextVars<ContextVar>` 到其值的映射。"
287293

288-
#: ../../library/contextvars.rst:176
294+
#: ../../library/contextvars.rst:178
289295
msgid ""
290296
"``Context()`` creates an empty context with no values in it. To get a copy "
291297
"of the current context use the :func:`~contextvars.copy_context` function."
292298
msgstr ""
293299
"``Context()`` 會建立一個沒有值的空情境。要取得目前情境的複本,請使用 :func:"
294300
"`~contextvars.copy_context` 函式。"
295301

296-
#: ../../library/contextvars.rst:180
302+
#: ../../library/contextvars.rst:182
297303
msgid ""
298304
"Each thread has its own effective stack of :class:`!Context` objects. The :"
299305
"term:`current context` is the :class:`!Context` object at the top of the "
@@ -304,7 +310,7 @@ msgstr ""
304310
"term:`current context` 是目前執行緒堆疊頂端的 :class:`!Context` 物件。 堆疊"
305311
"中的所有 :class:`!Context` 物件都被視為\\ *已進入*。"
306312

307-
#: ../../library/contextvars.rst:185
313+
#: ../../library/contextvars.rst:187
308314
msgid ""
309315
"*Entering* a context, which can be done by calling its :meth:`~Context.run` "
310316
"method, makes the context the current context by pushing it onto the top of "
@@ -313,7 +319,7 @@ msgstr ""
313319
"*進入*\\ 一個情境,可以藉由呼叫其 :meth:`~Context.run` 方法來完成,此\\ *進入"
314320
"*\\ 的動作會將一情境推到目前執行緒的情境堆疊的頂端,使該情境成為目前的情境。"
315321

316-
#: ../../library/contextvars.rst:189
322+
#: ../../library/contextvars.rst:191
317323
msgid ""
318324
"*Exiting* from the current context, which can be done by returning from the "
319325
"callback passed to the :meth:`~Context.run` method, restores the current "
@@ -324,7 +330,7 @@ msgstr ""
324330
"式回傳之後,就會自動\\ *退出*\\ 目前的情境,這會將目前的情境還原到進入情境之"
325331
"前的狀態,方法是將情境從情境堆疊的頂端彈出。"
326332

327-
#: ../../library/contextvars.rst:194
333+
#: ../../library/contextvars.rst:196
328334
msgid ""
329335
"Since each thread has its own context stack, :class:`ContextVar` objects "
330336
"behave in a similar fashion to :func:`threading.local` when values are "
@@ -333,19 +339,19 @@ msgstr ""
333339
"因為每個執行緒都有自己的情境堆疊,當值在不同的執行緒中被指定時, :class:"
334340
"`ContextVar` 物件的行為與 :func:`threading.local` 相似。"
335341

336-
#: ../../library/contextvars.rst:198
342+
#: ../../library/contextvars.rst:200
337343
msgid ""
338344
"Attempting to enter an already entered context, including contexts entered "
339345
"in other threads, raises a :exc:`RuntimeError`."
340346
msgstr ""
341347
"嘗試進入已進入的情境,包括在其他執行緒中進入的情境,會引發 :exc:"
342348
"`RuntimeError`。"
343349

344-
#: ../../library/contextvars.rst:201
350+
#: ../../library/contextvars.rst:203
345351
msgid "After exiting a context, it can later be re-entered (from any thread)."
346352
msgstr "退出情境後,之後可以重新進入(從任何執行緒)。"
347353

348-
#: ../../library/contextvars.rst:203
354+
#: ../../library/contextvars.rst:205
349355
msgid ""
350356
"Any changes to :class:`ContextVar` values via the :meth:`ContextVar.set` "
351357
"method are recorded in the current context. The :meth:`ContextVar.get` "
@@ -359,11 +365,11 @@ msgstr ""
359365
"實際造成的效果會像是將其在進入情境時對情境變數所做的任何變一一彈出並還原(如"
360366
"果需要,可以透過重新進入情境來還原值)。"
361367

362-
#: ../../library/contextvars.rst:210
368+
#: ../../library/contextvars.rst:212
363369
msgid "Context implements the :class:`collections.abc.Mapping` interface."
364370
msgstr "情境(Context)實作了 :class:`collections.abc.Mapping` 介面。"
365371

366-
#: ../../library/contextvars.rst:214
372+
#: ../../library/contextvars.rst:216
367373
msgid ""
368374
"Enters the Context, executes ``callable(*args, **kwargs)``, then exits the "
369375
"Context. Returns *callable*'s return value, or propagates an exception if "
@@ -372,11 +378,11 @@ msgstr ""
372378
"進入 Context,執行 ``callable(*args, **kwargs)``,然後退出 Context。 回傳 "
373379
"*callable* 的回傳值,如果發生例外(exception),則傳播例外。"
374380

375-
#: ../../library/contextvars.rst:218
381+
#: ../../library/contextvars.rst:220
376382
msgid "Example:"
377383
msgstr "例如:"
378384

379-
#: ../../library/contextvars.rst:220
385+
#: ../../library/contextvars.rst:222
380386
msgid ""
381387
"import contextvars\n"
382388
"\n"
@@ -440,60 +446,60 @@ msgstr ""
440446
"# 但是,在 'ctx' 外, 'var' 的值仍然是 'spam':\n"
441447
"print(var.get()) # 'spam'"
442448

443-
#: ../../library/contextvars.rst:266
449+
#: ../../library/contextvars.rst:268
444450
msgid "Return a shallow copy of the context object."
445451
msgstr "回傳情境物件的淺層複本(shallow copy)。"
446452

447-
#: ../../library/contextvars.rst:270
453+
#: ../../library/contextvars.rst:272
448454
msgid ""
449455
"Return ``True`` if the *context* has a value for *var* set; return ``False`` "
450456
"otherwise."
451457
msgstr ""
452458
"如果\\ *情境*\\ 裡面有 *var* 的值,則回傳 ``True``,否則回傳 ``False``。"
453459

454-
#: ../../library/contextvars.rst:275
460+
#: ../../library/contextvars.rst:277
455461
msgid ""
456462
"Return the value of the *var* :class:`ContextVar` variable. If the variable "
457463
"is not set in the context object, a :exc:`KeyError` is raised."
458464
msgstr ""
459465
"回傳 *var* :class:`ContextVar` 變數的值。如果該變數並沒有在情境物件中設定,則"
460466
"會引發 :exc:`KeyError` 錯誤。"
461467

462-
#: ../../library/contextvars.rst:281
468+
#: ../../library/contextvars.rst:283
463469
msgid ""
464470
"Return the value for *var* if *var* has the value in the context object. "
465471
"Return *default* otherwise. If *default* is not given, return ``None``."
466472
msgstr ""
467473
"如果 *var* 的值在情境物件中,則回傳 *var* 的值。否則回傳 *default*。如果沒有 "
468474
"*default* 值,則回傳 ``None``。"
469475

470-
#: ../../library/contextvars.rst:287
476+
#: ../../library/contextvars.rst:289
471477
msgid "Return an iterator over the variables stored in the context object."
472478
msgstr "回傳儲存於情境物件中變數的疊代器。"
473479

474-
#: ../../library/contextvars.rst:292
480+
#: ../../library/contextvars.rst:294
475481
msgid "Return the number of variables set in the context object."
476482
msgstr "回傳情境物件中的變數個數。"
477483

478-
#: ../../library/contextvars.rst:296
484+
#: ../../library/contextvars.rst:298
479485
msgid "Return a list of all variables in the context object."
480486
msgstr "回傳情境物件中所有變數的串列。"
481487

482-
#: ../../library/contextvars.rst:300
488+
#: ../../library/contextvars.rst:302
483489
msgid "Return a list of all variables' values in the context object."
484490
msgstr "回傳情境物件中所有變數的值的串列。"
485491

486-
#: ../../library/contextvars.rst:305
492+
#: ../../library/contextvars.rst:307
487493
msgid ""
488494
"Return a list of 2-tuples containing all variables and their values in the "
489495
"context object."
490496
msgstr "回傳情境物件中所有變數與其值的 2-元組(2-tuples)的串列。"
491497

492-
#: ../../library/contextvars.rst:310
498+
#: ../../library/contextvars.rst:312
493499
msgid "asyncio support"
494500
msgstr "對 asyncio 的支援"
495501

496-
#: ../../library/contextvars.rst:312
502+
#: ../../library/contextvars.rst:314
497503
msgid ""
498504
"Context variables are natively supported in :mod:`asyncio` and are ready to "
499505
"be used without any extra configuration. For example, here is a simple echo "
@@ -503,7 +509,7 @@ msgstr ""
503509
":mod:`asyncio` 原生支援情境變數,不需任何額外設定。 舉例來說,以下是一個簡單"
504510
"的 echo 伺服器,使用情境變數讓遠端用戶端的位址在處理該用戶端的任務中可用:"
505511

506-
#: ../../library/contextvars.rst:318
512+
#: ../../library/contextvars.rst:320
507513
msgid ""
508514
"import asyncio\n"
509515
"import contextvars\n"

0 commit comments

Comments
 (0)