Skip to content

Sync with CPython 3.11 #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
442 changes: 231 additions & 211 deletions c-api/arg.po

Large diffs are not rendered by default.

76 changes: 42 additions & 34 deletions howto/annotations.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Python 3.11\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-03 00:13+0000\n"
"POT-Creation-Date: 2022-12-25 00:16+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
Expand Down Expand Up @@ -91,18 +91,26 @@ msgid ""
"three arguments, for example ``getattr(o, '__annotations__', None)``."
msgstr ""

#: ../../howto/annotations.rst:62
#: ../../howto/annotations.rst:60
msgid ""
"Before Python 3.10, accessing ``__annotations__`` on a class that defines no "
"annotations but that has a parent class with annotations would return the "
"parent's ``__annotations__``. In Python 3.10 and newer, the child class's "
"annotations will be an empty dict instead."
msgstr ""

#: ../../howto/annotations.rst:68
msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older"
msgstr ""

#: ../../howto/annotations.rst:64
#: ../../howto/annotations.rst:70
msgid ""
"In Python 3.9 and older, accessing the annotations dict of an object is much "
"more complicated than in newer versions. The problem is a design flaw in "
"these older versions of Python, specifically to do with class annotations."
msgstr ""

#: ../../howto/annotations.rst:69
#: ../../howto/annotations.rst:75
msgid ""
"Best practice for accessing the annotations dict of other objects--"
"functions, other callables, and modules--is the same as best practice for "
Expand All @@ -111,7 +119,7 @@ msgid ""
"``__annotations__`` attribute."
msgstr ""

#: ../../howto/annotations.rst:76
#: ../../howto/annotations.rst:82
msgid ""
"Unfortunately, this isn't best practice for classes. The problem is that, "
"since ``__annotations__`` is optional on classes, and because classes can "
Expand All @@ -120,11 +128,11 @@ msgid ""
"annotations dict of a *base class.* As an example::"
msgstr ""

#: ../../howto/annotations.rst:92
#: ../../howto/annotations.rst:98
msgid "This will print the annotations dict from ``Base``, not ``Derived``."
msgstr ""

#: ../../howto/annotations.rst:95
#: ../../howto/annotations.rst:101
msgid ""
"Your code will have to have a separate code path if the object you're "
"examining is a class (``isinstance(o, type)``). In that case, best practice "
Expand All @@ -134,81 +142,81 @@ msgid ""
"practice is to call the ``get`` method on the class dict."
msgstr ""

#: ../../howto/annotations.rst:103
#: ../../howto/annotations.rst:109
msgid ""
"To put it all together, here is some sample code that safely accesses the "
"``__annotations__`` attribute on an arbitrary object in Python 3.9 and "
"before::"
msgstr ""

#: ../../howto/annotations.rst:112
#: ../../howto/annotations.rst:118
msgid ""
"After running this code, ``ann`` should be either a dictionary or ``None``. "
"You're encouraged to double-check the type of ``ann`` using :func:"
"`isinstance` before further examination."
msgstr ""

#: ../../howto/annotations.rst:117
#: ../../howto/annotations.rst:123
msgid ""
"Note that some exotic or malformed type objects may not have a ``__dict__`` "
"attribute, so for extra safety you may also wish to use :func:`getattr` to "
"access ``__dict__``."
msgstr ""

#: ../../howto/annotations.rst:123
#: ../../howto/annotations.rst:129
msgid "Manually Un-Stringizing Stringized Annotations"
msgstr ""

#: ../../howto/annotations.rst:125
#: ../../howto/annotations.rst:131
msgid ""
"In situations where some annotations may be \"stringized\", and you wish to "
"evaluate those strings to produce the Python values they represent, it "
"really is best to call :func:`inspect.get_annotations` to do this work for "
"you."
msgstr ""

#: ../../howto/annotations.rst:131
#: ../../howto/annotations.rst:137
msgid ""
"If you're using Python 3.9 or older, or if for some reason you can't use :"
"func:`inspect.get_annotations`, you'll need to duplicate its logic. You're "
"encouraged to examine the implementation of :func:`inspect.get_annotations` "
"in the current Python version and follow a similar approach."
msgstr ""

#: ../../howto/annotations.rst:137
#: ../../howto/annotations.rst:143
msgid ""
"In a nutshell, if you wish to evaluate a stringized annotation on an "
"arbitrary object ``o``:"
msgstr ""

#: ../../howto/annotations.rst:140
#: ../../howto/annotations.rst:146
msgid ""
"If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when calling :"
"func:`eval`."
msgstr ""

