Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb47edf3

Browse files
sync with cpython 75b75dfd
1 parent4a0f727 commitb47edf3

File tree

9 files changed

+472
-456
lines changed

9 files changed

+472
-456
lines changed

‎howto/annotations.po

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version:Python 3.11\n"
99
"Report-Msgid-Bugs-To:\n"
10-
"POT-Creation-Date:2022-06-03 00:13+0000\n"
10+
"POT-Creation-Date:2022-12-25 00:16+0000\n"
1111
"PO-Revision-Date:YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator:FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language-Team:Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -91,18 +91,26 @@ msgid ""
9191
"three arguments, for example ``getattr(o, '__annotations__', None)``."
9292
msgstr""
9393

94-
#:../../howto/annotations.rst:62
94+
#:../../howto/annotations.rst:60
95+
msgid""
96+
"Before Python 3.10, accessing ``__annotations__`` on a class that defines no "
97+
"annotations but that has a parent class with annotations would return the "
98+
"parent's ``__annotations__``. In Python 3.10 and newer, the child class's "
99+
"annotations will be an empty dict instead."
100+
msgstr""
101+
102+
#:../../howto/annotations.rst:68
95103
msgid"Accessing The Annotations Dict Of An Object In Python 3.9 And Older"
96104
msgstr""
97105

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

105-
#:../../howto/annotations.rst:69
113+
#:../../howto/annotations.rst:75
106114
msgid""
107115
"Best practice for accessing the annotations dict of other objects--"
108116
"functions, other callables, and modules--is the same as best practice for "
@@ -111,7 +119,7 @@ msgid ""
111119
"``__annotations__`` attribute."
112120
msgstr""
113121

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

123-
#:../../howto/annotations.rst:92
131+
#:../../howto/annotations.rst:98
124132
msgid"This will print the annotations dict from ``Base``, not ``Derived``."
125133
msgstr""
126134

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

137-
#:../../howto/annotations.rst:103
145+
#:../../howto/annotations.rst:109
138146
msgid""
139147
"To put it all together, here is some sample code that safely accesses the "
140148
"``__annotations__`` attribute on an arbitrary object in Python 3.9 and "
141149
"before::"
142150
msgstr""
143151

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

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

158-
#:../../howto/annotations.rst:123
166+
#:../../howto/annotations.rst:129
159167
msgid"Manually Un-Stringizing Stringized Annotations"
160168
msgstr""
161169

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

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

178-
#:../../howto/annotations.rst:137
186+
#:../../howto/annotations.rst:143
179187
msgid""
180188
"In a nutshell, if you wish to evaluate a stringized annotation on an "
181189
"arbitrary object ``o``:"
182190
msgstr""
183191

184-
#:../../howto/annotations.rst:140
192+
#:../../howto/annotations.rst:146
185193
msgid""
186194
"If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when calling :"
187195
"func:`eval`."
188196
msgstr""
189197

190-
#:../../howto/annotations.rst:142
198+
#:../../howto/annotations.rst:148
191199
msgid""
192200
"If ``o`` is a class, use ``sys.modules[o.__module__].__dict__`` as the "
193201
"``globals``, and ``dict(vars(o))`` as the ``locals``, when calling :func:"
194202
"`eval`."
195203
msgstr""
196204

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

205-
#:../../howto/annotations.rst:149
213+
#:../../howto/annotations.rst:155
206214
msgid""
207215
"If ``o`` is a callable (but not a class), use ``o.__globals__`` as the "
208216
"globals when calling :func:`eval`."
209217
msgstr""
210218

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

220-
#:../../howto/annotations.rst:159
228+
#:../../howto/annotations.rst:165
221229
msgid""
222230
":pep:`604` union types using ``|``, before support for this was added to "
223231
"Python 3.10."
224232
msgstr""
225233

226-
#:../../howto/annotations.rst:161
234+
#:../../howto/annotations.rst:167
227235
msgid""
228236
"Definitions that aren't needed at runtime, only imported when :const:`typing."
229237
"TYPE_CHECKING` is true."
230238
msgstr""
231239

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

240-
#:../../howto/annotations.rst:172
248+
#:../../howto/annotations.rst:178
241249
msgid"Best Practices For ``__annotations__`` In Any Python Version"
242250
msgstr""
243251

244-
#:../../howto/annotations.rst:174
252+
#:../../howto/annotations.rst:180
245253
msgid""
246254
"You should avoid assigning to the ``__annotations__`` member of objects "
247255
"directly. Let Python manage setting ``__annotations__``."
248256
msgstr""
249257

250-
#:../../howto/annotations.rst:177
258+
#:../../howto/annotations.rst:183
251259
msgid""
252260
"If you do assign directly to the ``__annotations__`` member of an object, "
253261
"you should always set it to a ``dict`` object."
254262
msgstr""
255263

256-
#:../../howto/annotations.rst:180
264+
#:../../howto/annotations.rst:186
257265
msgid""
258266
"If you directly access the ``__annotations__`` member of an object, you "
259267
"should ensure that it's a dictionary before attempting to examine its "
260268
"contents."
261269
msgstr""
262270

263-
#:../../howto/annotations.rst:184
271+
#:../../howto/annotations.rst:190
264272
msgid"You should avoid modifying ``__annotations__`` dicts."
265273
msgstr""
266274

267-
#:../../howto/annotations.rst:186
275+
#:../../howto/annotations.rst:192
268276
msgid""
269277
"You should avoid deleting the ``__annotations__`` attribute of an object."
270278
msgstr""
271279

272-
#:../../howto/annotations.rst:191
280+
#:../../howto/annotations.rst:197
273281
msgid"``__annotations__`` Quirks"
274282
msgstr""
275283

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

288-
#:../../howto/annotations.rst:203
296+
#:../../howto/annotations.rst:209
289297
msgid""
290298
"Everything in the above paragraph also applies to class and module objects "
291299
"in Python 3.10 and newer."
292300
msgstr""
293301

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

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

313-
#:../../howto/annotations.rst:225
321+
#:../../howto/annotations.rst:231
314322
msgid""
315323
"This prints ``{'a':\"'str'\"}``. This shouldn't really be considered a "
316324
"\"quirk\"; it's mentioned here simply because it might be surprising."

‎library/compileall.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version:Python 3.11\n"
99
"Report-Msgid-Bugs-To:\n"
10-
"POT-Creation-Date:2022-10-15 20:43+0000\n"
10+
"POT-Creation-Date:2022-12-25 00:16+0000\n"
1111
"PO-Revision-Date:2018-05-23 14:41+0000\n"
1212
"Last-Translator:Adrian Liaw <adrianliaw2000@gmail.com>\n"
1313
"Language-Team:Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -281,7 +281,7 @@ msgstr ""
281281
msgid""
282282
"The *stripdir*, *prependdir* and *limit_sl_dest* arguments correspond to the "
283283
"``-s``, ``-p`` and ``-e`` options described above. They may be specified as "
284-
"``str``, ``bytes`` or :py:class:`os.PathLike`."
284+
"``str`` or :py:class:`os.PathLike`."
285285
msgstr""
286286

287287
#:../../library/compileall.rst:204../../library/compileall.rst:274

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp