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

Skip to content

Commit db2f5b7

Browse files
[po] auto sync
1 parent 0d7d319 commit db2f5b7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

extending/newtypes_tutorial.po

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ msgid ""
381381
"object's type might not be :class:`CustomType`, because the object may be an"
382382
" instance of a subclass."
383383
msgstr ""
384+
"此方法会先清空两个 Python 属性的引用计数。 :c:func:`Py_XDECREF` 可正确地处理其参数为 ``NULL`` 的情况(这可能在 "
385+
"``tp_new`` 中途失败时发生)。 随后它将调用对象类型的 :c:member:`~PyTypeObject.tp_free` 成员(通过 "
386+
"``Py_TYPE(self)`` 获取对象类型)来释放对象的内存。 请注意对象类型可以不是 "
387+
":class:`CustomType`,因为对象可能是一个子类的实例。"
384388

385389
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/extending/newtypes_tutorial.rst:285
386390
msgid ""
@@ -390,16 +394,19 @@ msgid ""
390394
"argument. Otherwise, the compiler will emit a warning. This is object-"
391395
"oriented polymorphism, in C!"
392396
msgstr ""
397+
"上面需要强制转换 ``destructor`` 是因为我们定义了 ``Custom_dealloc`` 接受一个 ``CustomObject *`` "
398+
"参数,但 ``tp_dealloc`` 函数指针预期接受一个 ``PyObject *`` 参数。 如果不这样做,编译器将发出警告。 这是 C "
399+
"语言中面向对象的多态性!"
393400

394401
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/extending/newtypes_tutorial.rst:291
395402
msgid ""
396403
"We want to make sure that the first and last names are initialized to empty "
397404
"strings, so we provide a ``tp_new`` implementation::"
398-
msgstr ""
405+
msgstr "我们希望确保头一个和末一个名称被初始化为空字符串,因此我们提供了一个 ``tp_new`` 实现::"
399406

400407
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/extending/newtypes_tutorial.rst:315
401408
msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::"
402-
msgstr ""
409+
msgstr "并在 :c:member:`~PyTypeObject.tp_new` 成员中安装它::"
403410

404411
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/extending/newtypes_tutorial.rst:319
405412
msgid ""
@@ -411,6 +418,10 @@ msgid ""
411418
"type above. In this case, we use the ``tp_new`` handler to initialize the "
412419
"``first`` and ``last`` attributes to non-``NULL`` default values."
413420
msgstr ""
421+
"``tp_new`` 处理句柄负责创建(而不是初始化)该类型的对象。 它在 Python 中被暴露为 :meth:`__new__` 方法。 "
422+
"它不需要定义 ``tp_new`` 成员,实际上许多扩展类型会简单地重用 :c:func:`PyType_GenericNew`,就像上面第一版 "
423+
"``Custom`` 类型所作的那样。 在此情况下,我们使用 ``tp_new`` 处理句柄来将 ``first`` 和 ``last`` "
424+
"属性初始化为非 ``NULL`` 的默认值。"
414425

415426
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/extending/newtypes_tutorial.rst:327
416427
msgid ""

0 commit comments

Comments
 (0)