#: ../../howto/annotations.rst:142
#: ../../howto/annotations.rst:148
msgid ""
"If ``o`` is a class, use ``sys.modules[o.__module__].__dict__`` as the "
"``globals``, and ``dict(vars(o))`` as the ``locals``, when calling :func:"
"`eval`."
msgstr ""

#: ../../howto/annotations.rst:145
#: ../../howto/annotations.rst:151
msgid ""
"If ``o`` is a wrapped callable using :func:`functools.update_wrapper`, :func:"
"`functools.wraps`, or :func:`functools.partial`, iteratively unwrap it by "
"accessing either ``o.__wrapped__`` or ``o.func`` as appropriate, until you "
"have found the root unwrapped function."
msgstr ""

#: ../../howto/annotations.rst:149
#: ../../howto/annotations.rst:155
msgid ""
"If ``o`` is a callable (but not a class), use ``o.__globals__`` as the "
"globals when calling :func:`eval`."
msgstr ""

#: ../../howto/annotations.rst:152
#: ../../howto/annotations.rst:158
msgid ""
"However, not all string values used as annotations can be successfully "
"turned into Python values by :func:`eval`. String values could theoretically "
Expand All @@ -217,63 +225,63 @@ msgid ""
"be evaluated. For example:"
msgstr ""

#: ../../howto/annotations.rst:159
#: ../../howto/annotations.rst:165
msgid ""
":pep:`604` union types using ``|``, before support for this was added to "
"Python 3.10."
msgstr ""

#: ../../howto/annotations.rst:161
#: ../../howto/annotations.rst:167
msgid ""
"Definitions that aren't needed at runtime, only imported when :const:`typing."
"TYPE_CHECKING` is true."
msgstr ""

#: ../../howto/annotations.rst:164
#: ../../howto/annotations.rst:170
msgid ""
"If :func:`eval` attempts to evaluate such values, it will fail and raise an "
"exception. So, when designing a library API that works with annotations, "
"it's recommended to only attempt to evaluate string values when explicitly "
"requested to by the caller."
msgstr ""

#: ../../howto/annotations.rst:172
#: ../../howto/annotations.rst:178
msgid "Best Practices For ``__annotations__`` In Any Python Version"
msgstr ""

#: ../../howto/annotations.rst:174
#: ../../howto/annotations.rst:180
msgid ""
"You should avoid assigning to the ``__annotations__`` member of objects "
"directly. Let Python manage setting ``__annotations__``."
msgstr ""

#: ../../howto/annotations.rst:177
#: ../../howto/annotations.rst:183
msgid ""
"If you do assign directly to the ``__annotations__`` member of an object, "
"you should always set it to a ``dict`` object."
msgstr ""

#: ../../howto/annotations.rst:180
#: ../../howto/annotations.rst:186
msgid ""
"If you directly access the ``__annotations__`` member of an object, you "
"should ensure that it's a dictionary before attempting to examine its "
"contents."
msgstr ""

#: ../../howto/annotations.rst:184
#: ../../howto/annotations.rst:190
msgid "You should avoid modifying ``__annotations__`` dicts."
msgstr ""

#: ../../howto/annotations.rst:186
#: ../../howto/annotations.rst:192
msgid ""
"You should avoid deleting the ``__annotations__`` attribute of an object."
msgstr ""

#: ../../howto/annotations.rst:191
#: ../../howto/annotations.rst:197
msgid "``__annotations__`` Quirks"
msgstr ""

#: ../../howto/annotations.rst:193
#: ../../howto/annotations.rst:199
msgid ""
"In all versions of Python 3, function objects lazy-create an annotations "
"dict if no annotations are defined on that object. You can delete the "
Expand All @@ -285,13 +293,13 @@ msgid ""
"guaranteed to always throw an ``AttributeError``."
msgstr ""

#: ../../howto/annotations.rst:203
#: ../../howto/annotations.rst:209
msgid ""
"Everything in the above paragraph also applies to class and module objects "
"in Python 3.10 and newer."
msgstr ""

#: ../../howto/annotations.rst:206
#: ../../howto/annotations.rst:212
msgid ""
"In all versions of Python 3, you can set ``__annotations__`` on a function "
"object to ``None``. However, subsequently accessing the annotations on that "
Expand All @@ -302,15 +310,15 @@ msgid ""
"set."
msgstr ""

#: ../../howto/annotations.rst:214
#: ../../howto/annotations.rst:220
msgid ""
"If Python stringizes your annotations for you (using ``from __future__ "
"import annotations``), and you specify a string as an annotation, the string "
"will itself be quoted. In effect the annotation is quoted *twice.* For "
"example::"
msgstr ""

