# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # # Translators: # Rafael Fontenelle , 2025 # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-07-25 16:03+0000\n" "PO-Revision-Date: 2025-07-18 19:57+0000\n" "Last-Translator: Rafael Fontenelle , 2025\n" "Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/code.rst:8 msgid "Code Objects" msgstr "代码对象" #: ../../c-api/code.rst:12 msgid "" "Code objects are a low-level detail of the CPython implementation. Each one " "represents a chunk of executable code that hasn't yet been bound into a " "function." msgstr "代码对象是 CPython 实现的低层级细节。 每个代表一块尚未绑定到函数中的可执行代码。" #: ../../c-api/code.rst:18 msgid "" "The C structure of the objects used to describe code objects. The fields of" " this type are subject to change at any time." msgstr "用于描述代码对象的对象的 C 结构。 此类型字段可随时更改。" #: ../../c-api/code.rst:24 msgid "" "This is an instance of :c:type:`PyTypeObject` representing the Python " ":ref:`code object `." msgstr "这一个代表 Python :ref:`代码对象 ` 的 :c:type:`PyTypeObject` 实例。" #: ../../c-api/code.rst:30 msgid "" "Return true if *co* is a :ref:`code object `. This function " "always succeeds." msgstr "如果 *co* 是一个 :ref:`代码对象 ` 则返回真值。 此函数总是会成功执行。" #: ../../c-api/code.rst:35 msgid "Return the number of free variables in a code object." msgstr "返回代码对象中的自由变量数。" #: ../../c-api/code.rst:39 msgid "Return the position of the first free variable in a code object." msgstr "返回代码对象中第一个自由变量的位置。" #: ../../c-api/code.rst:43 msgid "" "Return a new code object. If you need a dummy code object to create a " "frame, use :c:func:`PyCode_NewEmpty` instead." msgstr "返回一个新的代码对象。 如果你需要一个用空代码对象来创建帧,请改用 :c:func:`PyCode_NewEmpty`。" #: ../../c-api/code.rst:46 msgid "" "Since the definition of the bytecode changes often, calling " ":c:func:`PyUnstable_Code_New` directly can bind you to a precise Python " "version." msgstr "由于字节码的定义经常变化,可以直接调用 :c:func:`PyUnstable_Code_New` 来绑定某个确定的 Python 版本。" #: ../../c-api/code.rst:49 msgid "" "The many arguments of this function are inter-dependent in complex ways, " "meaning that subtle changes to values are likely to result in incorrect " "execution or VM crashes. Use this function only with extreme care." msgstr "此函数的许多参数以复杂的方式相互依赖,这意味着参数值的细微改变可能导致不正确的执行或 VM 崩溃。 使用此函数需要极度小心。" #: ../../c-api/code.rst:53 msgid "Added ``qualname`` and ``exceptiontable`` parameters." msgstr "添加了 ``qualname`` 和 ``exceptiontable`` 形参。" #: ../../c-api/code.rst:60 msgid "" "Renamed from ``PyCode_New`` as part of :ref:`unstable-c-api`. The old name " "is deprecated, but will remain available until the signature changes again." msgstr "" "由 ``PyCode_New`` 更名而来,是 :ref:`unstable-c-api` 的一部分。 旧名称已被弃用,但在签名再次更改之前仍然可用。" #: ../../c-api/code.rst:66 msgid "" "Similar to :c:func:`PyUnstable_Code_New`, but with an extra " "\"posonlyargcount\" for positional-only arguments. The same caveats that " "apply to ``PyUnstable_Code_New`` also apply to this function." msgstr "" "与 :c:func:`PyUnstable_Code_New` 类似,但额外增加了一个针对仅限位置参数的 \"posonlyargcount\"。 " "适用于 ``PyUnstable_Code_New`` 的适用事项同样适用于这个函数。" #: ../../c-api/code.rst:71 msgid "as ``PyCode_NewWithPosOnlyArgs``" msgstr "作为 ``PyCode_NewWithPosOnlyArgs``" #: ../../c-api/code.rst:73 msgid "Added ``qualname`` and ``exceptiontable`` parameters." msgstr "增加了 ``qualname`` 和 ``exceptiontable`` 形参。" #: ../../c-api/code.rst:78 msgid "" "Renamed to ``PyUnstable_Code_NewWithPosOnlyArgs``. The old name is " "deprecated, but will remain available until the signature changes again." msgstr "重命名为 ``PyUnstable_Code_NewWithPosOnlyArgs``。 旧名称已被弃用,但在签名再次更改之前将保持可用。" #: ../../c-api/code.rst:84 msgid "" "Return a new empty code object with the specified filename, function name, " "and first line number. The resulting code object will raise an ``Exception``" " if executed." msgstr "返回一个具有指定用户名、函数名和首行行号的空代码对象。 结果代码对象如果被执行则将引发一个 ``Exception``。" #: ../../c-api/code.rst:90 msgid "" "Return the line number of the instruction that occurs on or before " "``byte_offset`` and ends after it. If you just need the line number of a " "frame, use :c:func:`PyFrame_GetLineNumber` instead." msgstr "" "返回在 ``byte_offset`` 位置或之前以及之后发生的指令的行号。 如果你只需要一个帧的行号,请改用 " ":c:func:`PyFrame_GetLineNumber`。" #: ../../c-api/code.rst:93 msgid "" "For efficiently iterating over the line numbers in a code object, use " ":pep:`the API described in PEP 626 <0626#out-of-process-debuggers-and-" "profilers>`." msgstr "" "要高效地对代码对象中的行号进行迭代,请使用 :pep:`在 PEP 626 中描述的 API <0626#out-of-process-" "debuggers-and-profilers>`。" #: ../../c-api/code.rst:98 msgid "" "Sets the passed ``int`` pointers to the source code line and column numbers " "for the instruction at ``byte_offset``. Sets the value to ``0`` when " "information is not available for any particular element." msgstr "" "将传入的 ``int`` 指针设为 ``byte_offset`` 处的指令的源代码行编号和列编号。 当没有任何特定元素的信息时则将值设为 ``0``。" #: ../../c-api/code.rst:102 msgid "Returns ``1`` if the function succeeds and 0 otherwise." msgstr "如果函数执行成功则返回 ``1`` 否则返回 0。" #: ../../c-api/code.rst:108 msgid "" "Equivalent to the Python code ``getattr(co, 'co_code')``. Returns a strong " "reference to a :c:type:`PyBytesObject` representing the bytecode in a code " "object. On error, ``NULL`` is returned and an exception is raised." msgstr "" "等价于 Python 代码 ``getattr(co, 'co_code')``。 返回一个指向表示代码对象中的字节码的 " ":c:type:`PyBytesObject` 的强引用。 当出错时,将返回 ``NULL`` 并引发一个异常。" #: ../../c-api/code.rst:113 msgid "" "This ``PyBytesObject`` may be created on-demand by the interpreter and does " "not necessarily represent the bytecode actually executed by CPython. The " "primary use case for this function is debuggers and profilers." msgstr "" "这个 ``PyBytesObject`` 可以由解释器按需创建并且不必代表 CPython 所实际执行的字节码。 " "此函数的主要用途是调试器和性能分析工具。" #: ../../c-api/code.rst:121 msgid "" "Equivalent to the Python code ``getattr(co, 'co_varnames')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the local " "variables. On error, ``NULL`` is returned and an exception is raised." msgstr "" "等价于 Python 代码 ``getattr(co, 'co_varnames')``。 返回一个指向包含局部变量名称的 " ":c:type:`PyTupleObject` 的新引用。 当出错时,将返回 ``NULL`` 并引发一个异常。" #: ../../c-api/code.rst:130 msgid "" "Equivalent to the Python code ``getattr(co, 'co_cellvars')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the local " "variables that are referenced by nested functions. On error, ``NULL`` is " "returned and an exception is raised." msgstr "" "等价于 Python 代码 ``getattr(co, 'co_cellvars')``。 返回一个包含被嵌套的函数所引用的局部变量名称的 " ":c:type:`PyTupleObject` 的新引用。 当出错时,将返回 ``NULL`` 并引发一个异常。" #: ../../c-api/code.rst:139 msgid "" "Equivalent to the Python code ``getattr(co, 'co_freevars')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the free " "variables. On error, ``NULL`` is returned and an exception is raised." msgstr "" "等价于 Python 代码 ``getattr(co, 'co_freevars')``。 返回一个指向包含自由变量名称的 " ":c:type:`PyTupleObject` 的新引用。 当出错时,将返回 ``NULL`` 并引发一个异常。" #: ../../c-api/code.rst:147 msgid "" "Register *callback* as a code object watcher for the current interpreter. " "Return an ID which may be passed to :c:func:`PyCode_ClearWatcher`. In case " "of error (e.g. no more watcher IDs available), return ``-1`` and set an " "exception." msgstr "" "注册 *callback* 作为当前解释器的代码对象监视器。 返回一个可被传给 :c:func:`PyCode_ClearWatcher` 的 ID。 " "如果出现错误(例如没有足够的可用监视器 ID),则返回 ``-1`` 并设置一个异常。" #: ../../c-api/code.rst:156 msgid "" "Clear watcher identified by *watcher_id* previously returned from " ":c:func:`PyCode_AddWatcher` for the current interpreter. Return ``0`` on " "success, or ``-1`` and set an exception on error (e.g. if the given " "*watcher_id* was never registered.)" msgstr "" "清除之前从 :c:func:`PyCode_AddWatcher` 返回的当前解释器中由 *watcher_id* 所标识的监视器。 成功时返回 " "``0``,或者出错时(例如当给定的 *watcher_id* 未被注册)返回 ``-1`` 并设置异常。" #: ../../c-api/code.rst:165 msgid "" "Enumeration of possible code object watcher events: - " "``PY_CODE_EVENT_CREATE`` - ``PY_CODE_EVENT_DESTROY``" msgstr "" "由可能的代码对象监视器事件组成的枚举: - ``PY_CODE_EVENT_CREATE`` - ``PY_CODE_EVENT_DESTROY``" #: ../../c-api/code.rst:173 msgid "Type of a code object watcher callback function." msgstr "代码对象监视器回调函数的类型。" #: ../../c-api/code.rst:175 msgid "" "If *event* is ``PY_CODE_EVENT_CREATE``, then the callback is invoked after " "`co` has been fully initialized. Otherwise, the callback is invoked before " "the destruction of *co* takes place, so the prior state of *co* can be " "inspected." msgstr "" "如果 *event* 为 ``PY_CODE_EVENT_CREATE`` ,则回调会在 `co` 完全初始化后被唤起。 否则,回调会在 *co* " "执行销毁之前被唤起,这样就可以检查 *co* 之前的状态。" #: ../../c-api/code.rst:180 msgid "" "If *event* is ``PY_CODE_EVENT_DESTROY``, taking a reference in the callback " "to the about-to-be-destroyed code object will resurrect it and prevent it " "from being freed at this time. When the resurrected object is destroyed " "later, any watcher callbacks active at that time will be called again." msgstr "" "如果 *event* 为 " "``PY_CODE_EVENT_DESTROY``,则在回调中接受一个即将被销毁的代码对象的引用将使其重生,并阻止其在此时被释放。 " "当重生的对象以后再被销毁时,任何在当时已激活的监视器回调将再次被调用。" #: ../../c-api/code.rst:185 msgid "" "Users of this API should not rely on internal runtime implementation " "details. Such details may include, but are not limited to, the exact order " "and timing of creation and destruction of code objects. While changes in " "these details may result in differences observable by watchers (including " "whether a callback is invoked or not), it does not change the semantics of " "the Python code being executed." msgstr "" "本 API 的用户不应依赖内部运行时的实现细节。 这类细节可能包括但不限于创建和销毁代码对象的确切顺序和时间。 " "虽然这些细节的变化可能会导致监视器可观察到的差异(包括回调是否被唤起),但不会改变正在执行的 Python 代码的语义。" #: ../../c-api/code.rst:192 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " "will be printed as an unraisable exception using " ":c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" "如果该回调设置了一个异常,则它必须返回 ``-1``;此异常将作为不可引发的异常使用 :c:func:`PyErr_WriteUnraisable` " "打印出来。 在其他情况下它应当返回 ``0``。" #: ../../c-api/code.rst:196 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " "set. This means the callback may not call any other API that can set an " "exception unless it saves and clears the exception state first, and restores" " it before returning." msgstr "" "在进入回调时可能已经设置了尚未处理的异常。 在此情况下,回调应当返回 ``0`` 并仍然设置同样的异常。 这意味着该回调可能不会调用任何其他可设置异常的" " API 除非它先保存并清空异常状态,并在返回之前恢复它。" #: ../../c-api/code.rst:206 msgid "Extra information" msgstr "附加信息" #: ../../c-api/code.rst:208 msgid "" "To support low-level extensions to frame evaluation, such as external just-" "in-time compilers, it is possible to attach arbitrary extra data to code " "objects." msgstr "为了支持对帧求值的低层级扩展,如外部即时编译器等,可以在代码对象上附加任意的额外数据。" #: ../../c-api/code.rst:212 msgid "" "These functions are part of the unstable C API tier: this functionality is a" " CPython implementation detail, and the API may change without deprecation " "warnings." msgstr "这些函数是不稳定 C API 层的一部分:该功能是 CPython 的实现细节,此 API 可能随时改变而不发出弃用警告。" #: ../../c-api/code.rst:218 msgid "" "Return a new an opaque index value used to adding data to code objects." msgstr "返回一个新的不透明索引值用于向代码对象添加数据。" #: ../../c-api/code.rst:220 msgid "" "You generally call this function once (per interpreter) and use the result " "with ``PyCode_GetExtra`` and ``PyCode_SetExtra`` to manipulate data on " "individual code objects." msgstr "" "通常情况下(对于每个解释器)你只需调用该函数一次然后将调用结果与 ``PyCode_GetExtra`` 和 ``PyCode_SetExtra`` " "一起使用以操作单个代码对象上的数据。" #: ../../c-api/code.rst:224 msgid "" "If *free* is not ``NULL``: when a code object is deallocated, *free* will be" " called on non-``NULL`` data stored under the new index. Use " ":c:func:`Py_DecRef` when storing :c:type:`PyObject`." msgstr "" "如果 *free* 没有不为 ``NULL``: 当代码对象被释放时,*free* 将在存储于新索引下的非 ``NULL`` 数据上被调用。 当存储 " ":c:type:`PyObject` 时使用 :c:func:`Py_DecRef`。" #: ../../c-api/code.rst:230 msgid "as ``_PyEval_RequestCodeExtraIndex``" msgstr "作为 ``_PyEval_RequestCodeExtraIndex``" #: ../../c-api/code.rst:234 msgid "" "Renamed to ``PyUnstable_Eval_RequestCodeExtraIndex``. The old private name " "is deprecated, but will be available until the API changes." msgstr "" "重命名为 ``PyUnstable_Eval_RequestCodeExtraIndex``。 旧的私有名称已被弃用,但在 API 更改之前仍将可用。" #: ../../c-api/code.rst:240 msgid "" "Set *extra* to the extra data stored under the given index. Return 0 on " "success. Set an exception and return -1 on failure." msgstr "将 *extra* 设为存储在给定索引下的额外数据。 成功时将返回 0。 失败时将设置一个异常并返回 -1。" #: ../../c-api/code.rst:243 msgid "" "If no data was set under the index, set *extra* to ``NULL`` and return 0 " "without setting an exception." msgstr "如果未在索引下设置数据,则将 *extra* 设为 ``NULL`` 并返回 0 而不设置异常。" #: ../../c-api/code.rst:248 msgid "as ``_PyCode_GetExtra``" msgstr "作为 ``_PyCode_GetExtra``" #: ../../c-api/code.rst:252 msgid "" "Renamed to ``PyUnstable_Code_GetExtra``. The old private name is deprecated," " but will be available until the API changes." msgstr "重命名为 ``PyUnstable_Code_GetExtra``。 旧的私有名称已被弃用,但在 API 更改之前仍将可用。" #: ../../c-api/code.rst:258 msgid "" "Set the extra data stored under the given index to *extra*. Return 0 on " "success. Set an exception and return -1 on failure." msgstr "将存储在给定索引下的额外数据设为 *extra*。 成功时将返回 0。 失败时将设置一个异常并返回 -1。" #: ../../c-api/code.rst:263 msgid "as ``_PyCode_SetExtra``" msgstr "作为 ``_PyCode_SetExtra``" #: ../../c-api/code.rst:267 msgid "" "Renamed to ``PyUnstable_Code_SetExtra``. The old private name is deprecated," " but will be available until the API changes." msgstr "重命名为 ``PyUnstable_Code_SetExtra``。 旧的私有名称已被弃用,但在 API 更改之前仍将可用。" #: ../../c-api/code.rst:3 msgid "object" msgstr "object -- 对象" #: ../../c-api/code.rst:3 msgid "code" msgstr "code" #: ../../c-api/code.rst:3 msgid "code object" msgstr "代码对象" #: ../../c-api/code.rst:56 msgid "PyCode_New (C function)" msgstr "PyCode_New (C 函数)" #: ../../c-api/code.rst:69 msgid "PyCode_NewWithPosOnlyArgs (C function)" msgstr "PyCode_NewWithPosOnlyArgs (C 函数)" #: ../../c-api/code.rst:228 msgid "_PyEval_RequestCodeExtraIndex (C function)" msgstr "_PyEval_RequestCodeExtraIndex (C 函数)" #: ../../c-api/code.rst:246 msgid "_PyCode_GetExtra (C function)" msgstr "_PyCode_GetExtra (C 函数)" #: ../../c-api/code.rst:261 msgid "_PyCode_SetExtra (C function)" msgstr "_PyCode_SetExtra (C 函数)"