From e93a8cb9b75d8a63c7ec678e6693f7a13618952b Mon Sep 17 00:00:00 2001 From: Steven Hsu <81967953+StevenHsuYL@users.noreply.github.com> Date: Sat, 29 May 2021 19:29:39 +0800 Subject: [PATCH 1/2] Translate tutorial/errors.po Completed and updated. --- tutorial/errors.po | 214 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 192 insertions(+), 22 deletions(-) diff --git a/tutorial/errors.po b/tutorial/errors.po index 4f09130213..eb9585961c 100644 --- a/tutorial/errors.po +++ b/tutorial/errors.po @@ -1,15 +1,16 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2018, Python Software Foundation +# Copyright (C) 2001-2021, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # jerrychen , 2016 +# Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.7\n" +"Project-Id-Version: Python 3.9\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-06-20 18:08+0800\n" -"PO-Revision-Date: 2018-05-23 16:18+0000\n" +"PO-Revision-Date: 2021-05-29 19:28+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -18,6 +19,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Poedit 2.4.3\n" #: ../../tutorial/errors.rst:5 msgid "Errors and Exceptions" @@ -29,16 +31,23 @@ msgid "" "tried out the examples you have probably seen some. There are (at least) " "two distinguishable kinds of errors: *syntax errors* and *exceptions*." msgstr "" +"到目前為止還沒有提到錯誤訊息,但如果你嘗試運行範例,你可能會發現一些錯誤訊" +"息。常見的(至少)兩種不同的錯誤類別為:\\ *語法錯誤 (syntax error)* 和\\ *例" +"外 (exception)*\\ 。" #: ../../tutorial/errors.rst:15 msgid "Syntax Errors" -msgstr "語法錯誤" +msgstr "語法錯誤 (Syntax Error)" #: ../../tutorial/errors.rst:17 msgid "" "Syntax errors, also known as parsing errors, are perhaps the most common " "kind of complaint you get while you are still learning Python::" msgstr "" +"句法錯誤又稱剖析錯誤 (parsing error),它或許是學習 Python 的過程最常聽見的抱" +"怨:\n" +"\n" +"::" #: ../../tutorial/errors.rst:26 msgid "" @@ -49,10 +58,15 @@ msgid "" "colon (``':'``) is missing before it. File name and line number are printed " "so you know where to look in case the input came from a script." msgstr "" +"剖析器 (parser) 會重複犯錯的那一行,並用一個小「箭頭」指向該行檢測到的第一個" +"錯誤點。錯誤是由箭頭\\ *之前*\\ 的符記 (token) 導致的(或至少是在這裡檢測到" +"的):此例中,錯誤是在 :func:`print` 函式中被檢測到,因為在它前面少了一個冒號" +"(\\ ``':'``)。檔案名稱和行號會被印出來,所以如果訊息是來自腳本時,就可以知" +"道去哪裡找問題。" #: ../../tutorial/errors.rst:37 msgid "Exceptions" -msgstr "例外" +msgstr "例外 (Exception)" #: ../../tutorial/errors.rst:39 msgid "" @@ -63,6 +77,11 @@ msgid "" "not handled by programs, however, and result in error messages as shown " "here::" msgstr "" +"即使一段陳述式或運算式使用了正確的語法,嘗試執行時仍可能導致錯誤。執行時檢測" +"到的錯誤稱為\\ *例外*\\ ,例外不一定都很嚴重:你很快就能學會在 Python 程式中" +"如何處理它們。大多數的例外不會被程式處理,但會顯示如下的錯誤訊息:\n" +"\n" +"::" #: ../../tutorial/errors.rst:58 msgid "" @@ -75,12 +94,18 @@ msgid "" "convention). Standard exception names are built-in identifiers (not reserved " "keywords)." msgstr "" +"錯誤訊息的最後一行指示發生了什麼事。例外有不同的類型,而類型名稱會作為訊息的" +"一部份被印出。範例中的例外類型為:\\ :exc:`ZeroDivisionError`\\ 、\\ :exc:" +"`NameError` 和 :exc:`TypeError`\\ 。作為例外類型被印出的字串,就是發生的內建" +"例外 (built-in exception) 的名稱。所有的內建例外都是如此運作,但對於使用者自" +"定的例外則不一定需要遵守(雖然這是一個有用的慣例)。標準例外名稱是內建的識別" +"符 (identifier),不是保留關鍵字 (reserved keyword)。" #: ../../tutorial/errors.rst:66 msgid "" "The rest of the line provides detail based on the type of exception and what " "caused it." -msgstr "" +msgstr "此行其餘部分,根據例外的類型及導致例外的原因,說明例外的細節。" #: ../../tutorial/errors.rst:69 msgid "" @@ -89,11 +114,14 @@ msgid "" "a stack traceback listing source lines; however, it will not display lines " "read from standard input." msgstr "" +"錯誤訊息的開頭,用堆疊回溯 (stack traceback) 的形式顯示發生例外的語境。一般來" +"說,它含有一個列出源程式碼行 (source line) 的堆疊回溯;但它不會顯示從標準輸入" +"中讀取的程式碼。" #: ../../tutorial/errors.rst:74 msgid "" ":ref:`bltin-exceptions` lists the built-in exceptions and their meanings." -msgstr "" +msgstr ":ref:`bltin-exceptions`\\ 章節列出內建的例外及它們的意義。" #: ../../tutorial/errors.rst:80 msgid "Handling Exceptions" @@ -108,22 +136,32 @@ msgid "" "generated interruption is signalled by raising the :exc:`KeyboardInterrupt` " "exception. ::" msgstr "" +"編寫程式處理選定的例外是可行的。以下範例會要求使用者輸入內容,直到有效的整數" +"被輸入為止,但它允許使用者中斷程式(使用 :kbd:`Control-C` 或作業系統支援的指" +"令);請注意,由使用者產生的程式中斷會引發 :exc:`KeyboardInterrupt` 例外信" +"號。\n" +"\n" +"::" #: ../../tutorial/errors.rst:96 msgid "The :keyword:`try` statement works as follows." -msgstr "" +msgstr ":keyword:`try` 陳述式運作方式如下。" #: ../../tutorial/errors.rst:98 msgid "" "First, the *try clause* (the statement(s) between the :keyword:`try` and :" "keyword:`except` keywords) is executed." msgstr "" +"首先,執行 *try 子句*\\ (\\ :keyword:`try` 和 :keyword:`except` 關鍵字之間的" +"陳述式)。" #: ../../tutorial/errors.rst:101 msgid "" "If no exception occurs, the *except clause* is skipped and execution of the :" "keyword:`try` statement is finished." msgstr "" +"如果沒有發生例外,則 *except 子句*\\ 會被跳過,\\ :keyword:`try` 陳述式執行完" +"畢。" #: ../../tutorial/errors.rst:104 msgid "" @@ -132,6 +170,9 @@ msgid "" "keyword:`except` keyword, the except clause is executed, and then execution " "continues after the :keyword:`try` statement." msgstr "" +"如果執行 try 子句時發生了例外,則該子句中剩下的部分會被跳過。如果例外的類型" +"與 :keyword:`except` 關鍵字後面的例外名稱相符,則 except 子句被執行,然後,繼" +"續執行 :keyword:`try` 陳述式之後的程式碼。" #: ../../tutorial/errors.rst:109 msgid "" @@ -140,6 +181,9 @@ msgid "" "handler is found, it is an *unhandled exception* and execution stops with a " "message as shown above." msgstr "" +"如果發生的例外未符合 except 子句中的例外名稱,則將其傳遞到外層的 :keyword:" +"`try` 陳述式;如果仍無法找到 handler(處置器),則它是一個\\ *未處理例外 " +"(unhandled exception)*\\ ,執行將停止,並顯示如上所示的訊息。" #: ../../tutorial/errors.rst:114 msgid "" @@ -149,6 +193,12 @@ msgid "" "not in other handlers of the same :keyword:`!try` statement. An except " "clause may name multiple exceptions as a parenthesized tuple, for example::" msgstr "" +":keyword:`try` 陳述式可以有不只一個 except 子句,為不同的例外指定 handler,而" +"最多只有一個 handler 會被執行。Handler 只處理對應的 try 子句中發生的例外,而" +"不會處理同一 :keyword:`!try` 陳述式裡其他 handler 內的例外。一個 except 子句" +"可以用一組括號內的 tuple 命名多個例外,例如:\n" +"\n" +"::" #: ../../tutorial/errors.rst:123 msgid "" @@ -157,12 +207,20 @@ msgid "" "an except clause listing a derived class is not compatible with a base " "class). For example, the following code will print B, C, D in that order::" msgstr "" +"一個在 :keyword:`except` 子句中的 class(類別)和一個例外是可相容的,只要它與" +"例外是同一個 class 或是為其 base class(基底類別);反之則無法成立——列出 " +"derived class (衍生類別)的 except 子句並不能與 base class 相容。例如,以下" +"程式碼會依序印出 B, C, D:\n" +"\n" +"::" #: ../../tutorial/errors.rst:147 msgid "" "Note that if the except clauses were reversed (with ``except B`` first), it " "would have printed B, B, B --- the first matching except clause is triggered." msgstr "" +"請注意,如果 except 子句的順序被反轉(把 ``except B`` 放到第一個),則會印出 " +"B,B,B ­­——第一個符合的 except 子句會被觸發。" #: ../../tutorial/errors.rst:150 msgid "" @@ -172,6 +230,11 @@ msgid "" "message and then re-raise the exception (allowing a caller to handle the " "exception as well)::" msgstr "" +"最後一個 except 子句可以省略例外名稱,以用作通配符 (wildcard)。但使用上要極其" +"小心,因為這種方式容易遮蔽真正的程式設計錯誤!它也可用於印出錯誤訊息,然後重" +"新引發 (re-raise) 例外(也容許一個呼叫程式 (caller) 處理例外):\n" +"\n" +"::" #: ../../tutorial/errors.rst:169 msgid "" @@ -180,6 +243,11 @@ msgid "" "for code that must be executed if the try clause does not raise an " "exception. For example::" msgstr "" +":keyword:`try` ... :keyword:`except` 陳述式有一個可選的 *else 子句*\\ ,使用" +"時,該子句必須放在所有 except 子句之後。如果一段程式碼必須被執行,但 try 子句" +"又沒有引發例外時,這個子句很有用。例如:\n" +"\n" +"::" #: ../../tutorial/errors.rst:183 msgid "" @@ -188,6 +256,9 @@ msgid "" "exception that wasn't raised by the code being protected by the :keyword:`!" "try` ... :keyword:`!except` statement." msgstr "" +"使用 :keyword:`!else` 子句比向 :keyword:`try` 子句添加額外的程式碼要好,因為" +"這可以避免意外地捕獲不是由 :keyword:`!try` ... :keyword:`!except` 陳述式保護" +"的程式碼所引發的例外。" #: ../../tutorial/errors.rst:188 msgid "" @@ -195,6 +266,8 @@ msgid "" "exception's *argument*. The presence and type of the argument depend on the " "exception type." msgstr "" +"當例外發生時,它可能有一個關聯值 (associated value),也就是例外的\\ *引數*" +"\\ 。此引數的存在與否及它的類型,是取決於例外的類型。" #: ../../tutorial/errors.rst:192 msgid "" @@ -205,12 +278,20 @@ msgid "" "reference ``.args``. One may also instantiate an exception first before " "raising it and add any attributes to it as desired. ::" msgstr "" +"``except`` 子句可以在例外名稱後面指定一個變數。這個變數被連結到一個例外實例 " +"(exception instance),其引數儲存在 ``instance.args`` 中。為了方便,例外實例會" +"定義 :meth:`__str__`\\ ,因此引數可以直接被印出而無須引用 ``.args``。你也可以" +"在引發例外前就先實例化 (instantiate) 一個例外,並隨心所欲地為它加入任何屬" +"性。\n" +"\n" +"::" #: ../../tutorial/errors.rst:216 msgid "" "If an exception has arguments, they are printed as the last part ('detail') " "of the message for unhandled exceptions." msgstr "" +"如果一個例外有引數,則它們會被印在未處理例外的訊息的最後一部分(「細節」)。" #: ../../tutorial/errors.rst:219 msgid "" @@ -218,16 +299,23 @@ msgid "" "the try clause, but also if they occur inside functions that are called " "(even indirectly) in the try clause. For example::" msgstr "" +"例外的 handler 不僅處理 try 子句內立即發生的例外,還處理 try 子句內(即使是間" +"接地)呼叫的函式內部發生的例外。例如:\n" +"\n" +"::" #: ../../tutorial/errors.rst:237 msgid "Raising Exceptions" -msgstr "" +msgstr "引發例外" #: ../../tutorial/errors.rst:239 msgid "" "The :keyword:`raise` statement allows the programmer to force a specified " "exception to occur. For example::" msgstr "" +":keyword:`raise` 陳述式可讓程式設計師強制引發指定的例外。例如:\n" +"\n" +"::" #: ../../tutorial/errors.rst:247 msgid "" @@ -237,6 +325,12 @@ msgid "" "will be implicitly instantiated by calling its constructor with no " "arguments::" msgstr "" +":keyword:`raise` 唯一的引數就是要引發的例外。該引數必須是一個例外實例或例外 " +"class(衍生自 :class:`Exception` 的 class)。如果一個例外 class 被傳遞,它會" +"不含引數地呼叫它的建構函式 (constructor) ,使它被隱含地實例化 (implicitly " +"instantiated):\n" +"\n" +"::" #: ../../tutorial/errors.rst:254 msgid "" @@ -244,34 +338,49 @@ msgid "" "handle it, a simpler form of the :keyword:`raise` statement allows you to re-" "raise the exception::" msgstr "" +"如果你只想判斷是否引發了例外,但並不打算處理它,則可以使用簡單的 :keyword:" +"`raise` 陳述式來重新引發該例外:\n" +"\n" +"::" #: ../../tutorial/errors.rst:273 -#, fuzzy msgid "Exception Chaining" -msgstr "例外" +msgstr "例外鍊接 (Exception Chaining)" #: ../../tutorial/errors.rst:275 msgid "" -"The :keyword:`raise` statement allows an optional :keyword:`from` which " -"enables chaining exceptions by setting the ``__cause__`` attribute of the " -"raised exception. For example::" +"The :keyword:`raise` statement allows an optional :keyword:`from` " +"which enables chaining exceptions. For example::" msgstr "" +":keyword:`raise` 陳述式容許一個可選的 :keyword:`from`\\ ,它透過被引發" +"例外中的 ``__cause__`` 屬性的設定,來啟用例外鍊接。例如:\n" +"\n" +"::" #: ../../tutorial/errors.rst:281 msgid "This can be useful when you are transforming exceptions. For example::" msgstr "" +"要變換例外時,這種方式很有用。例如:\n" +"\n" +"::" #: ../../tutorial/errors.rst:302 msgid "" -"The expression following the :keyword:`from` must be either an exception or " -"``None``. Exception chaining happens automatically when an exception is " -"raised inside an exception handler or :keyword:`finally` section. Exception " -"chaining can be disabled by using ``from None`` idiom:" +"Exception chaining happens automatically when an exception is raised inside " +"an :keyword:`except` or :keyword:`finally` section. Exception chaining can " +"be disabled by using ``from None`` idiom:" msgstr "" +"當例外是在一個 :keyword:`except` 或 :keyword:`finally` 段落的內部被引發時,例" +"外鍊接會自動發生。要禁止例外鍊接,可以使用慣用語 ``from None``:" + +#: ../../tutorial/errors.rst:315 +msgid "" +"For more information about chaining mechanics, see :ref:`bltin-exceptions`." +msgstr "更多關於鍊接技術的資訊,詳見\\ :ref:`bltin-exceptions`\\ 。" #: ../../tutorial/errors.rst:320 msgid "User-defined Exceptions" -msgstr "" +msgstr "使用者自定的例外 (User-defined Exceptions)" #: ../../tutorial/errors.rst:322 msgid "" @@ -280,6 +389,9 @@ msgid "" "typically be derived from the :exc:`Exception` class, either directly or " "indirectly." msgstr "" +"程式可以通過建立新的例外 class 來命名自己的例外(深入了解 Python class,詳見" +"\\ :ref:`tut-classes`\\ )。不論是直接還是間接地,例外通常應該從 :exc:" +"`Exception` class 衍生出來。" #: ../../tutorial/errors.rst:326 msgid "" @@ -291,12 +403,18 @@ msgid "" "module, and subclass that to create specific exception classes for different " "error conditions::" msgstr "" +"例外 class 可被定義來做任何其他 class 能夠做的事,但通常會讓它維持簡單,只提" +"供一些屬性,讓關於錯誤的資訊可被例外的 handler 抽取出來。在建立一個可能引發多" +"種不同錯誤的模組時,常見做法是為該模組定義的例外建立一個 base class,以及多" +"個 subclass,其能為不同錯誤情況建立特定的例外 class:\n" +"\n" +"::" #: ../../tutorial/errors.rst:364 msgid "" "Most exceptions are defined with names that end in \"Error\", similar to the " "naming of the standard exceptions." -msgstr "" +msgstr "大多數的例外定義,都會以「Error」作為名稱結尾,類似於標準例外的命名。" #: ../../tutorial/errors.rst:367 msgid "" @@ -304,10 +422,12 @@ msgid "" "occur in functions they define. More information on classes is presented in " "chapter :ref:`tut-classes`." msgstr "" +"許多標準模組會定義它們自己的例外,以報告在其定義的函式中發生的錯誤。更多有關 " +"class 的資訊,詳見\\ :ref:`tut-classes`\\ 章節。" #: ../../tutorial/errors.rst:375 msgid "Defining Clean-up Actions" -msgstr "" +msgstr "定義清理動作 (Clean-up Actions)" #: ../../tutorial/errors.rst:377 msgid "" @@ -315,6 +435,10 @@ msgid "" "to define clean-up actions that must be executed under all circumstances. " "For example::" msgstr "" +":keyword:`try` 陳述式有另一個可選子句,用於定義在所有情況下都必須被執行的清理" +"動作。例如:\n" +"\n" +"::" #: ../../tutorial/errors.rst:391 msgid "" @@ -324,6 +448,10 @@ msgid "" "statement produces an exception. The following points discuss more complex " "cases when an exception occurs:" msgstr "" +"如果 :keyword:`finally` 子句存在,則 :keyword:`!finally` 子句會是 :keyword:" +"`try` 陳述式結束前執行的最後一項任務。不論 :keyword:`!try` 陳述式是否產生例" +"外,都會執行 :keyword:`!finally` 子句。以下幾點將探討例外發生時,比較複雜的情" +"況:" #: ../../tutorial/errors.rst:397 msgid "" @@ -332,6 +460,9 @@ msgid "" "not handled by an :keyword:`!except` clause, the exception is re-raised " "after the :keyword:`!finally` clause has been executed." msgstr "" +"若一個例外發生於 :keyword:`!try` 子句的執行過程,則該例外會被某個 :keyword:" +"`except` 子句處理。如果該例外沒有被 :keyword:`!except` 子句處理,它會在 :" +"keyword:`!finally` 子句執行後被重新引發。" #: ../../tutorial/errors.rst:403 msgid "" @@ -339,14 +470,27 @@ msgid "" "keyword:`!else` clause. Again, the exception is re-raised after the :keyword:" "`!finally` clause has been executed." msgstr "" +"一個例外可能發生於 :keyword:`!except` 或 :keyword:`!else` 子句的執行過程。同" +"樣地,該例外會在 :keyword:`!finally` 子句執行後被重新引發。" #: ../../tutorial/errors.rst:407 msgid "" +"If the :keyword:`!finally` clause executes a :keyword:`break`, :keyword:" +"`continue` or :keyword:`return` statement, exceptions are not re-raised." +msgstr "" +"如果 :keyword:`!finally` 子句執行 :keyword:`break`\\ 、\\ :keyword:" +"`continue` 或 :keyword:`return` 陳述式,則例外不會被重新引發。" + +#: ../../tutorial/errors.rst:411 +msgid "" "If the :keyword:`!try` statement reaches a :keyword:`break`, :keyword:" "`continue` or :keyword:`return` statement, the :keyword:`!finally` clause " "will execute just prior to the :keyword:`!break`, :keyword:`!continue` or :" "keyword:`!return` statement's execution." msgstr "" +"如果 :keyword:`!try` 陳述式遇到 :keyword:`break`\\ 、\\ :keyword:`continue` " +"或 :keyword:`return` 陳述式,則 :keyword:`!finally` 子句會在執行 :keyword:`!" +"break`\\ 、\\ :keyword:`!continue` 或 :keyword:`!return` 陳述式之前先執行。" #: ../../tutorial/errors.rst:413 msgid "" @@ -355,14 +499,23 @@ msgid "" "keyword:`!return` statement, not the value from the :keyword:`!try` " "clause's :keyword:`!return` statement." msgstr "" +"如果 :keyword:`!finally` 子句中包含 :keyword:`!return` 陳述式,則回傳值會是來" +"自 :keyword:`!finally` 子句的 :keyword:`!return` 陳述式的回傳值,而不是來自 :" +"keyword:`!try` 子句的 :keyword:`!return` 陳述式的回傳值。" #: ../../tutorial/errors.rst:419 msgid "For example::" msgstr "" +"例如:\n" +"\n" +"::" #: ../../tutorial/errors.rst:430 msgid "A more complicated example::" msgstr "" +"另一個比較複雜的範例:\n" +"\n" +"::" #: ../../tutorial/errors.rst:455 msgid "" @@ -371,6 +524,9 @@ msgid "" "keyword:`except` clause and therefore re-raised after the :keyword:`!" "finally` clause has been executed." msgstr "" +"如你所見,\\ :keyword:`finally` 子句在任何情況下都會被執行。兩個字串相除所引" +"發的 :exc:`TypeError` 沒有被 :keyword:`except` 子句處理,因此會在 :keyword:`!" +"finally` 子句執行後被重新引發。" #: ../../tutorial/errors.rst:460 msgid "" @@ -378,10 +534,12 @@ msgid "" "releasing external resources (such as files or network connections), " "regardless of whether the use of the resource was successful." msgstr "" +"在真實應用程式中,\\ :keyword:`finally` 子句對於釋放外部資源(例如檔案或網路" +"連接)很有用,無論該資源的使用是否成功。" #: ../../tutorial/errors.rst:468 msgid "Predefined Clean-up Actions" -msgstr "" +msgstr "預定義 (Predefined) 的清理動作" #: ../../tutorial/errors.rst:470 msgid "" @@ -390,6 +548,10 @@ msgid "" "the object succeeded or failed. Look at the following example, which tries " "to open a file and print its contents to the screen. ::" msgstr "" +"某些物件定義了在物件不再被需要時的標準清理動作,無論使用該物件的作業是成功或" +"失敗。請看以下範例,它嘗試開啟一個檔案,並印出檔案內容至螢幕。\n" +"\n" +"::" #: ../../tutorial/errors.rst:478 msgid "" @@ -400,6 +562,12 @@ msgid "" "to be used in a way that ensures they are always cleaned up promptly and " "correctly. ::" msgstr "" +"這段程式碼的問題在於,執行完該程式碼後,它讓檔案在一段不確定的時間內處於開啟" +"狀態。在簡單腳本中這不是問題,但對於較大的應用程式來說可能會是個問題。\\ :" +"keyword:`with` 陳述式讓物件(例如檔案)在被使用時,能保證它們總是及時、正確地" +"被清理。\n" +"\n" +"::" #: ../../tutorial/errors.rst:488 msgid "" @@ -408,3 +576,5 @@ msgid "" "files, provide predefined clean-up actions will indicate this in their " "documentation." msgstr "" +"陳述式執行完畢後,就算是在處理行 (line) 時遇到問題,檔案 *f* 總是會被關閉。和" +"檔案一樣,提供預定義清理動作的物件會在說明文件中表明這一點。" From a8e87bc53cc9c932d76cd9fac627dd1f191b4794 Mon Sep 17 00:00:00 2001 From: Steven Hsu <81967953+StevenHsuYL@users.noreply.github.com> Date: Tue, 29 Jun 2021 22:20:03 +0800 Subject: [PATCH 2/2] Update errors.po All suggestions were applied. --- tutorial/errors.po | 87 +++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/tutorial/errors.po b/tutorial/errors.po index eb9585961c..687c0fbe46 100644 --- a/tutorial/errors.po +++ b/tutorial/errors.po @@ -10,7 +10,7 @@ msgstr "" "Project-Id-Version: Python 3.9\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-06-20 18:08+0800\n" -"PO-Revision-Date: 2021-05-29 19:28+0800\n" +"PO-Revision-Date: 2021-06-29 22:16+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -44,7 +44,7 @@ msgid "" "Syntax errors, also known as parsing errors, are perhaps the most common " "kind of complaint you get while you are still learning Python::" msgstr "" -"句法錯誤又稱剖析錯誤 (parsing error),它或許是學習 Python 的過程最常聽見的抱" +"語法錯誤又稱剖析錯誤 (parsing error),它或許是學習 Python 的過程最常聽見的抱" "怨:\n" "\n" "::" @@ -59,7 +59,7 @@ msgid "" "so you know where to look in case the input came from a script." msgstr "" "剖析器 (parser) 會重複犯錯的那一行,並用一個小「箭頭」指向該行檢測到的第一個" -"錯誤點。錯誤是由箭頭\\ *之前*\\ 的符記 (token) 導致的(或至少是在這裡檢測到" +"錯誤點。錯誤是由箭頭\\ *之前*\\ 的標記 (token) 導致的(或至少是在這裡檢測到" "的):此例中,錯誤是在 :func:`print` 函式中被檢測到,因為在它前面少了一個冒號" "(\\ ``':'``)。檔案名稱和行號會被印出來,所以如果訊息是來自腳本時,就可以知" "道去哪裡找問題。" @@ -79,7 +79,7 @@ msgid "" msgstr "" "即使一段陳述式或運算式使用了正確的語法,嘗試執行時仍可能導致錯誤。執行時檢測" "到的錯誤稱為\\ *例外*\\ ,例外不一定都很嚴重:你很快就能學會在 Python 程式中" -"如何處理它們。大多數的例外不會被程式處理,但會顯示如下的錯誤訊息:\n" +"如何處理它們。不過大多數的例外不會被程式處理,並且會顯示如下的錯誤訊息:\n" "\n" "::" @@ -99,7 +99,7 @@ msgstr "" "`NameError` 和 :exc:`TypeError`\\ 。作為例外類型被印出的字串,就是發生的內建" "例外 (built-in exception) 的名稱。所有的內建例外都是如此運作,但對於使用者自" "定的例外則不一定需要遵守(雖然這是一個有用的慣例)。標準例外名稱是內建的識別" -"符 (identifier),不是保留關鍵字 (reserved keyword)。" +"字 (identifier),不是保留關鍵字 (reserved keyword)。" #: ../../tutorial/errors.rst:66 msgid "" @@ -182,8 +182,8 @@ msgid "" "message as shown above." msgstr "" "如果發生的例外未符合 except 子句中的例外名稱,則將其傳遞到外層的 :keyword:" -"`try` 陳述式;如果仍無法找到 handler(處置器),則它是一個\\ *未處理例外 " -"(unhandled exception)*\\ ,執行將停止,並顯示如上所示的訊息。" +"`try` 陳述式;如果仍無法找到處理者,則它是一個\\ *未處理例外 (unhandled " +"exception)*\\ ,執行將停止,並顯示如上所示的訊息。" #: ../../tutorial/errors.rst:114 msgid "" @@ -193,10 +193,10 @@ msgid "" "not in other handlers of the same :keyword:`!try` statement. An except " "clause may name multiple exceptions as a parenthesized tuple, for example::" msgstr "" -":keyword:`try` 陳述式可以有不只一個 except 子句,為不同的例外指定 handler,而" -"最多只有一個 handler 會被執行。Handler 只處理對應的 try 子句中發生的例外,而" -"不會處理同一 :keyword:`!try` 陳述式裡其他 handler 內的例外。一個 except 子句" -"可以用一組括號內的 tuple 命名多個例外,例如:\n" +":keyword:`try` 陳述式可以有不只一個 except 子句,為不同的例外指定處理者,而最" +"多只有一個處理者會被執行。處理者只處理對應的 try 子句中發生的例外,而不會處理" +"同一 :keyword:`!try` 陳述式裡其他處理者內的例外。一個 except 子句可以用一組括" +"號內的 tuple 列舉多個例外,例如:\n" "\n" "::" @@ -210,7 +210,7 @@ msgstr "" "一個在 :keyword:`except` 子句中的 class(類別)和一個例外是可相容的,只要它與" "例外是同一個 class 或是為其 base class(基底類別);反之則無法成立——列出 " "derived class (衍生類別)的 except 子句並不能與 base class 相容。例如,以下" -"程式碼會依序印出 B, C, D:\n" +"程式碼會依序印出 B、C、D:\n" "\n" "::" @@ -220,7 +220,7 @@ msgid "" "would have printed B, B, B --- the first matching except clause is triggered." msgstr "" "請注意,如果 except 子句的順序被反轉(把 ``except B`` 放到第一個),則會印出 " -"B,B,B ­­——第一個符合的 except 子句會被觸發。" +"B、B、B ­­——第一個符合的 except 子句會被觸發。" #: ../../tutorial/errors.rst:150 msgid "" @@ -230,9 +230,9 @@ msgid "" "message and then re-raise the exception (allowing a caller to handle the " "exception as well)::" msgstr "" -"最後一個 except 子句可以省略例外名稱,以用作通配符 (wildcard)。但使用上要極其" +"最後一個 except 子句可以省略例外名稱,以統一處理所有其他例外。但使用上要極其" "小心,因為這種方式容易遮蔽真正的程式設計錯誤!它也可用於印出錯誤訊息,然後重" -"新引發 (re-raise) 例外(也容許一個呼叫程式 (caller) 處理例外):\n" +"新引發例外(也讓呼叫者可以處理該例外):\n" "\n" "::" @@ -243,9 +243,9 @@ msgid "" "for code that must be executed if the try clause does not raise an " "exception. For example::" msgstr "" -":keyword:`try` ... :keyword:`except` 陳述式有一個可選的 *else 子句*\\ ,使用" -"時,該子句必須放在所有 except 子句之後。如果一段程式碼必須被執行,但 try 子句" -"又沒有引發例外時,這個子句很有用。例如:\n" +":keyword:`try` ... :keyword:`except` 陳述式有一個選擇性的 *else 子句*\\ ,使" +"用時,該子句必須放在所有 except 子句之後。如果一段程式碼必須被執行,但 try 子" +"句又沒有引發例外時,這個子句很有用。例如:\n" "\n" "::" @@ -266,8 +266,8 @@ msgid "" "exception's *argument*. The presence and type of the argument depend on the " "exception type." msgstr "" -"當例外發生時,它可能有一個關聯值 (associated value),也就是例外的\\ *引數*" -"\\ 。此引數的存在與否及它的類型,是取決於例外的類型。" +"當例外發生時,它可能有一個相關的值,也就是例外的\\ *引數*\\ 。此引數的存在與" +"否及它的類型,是取決於例外的類型。" #: ../../tutorial/errors.rst:192 msgid "" @@ -278,11 +278,10 @@ msgid "" "reference ``.args``. One may also instantiate an exception first before " "raising it and add any attributes to it as desired. ::" msgstr "" -"``except`` 子句可以在例外名稱後面指定一個變數。這個變數被連結到一個例外實例 " -"(exception instance),其引數儲存在 ``instance.args`` 中。為了方便,例外實例會" -"定義 :meth:`__str__`\\ ,因此引數可以直接被印出而無須引用 ``.args``。你也可以" -"在引發例外前就先實例化 (instantiate) 一個例外,並隨心所欲地為它加入任何屬" -"性。\n" +"``except`` 子句可以在例外名稱後面指定一個變數。這個變數被綁定到一個例外實例 " +"(instance),其引數儲存在 ``instance.args`` 中。為了方便,例外實例會定義 :" +"meth:`__str__`\\ ,因此引數可以直接被印出而無須引用 ``.args``。你也可以在引發" +"例外前就先建立一個例外實例,並隨心所欲地為它加入任何屬性。\n" "\n" "::" @@ -299,8 +298,8 @@ msgid "" "the try clause, but also if they occur inside functions that are called " "(even indirectly) in the try clause. For example::" msgstr "" -"例外的 handler 不僅處理 try 子句內立即發生的例外,還處理 try 子句內(即使是間" -"接地)呼叫的函式內部發生的例外。例如:\n" +"例外的處理者不僅處理 try 子句內立即發生的例外,還處理 try 子句內(即使是間接" +"地)呼叫的函式內部發生的例外。例如:\n" "\n" "::" @@ -327,7 +326,7 @@ msgid "" msgstr "" ":keyword:`raise` 唯一的引數就是要引發的例外。該引數必須是一個例外實例或例外 " "class(衍生自 :class:`Exception` 的 class)。如果一個例外 class 被傳遞,它會" -"不含引數地呼叫它的建構函式 (constructor) ,使它被隱含地實例化 (implicitly " +"不含引數地呼叫它的建構函式 (constructor) ,使它被自動建立實例 (implicitly " "instantiated):\n" "\n" "::" @@ -345,15 +344,15 @@ msgstr "" #: ../../tutorial/errors.rst:273 msgid "Exception Chaining" -msgstr "例外鍊接 (Exception Chaining)" +msgstr "例外鏈接 (Exception Chaining)" #: ../../tutorial/errors.rst:275 msgid "" "The :keyword:`raise` statement allows an optional :keyword:`from` " "which enables chaining exceptions. For example::" msgstr "" -":keyword:`raise` 陳述式容許一個可選的 :keyword:`from`\\ ,它透過被引發" -"例外中的 ``__cause__`` 屬性的設定,來啟用例外鍊接。例如:\n" +":keyword:`raise` 陳述式容許一個選擇性的 :keyword:`from`\\ ,它透過被引" +"發例外中的 ``__cause__`` 屬性的設定,來啟用例外鏈接。例如:\n" "\n" "::" @@ -371,16 +370,16 @@ msgid "" "be disabled by using ``from None`` idiom:" msgstr "" "當例外是在一個 :keyword:`except` 或 :keyword:`finally` 段落的內部被引發時,例" -"外鍊接會自動發生。要禁止例外鍊接,可以使用慣用語 ``from None``:" +"外鏈接會自動發生。要禁止例外鏈接,可以使用慣用語 ``from None``:" #: ../../tutorial/errors.rst:315 msgid "" "For more information about chaining mechanics, see :ref:`bltin-exceptions`." -msgstr "更多關於鍊接技術的資訊,詳見\\ :ref:`bltin-exceptions`\\ 。" +msgstr "更多關於鏈接機制的資訊,詳見\\ :ref:`bltin-exceptions`\\ 。" #: ../../tutorial/errors.rst:320 msgid "User-defined Exceptions" -msgstr "使用者自定的例外 (User-defined Exceptions)" +msgstr "使用者自定的例外" #: ../../tutorial/errors.rst:322 msgid "" @@ -404,9 +403,9 @@ msgid "" "error conditions::" msgstr "" "例外 class 可被定義來做任何其他 class 能夠做的事,但通常會讓它維持簡單,只提" -"供一些屬性,讓關於錯誤的資訊可被例外的 handler 抽取出來。在建立一個可能引發多" -"種不同錯誤的模組時,常見做法是為該模組定義的例外建立一個 base class,以及多" -"個 subclass,其能為不同錯誤情況建立特定的例外 class:\n" +"供一些屬性,讓關於錯誤的資訊可被例外的處理者抽取出來。在建立一個可能引發多種" +"不同錯誤的模組時,常見做法是為該模組定義的例外建立一個 base class,以及多個 " +"subclass,其能為不同錯誤情況建立特定的例外 class:\n" "\n" "::" @@ -427,7 +426,7 @@ msgstr "" #: ../../tutorial/errors.rst:375 msgid "Defining Clean-up Actions" -msgstr "定義清理動作 (Clean-up Actions)" +msgstr "定義清理動作" #: ../../tutorial/errors.rst:377 msgid "" @@ -435,8 +434,8 @@ msgid "" "to define clean-up actions that must be executed under all circumstances. " "For example::" msgstr "" -":keyword:`try` 陳述式有另一個可選子句,用於定義在所有情況下都必須被執行的清理" -"動作。例如:\n" +":keyword:`try` 陳述式有另一個選擇性子句,用於定義在所有情況下都必須被執行的清" +"理動作。例如:\n" "\n" "::" @@ -535,11 +534,11 @@ msgid "" "regardless of whether the use of the resource was successful." msgstr "" "在真實應用程式中,\\ :keyword:`finally` 子句對於釋放外部資源(例如檔案或網路" -"連接)很有用,無論該資源的使用是否成功。" +"連線)很有用,無論該資源的使用是否成功。" #: ../../tutorial/errors.rst:468 msgid "Predefined Clean-up Actions" -msgstr "預定義 (Predefined) 的清理動作" +msgstr "預定義的清理動作" #: ../../tutorial/errors.rst:470 msgid "" @@ -576,5 +575,5 @@ msgid "" "files, provide predefined clean-up actions will indicate this in their " "documentation." msgstr "" -"陳述式執行完畢後,就算是在處理行 (line) 時遇到問題,檔案 *f* 總是會被關閉。和" -"檔案一樣,提供預定義清理動作的物件會在說明文件中表明這一點。" +"陳述式執行完畢後,就算是在處理內容時遇到問題,檔案 *f* 總是會被關閉。和檔案一" +"樣,提供預定義清理動作的物件會在說明文件中表明這一點。"