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

Skip to content

Commit 1a6c0f4

Browse files
[po] auto sync
1 parent 73978f1 commit 1a6c0f4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

extending/newtypes_tutorial.po

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,16 +480,22 @@ msgid ""
480480
"may not work correctly. (Specifically, you may not be able to create "
481481
"instances of such subclasses without getting a :exc:`TypeError`.)"
482482
msgstr ""
483+
"如果你要创建一个协作 :c:member:`~PyTypeObject.tp_new` (它会调用基类型的 "
484+
":c:member:`~PyTypeObject.tp_new` 或 :meth:`__new__`),那么你 *不能* "
485+
"在运行时尝试使用方法解析顺序来确定要调用的方法。 必须总是静态地确定你要调用的类型,并直接调用它的 "
486+
":c:member:`~PyTypeObject.tp_new`,或是通过 ``type->tp_base->tp_new``。 "
487+
"如果你不这样做,你的类型的同样从其他 Python 定义的类继承的 Python 子类可能无法正确工作。 "
488+
"(特别地,你可能无法创建这样的子类的实例而是会引发 :exc:`TypeError`。)"
483489

484490
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/extending/newtypes_tutorial.rst:363
485491
msgid ""
486492
"We also define an initialization function which accepts arguments to provide"
487493
" initial values for our instance::"
488-
msgstr ""
494+
msgstr "我们还定义了一个接受参数来为我们的实例提供初始值的初始化函数::"
489495

490496
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/extending/newtypes_tutorial.rst:392
491497
msgid "by filling the :c:member:`~PyTypeObject.tp_init` slot. ::"
492-
msgstr ""
498+
msgstr "通过填充 :c:member:`~PyTypeObject.tp_init` 槽位。 ::"
493499

494500
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/extending/newtypes_tutorial.rst:396
495501
msgid ""
@@ -498,6 +504,8 @@ msgid ""
498504
"created. Initializers always accept positional and keyword arguments, and "
499505
"they should return either ``0`` on success or ``-1`` on error."
500506
msgstr ""
507+
":c:member:`~PyTypeObject.tp_init` 槽位在 Python 中暴露为 :meth:`__init__` 方法。 "
508+
"它被用来在对象被创建后初始化它。 初始化器总是接受位置和关键字参数,它们应当在成功时返回 ``0`` 而在出错时返回 ``-1``。"
501509

502510
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/extending/newtypes_tutorial.rst:401
503511
msgid ""
@@ -509,6 +517,10 @@ msgid ""
509517
"values. We might be tempted, for example to assign the ``first`` member "
510518
"like this::"
511519
msgstr ""
520+
"不同于 ``tp_new`` 处理句柄,``tp_init`` 不保证一定会被调用 (例如,在默认情况下 :mod:`pickle` "
521+
"模块不会在被解封的实例上调用 :meth:`__init__`)。 它还可能被多次调用。 任何人都可以在我们的对象上调用 "
522+
":meth:`__init__` 方法。 由于这个原因,我们在为属性赋新值时必须非常小心。 我们可能会被误导,例如像这样给 ``first`` "
523+
"成员赋值::"
512524

513525
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/extending/newtypes_tutorial.rst:415
514526
msgid ""

0 commit comments

Comments
 (0)