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

Skip to content

Commit 7823bb1

Browse files
committed
fix: to rst: 406
- 382 / 388 些微超譯 - 399 populated 用填充總覺得怪,換了個寫法 - 403 根據已棄用的 load_module 判斷其為接管載入模組之功能
1 parent 950d450 commit 7823bb1

File tree

1 file changed

+51
-4
lines changed

1 file changed

+51
-4
lines changed

reference/import.po

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ msgstr ""
77
"Project-Id-Version: Python 3.13\n"
88
"Report-Msgid-Bugs-To: \n"
99
"POT-Creation-Date: 2024-09-03 11:11+0800\n"
10-
"PO-Revision-Date: 2024-10-07 21:14+0800\n"
11-
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
10+
"PO-Revision-Date: 2024-10-08 15:45+0800\n"
11+
"Last-Translator: Ken Cheng <ken71301@gmail.com>\n"
1212
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1313
"tw)\n"
1414
"Language: zh_TW\n"
@@ -599,14 +599,16 @@ msgstr ""
599599

600600
#: ../../reference/import.rst:342
601601
msgid "Loading"
602-
msgstr ""
602+
msgstr "載入"
603603

604604
#: ../../reference/import.rst:344
605605
msgid ""
606606
"If and when a module spec is found, the import machinery will use it (and "
607607
"the loader it contains) when loading the module. Here is an approximation "
608608
"of what happens during the loading portion of import::"
609609
msgstr ""
610+
"如果找到模組規格,引入機制會在載入模組時使用該規格(以及它包含的載入器)。以"
611+
"下是引入過程中載入部分的大致情況: ::"
610612

611613
#: ../../reference/import.rst:348
612614
msgid ""
@@ -639,16 +641,45 @@ msgid ""
639641
" raise\n"
640642
"return sys.modules[spec.name]"
641643
msgstr ""
644+
"module = None\n"
645+
"if spec.loader is not None and hasattr(spec.loader, 'create_module'):\n"
646+
" # 這裡假設載入器上也會定義 'exec_module'\n"
647+
" module = spec.loader.create_module(spec)\n"
648+
"if module is None:\n"
649+
" module = ModuleType(spec.name)\n"
650+
"# 與引入相關的模組屬性會在此處設定:\n"
651+
"_init_module_attrs(spec, module)\n"
652+
"\n"
653+
"if spec.loader is None:\n"
654+
" # 不支援\n"
655+
" raise ImportError\n"
656+
"if spec.origin is None and spec.submodule_search_locations is not None:\n"
657+
" # 命名空間套件\n"
658+
" sys.modules[spec.name] = module\n"
659+
"elif not hasattr(spec.loader, 'exec_module'):\n"
660+
" module = spec.loader.load_module(spec.name)\n"
661+
"else:\n"
662+
" sys.modules[spec.name] = module\n"
663+
" try:\n"
664+
" spec.loader.exec_module(module)\n"
665+
" except BaseException:\n"
666+
" try:\n"
667+
" del sys.modules[spec.name]\n"
668+
" except KeyError:\n"
669+
" pass\n"
670+
" raise\n"
671+
"return sys.modules[spec.name]"
642672

643673
#: ../../reference/import.rst:377
644674
msgid "Note the following details:"
645-
msgstr ""
675+
msgstr "請注意下列細節:"
646676

647677
#: ../../reference/import.rst:379
648678
msgid ""
649679
"If there is an existing module object with the given name in :data:`sys."
650680
"modules`, import will have already returned it."
651681
msgstr ""
682+
"如果 :data:`sys.modules` 中已存在具有給定名稱的模組物件,引入會已回傳該物件。"
652683

653684
#: ../../reference/import.rst:382
654685
msgid ""
@@ -658,6 +689,9 @@ msgid ""
658689
"prevents unbounded recursion in the worst case and multiple loading in the "
659690
"best."
660691
msgstr ""
692+
"在載入器執行模組程式碼之前,模組將已存在於 :data:`sys.modules` 中。這一點至關"
693+
"重要,因為模組程式碼可能會(直接或間接)引入自己;事先將其增加到 :data:`sys."
694+
"modules` 可以預防類似無限遞迴以及多次重覆載入等情形。"
661695

662696
#: ../../reference/import.rst:388
663697
msgid ""
@@ -667,6 +701,10 @@ msgid ""
667701
"effect, must remain in the cache. This contrasts with reloading where even "
668702
"the failing module is left in :data:`sys.modules`."
669703
msgstr ""
704+
"如果載入失敗,只有載入失敗的模組會從 :data:`sys.modules` 中刪除。任何已存在"
705+
"於 :data:`sys.modules` 快取中的模組,以及任何在載入失敗前成功載入的模組,都必"
706+
"須保留在快取中。此情形與重新載入不同,在重新載入時,即使載入失敗的模組也會保"
707+
"留在 :data:`sys.modules` 中。"
670708

671709
#: ../../reference/import.rst:394
672710
msgid ""
@@ -675,26 +713,35 @@ msgid ""
675713
"code example above), as summarized in a :ref:`later section <import-mod-"
676714
"attrs>`."
677715
msgstr ""
716+
"模組建立後,在執行之前,引入機制會設置與引入相關的模組屬性(在上面的偽程式碼"
717+
"範例中為 \"_init_module_attrs\"),具體內容在\\ :ref:`之後的段落<import-mod-"
718+
"attrs>`\\ 會總結。"
678719

679720
#: ../../reference/import.rst:399
680721
msgid ""
681722
"Module execution is the key moment of loading in which the module's "
682723
"namespace gets populated. Execution is entirely delegated to the loader, "
683724
"which gets to decide what gets populated and how."
684725
msgstr ""
726+
"模組執行是載入過程中的關鍵時刻,此時模組的命名空間會被新增名稱。執行過程完全"
727+
"交由載入器處理,由其決定如何新增以及新增什麼。"
685728

686729
#: ../../reference/import.rst:403
687730
msgid ""
688731
"The module created during loading and passed to exec_module() may not be the "
689732
"one returned at the end of import [#fnlo]_."
690733
msgstr ""
734+
"在載入過程中建立並傳遞給 exec_module() 的模組,可能不會是引入結束時回傳的模"
735+
"組 [#fnlo]_。"
691736

692737
#: ../../reference/import.rst:406
693738
msgid ""
694739
"The import system has taken over the boilerplate responsibilities of "
695740
"loaders. These were previously performed by the :meth:`importlib.abc.Loader."
696741
"load_module` method."
697742
msgstr ""
743+
"引入系統已接管載入器中載入模組的功能。之前是由 :meth:`importlib.abc.Loader."
744+
"load_module` 方法執行的。"
698745

699746
#: ../../reference/import.rst:412
700747
msgid "Loaders"

0 commit comments

Comments
 (0)