#: ../../howto/annotations.rst:225
#: ../../howto/annotations.rst:231
msgid ""
"This prints ``{'a': \"'str'\"}``. This shouldn't really be considered a "
"\"quirk\"; it's mentioned here simply because it might be surprising."
Expand Down
18 changes: 9 additions & 9 deletions library/argparse.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Python 3.11\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-23 00:17+0000\n"
"POT-Creation-Date: 2022-12-26 13:06+0000\n"
"PO-Revision-Date: 2018-05-23 14:38+0000\n"
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
Expand Down Expand Up @@ -756,7 +756,7 @@ msgid ""
msgstr ""

#: ../../library/argparse.rst:758
msgid "choices_ - A container of the allowable values for the argument."
msgid "choices_ - A sequence of the allowable values for the argument."
msgstr ""

#: ../../library/argparse.rst:760
Expand Down Expand Up @@ -1136,23 +1136,23 @@ msgstr ""
#: ../../library/argparse.rst:1201
msgid ""
"Some command-line arguments should be selected from a restricted set of "
"values. These can be handled by passing a container object as the *choices* "
"values. These can be handled by passing a sequence object as the *choices* "
"keyword argument to :meth:`~ArgumentParser.add_argument`. When the command "
"line is parsed, argument values will be checked, and an error message will "
"be displayed if the argument was not one of the acceptable values::"
msgstr ""

#: ../../library/argparse.rst:1216
msgid ""
"Note that inclusion in the *choices* container is checked after any type_ "
"Note that inclusion in the *choices* sequence is checked after any type_ "
"conversions have been performed, so the type of the objects in the *choices* "
"container should match the type_ specified::"
"sequence should match the type_ specified::"
msgstr ""

#: ../../library/argparse.rst:1228
msgid ""
"Any container can be passed as the *choices* value, so :class:`list` "
"objects, :class:`set` objects, and custom containers are all supported."
"Any sequence can be passed as the *choices* value, so :class:`list` "
"objects, :class:`tuple` objects, and custom sequences are all supported."
msgstr ""

#: ../../library/argparse.rst:1231
Expand Down Expand Up @@ -1211,8 +1211,8 @@ msgid ""
"The ``help`` strings can include various format specifiers to avoid "
"repetition of things like the program name or the argument default_. The "
"available specifiers include the program name, ``%(prog)s`` and most keyword "
"arguments to :meth:`~ArgumentParser.add_argument`, e.g. ``%(default)s``, ``"
"%(type)s``, etc.::"
"arguments to :meth:`~ArgumentParser.add_argument`, e.g. ``%(default)s``, "
"``%(type)s``, etc.::"
msgstr ""

#: ../../library/argparse.rst:1310
Expand Down
4 changes: 2 additions & 2 deletions library/array.po
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ msgid ""
"``Py_UNICODE``. This change doesn't affect its behavior because "
"``Py_UNICODE`` is alias of ``wchar_t`` since Python 3.3."
msgstr ""
"目前 ``array(‘u’)`` 使用 ``wchar_t`` 取代已棄用的 ``Py_UNICODE`` 作為 C "
"目前 ``array('u')`` 使用 ``wchar_t`` 取代已棄用的 ``Py_UNICODE`` 作為 C "
"type。這個異動並沒有影響到它的作用,因爲自從 Python 3.3 開始 ``Py_UNICODE`` "
"即為 ``wchar_t`` 的別名。"

Expand Down Expand Up @@ -476,7 +476,7 @@ msgid ""
msgstr ""
"當一個陣列物件被列印或轉換成字串時,它會被表示為 ``array(typecode, "
"initializer)``\\ 。若為空陣列則參數 *initializer* 被省略,若 *typecode* 是 "
"``’u’`` 將被表示為字串,其他情況則被表示為由數字組成的 list。只要 :class:"
"``'u'`` 將被表示為字串,其他情況則被表示為由數字組成的 list。只要 :class:"
"`~array.array` class(類別)透過 ``from array import array`` 的方式引入,便能"
"確保該字串能透過 :func:`eval` 轉換回一個擁有相同型別及數值的陣列。範例:\n"
"\n"
Expand Down
4 changes: 2 additions & 2 deletions library/compileall.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Python 3.11\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-10-15 20:43+0000\n"
"POT-Creation-Date: 2022-12-25 00:16+0000\n"
"PO-Revision-Date: 2018-05-23 14:41+0000\n"
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
Expand Down Expand Up @@ -281,7 +281,7 @@ msgstr ""
msgid ""
"The *stripdir*, *prependdir* and *limit_sl_dest* arguments correspond to the "
"``-s``, ``-p`` and ``-e`` options described above. They may be specified as "
"``str``, ``bytes`` or :py:class:`os.PathLike`."
"``str`` or :py:class:`os.PathLike`."
msgstr ""

#: ../../library/compileall.rst:204 ../../library/compileall.rst:274
Expand Down
Loading