# 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/init_config.rst:7 msgid "Python Initialization Configuration" msgstr "Python初始化配置" #: ../../c-api/init_config.rst:11 msgid "" "Python can be initialized with :c:func:`Py_InitializeFromConfig` and the " ":c:type:`PyConfig` structure. It can be preinitialized with " ":c:func:`Py_PreInitialize` and the :c:type:`PyPreConfig` structure." msgstr "" "Python 可以使用 :c:func:`Py_InitializeFromConfig` 和 :c:type:`PyConfig` 结构体来初始化。 " "它可以使用 :c:func:`Py_PreInitialize` 和 :c:type:`PyPreConfig` 结构体来预初始化。" #: ../../c-api/init_config.rst:15 msgid "There are two kinds of configuration:" msgstr "有两种配置方式:" #: ../../c-api/init_config.rst:17 msgid "" "The :ref:`Python Configuration ` can be used to build a " "customized Python which behaves as the regular Python. For example, " "environment variables and command line arguments are used to configure " "Python." msgstr "" ":ref:`Python 配置 ` 可被用于构建一个定制的 Python,其行为与常规 Python 类似。 " "例如,环境变量和命令行参数可被用于配置 Python。" #: ../../c-api/init_config.rst:22 msgid "" "The :ref:`Isolated Configuration ` can be used to embed " "Python into an application. It isolates Python from the system. For example," " environment variables are ignored, the LC_CTYPE locale is left unchanged " "and no signal handler is registered." msgstr "" ":ref:`隔离配置 ` 可被用于将 Python 嵌入到应用程序。 它将 Python 与系统隔离开来。 " "例如,环境变量将被忽略,LC_CTYPE 语言区域设置保持不变并且不会注册任何信号处理器。" #: ../../c-api/init_config.rst:27 msgid "" "The :c:func:`Py_RunMain` function can be used to write a customized Python " "program." msgstr ":c:func:`Py_RunMain` 函数可被用来编写定制的 Python 程序。" #: ../../c-api/init_config.rst:30 msgid "" "See also :ref:`Initialization, Finalization, and Threads `." msgstr "参见 :ref:`Initialization, Finalization, and Threads `." #: ../../c-api/init_config.rst:33 msgid ":pep:`587` \"Python Initialization Configuration\"." msgstr ":pep:`587` \"Python 初始化配置\"." #: ../../c-api/init_config.rst:37 msgid "Example" msgstr "示例" #: ../../c-api/init_config.rst:39 msgid "Example of customized Python always running in isolated mode::" msgstr "定制的 Python 的示例总是会以隔离模式运行::" #: ../../c-api/init_config.rst:41 msgid "" "int main(int argc, char **argv)\n" "{\n" " PyStatus status;\n" "\n" " PyConfig config;\n" " PyConfig_InitPythonConfig(&config);\n" " config.isolated = 1;\n" "\n" " /* Decode command line arguments.\n" " Implicitly preinitialize Python (in isolated mode). */\n" " status = PyConfig_SetBytesArgv(&config, argc, argv);\n" " if (PyStatus_Exception(status)) {\n" " goto exception;\n" " }\n" "\n" " status = Py_InitializeFromConfig(&config);\n" " if (PyStatus_Exception(status)) {\n" " goto exception;\n" " }\n" " PyConfig_Clear(&config);\n" "\n" " return Py_RunMain();\n" "\n" "exception:\n" " PyConfig_Clear(&config);\n" " if (PyStatus_IsExit(status)) {\n" " return status.exitcode;\n" " }\n" " /* Display the error message and exit the process with\n" " non-zero exit code */\n" " Py_ExitStatusException(status);\n" "}" msgstr "" "int main(int argc, char **argv)\n" "{\n" " PyStatus status;\n" "\n" " PyConfig config;\n" " PyConfig_InitPythonConfig(&config);\n" " config.isolated = 1;\n" "\n" " /* 解码命令行参数。\n" " 隐式地预初始化 Python (隔离模式)。 */\n" " status = PyConfig_SetBytesArgv(&config, argc, argv);\n" " if (PyStatus_Exception(status)) {\n" " goto exception;\n" " }\n" "\n" " status = Py_InitializeFromConfig(&config);\n" " if (PyStatus_Exception(status)) {\n" " goto exception;\n" " }\n" " PyConfig_Clear(&config);\n" "\n" " return Py_RunMain();\n" "\n" "exception:\n" " PyConfig_Clear(&config);\n" " if (PyStatus_IsExit(status)) {\n" " return status.exitcode;\n" " }\n" " /* 显示错误消息然后退出进程\n" " 并设置非零值退出码 */\n" " Py_ExitStatusException(status);\n" "}" #: ../../c-api/init_config.rst:76 msgid "PyWideStringList" msgstr "PyWideStringList" #: ../../c-api/init_config.rst:80 msgid "List of ``wchar_t*`` strings." msgstr "由 ``wchar_t*`` 字符串组成的列表。" #: ../../c-api/init_config.rst:82 msgid "" "If *length* is non-zero, *items* must be non-``NULL`` and all strings must " "be non-``NULL``." msgstr "如果 *length* 为非零值,则 *items* 必须不为 ``NULL`` 并且所有字符串均必须不为 ``NULL``。" #: ../../c-api/init_config.rst:87 msgid "Methods:" msgstr "方法" #: ../../c-api/init_config.rst:91 msgid "Append *item* to *list*." msgstr "将 *item* 添加到 *list*。" #: ../../c-api/init_config.rst:93 ../../c-api/init_config.rst:104 msgid "Python must be preinitialized to call this function." msgstr "Python 必须被预初始化以便调用此函数。" #: ../../c-api/init_config.rst:97 msgid "Insert *item* into *list* at *index*." msgstr "将 *item* 插入到 *list* 的 *index* 位置上。" #: ../../c-api/init_config.rst:99 msgid "" "If *index* is greater than or equal to *list* length, append *item* to " "*list*." msgstr "如果 *index* 大于等于 *list* 的长度,则将 *item* 添加到 *list*。" #: ../../c-api/init_config.rst:102 msgid "*index* must be greater than or equal to ``0``." msgstr "*index* 必须大于等于 ``0``。" #: ../../c-api/init_config.rst:108 ../../c-api/init_config.rst:128 #: ../../c-api/init_config.rst:235 ../../c-api/init_config.rst:544 msgid "Structure fields:" msgstr "结构体字段:" #: ../../c-api/init_config.rst:112 msgid "List length." msgstr "List 长度。" #: ../../c-api/init_config.rst:116 msgid "List items." msgstr "列表项目。" #: ../../c-api/init_config.rst:119 msgid "PyStatus" msgstr "PyStatus" #: ../../c-api/init_config.rst:123 msgid "" "Structure to store an initialization function status: success, error or " "exit." msgstr "存储初始函数状态:成功、错误或退出的结构体。" #: ../../c-api/init_config.rst:126 msgid "" "For an error, it can store the C function name which created the error." msgstr "对于错误,它可以存储造成错误的 C 函数的名称。" #: ../../c-api/init_config.rst:132 msgid "Exit code. Argument passed to ``exit()``." msgstr "退出码。 传给 ``exit()`` 的参数。" #: ../../c-api/init_config.rst:136 msgid "Error message." msgstr "错误信息" #: ../../c-api/init_config.rst:140 msgid "Name of the function which created an error, can be ``NULL``." msgstr "造成错误的函数的名称,可以为 ``NULL``。" #: ../../c-api/init_config.rst:144 msgid "Functions to create a status:" msgstr "创建状态的函数:" #: ../../c-api/init_config.rst:148 msgid "Success." msgstr "完成。" #: ../../c-api/init_config.rst:152 msgid "Initialization error with a message." msgstr "带消息的初始化错误。" #: ../../c-api/init_config.rst:154 msgid "*err_msg* must not be ``NULL``." msgstr "*err_msg* 不可为 ``NULL``。" #: ../../c-api/init_config.rst:158 msgid "Memory allocation failure (out of memory)." msgstr "内存分配失败(内存不足)。" #: ../../c-api/init_config.rst:162 msgid "Exit Python with the specified exit code." msgstr "以指定的退出代码退出 Python。" #: ../../c-api/init_config.rst:164 msgid "Functions to handle a status:" msgstr "处理状态的函数:" #: ../../c-api/init_config.rst:168 msgid "" "Is the status an error or an exit? If true, the exception must be handled; " "by calling :c:func:`Py_ExitStatusException` for example." msgstr "状态为错误还是退出?如为真值,则异常必须被处理;例如通过调用 :c:func:`Py_ExitStatusException`。" #: ../../c-api/init_config.rst:173 msgid "Is the result an error?" msgstr "结果错误吗?" #: ../../c-api/init_config.rst:177 msgid "Is the result an exit?" msgstr "结果是否退出?" #: ../../c-api/init_config.rst:181 msgid "" "Call ``exit(exitcode)`` if *status* is an exit. Print the error message and " "exit with a non-zero exit code if *status* is an error. Must only be called" " if ``PyStatus_Exception(status)`` is non-zero." msgstr "" "如果 *status* 是一个退出码则调用 ``exit(exitcode)``。如果 *status* " "是一个错误码则打印错误消息并设置一个非零退出码再退出。 必须在 ``PyStatus_Exception(status)`` 为非零值时才能被调用。" #: ../../c-api/init_config.rst:186 msgid "" "Internally, Python uses macros which set ``PyStatus.func``, whereas " "functions to create a status set ``func`` to ``NULL``." msgstr "" "在内部,Python 将使用设置 ``PyStatus.func`` 的宏,而创建状态的函数则会将 ``func`` 设为 ``NULL``。" #: ../../c-api/init_config.rst:189 msgid "Example::" msgstr "示例::" #: ../../c-api/init_config.rst:191 msgid "" "PyStatus alloc(void **ptr, size_t size)\n" "{\n" " *ptr = PyMem_RawMalloc(size);\n" " if (*ptr == NULL) {\n" " return PyStatus_NoMemory();\n" " }\n" " return PyStatus_Ok();\n" "}\n" "\n" "int main(int argc, char **argv)\n" "{\n" " void *ptr;\n" " PyStatus status = alloc(&ptr, 16);\n" " if (PyStatus_Exception(status)) {\n" " Py_ExitStatusException(status);\n" " }\n" " PyMem_Free(ptr);\n" " return 0;\n" "}" msgstr "" "PyStatus alloc(void **ptr, size_t size)\n" "{\n" " *ptr = PyMem_RawMalloc(size);\n" " if (*ptr == NULL) {\n" " return PyStatus_NoMemory();\n" " }\n" " return PyStatus_Ok();\n" "}\n" "\n" "int main(int argc, char **argv)\n" "{\n" " void *ptr;\n" " PyStatus status = alloc(&ptr, 16);\n" " if (PyStatus_Exception(status)) {\n" " Py_ExitStatusException(status);\n" " }\n" " PyMem_Free(ptr);\n" " return 0;\n" "}" #: ../../c-api/init_config.rst:213 msgid "PyPreConfig" msgstr "PyPreConfig" #: ../../c-api/init_config.rst:217 msgid "Structure used to preinitialize Python." msgstr "用于预初始化 Python 的结构体。" #: ../../c-api/init_config.rst:221 msgid "Function to initialize a preconfiguration:" msgstr "用于初始化预先配置的函数:" #: ../../c-api/init_config.rst:225 msgid "" "Initialize the preconfiguration with :ref:`Python Configuration `." msgstr "通过 :ref:`Python 配置 ` 来初始化预先配置。" #: ../../c-api/init_config.rst:230 msgid "" "Initialize the preconfiguration with :ref:`Isolated Configuration `." msgstr "通过 :ref:`隔离配置 ` 来初始化预先配置。" #: ../../c-api/init_config.rst:239 msgid "Name of the Python memory allocators:" msgstr "Python 内存分配器名称:" #: ../../c-api/init_config.rst:241 msgid "" "``PYMEM_ALLOCATOR_NOT_SET`` (``0``): don't change memory allocators (use " "defaults)." msgstr "``PYMEM_ALLOCATOR_NOT_SET`` (``0``): 不改变内存分配器 (使用默认)。" #: ../../c-api/init_config.rst:243 msgid "" "``PYMEM_ALLOCATOR_DEFAULT`` (``1``): :ref:`default memory allocators " "`." msgstr "" "``PYMEM_ALLOCATOR_DEFAULT`` (``1``): :ref:`默认内存分配器 `。" #: ../../c-api/init_config.rst:245 msgid "" "``PYMEM_ALLOCATOR_DEBUG`` (``2``): :ref:`default memory allocators ` with :ref:`debug hooks `." msgstr "" "``PYMEM_ALLOCATOR_DEBUG`` (``2``): :ref:`默认内存分配器 ` 附带 :ref:`调试钩子 `。" #: ../../c-api/init_config.rst:248 msgid "``PYMEM_ALLOCATOR_MALLOC`` (``3``): use ``malloc()`` of the C library." msgstr "``PYMEM_ALLOCATOR_MALLOC`` (``3``): 使用 C 库的 ``malloc()``。" #: ../../c-api/init_config.rst:249 msgid "" "``PYMEM_ALLOCATOR_MALLOC_DEBUG`` (``4``): force usage of ``malloc()`` with " ":ref:`debug hooks `." msgstr "" "``PYMEM_ALLOCATOR_MALLOC_DEBUG`` (``4``): 强制使用 ``malloc()`` 附带 :ref:`调试钩子 " "`。" #: ../../c-api/init_config.rst:251 msgid "" "``PYMEM_ALLOCATOR_PYMALLOC`` (``5``): :ref:`Python pymalloc memory allocator" " `." msgstr "" "``PYMEM_ALLOCATOR_PYMALLOC`` (``5``): :ref:`Python pymalloc 内存分配器 " "`。" #: ../../c-api/init_config.rst:253 msgid "" "``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` (``6``): :ref:`Python pymalloc memory " "allocator ` with :ref:`debug hooks `." msgstr "" "``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` (``6``): :ref:`Python pymalloc 内存分配器 " "` 附带 :ref:`调试钩子 `。" #: ../../c-api/init_config.rst:257 msgid "" "``PYMEM_ALLOCATOR_PYMALLOC`` and ``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` are not " "supported if Python is :option:`configured using --without-pymalloc " "<--without-pymalloc>`." msgstr "" "如果 Python 是 :option:`使用 --without-pymalloc 进行配置 <--without-pymalloc>` 则 " "``PYMEM_ALLOCATOR_PYMALLOC`` 和 ``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` 将不被支持。" #: ../../c-api/init_config.rst:261 msgid "See :ref:`Memory Management `." msgstr "参见 :ref:`Memory Management `." #: ../../c-api/init_config.rst:263 msgid "Default: ``PYMEM_ALLOCATOR_NOT_SET``." msgstr "默认值: ``PYMEM_ALLOCATOR_NOT_SET``。" #: ../../c-api/init_config.rst:267 msgid "Set the LC_CTYPE locale to the user preferred locale." msgstr "将 LC_CTYPE 语言区域设为用户选择的语言区域。" #: ../../c-api/init_config.rst:269 msgid "" "If equals to ``0``, set :c:member:`~PyPreConfig.coerce_c_locale` and " ":c:member:`~PyPreConfig.coerce_c_locale_warn` members to ``0``." msgstr "" "如果等于 ``0``,则将 :c:member:`~PyPreConfig.coerce_c_locale` 和 " ":c:member:`~PyPreConfig.coerce_c_locale_warn` 的成员设为 ``0``。" #: ../../c-api/init_config.rst:272 ../../c-api/init_config.rst:283 msgid "See the :term:`locale encoding`." msgstr "参见 :term:`locale encoding`。" #: ../../c-api/init_config.rst:274 ../../c-api/init_config.rst:329 #: ../../c-api/init_config.rst:684 msgid "Default: ``1`` in Python config, ``0`` in isolated config." msgstr "默认值: 在 Python 配置中为 ``1``,在隔离配置中为 ``0``。" #: ../../c-api/init_config.rst:278 msgid "If equals to ``2``, coerce the C locale." msgstr "如果等于 ``2``,强制转换 C 语言区域。" #: ../../c-api/init_config.rst:280 msgid "" "If equals to ``1``, read the LC_CTYPE locale to decide if it should be " "coerced." msgstr "如果等于 ``1``,则读取 LC_CTYPE 语言区域来确定其是否应当被强制转换。" #: ../../c-api/init_config.rst:285 ../../c-api/init_config.rst:291 msgid "Default: ``-1`` in Python config, ``0`` in isolated config." msgstr "默认值: 在 Python 配置中为 ``-1``,在隔离配置中为 ``0``。" #: ../../c-api/init_config.rst:289 msgid "If non-zero, emit a warning if the C locale is coerced." msgstr "如为非零值,则会在 C 语言区域被强制转换时发出警告。" #: ../../c-api/init_config.rst:295 msgid "" ":ref:`Python Development Mode `: see :c:member:`PyConfig.dev_mode`." msgstr ":ref:`Python 开发模式 `: 参见 :c:member:`PyConfig.dev_mode`。" #: ../../c-api/init_config.rst:298 ../../c-api/init_config.rst:693 #: ../../c-api/init_config.rst:735 ../../c-api/init_config.rst:1188 msgid "Default: ``-1`` in Python mode, ``0`` in isolated mode." msgstr "默认值: 在 Python 模式中为 ``-1``,在隔离模式中为 ``0``。" #: ../../c-api/init_config.rst:302 msgid "Isolated mode: see :c:member:`PyConfig.isolated`." msgstr "隔离模式:参见 :c:member:`PyConfig.isolated`。" #: ../../c-api/init_config.rst:304 ../../c-api/init_config.rst:880 msgid "Default: ``0`` in Python mode, ``1`` in isolated mode." msgstr "默认值: 在 Python 模式中为 ``0``,在隔离模式中为 ``1``。" #: ../../c-api/init_config.rst:308 msgid "If non-zero:" msgstr "如为非零值:" #: ../../c-api/init_config.rst:310 msgid "Set :c:member:`PyPreConfig.utf8_mode` to ``0``," msgstr "设置 :c:member:`PyPreConfig.utf8_mode` 为 ``0``," #: ../../c-api/init_config.rst:311 msgid "Set :c:member:`PyConfig.filesystem_encoding` to ``\"mbcs\"``," msgstr "设置 :c:member:`PyConfig.filesystem_encoding` 为 ``\"mbcs\"``," #: ../../c-api/init_config.rst:312 msgid "Set :c:member:`PyConfig.filesystem_errors` to ``\"replace\"``." msgstr "设置 :c:member:`PyConfig.filesystem_errors` 为 ``\"replace\"``." #: ../../c-api/init_config.rst:314 msgid "" "Initialized from the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment " "variable value." msgstr "基于 :envvar:`PYTHONLEGACYWINDOWSFSENCODING` 环境变量值完成初始化。" #: ../../c-api/init_config.rst:317 ../../c-api/init_config.rst:894 msgid "" "Only available on Windows. ``#ifdef MS_WINDOWS`` macro can be used for " "Windows specific code." msgstr "仅在 Windows 上可用。 ``#ifdef MS_WINDOWS`` 宏可被用于 Windows 专属的代码。" #: ../../c-api/init_config.rst:320 ../../c-api/init_config.rst:632 #: ../../c-api/init_config.rst:639 ../../c-api/init_config.rst:706 #: ../../c-api/init_config.rst:815 ../../c-api/init_config.rst:829 #: ../../c-api/init_config.rst:843 ../../c-api/init_config.rst:897 #: ../../c-api/init_config.rst:911 ../../c-api/init_config.rst:971 #: ../../c-api/init_config.rst:1023 ../../c-api/init_config.rst:1083 #: ../../c-api/init_config.rst:1123 ../../c-api/init_config.rst:1152 #: ../../c-api/init_config.rst:1239 msgid "Default: ``0``." msgstr "默认值: ``0``." #: ../../c-api/init_config.rst:324 msgid "" "If non-zero, :c:func:`Py_PreInitializeFromArgs` and " ":c:func:`Py_PreInitializeFromBytesArgs` parse their ``argv`` argument the " "same way the regular Python parses command line arguments: see :ref:`Command" " Line Arguments `." msgstr "" "如为非零值,:c:func:`Py_PreInitializeFromArgs` 和 " ":c:func:`Py_PreInitializeFromBytesArgs` 将以与常规 Python 解析命令行参数的相同方式解析其 " "``argv`` 参数:参见 :ref:`命令行参数 `。" #: ../../c-api/init_config.rst:333 msgid "" "Use :ref:`environment variables `? See " ":c:member:`PyConfig.use_environment`." msgstr "" "使用 :ref:`环境变量 `? 参见 :c:member:`PyConfig.use_environment`。" #: ../../c-api/init_config.rst:336 ../../c-api/init_config.rst:1213 msgid "Default: ``1`` in Python config and ``0`` in isolated config." msgstr "默认值: 在 Python 配置中为 ``1`` 而在隔离配置中为 ``0``。" #: ../../c-api/init_config.rst:340 msgid "If non-zero, enable the :ref:`Python UTF-8 Mode `." msgstr "如为非零值,则启用 :ref:`Python UTF-8 模式 `。" #: ../../c-api/init_config.rst:342 msgid "" "Set to ``0`` or ``1`` by the :option:`-X utf8 <-X>` command line option and " "the :envvar:`PYTHONUTF8` environment variable." msgstr "" "通过 :option:`-X utf8 <-X>` 命令行选项和 :envvar:`PYTHONUTF8` 环境变量设为 ``0`` 或 ``1``。" #: ../../c-api/init_config.rst:345 msgid "Also set to ``1`` if the ``LC_CTYPE`` locale is ``C`` or ``POSIX``." msgstr "如果 ``LC_CTYPE`` 语言区域为 ``C`` 或 ``POSIX`` 也会被设为 ``1``。" #: ../../c-api/init_config.rst:347 msgid "Default: ``-1`` in Python config and ``0`` in isolated config." msgstr "默认值: 在 Python 配置中为 ``-1`` 而在隔离配置中为 ``0``。" #: ../../c-api/init_config.rst:353 msgid "Preinitialize Python with PyPreConfig" msgstr "使用 PyPreConfig 预初始化 Python" #: ../../c-api/init_config.rst:355 msgid "The preinitialization of Python:" msgstr "Python 的预初始化:" #: ../../c-api/init_config.rst:357 msgid "Set the Python memory allocators (:c:member:`PyPreConfig.allocator`)" msgstr "设置 Python 内存分配器 (:c:member:`PyPreConfig.allocator`)" #: ../../c-api/init_config.rst:358 msgid "Configure the LC_CTYPE locale (:term:`locale encoding`)" msgstr "配置 LC_CTYPE 语言区域 (:term:`locale encoding`)" #: ../../c-api/init_config.rst:359 msgid "" "Set the :ref:`Python UTF-8 Mode ` " "(:c:member:`PyPreConfig.utf8_mode`)" msgstr "" "设置 :ref:`Python UTF-8 模式 ` (:c:member:`PyPreConfig.utf8_mode`)" #: ../../c-api/init_config.rst:362 msgid "" "The current preconfiguration (``PyPreConfig`` type) is stored in " "``_PyRuntime.preconfig``." msgstr "当前的预配置 (``PyPreConfig`` 类型) 保存在 ``_PyRuntime.preconfig`` 中。" #: ../../c-api/init_config.rst:365 msgid "Functions to preinitialize Python:" msgstr "用于预初始化 Python 的函数:" #: ../../c-api/init_config.rst:369 ../../c-api/init_config.rst:375 #: ../../c-api/init_config.rst:384 msgid "Preinitialize Python from *preconfig* preconfiguration." msgstr "根据 *preconfig* 预配置来预初始化 Python。" #: ../../c-api/init_config.rst:371 ../../c-api/init_config.rst:380 #: ../../c-api/init_config.rst:389 msgid "*preconfig* must not be ``NULL``." msgstr "*preconfig* 不可为 ``NULL``。" #: ../../c-api/init_config.rst:377 msgid "" "Parse *argv* command line arguments (bytes strings) if " ":c:member:`~PyPreConfig.parse_argv` of *preconfig* is non-zero." msgstr "" "如果 *preconfig* 的 :c:member:`~PyPreConfig.parse_argv` 为非零值则解析 *argv* " "命令行参数(字节串)。" #: ../../c-api/init_config.rst:386 msgid "" "Parse *argv* command line arguments (wide strings) if " ":c:member:`~PyPreConfig.parse_argv` of *preconfig* is non-zero." msgstr "" "如果 *preconfig* 的 :c:member:`~PyPreConfig.parse_argv` 为非零值则解析 *argv* " "命令行参数(宽字符串)。" #: ../../c-api/init_config.rst:391 ../../c-api/init_config.rst:1301 msgid "" "The caller is responsible to handle exceptions (error or exit) using " ":c:func:`PyStatus_Exception` and :c:func:`Py_ExitStatusException`." msgstr "" "调用方要负责使用 :c:func:`PyStatus_Exception` 和 :c:func:`Py_ExitStatusException` " "来处理异常(错误或退出)。" #: ../../c-api/init_config.rst:394 msgid "" "For :ref:`Python Configuration ` " "(:c:func:`PyPreConfig_InitPythonConfig`), if Python is initialized with " "command line arguments, the command line arguments must also be passed to " "preinitialize Python, since they have an effect on the pre-configuration " "like encodings. For example, the :option:`-X utf8 <-X>` command line option " "enables the :ref:`Python UTF-8 Mode `." msgstr "" "对于 :ref:`Python 配置 ` " "(:c:func:`PyPreConfig_InitPythonConfig`),如果 Python 是用命令行参数初始化的,那么在预初始化 " "Python 时也必须传递命令行参数,因为它们会对编码格式等预配置产生影响。 例如,:option:`-X utf8<-X>` 命令行选项将启用 " ":ref:`Python UTF-8 模式`。" #: ../../c-api/init_config.rst:401 msgid "" "``PyMem_SetAllocator()`` can be called after :c:func:`Py_PreInitialize` and " "before :c:func:`Py_InitializeFromConfig` to install a custom memory " "allocator. It can be called before :c:func:`Py_PreInitialize` if " ":c:member:`PyPreConfig.allocator` is set to ``PYMEM_ALLOCATOR_NOT_SET``." msgstr "" "``PyMem_SetAllocator()`` 可在 :c:func:`Py_PreInitialize` " "之后、:c:func:`Py_InitializeFromConfig` 之前被调用以安装自定义的内存分配器。 如果 " ":c:member:`PyPreConfig.allocator` 被设为 ``PYMEM_ALLOCATOR_NOT_SET`` 则可在 " ":c:func:`Py_PreInitialize` 之前被调用。" #: ../../c-api/init_config.rst:406 msgid "" "Python memory allocation functions like :c:func:`PyMem_RawMalloc` must not " "be used before the Python preinitialization, whereas calling directly " "``malloc()`` and ``free()`` is always safe. :c:func:`Py_DecodeLocale` must " "not be called before the Python preinitialization." msgstr "" "像 :c:func:`PyMem_RawMalloc` 这样的 Python 内存分配函数不能在 Python 预初始化之前使用,而直接调用 " "``malloc()`` 和 ``free()`` 则始终会是安全的。 :c:func:`Py_DecodeLocale` 不能在 Python " "预初始化之前被调用。" #: ../../c-api/init_config.rst:411 msgid "" "Example using the preinitialization to enable the :ref:`Python UTF-8 Mode " "`::" msgstr "使用预初始化来启用 :ref:`Python UTF-8 模式 ` 的例子::" #: ../../c-api/init_config.rst:414 msgid "" "PyStatus status;\n" "PyPreConfig preconfig;\n" "PyPreConfig_InitPythonConfig(&preconfig);\n" "\n" "preconfig.utf8_mode = 1;\n" "\n" "status = Py_PreInitialize(&preconfig);\n" "if (PyStatus_Exception(status)) {\n" " Py_ExitStatusException(status);\n" "}\n" "\n" "/* at this point, Python speaks UTF-8 */\n" "\n" "Py_Initialize();\n" "/* ... use Python API here ... */\n" "Py_Finalize();" msgstr "" "PyStatus status;\n" "PyPreConfig preconfig;\n" "PyPreConfig_InitPythonConfig(&preconfig);\n" "\n" "preconfig.utf8_mode = 1;\n" "\n" "status = Py_PreInitialize(&preconfig);\n" "if (PyStatus_Exception(status)) {\n" " Py_ExitStatusException(status);\n" "}\n" "\n" "/* 此时,Python 将使用 UTF-8 */\n" "\n" "Py_Initialize();\n" "/* ... 在此使用 Python API ... */\n" "Py_Finalize();" #: ../../c-api/init_config.rst:433 msgid "PyConfig" msgstr "PyConfig" #: ../../c-api/init_config.rst:437 msgid "Structure containing most parameters to configure Python." msgstr "包含了大部分用于配置 Python 的形参的结构体。" #: ../../c-api/init_config.rst:439 msgid "" "When done, the :c:func:`PyConfig_Clear` function must be used to release the" " configuration memory." msgstr "在完成后,必须使用 :c:func:`PyConfig_Clear` 函数来释放配置内存。" #: ../../c-api/init_config.rst:444 msgid "Structure methods:" msgstr "结构体方法:" #: ../../c-api/init_config.rst:448 msgid "" "Initialize configuration with the :ref:`Python Configuration `." msgstr "通过 :ref:`Python 配置 ` 来初始化配置。" #: ../../c-api/init_config.rst:453 msgid "" "Initialize configuration with the :ref:`Isolated Configuration `." msgstr "通过 :ref:`隔离配置 ` 来初始化配置。" #: ../../c-api/init_config.rst:458 msgid "Copy the wide character string *str* into ``*config_str``." msgstr "将宽字符串 *str* 拷贝至 ``*config_str``。" #: ../../c-api/init_config.rst:460 ../../c-api/init_config.rst:467 #: ../../c-api/init_config.rst:474 ../../c-api/init_config.rst:482 #: ../../c-api/init_config.rst:488 ../../c-api/init_config.rst:505 msgid ":ref:`Preinitialize Python ` if needed." msgstr "在必要时 :ref:`预初始化 Python `。" #: ../../c-api/init_config.rst:464 msgid "" "Decode *str* using :c:func:`Py_DecodeLocale` and set the result into " "``*config_str``." msgstr "使用 :c:func:`Py_DecodeLocale` 对 *str* 进行解码并将结果设置到 ``*config_str``。" #: ../../c-api/init_config.rst:471 msgid "" "Set command line arguments (:c:member:`~PyConfig.argv` member of *config*) " "from the *argv* list of wide character strings." msgstr "根据宽字符串列表 *argv* 设置命令行参数 (*config* 的 :c:member:`~PyConfig.argv` 成员)。" #: ../../c-api/init_config.rst:478 msgid "" "Set command line arguments (:c:member:`~PyConfig.argv` member of *config*) " "from the *argv* list of bytes strings. Decode bytes using " ":c:func:`Py_DecodeLocale`." msgstr "" "根据字节串列表 *argv* 设置命令行参数 (*config* 的 :c:member:`~PyConfig.argv` 成员)。 使用 " ":c:func:`Py_DecodeLocale` 对字节串进行解码。" #: ../../c-api/init_config.rst:486 msgid "Set the list of wide strings *list* to *length* and *items*." msgstr "将宽字符串列表 *list* 设置为 *length* 和 *items*。" #: ../../c-api/init_config.rst:492 msgid "Read all Python configuration." msgstr "读取所有 Python 配置。" #: ../../c-api/init_config.rst:494 msgid "Fields which are already initialized are left unchanged." msgstr "已经初始化的字段会保持不变。" #: ../../c-api/init_config.rst:496 msgid "" "Fields for :ref:`path configuration ` are no longer " "calculated or modified when calling this function, as of Python 3.11." msgstr "调用此函数时不再计算或修改用于 :ref:`路径配置 ` 的字段,如 Python 3.11 那样。" #: ../../c-api/init_config.rst:499 ../../c-api/init_config.rst:1000 msgid "" "The :c:func:`PyConfig_Read` function only parses :c:member:`PyConfig.argv` " "arguments once: :c:member:`PyConfig.parse_argv` is set to ``2`` after " "arguments are parsed. Since Python arguments are stripped from " ":c:member:`PyConfig.argv`, parsing arguments twice would parse the " "application options as Python options." msgstr "" ":c:func:`PyConfig_Read` 函数对 :c:member:`PyConfig.argv` 参数只会解析一次:在参数解析完成后 " ":c:member:`PyConfig.parse_argv` 将被设为 ``2``。 由于 Python 参数是从 " ":c:member:`PyConfig.argv` 提取的,因此解析参数两次会将应用程序选项解析为 Python 选项。" #: ../../c-api/init_config.rst:507 msgid "" "The :c:member:`PyConfig.argv` arguments are now only parsed once, " ":c:member:`PyConfig.parse_argv` is set to ``2`` after arguments are parsed, " "and arguments are only parsed if :c:member:`PyConfig.parse_argv` equals " "``1``." msgstr "" ":c:member:`PyConfig.argv` " "参数现在只会被解析一次,在参数解析完成后,:c:member:`PyConfig.parse_argv` 将被设为 ``2``,只有当 " ":c:member:`PyConfig.parse_argv` 等于 ``1`` 时才会解析参数。" #: ../../c-api/init_config.rst:513 msgid "" ":c:func:`PyConfig_Read` no longer calculates all paths, and so fields listed" " under :ref:`Python Path Configuration ` may no longer be " "updated until :c:func:`Py_InitializeFromConfig` is called." msgstr "" ":c:func:`PyConfig_Read` 不会再计算所有路径,因此在 :ref:`Python 路径配置 ` " "下列出的字段可能不会再更新直到 :c:func:`Py_InitializeFromConfig` 被调用。" #: ../../c-api/init_config.rst:521 msgid "Release configuration memory." msgstr "释放配置内存" #: ../../c-api/init_config.rst:523 msgid "" "Most ``PyConfig`` methods :ref:`preinitialize Python ` if needed." " In that case, the Python preinitialization configuration " "(:c:type:`PyPreConfig`) in based on the :c:type:`PyConfig`. If configuration" " fields which are in common with :c:type:`PyPreConfig` are tuned, they must " "be set before calling a :c:type:`PyConfig` method:" msgstr "" "如有必要大多数 ``PyConfig`` 方法将会 :ref:`预初始化 Python `。 在这种情况下,Python " "预初始化配置 (:c:type:`PyPreConfig`) 将以 :c:type:`PyConfig` 为基础。 如果要调整与 " ":c:type:`PyPreConfig` 相同的配置字段,它们必须在调用 :c:type:`PyConfig` 方法之前被设置:" #: ../../c-api/init_config.rst:529 msgid ":c:member:`PyConfig.dev_mode`" msgstr ":c:member:`PyConfig.dev_mode`" #: ../../c-api/init_config.rst:530 msgid ":c:member:`PyConfig.isolated`" msgstr ":c:member:`PyConfig.isolated`" #: ../../c-api/init_config.rst:531 msgid ":c:member:`PyConfig.parse_argv`" msgstr ":c:member:`PyConfig.parse_argv`" #: ../../c-api/init_config.rst:532 msgid ":c:member:`PyConfig.use_environment`" msgstr ":c:member:`PyConfig.use_environment`" #: ../../c-api/init_config.rst:534 msgid "" "Moreover, if :c:func:`PyConfig_SetArgv` or :c:func:`PyConfig_SetBytesArgv` " "is used, this method must be called before other methods, since the " "preinitialization configuration depends on command line arguments (if " ":c:member:`~PyConfig.parse_argv` is non-zero)." msgstr "" "此外,如果使用了 :c:func:`PyConfig_SetArgv` 或 " ":c:func:`PyConfig_SetBytesArgv`,则必须在调用其他方法之前调用该方法,因为预初始化配置取决于命令行参数(如果 " ":c:member:`~PyConfig.parse_argv` 为非零值)。" #: ../../c-api/init_config.rst:539 msgid "" "The caller of these methods is responsible to handle exceptions (error or " "exit) using ``PyStatus_Exception()`` and ``Py_ExitStatusException()``." msgstr "" "这些方法的调用者要负责使用 ``PyStatus_Exception()`` 和 ``Py_ExitStatusException()`` " "来处理异常(错误或退出)。" #: ../../c-api/init_config.rst:548 msgid "Command line arguments: :data:`sys.argv`." msgstr "命令行参数: :data:`sys.argv`。" #: ../../c-api/init_config.rst:550 msgid "" "Set :c:member:`~PyConfig.parse_argv` to ``1`` to parse " ":c:member:`~PyConfig.argv` the same way the regular Python parses Python " "command line arguments and then to strip Python arguments from " ":c:member:`~PyConfig.argv`." msgstr "" "将 :c:member:`~PyConfig.parse_argv` 设为 ``1`` 将以与普通 Python 解析 Python " "命令行参数相同的方式解析 :c:member:`~PyConfig.argv` 再从 :c:member:`~PyConfig.argv` 中剥离 " "Python 参数。" #: ../../c-api/init_config.rst:555 msgid "" "If :c:member:`~PyConfig.argv` is empty, an empty string is added to ensure " "that :data:`sys.argv` always exists and is never empty." msgstr "" "如果 :c:member:`~PyConfig.argv` 为空,则会添加一个空字符串以确保 :data:`sys.argv` 始终存在并且永远不为空。" #: ../../c-api/init_config.rst:558 ../../c-api/init_config.rst:585 #: ../../c-api/init_config.rst:597 ../../c-api/init_config.rst:605 #: ../../c-api/init_config.rst:713 ../../c-api/init_config.rst:722 #: ../../c-api/init_config.rst:804 ../../c-api/init_config.rst:941 #: ../../c-api/init_config.rst:1042 ../../c-api/init_config.rst:1060 #: ../../c-api/init_config.rst:1074 ../../c-api/init_config.rst:1091 #: ../../c-api/init_config.rst:1104 ../../c-api/init_config.rst:1112 msgid "Default: ``NULL``." msgstr "默认值: ``NULL``." #: ../../c-api/init_config.rst:560 msgid "See also the :c:member:`~PyConfig.orig_argv` member." msgstr "另请参阅 :c:member:`~PyConfig.orig_argv` 成员。" #: ../../c-api/init_config.rst:564 msgid "" "If equals to zero, ``Py_RunMain()`` prepends a potentially unsafe path to " ":data:`sys.path` at startup:" msgstr "如果等于零,``Py_RunMain()`` 会在启动时向 :data:`sys.path` 开头添加一个可能不安全的路径:" #: ../../c-api/init_config.rst:567 msgid "" "If :c:member:`argv[0] ` is equal to ``L\"-m\"`` (``python -m " "module``), prepend the current working directory." msgstr "" "如果 :c:member:`argv[0] ` 等于 ``L\"-m\"`` (``python -m " "module``),则添加当前工作目录。" #: ../../c-api/init_config.rst:569 msgid "" "If running a script (``python script.py``), prepend the script's directory." " If it's a symbolic link, resolve symbolic links." msgstr "如果是运行脚本 (``python script.py``),则添加脚本的目录。 如果是符号链接,则会解析符号链接。" #: ../../c-api/init_config.rst:571 msgid "" "Otherwise (``python -c code`` and ``python``), prepend an empty string, " "which means the current working directory." msgstr "在其他情况下 (``python -c code`` 和 ``python``),将添加一个空字符串,这表示当前工作目录。" #: ../../c-api/init_config.rst:574 msgid "" "Set to ``1`` by the :option:`-P` command line option and the " ":envvar:`PYTHONSAFEPATH` environment variable." msgstr "通过 :option:`-P` 命令行选项和 :envvar:`PYTHONSAFEPATH` 环境变量设置为 ``1``。" #: ../../c-api/init_config.rst:577 msgid "Default: ``0`` in Python config, ``1`` in isolated config." msgstr "默认值:Python 配置中为 ``0``,隔离配置中为 ``1``。" #: ../../c-api/init_config.rst:583 msgid ":data:`sys.base_exec_prefix`." msgstr ":data:`sys.base_exec_prefix`." #: ../../c-api/init_config.rst:587 ../../c-api/init_config.rst:599 #: ../../c-api/init_config.rst:607 ../../c-api/init_config.rst:715 #: ../../c-api/init_config.rst:724 ../../c-api/init_config.rst:958 #: ../../c-api/init_config.rst:1044 msgid "" "Part of the :ref:`Python Path Configuration ` output." msgstr ":ref:`Python 路径配置 ` 的一部分。" #: ../../c-api/init_config.rst:591 msgid "Python base executable: :data:`sys._base_executable`." msgstr "Python 基础可执行文件: :data:`sys._base_executable`。" #: ../../c-api/init_config.rst:593 msgid "Set by the :envvar:`__PYVENV_LAUNCHER__` environment variable." msgstr "由 :envvar:`__PYVENV_LAUNCHER__` 环境变量设置。" #: ../../c-api/init_config.rst:595 msgid "Set from :c:member:`PyConfig.executable` if ``NULL``." msgstr "如为 ``NULL`` 则从 :c:member:`PyConfig.executable` 设置。" #: ../../c-api/init_config.rst:603 msgid ":data:`sys.base_prefix`." msgstr ":data:`sys.base_prefix`." #: ../../c-api/init_config.rst:611 msgid "" "If equals to ``0`` and :c:member:`~PyConfig.configure_c_stdio` is non-zero, " "disable buffering on the C streams stdout and stderr." msgstr "" "如果等于 ``0`` 且 :c:member:`~PyConfig.configure_c_stdio` 为非零值,则禁用 C 数据流 stdout 和" " stderr 的缓冲。" #: ../../c-api/init_config.rst:614 msgid "" "Set to ``0`` by the :option:`-u` command line option and the " ":envvar:`PYTHONUNBUFFERED` environment variable." msgstr "通过 :option:`-u` 命令行选项和 :envvar:`PYTHONUNBUFFERED` 环境变量设置为 ``0``。" #: ../../c-api/init_config.rst:617 msgid "stdin is always opened in buffered mode." msgstr "stdin 始终以缓冲模式打开。" #: ../../c-api/init_config.rst:619 ../../c-api/init_config.rst:652 #: ../../c-api/init_config.rst:1140 ../../c-api/init_config.rst:1271 msgid "Default: ``1``." msgstr "默认值: ``1``." #: ../../c-api/init_config.rst:623 msgid "" "If equals to ``1``, issue a warning when comparing :class:`bytes` or " ":class:`bytearray` with :class:`str`, or comparing :class:`bytes` with " ":class:`int`." msgstr "" "如果等于 ``1``,则在将 :class:`bytes` 或 :class:`bytearray` 与 :class:`str` 进行比较,或将 " ":class:`bytes` 与 :class:`int` 进行比较时发出警告。" #: ../../c-api/init_config.rst:627 msgid "" "If equal or greater to ``2``, raise a :exc:`BytesWarning` exception in these" " cases." msgstr "如果大于等于 ``2``,则在这些情况下引发 :exc:`BytesWarning` 异常。" #: ../../c-api/init_config.rst:630 msgid "Incremented by the :option:`-b` command line option." msgstr "由 :option:`-b` 命令行选项执行递增。" #: ../../c-api/init_config.rst:636 msgid "" "If non-zero, emit a :exc:`EncodingWarning` warning when " ":class:`io.TextIOWrapper` uses its default encoding. See :ref:`io-encoding-" "warning` for details." msgstr "" "如为非零值,则在 :class:`io.TextIOWrapper` 使用默认编码格式时发出 :exc:`EncodingWarning` 警告。 " "详情请参阅 :ref:`io-encoding-warning`。" #: ../../c-api/init_config.rst:645 msgid "" "If equals to ``0``, disables the inclusion of the end line and column " "mappings in code objects. Also disables traceback printing carets to " "specific error locations." msgstr "如果等于 ``0``,则禁用在代码对象中包括末尾行和列映射。 并且禁用在特定错误位置打印回溯标记。" #: ../../c-api/init_config.rst:649 msgid "" "Set to ``0`` by the :envvar:`PYTHONNODEBUGRANGES` environment variable and " "by the :option:`-X no_debug_ranges <-X>` command line option." msgstr "" "通过 :envvar:`PYTHONNODEBUGRANGES` 环境变量和 :option:`-X no_debug_ranges <-X>` " "命令行选项设置为 ``0``。" #: ../../c-api/init_config.rst:658 msgid "" "Control the validation behavior of hash-based ``.pyc`` files: value of the " ":option:`--check-hash-based-pycs` command line option." msgstr "控制基于哈希值的 ``.pyc`` 文件的验证行为: :option:`--check-hash-based-pycs` 命令行选项的值。" #: ../../c-api/init_config.rst:661 msgid "Valid values:" msgstr "有效的值:" #: ../../c-api/init_config.rst:663 msgid "" "``L\"always\"``: Hash the source file for invalidation regardless of value " "of the 'check_source' flag." msgstr "``L\"always\"``: 无论 'check_source' 旗标的值是什么都会对源文件进行哈希验证。" #: ../../c-api/init_config.rst:665 msgid "``L\"never\"``: Assume that hash-based pycs always are valid." msgstr "``L\"never\"``: 假定基于哈希值的 pyc 始终是有效的。" #: ../../c-api/init_config.rst:666 msgid "" "``L\"default\"``: The 'check_source' flag in hash-based pycs determines " "invalidation." msgstr "``L\"default\"``: 基于哈希值的 pyc 中的 'check_source' 旗标确定是否验证无效。" #: ../../c-api/init_config.rst:669 msgid "Default: ``L\"default\"``." msgstr "默认值: ``L\"default\"``。" #: ../../c-api/init_config.rst:671 msgid "See also :pep:`552` \"Deterministic pycs\"." msgstr "参见 :pep:`552` \"Deterministic pycs\"。" #: ../../c-api/init_config.rst:675 msgid "If non-zero, configure C standard streams:" msgstr "如为非零值,则配置 C 标准流:" #: ../../c-api/init_config.rst:677 msgid "" "On Windows, set the binary mode (``O_BINARY``) on stdin, stdout and stderr." msgstr "在 Windows 中,在 stdin, stdout 和 stderr 上设置二进制模式 (``O_BINARY``)。" #: ../../c-api/init_config.rst:679 msgid "" "If :c:member:`~PyConfig.buffered_stdio` equals zero, disable buffering of " "stdin, stdout and stderr streams." msgstr "" "如果 :c:member:`~PyConfig.buffered_stdio` 等于零,则禁用 stdin, stdout 和 stderr 流的缓冲。" #: ../../c-api/init_config.rst:681 msgid "" "If :c:member:`~PyConfig.interactive` is non-zero, enable stream buffering on" " stdin and stdout (only stdout on Windows)." msgstr "" "如果 :c:member:`~PyConfig.interactive` 为非零值,则启用 stdin 和 stdout 上的流缓冲(Windows " "中仅限 stdout)。" #: ../../c-api/init_config.rst:688 msgid "If non-zero, enable the :ref:`Python Development Mode `." msgstr "如果为非零值,则启用 :ref:`Python 开发模式 `。" #: ../../c-api/init_config.rst:690 msgid "" "Set to ``1`` by the :option:`-X dev <-X>` option and the " ":envvar:`PYTHONDEVMODE` environment variable." msgstr "通过 :option:`-X dev <-X>` 选项和 :envvar:`PYTHONDEVMODE` 环境变量设置为 ``1``。" #: ../../c-api/init_config.rst:697 msgid "Dump Python references?" msgstr "转储 Python 引用?" #: ../../c-api/init_config.rst:699 msgid "If non-zero, dump all objects which are still alive at exit." msgstr "如果为非零值,则转储所有在退出时仍存活的对象。" #: ../../c-api/init_config.rst:701 msgid "Set to ``1`` by the :envvar:`PYTHONDUMPREFS` environment variable." msgstr "由 :envvar:`PYTHONDUMPREFS` 环境变量设置为 ``1``。" #: ../../c-api/init_config.rst:703 msgid "" "Need a special build of Python with the ``Py_TRACE_REFS`` macro defined: see" " the :option:`configure --with-trace-refs option <--with-trace-refs>`." msgstr "" "需要定义了 ``Py_TRACE_REFS`` 宏的特殊 Python 编译版:参见 :option:`configure --with-trace-" "refs 选项 <--with-trace-refs>`。" #: ../../c-api/init_config.rst:710 msgid "" "The site-specific directory prefix where the platform-dependent Python files" " are installed: :data:`sys.exec_prefix`." msgstr "安装依赖于平台的 Python 文件的站点专属目录前缀: :data:`sys.exec_prefix`。" #: ../../c-api/init_config.rst:719 msgid "" "The absolute path of the executable binary for the Python interpreter: " ":data:`sys.executable`." msgstr "Python 解释器可执行二进制文件的绝对路径: :data:`sys.executable`。" #: ../../c-api/init_config.rst:728 msgid "Enable faulthandler?" msgstr "启用 faulthandler?" #: ../../c-api/init_config.rst:730 msgid "If non-zero, call :func:`faulthandler.enable` at startup." msgstr "如果为非零值,则在启动时调用 :func:`faulthandler.enable`。" #: ../../c-api/init_config.rst:732 msgid "" "Set to ``1`` by :option:`-X faulthandler <-X>` and the " ":envvar:`PYTHONFAULTHANDLER` environment variable." msgstr "" "通过 :option:`-X faulthandler <-X>` 和 :envvar:`PYTHONFAULTHANDLER` 环境变量设为 " "``1``。" #: ../../c-api/init_config.rst:739 msgid "" ":term:`Filesystem encoding `: " ":func:`sys.getfilesystemencoding`." msgstr "" ":term:`文件系统编码格式 `: " ":func:`sys.getfilesystemencoding`。" #: ../../c-api/init_config.rst:742 msgid "On macOS, Android and VxWorks: use ``\"utf-8\"`` by default." msgstr "在 macOS, Android 和 VxWorks 上:默认使用 ``\"utf-8\"``。" #: ../../c-api/init_config.rst:744 msgid "" "On Windows: use ``\"utf-8\"`` by default, or ``\"mbcs\"`` if " ":c:member:`~PyPreConfig.legacy_windows_fs_encoding` of :c:type:`PyPreConfig`" " is non-zero." msgstr "" "在 Windows 上:默认使用 ``\"utf-8\"``,或者如果 :c:type:`PyPreConfig` 的 " ":c:member:`~PyPreConfig.legacy_windows_fs_encoding` 为非零值则使用 ``\"mbcs\"``。" #: ../../c-api/init_config.rst:748 msgid "Default encoding on other platforms:" msgstr "在其他平台上的默认编码格式:" #: ../../c-api/init_config.rst:750 msgid "``\"utf-8\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero." msgstr "如果 :c:member:`PyPreConfig.utf8_mode` 为非零值则使用 ``\"utf-8\"``。" #: ../../c-api/init_config.rst:751 msgid "" "``\"ascii\"`` if Python detects that ``nl_langinfo(CODESET)`` announces the " "ASCII encoding, whereas the ``mbstowcs()`` function decodes from a different" " encoding (usually Latin1)." msgstr "" "如果 Python 检测到 ``nl_langinfo(CODESET)`` 声明为 ASCII 编码格式,而 ``mbstowcs()`` " "是从其他的编码格式解码(通常为 Latin1)则使用 ``\"ascii\"``。" #: ../../c-api/init_config.rst:754 msgid "``\"utf-8\"`` if ``nl_langinfo(CODESET)`` returns an empty string." msgstr "如果 ``nl_langinfo(CODESET)`` 返回空字符串则使用 ``\"utf-8\"``。" #: ../../c-api/init_config.rst:755 msgid "" "Otherwise, use the :term:`locale encoding`: ``nl_langinfo(CODESET)`` result." msgstr "在其他情况下,使用 :term:`locale encoding`: ``nl_langinfo(CODESET)`` 的结果。" #: ../../c-api/init_config.rst:758 msgid "" "At Python startup, the encoding name is normalized to the Python codec name." " For example, ``\"ANSI_X3.4-1968\"`` is replaced with ``\"ascii\"``." msgstr "" "在 Python 启动时,编码格式名称会规范化为 Python 编解码器名称。 例如,``\"ANSI_X3.4-1968\"`` 将被替换为 " "``\"ascii\"``。" #: ../../c-api/init_config.rst:761 msgid "See also the :c:member:`~PyConfig.filesystem_errors` member." msgstr "参见 :c:member:`~PyConfig.filesystem_errors` 的成员。" #: ../../c-api/init_config.rst:765 msgid "" ":term:`Filesystem error handler `: " ":func:`sys.getfilesystemencodeerrors`." msgstr "" ":term:`文件系统错误处理器 `: " ":func:`sys.getfilesystemencodeerrors`。" #: ../../c-api/init_config.rst:768 msgid "" "On Windows: use ``\"surrogatepass\"`` by default, or ``\"replace\"`` if " ":c:member:`~PyPreConfig.legacy_windows_fs_encoding` of :c:type:`PyPreConfig`" " is non-zero." msgstr "" "在 Windows 上:默认使用 ``\"surrogatepass\"``,或者如果 :c:type:`PyPreConfig` 的 " ":c:member:`~PyPreConfig.legacy_windows_fs_encoding` 为非零值则使用 ``\"replace\"``。" #: ../../c-api/init_config.rst:772 msgid "On other platforms: use ``\"surrogateescape\"`` by default." msgstr "在其他平台上:默认使用 ``\"surrogateescape\"``。" #: ../../c-api/init_config.rst:774 msgid "Supported error handlers:" msgstr "支持的错误处理器:" #: ../../c-api/init_config.rst:776 msgid "``\"strict\"``" msgstr "``\"strict\"``" #: ../../c-api/init_config.rst:777 msgid "``\"surrogateescape\"``" msgstr "``\"surrogateescape\"``" #: ../../c-api/init_config.rst:778 msgid "``\"surrogatepass\"`` (only supported with the UTF-8 encoding)" msgstr "``\"surrogatepass\"`` (仅支持 UTF-8 编码格式)" #: ../../c-api/init_config.rst:780 msgid "See also the :c:member:`~PyConfig.filesystem_encoding` member." msgstr "参见 :c:member:`~PyConfig.filesystem_encoding` 的成员。" #: ../../c-api/init_config.rst:785 msgid "Randomized hash function seed." msgstr "随机化的哈希函数种子。" #: ../../c-api/init_config.rst:787 msgid "" "If :c:member:`~PyConfig.use_hash_seed` is zero, a seed is chosen randomly at" " Python startup, and :c:member:`~PyConfig.hash_seed` is ignored." msgstr "" "如果 :c:member:`~PyConfig.use_hash_seed` 为零,则在 Python 启动时随机选择一个种子,并忽略 " ":c:member:`~PyConfig.hash_seed`。" #: ../../c-api/init_config.rst:790 msgid "Set by the :envvar:`PYTHONHASHSEED` environment variable." msgstr "由 :envvar:`PYTHONHASHSEED` 环境变量设置。" #: ../../c-api/init_config.rst:792 msgid "" "Default *use_hash_seed* value: ``-1`` in Python mode, ``0`` in isolated " "mode." msgstr "默认的 *use_hash_seed* 值:在 Python 模式下为 ``-1``,在隔离模式下为 ``0``。" #: ../../c-api/init_config.rst:797 msgid "Python home directory." msgstr "Python 主目录。" #: ../../c-api/init_config.rst:799 msgid "" "If :c:func:`Py_SetPythonHome` has been called, use its argument if it is not" " ``NULL``." msgstr "如果 :c:func:`Py_SetPythonHome` 已被调用,则当其参数不为 ``NULL`` 时将使用它。" #: ../../c-api/init_config.rst:802 msgid "Set by the :envvar:`PYTHONHOME` environment variable." msgstr "由 :envvar:`PYTHONHOME` 环境变量设置。" #: ../../c-api/init_config.rst:806 ../../c-api/init_config.rst:923 #: ../../c-api/init_config.rst:943 ../../c-api/init_config.rst:1032 #: ../../c-api/init_config.rst:1062 msgid "Part of the :ref:`Python Path Configuration ` input." msgstr ":ref:`Python 路径配置 ` 输入的一部分。" #: ../../c-api/init_config.rst:810 msgid "If non-zero, profile import time." msgstr "如为非零值,则对导入时间执行性能分析。" #: ../../c-api/init_config.rst:812 msgid "" "Set the ``1`` by the :option:`-X importtime <-X>` option and the " ":envvar:`PYTHONPROFILEIMPORTTIME` environment variable." msgstr "" "通过 :option:`-X importtime <-X>` 选项和 :envvar:`PYTHONPROFILEIMPORTTIME` " "环境变量设置为 ``1``。" #: ../../c-api/init_config.rst:819 msgid "Enter interactive mode after executing a script or a command." msgstr "在执行脚本或命令之后进入交互模式。" #: ../../c-api/init_config.rst:821 msgid "" "If greater than ``0``, enable inspect: when a script is passed as first " "argument or the -c option is used, enter interactive mode after executing " "the script or the command, even when :data:`sys.stdin` does not appear to be" " a terminal." msgstr "" "如果大于 ``0`` ,则启用检查:当脚本作为第一个参数传入或使用了 -c 选项时,在执行脚本或命令后进入交互模式,即使在 " ":data:`sys.stdin` 看来并非一个终端时也是如此。" #: ../../c-api/init_config.rst:826 msgid "" "Incremented by the :option:`-i` command line option. Set to ``1`` if the " ":envvar:`PYTHONINSPECT` environment variable is non-empty." msgstr "" "通过 :option:`-i` 命令行选项执行递增。 如果 :envvar:`PYTHONINSPECT` 环境变量为非空值则设为 ``1``。" #: ../../c-api/init_config.rst:833 msgid "Install Python signal handlers?" msgstr "安装 Python 信号处理器?" #: ../../c-api/init_config.rst:835 ../../c-api/init_config.rst:1006 #: ../../c-api/init_config.rst:1030 ../../c-api/init_config.rst:1223 msgid "Default: ``1`` in Python mode, ``0`` in isolated mode." msgstr "默认值:在 Python 模式下为 ``1``,在隔离模式下为 ``0``。" #: ../../c-api/init_config.rst:839 msgid "If greater than ``0``, enable the interactive mode (REPL)." msgstr "如果大于 ``0``,则启用交互模式(REPL)。" #: ../../c-api/init_config.rst:841 msgid "Incremented by the :option:`-i` command line option." msgstr "由 :option:`-i` 命令行选项执行递增。" #: ../../c-api/init_config.rst:847 msgid "" "Configures the :ref:`integer string conversion length limitation " "`. An initial value of ``-1`` means the value will be " "taken from the command line or environment or otherwise default to 4300 " "(:data:`sys.int_info.default_max_str_digits`). A value of ``0`` disables " "the limitation. Values greater than zero but less than 640 " "(:data:`sys.int_info.str_digits_check_threshold`) are unsupported and will " "produce an error." msgstr "" "配置 :ref:`整数字符串转换长度限制 `。 初始值为 ``-1`` 表示该值将从命令行或环境获取否则默认为 " "4300 (:data:`sys.int_info.default_max_str_digits`)。 值为 ``0`` 表示禁用限制。 大于 0 " "但小于 640 (:data:`sys.int_info.str_digits_check_threshold`) 的值将不被支持并会产生错误。" #: ../../c-api/init_config.rst:855 msgid "" "Configured by the :option:`-X int_max_str_digits <-X>` command line flag or " "the :envvar:`PYTHONINTMAXSTRDIGITS` environment variable." msgstr "" "通过 :option:`-X int_max_str_digits <-X>` 命令行旗标或 " ":envvar:`PYTHONINTMAXSTRDIGITS` 环境变量配置。" #: ../../c-api/init_config.rst:858 msgid "" "Default: ``-1`` in Python mode. 4300 " "(:data:`sys.int_info.default_max_str_digits`) in isolated mode." msgstr "" "默认值:在 Python 模式下为 ``-1`` 。 在孤立模式下为 4300 " "(:data:`sys.int_info.default_max_str_digits`)。" #: ../../c-api/init_config.rst:865 msgid "If greater than ``0``, enable isolated mode:" msgstr "如果大于 ``0`` ,则启用隔离模式:" #: ../../c-api/init_config.rst:867 msgid "" "Set :c:member:`~PyConfig.safe_path` to ``1``: don't prepend a potentially " "unsafe path to :data:`sys.path` at Python startup, such as the current " "directory, the script's directory or an empty string." msgstr "" "将 :c:member:`~PyConfig.safe_path` 设为 ``1``: 在 Python 启动时将不在 :data:`sys.path`" " 前添加有潜在不安全性的路径,如当前目录、脚本所在目录或空字符串。" #: ../../c-api/init_config.rst:871 msgid "" "Set :c:member:`~PyConfig.use_environment` to ``0``: ignore ``PYTHON`` " "environment variables." msgstr "将 :c:member:`~PyConfig.use_environment` 设为 ``0``: 忽略 ``PYTHON`` 环境变量。" #: ../../c-api/init_config.rst:873 msgid "" "Set :c:member:`~PyConfig.user_site_directory` to ``0``: don't add the user " "site directory to :data:`sys.path`." msgstr "" "将 :c:member:`~PyConfig.user_site_directory` 设为 ``0``: 不要将用户级站点目录添加到 " ":data:`sys.path`。" #: ../../c-api/init_config.rst:875 msgid "" "Python REPL doesn't import :mod:`readline` nor enable default readline " "configuration on interactive prompts." msgstr "Python REPL 将不导入 :mod:`readline` 也不在交互提示符中启用默认的 readline 配置。" #: ../../c-api/init_config.rst:878 msgid "Set to ``1`` by the :option:`-I` command line option." msgstr "通过 :option:`-I` 命令行选项设置为 ``1``。" #: ../../c-api/init_config.rst:882 msgid "" "See also the :ref:`Isolated Configuration ` and " ":c:member:`PyPreConfig.isolated`." msgstr "" "另请参阅 :ref:`隔离配置 ` 和 :c:member:`PyPreConfig.isolated`。" #: ../../c-api/init_config.rst:887 msgid "" "If non-zero, use :class:`io.FileIO` instead of " ":class:`!io._WindowsConsoleIO` for :data:`sys.stdin`, :data:`sys.stdout` and" " :data:`sys.stderr`." msgstr "" "如为非零值,则使用 :class:`io.FileIO` 代替 :class:`!io._WindowsConsoleIO` 作为 " ":data:`sys.stdin`、:data:`sys.stdout` 和 :data:`sys.stderr`。" #: ../../c-api/init_config.rst:891 msgid "" "Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSSTDIO` environment variable " "is set to a non-empty string." msgstr "如果 :envvar:`PYTHONLEGACYWINDOWSSTDIO` 环境变量被设为非空字符串则设为 ``1``。" #: ../../c-api/init_config.rst:899 msgid "See also the :pep:`528` (Change Windows console encoding to UTF-8)." msgstr "另请参阅 :pep:`528` (将 Windows 控制台编码格式更改为 UTF-8)。" #: ../../c-api/init_config.rst:903 msgid "" "If non-zero, dump statistics on :ref:`Python pymalloc memory allocator " "` at exit." msgstr "如为非零值,则在退出时转储 :ref:`Python pymalloc 内存分配器 ` 的统计数据。" #: ../../c-api/init_config.rst:906 msgid "Set to ``1`` by the :envvar:`PYTHONMALLOCSTATS` environment variable." msgstr "由 :envvar:`PYTHONMALLOCSTATS` 环境变量设置为 ``1``。" #: ../../c-api/init_config.rst:908 msgid "" "The option is ignored if Python is :option:`configured using the --without-" "pymalloc option <--without-pymalloc>`." msgstr "" "如果 Python 是 :option:`使用 --without-pymalloc 选项进行配置 <--without-pymalloc>` " "则该选项将被忽略。" #: ../../c-api/init_config.rst:915 msgid "Platform library directory name: :data:`sys.platlibdir`." msgstr "平台库目录名称: :data:`sys.platlibdir`。" #: ../../c-api/init_config.rst:917 msgid "Set by the :envvar:`PYTHONPLATLIBDIR` environment variable." msgstr "由 :envvar:`PYTHONPLATLIBDIR` 环境变量设置。" #: ../../c-api/init_config.rst:919 msgid "" "Default: value of the ``PLATLIBDIR`` macro which is set by the " ":option:`configure --with-platlibdir option <--with-platlibdir>` (default: " "``\"lib\"``, or ``\"DLLs\"`` on Windows)." msgstr "" "默认值:由 :option:`configure --with-platlibdir 选项 <--with-platlibdir>` 设置的 " "``PLATLIBDIR`` 宏的值 (默认值: ``\"lib\"``,在 Windows 上则为 ``\"DLLs\"``)。" #: ../../c-api/init_config.rst:927 msgid "" "This macro is now used on Windows to locate the standard library extension " "modules, typically under ``DLLs``. However, for compatibility, note that " "this value is ignored for any non-standard layouts, including in-tree builds" " and virtual environments." msgstr "" "目前在 Windows 系统中该宏被用于定位标准库扩展模块,通常位于 ``DLLs`` 下。 " "不过,出于兼容性考虑,请注意在任何非标准布局包括树内构建和虚拟环境中,该值都将被忽略。" #: ../../c-api/init_config.rst:936 msgid "" "Module search paths (:data:`sys.path`) as a string separated by ``DELIM`` " "(:data:`os.pathsep`)." msgstr "模块搜索路径 (:data:`sys.path`) 为一个用 ``DELIM`` (:data:`os.pathsep`) 分隔的字符串。" #: ../../c-api/init_config.rst:939 msgid "Set by the :envvar:`PYTHONPATH` environment variable." msgstr "由 :envvar:`PYTHONPATH` 环境变量设置。" #: ../../c-api/init_config.rst:948 msgid "Module search paths: :data:`sys.path`." msgstr "模块搜索路径: :data:`sys.path`。" #: ../../c-api/init_config.rst:950 msgid "" "If :c:member:`~PyConfig.module_search_paths_set` is equal to ``0``, " ":c:func:`Py_InitializeFromConfig` will replace " ":c:member:`~PyConfig.module_search_paths` and sets " ":c:member:`~PyConfig.module_search_paths_set` to ``1``." msgstr "" "如果 :c:member:`~PyConfig.module_search_paths_set` 等于 " "``0``,:c:func:`Py_InitializeFromConfig` 将替代 " ":c:member:`~PyConfig.module_search_paths` 并将 " ":c:member:`~PyConfig.module_search_paths_set` 设为 ``1``。" #: ../../c-api/init_config.rst:955 msgid "" "Default: empty list (``module_search_paths``) and ``0`` " "(``module_search_paths_set``)." msgstr "" "默认值:空列表 (``module_search_paths``) 和 ``0`` (``module_search_paths_set``)。" #: ../../c-api/init_config.rst:962 msgid "Compilation optimization level:" msgstr "编译优化级别:" #: ../../c-api/init_config.rst:964 msgid "``0``: Peephole optimizer, set ``__debug__`` to ``True``." msgstr "``0``: Peephole 优化器,将 ``__debug__`` 设为 ``True``。" #: ../../c-api/init_config.rst:965 msgid "``1``: Level 0, remove assertions, set ``__debug__`` to ``False``." msgstr "``1``: 0 级,移除断言,将 ``__debug__`` 设为 ``False``。" #: ../../c-api/init_config.rst:966 msgid "``2``: Level 1, strip docstrings." msgstr "``2``: 1 级,去除文档字符串。" #: ../../c-api/init_config.rst:968 msgid "" "Incremented by the :option:`-O` command line option. Set to the " ":envvar:`PYTHONOPTIMIZE` environment variable value." msgstr "通过 :option:`-O` 命令行选项递增。 设置为 :envvar:`PYTHONOPTIMIZE` 环境变量值。" #: ../../c-api/init_config.rst:975 msgid "" "The list of the original command line arguments passed to the Python " "executable: :data:`sys.orig_argv`." msgstr "传给 Python 可执行程序的原始命令行参数列表: :data:`sys.orig_argv`。" #: ../../c-api/init_config.rst:978 msgid "" "If :c:member:`~PyConfig.orig_argv` list is empty and " ":c:member:`~PyConfig.argv` is not a list only containing an empty string, " ":c:func:`PyConfig_Read` copies :c:member:`~PyConfig.argv` into " ":c:member:`~PyConfig.orig_argv` before modifying :c:member:`~PyConfig.argv` " "(if :c:member:`~PyConfig.parse_argv` is non-zero)." msgstr "" "如果 :c:member:`~PyConfig.orig_argv` 列表为空并且 :c:member:`~PyConfig.argv` " "不是一个只包含空字符串的列表,:c:func:`PyConfig_Read` 将在修改 :c:member:`~PyConfig.argv` 之前把 " ":c:member:`~PyConfig.argv` 拷贝至 :c:member:`~PyConfig.orig_argv` (如果 " ":c:member:`~PyConfig.parse_argv` 不为空)。" #: ../../c-api/init_config.rst:985 msgid "" "See also the :c:member:`~PyConfig.argv` member and the " ":c:func:`Py_GetArgcArgv` function." msgstr "另请参阅 :c:member:`~PyConfig.argv` 成员和 :c:func:`Py_GetArgcArgv` 函数。" #: ../../c-api/init_config.rst:988 ../../c-api/init_config.rst:1258 #: ../../c-api/init_config.rst:1277 msgid "Default: empty list." msgstr "默认值:空列表。" #: ../../c-api/init_config.rst:994 msgid "Parse command line arguments?" msgstr "解析命令行参数?" #: ../../c-api/init_config.rst:996 msgid "" "If equals to ``1``, parse :c:member:`~PyConfig.argv` the same way the " "regular Python parses :ref:`command line arguments `, and " "strip Python arguments from :c:member:`~PyConfig.argv`." msgstr "" "如果等于 ``1``,则以与常规 Python 解析 :ref:`命令行参数 ` 相同的方式解析 " ":c:member:`~PyConfig.argv`,并从 :c:member:`~PyConfig.argv` 中剥离 Python 参数。" #: ../../c-api/init_config.rst:1008 msgid "" "The :c:member:`PyConfig.argv` arguments are now only parsed if " ":c:member:`PyConfig.parse_argv` equals to ``1``." msgstr "" "现在只有当 :c:member:`PyConfig.parse_argv` 等于 ``1`` 时才会解析 " ":c:member:`PyConfig.argv` 参数。" #: ../../c-api/init_config.rst:1014 msgid "" "Parser debug mode. If greater than ``0``, turn on parser debugging output " "(for expert only, depending on compilation options)." msgstr "解析器调试模式。 如果大于 ``0``,则打开解析器调试输出(仅针对专家,取决于编译选项)。" #: ../../c-api/init_config.rst:1017 msgid "" "Incremented by the :option:`-d` command line option. Set to the " ":envvar:`PYTHONDEBUG` environment variable value." msgstr "通过 :option:`-d` 命令行选项递增。 设置为 :envvar:`PYTHONDEBUG` 环境变量值。" #: ../../c-api/init_config.rst:1020 msgid "" "Need a :ref:`debug build of Python ` (the ``Py_DEBUG`` macro " "must be defined)." msgstr "需要 :ref:`Python 调试编译版 ` (必须定义 ``Py_DEBUG`` 宏)。" #: ../../c-api/init_config.rst:1027 msgid "" "If non-zero, calculation of path configuration is allowed to log warnings " "into ``stderr``. If equals to ``0``, suppress these warnings." msgstr "如为非零值,则允许计算路径配置以将警告记录到 ``stderr`` 中。 如果等于 ``0``,则抑制这些警告。" #: ../../c-api/init_config.rst:1034 msgid "Now also applies on Windows." msgstr "现在也适用于 Windows。" #: ../../c-api/init_config.rst:1039 msgid "" "The site-specific directory prefix where the platform independent Python " "files are installed: :data:`sys.prefix`." msgstr "安装依赖于平台的 Python 文件的站点专属目录前缀: :data:`sys.prefix`。" #: ../../c-api/init_config.rst:1048 msgid "" "Program name used to initialize :c:member:`~PyConfig.executable` and in " "early error messages during Python initialization." msgstr "用于初始化 :c:member:`~PyConfig.executable` 和在 Python 初始化期间早期错误消息中使用的程序名称。" #: ../../c-api/init_config.rst:1051 msgid "If :func:`Py_SetProgramName` has been called, use its argument." msgstr "如果 :func:`Py_SetProgramName` 已被调用,将使用其参数。" #: ../../c-api/init_config.rst:1052 msgid "On macOS, use :envvar:`PYTHONEXECUTABLE` environment variable if set." msgstr "在 macOS 上,如果设置了 :envvar:`PYTHONEXECUTABLE` 环境变量则会使用它。" #: ../../c-api/init_config.rst:1053 msgid "" "If the ``WITH_NEXT_FRAMEWORK`` macro is defined, use " ":envvar:`__PYVENV_LAUNCHER__` environment variable if set." msgstr "" "如果定义了 ``WITH_NEXT_FRAMEWORK`` 宏,当设置了 :envvar:`__PYVENV_LAUNCHER__` " "环境变量时将会使用它。" #: ../../c-api/init_config.rst:1055 msgid "" "Use ``argv[0]`` of :c:member:`~PyConfig.argv` if available and non-empty." msgstr "如果 :c:member:`~PyConfig.argv` 的 ``argv[0]`` 可用并且不为空值则会使用它。" #: ../../c-api/init_config.rst:1057 msgid "" "Otherwise, use ``L\"python\"`` on Windows, or ``L\"python3\"`` on other " "platforms." msgstr "否则,在 Windows 上将使用 ``L\"python\"``,在其他平台上将使用 ``L\"python3\"``。" #: ../../c-api/init_config.rst:1066 msgid "" "Directory where cached ``.pyc`` files are written: " ":data:`sys.pycache_prefix`." msgstr "缓存 ``.pyc`` 文件被写入到的目录: :data:`sys.pycache_prefix`。" #: ../../c-api/init_config.rst:1069 msgid "" "Set by the :option:`-X pycache_prefix=PATH <-X>` command line option and the" " :envvar:`PYTHONPYCACHEPREFIX` environment variable." msgstr "" "通过 :option:`-X pycache_prefix=PATH <-X>` 命令行选项和 " ":envvar:`PYTHONPYCACHEPREFIX` 环境变量设置。" #: ../../c-api/init_config.rst:1072 msgid "If ``NULL``, :data:`sys.pycache_prefix` is set to ``None``." msgstr "如果为 ``NULL``,则 :data:`sys.pycache_prefix` 将被设为 ``None``。" #: ../../c-api/init_config.rst:1078 msgid "" "Quiet mode. If greater than ``0``, don't display the copyright and version " "at Python startup in interactive mode." msgstr "安静模式。 如果大于 ``0``,则在交互模式下启动 Python 时不显示版权和版本。" #: ../../c-api/init_config.rst:1081 msgid "Incremented by the :option:`-q` command line option." msgstr "由 :option:`-q` 命令行选项执行递增。" #: ../../c-api/init_config.rst:1087 msgid "Value of the :option:`-c` command line option." msgstr ":option:`-c` 命令行选项的值。" #: ../../c-api/init_config.rst:1089 ../../c-api/init_config.rst:1110 msgid "Used by :c:func:`Py_RunMain`." msgstr "由 :c:func:`Py_RunMain` 使用。" #: ../../c-api/init_config.rst:1095 msgid "" "Filename passed on the command line: trailing command line argument without " ":option:`-c` or :option:`-m`. It is used by the :c:func:`Py_RunMain` " "function." msgstr "" "通过命令行传入的文件名:不包含 :option:`-c` 或 :option:`-m` 的附加命令行参数。 它会被 " ":c:func:`Py_RunMain` 函数使用。" #: ../../c-api/init_config.rst:1099 msgid "" "For example, it is set to ``script.py`` by the ``python3 script.py arg`` " "command line." msgstr "例如,对于命令行 ``python3 script.py arg`` 它将被设为 ``script.py``。" #: ../../c-api/init_config.rst:1102 msgid "See also the :c:member:`PyConfig.skip_source_first_line` option." msgstr "另请参阅 :c:member:`PyConfig.skip_source_first_line` 选项。" #: ../../c-api/init_config.rst:1108 msgid "Value of the :option:`-m` command line option." msgstr ":option:`-m` 命令行选项的值。" #: ../../c-api/init_config.rst:1116 msgid "Show total reference count at exit (excluding immortal objects)?" msgstr "在退出时显示总引用计数(不包括永生对象)?" #: ../../c-api/init_config.rst:1118 msgid "Set to ``1`` by :option:`-X showrefcount <-X>` command line option." msgstr "通过 :option:`-X showrefcount <-X>` 命令行选项设置为 ``1``。" #: ../../c-api/init_config.rst:1120 msgid "" "Need a :ref:`debug build of Python ` (the ``Py_REF_DEBUG`` " "macro must be defined)." msgstr "需要 :ref:`Python 调试编译版 ` (必须定义 ``Py_REF_DEBUG`` 宏)。" #: ../../c-api/init_config.rst:1127 msgid "Import the :mod:`site` module at startup?" msgstr "在启动时导入 :mod:`site` 模块?" #: ../../c-api/init_config.rst:1129 msgid "" "If equal to zero, disable the import of the module site and the site-" "dependent manipulations of :data:`sys.path` that it entails." msgstr "如果等于零,则禁用模块站点的导入以及由此产生的与站点相关的 :data:`sys.path` 操作。" #: ../../c-api/init_config.rst:1132 msgid "" "Also disable these manipulations if the :mod:`site` module is explicitly " "imported later (call :func:`site.main` if you want them to be triggered)." msgstr "" "如果以后显式地导入 :mod:`site` 模块也要禁用这些操作(如果你希望触发这些操作,请调用 :func:`site.main` 函数)。" #: ../../c-api/init_config.rst:1135 msgid "Set to ``0`` by the :option:`-S` command line option." msgstr "通过 :option:`-S` 命令行选项设置为 ``0``。" #: ../../c-api/init_config.rst:1137 msgid "" ":data:`sys.flags.no_site ` is set to the inverted value of " ":c:member:`~PyConfig.site_import`." msgstr "" ":data:`sys.flags.no_site ` 会被设为 :c:member:`~PyConfig.site_import`" " 取反后的值。" #: ../../c-api/init_config.rst:1144 msgid "" "If non-zero, skip the first line of the :c:member:`PyConfig.run_filename` " "source." msgstr "如为非零值,则跳过 :c:member:`PyConfig.run_filename` 源的第一行。" #: ../../c-api/init_config.rst:1147 msgid "" "It allows the usage of non-Unix forms of ``#!cmd``. This is intended for a " "DOS specific hack only." msgstr "它将允许使用非 Unix 形式的 ``#!cmd``。 这是针对 DOS 专属的破解操作。" #: ../../c-api/init_config.rst:1150 msgid "Set to ``1`` by the :option:`-x` command line option." msgstr "通过 :option:`-x` 命令行选项设置为 ``1``。" #: ../../c-api/init_config.rst:1157 msgid "" "Encoding and encoding errors of :data:`sys.stdin`, :data:`sys.stdout` and " ":data:`sys.stderr` (but :data:`sys.stderr` always uses " "``\"backslashreplace\"`` error handler)." msgstr "" ":data:`sys.stdin`、:data:`sys.stdout` 和 :data:`sys.stderr` 的编码格式和编码格式错误(但 " ":data:`sys.stderr` 将始终使用 ``\"backslashreplace\"`` 错误处理器)。" #: ../../c-api/init_config.rst:1161 msgid "" "If :c:func:`Py_SetStandardStreamEncoding` has been called, use its *error* " "and *errors* arguments if they are not ``NULL``." msgstr "" "如果 :c:func:`Py_SetStandardStreamEncoding` 已被调用,则当其 *error* 和 *errors* 参数不为 " "``NULL`` 时将使用它们。" #: ../../c-api/init_config.rst:1164 msgid "" "Use the :envvar:`PYTHONIOENCODING` environment variable if it is non-empty." msgstr "如果 :envvar:`PYTHONIOENCODING` 环境变量非空则会使用它。" #: ../../c-api/init_config.rst:1167 msgid "Default encoding:" msgstr "默认编码格式:" #: ../../c-api/init_config.rst:1169 msgid "``\"UTF-8\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero." msgstr "如果 :c:member:`PyPreConfig.utf8_mode` 为非零值则使用 ``\"UTF-8\"``。" #: ../../c-api/init_config.rst:1170 msgid "Otherwise, use the :term:`locale encoding`." msgstr "在其他情况下,使用 :term:`locale encoding`。" #: ../../c-api/init_config.rst:1172 msgid "Default error handler:" msgstr "默认错误处理器:" #: ../../c-api/init_config.rst:1174 msgid "On Windows: use ``\"surrogateescape\"``." msgstr "在 Windows 上:使用 ``\"surrogateescape\"``。" #: ../../c-api/init_config.rst:1175 msgid "" "``\"surrogateescape\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero, or" " if the LC_CTYPE locale is \"C\" or \"POSIX\"." msgstr "" "如果 :c:member:`PyPreConfig.utf8_mode` 为非零值,或者如果 LC_CTYPE 语言区域为 \"C\" 或 " "\"POSIX\" 则使用 ``\"surrogateescape\"``。" #: ../../c-api/init_config.rst:1177 msgid "``\"strict\"`` otherwise." msgstr "在其他情况下则使用 ``\"strict\"``。" #: ../../c-api/init_config.rst:1181 msgid "Enable tracemalloc?" msgstr "启用 tracemalloc?" #: ../../c-api/init_config.rst:1183 msgid "If non-zero, call :func:`tracemalloc.start` at startup." msgstr "如果为非零值,则在启动时调用 :func:`tracemalloc.start`。" #: ../../c-api/init_config.rst:1185 msgid "" "Set by :option:`-X tracemalloc=N <-X>` command line option and by the " ":envvar:`PYTHONTRACEMALLOC` environment variable." msgstr "" "通过 :option:`-X tracemalloc=N <-X>` 命令行选项和 :envvar:`PYTHONTRACEMALLOC` " "环境变量设置。" #: ../../c-api/init_config.rst:1192 msgid "Enable compatibility mode with the perf profiler?" msgstr "启用与 perf 性能分析器兼容的模式?" #: ../../c-api/init_config.rst:1194 msgid "" "If non-zero, initialize the perf trampoline. See :ref:`perf_profiling` for " "more information." msgstr "如果为非零值,则初始化 perf trampoline。 更多信息参见 :ref:`perf_profiling`。" #: ../../c-api/init_config.rst:1197 msgid "" "Set by :option:`-X perf <-X>` command line option and by the " ":envvar:`PYTHONPERFSUPPORT` environment variable." msgstr "通过 :option:`-X perf <-X>` 命令行选项和 :envvar:`PYTHONPERFSUPPORT` 环境变量设置。" #: ../../c-api/init_config.rst:1200 msgid "Default: ``-1``." msgstr "默认值: ``-1``。" #: ../../c-api/init_config.rst:1206 msgid "Use :ref:`environment variables `?" msgstr "使用 :ref:`环境变量 `?" #: ../../c-api/init_config.rst:1208 msgid "" "If equals to zero, ignore the :ref:`environment variables `." msgstr "如果等于零,则忽略 :ref:`环境变量 `。" #: ../../c-api/init_config.rst:1211 msgid "Set to ``0`` by the :option:`-E` environment variable." msgstr "由 :option:`-E` 环境变量设置为 ``0``。" #: ../../c-api/init_config.rst:1217 msgid "If non-zero, add the user site directory to :data:`sys.path`." msgstr "如果为非零值,则将用户站点目录添加到 :data:`sys.path`。" #: ../../c-api/init_config.rst:1219 msgid "" "Set to ``0`` by the :option:`-s` and :option:`-I` command line options." msgstr "通过 :option:`-s` 和 :option:`-I` 命令行选项设置为 ``0``。" #: ../../c-api/init_config.rst:1221 msgid "Set to ``0`` by the :envvar:`PYTHONNOUSERSITE` environment variable." msgstr "由 :envvar:`PYTHONNOUSERSITE` 环境变量设置为 ``0``。" #: ../../c-api/init_config.rst:1227 msgid "" "Verbose mode. If greater than ``0``, print a message each time a module is " "imported, showing the place (filename or built-in module) from which it is " "loaded." msgstr "详细模式。 如果大于 ``0``,则每次导入模块时都会打印一条消息,显示加载模块的位置(文件名或内置模块)。" #: ../../c-api/init_config.rst:1231 msgid "" "If greater than or equal to ``2``, print a message for each file that is " "checked for when searching for a module. Also provides information on module" " cleanup at exit." msgstr "如果大于等于 ``2``,则为搜索模块时每个被检查的文件打印一条消息。 还在退出时提供关于模块清理的信息。" #: ../../c-api/init_config.rst:1235 msgid "Incremented by the :option:`-v` command line option." msgstr "由 :option:`-v` 命令行选项执行递增。" #: ../../c-api/init_config.rst:1237 msgid "Set by the :envvar:`PYTHONVERBOSE` environment variable value." msgstr "通过 :envvar:`PYTHONVERBOSE` 环境变量值设置。" #: ../../c-api/init_config.rst:1243 msgid "" "Options of the :mod:`warnings` module to build warnings filters, lowest to " "highest priority: :data:`sys.warnoptions`." msgstr ":mod:`warnings` 模块用于构建警告过滤器的选项,优先级从低到高: :data:`sys.warnoptions`。" #: ../../c-api/init_config.rst:1246 msgid "" "The :mod:`warnings` module adds :data:`sys.warnoptions` in the reverse " "order: the last :c:member:`PyConfig.warnoptions` item becomes the first item" " of :data:`warnings.filters` which is checked first (highest priority)." msgstr "" ":mod:`warnings` 模块以相反的顺序添加 :data:`sys.warnoptions`: 最后一个 " ":c:member:`PyConfig.warnoptions` 条目将成为 :data:`warnings.filters` " "的第一个条目并将最先被检查(最高优先级)。" #: ../../c-api/init_config.rst:1251 msgid "" "The :option:`-W` command line options adds its value to " ":c:member:`~PyConfig.warnoptions`, it can be used multiple times." msgstr "" ":option:`-W` 命令行选项会将其值添加到 :c:member:`~PyConfig.warnoptions` 中,它可以被多次使用。" #: ../../c-api/init_config.rst:1254 msgid "" "The :envvar:`PYTHONWARNINGS` environment variable can also be used to add " "warning options. Multiple options can be specified, separated by commas " "(``,``)." msgstr ":envvar:`PYTHONWARNINGS` 环境变量也可被用于添加警告选项。 可以指定多个选项,并以逗号 (``,``) 分隔。" #: ../../c-api/init_config.rst:1262 msgid "" "If equal to ``0``, Python won't try to write ``.pyc`` files on the import of" " source modules." msgstr "如果等于 ``0``,Python 将不会尝试在导入源模块时写入 ``.pyc`` 文件。" #: ../../c-api/init_config.rst:1265 msgid "" "Set to ``0`` by the :option:`-B` command line option and the " ":envvar:`PYTHONDONTWRITEBYTECODE` environment variable." msgstr "" "通过 :option:`-B` 命令行选项和 :envvar:`PYTHONDONTWRITEBYTECODE` 环境变量设置为 ``0``。" #: ../../c-api/init_config.rst:1268 msgid "" ":data:`sys.dont_write_bytecode` is initialized to the inverted value of " ":c:member:`~PyConfig.write_bytecode`." msgstr "" ":data:`sys.dont_write_bytecode` 会被初始化为 :c:member:`~PyConfig.write_bytecode` " "取反后的值。" #: ../../c-api/init_config.rst:1275 msgid "" "Values of the :option:`-X` command line options: :data:`sys._xoptions`." msgstr ":option:`-X` 命令行选项的值: :data:`sys._xoptions`。" #: ../../c-api/init_config.rst:1279 msgid "" "If :c:member:`~PyConfig.parse_argv` is non-zero, :c:member:`~PyConfig.argv` " "arguments are parsed the same way the regular Python parses :ref:`command " "line arguments `, and Python arguments are stripped from " ":c:member:`~PyConfig.argv`." msgstr "" "如果 :c:member:`~PyConfig.parse_argv` 为非零值,则 :c:member:`~PyConfig.argv` " "参数将以与常规 Python 解析 :ref:`命令行参数 ` 相同的方式被解析,并从 " ":c:member:`~PyConfig.argv` 中剥离 Python 参数。" #: ../../c-api/init_config.rst:1284 msgid "" "The :c:member:`~PyConfig.xoptions` options are parsed to set other options: " "see the :option:`-X` command line option." msgstr ":c:member:`~PyConfig.xoptions` 选项将会被解析以设置其他选项:参见 :option:`-X` 命令行选项。" #: ../../c-api/init_config.rst:1289 msgid "The ``show_alloc_count`` field has been removed." msgstr "``show_alloc_count`` 字段已被移除。" #: ../../c-api/init_config.rst:1293 msgid "Initialization with PyConfig" msgstr "使用 PyConfig 初始化" #: ../../c-api/init_config.rst:1295 msgid "Function to initialize Python:" msgstr "用于初始化 Python 的函数:" #: ../../c-api/init_config.rst:1299 msgid "Initialize Python from *config* configuration." msgstr "根据 *config* 配置来初始化 Python。" #: ../../c-api/init_config.rst:1304 msgid "" "If :c:func:`PyImport_FrozenModules`, :c:func:`PyImport_AppendInittab` or " ":c:func:`PyImport_ExtendInittab` are used, they must be set or called after " "Python preinitialization and before the Python initialization. If Python is " "initialized multiple times, :c:func:`PyImport_AppendInittab` or " ":c:func:`PyImport_ExtendInittab` must be called before each Python " "initialization." msgstr "" "如果使用了 :c:func:`PyImport_FrozenModules`、:c:func:`PyImport_AppendInittab` 或 " ":c:func:`PyImport_ExtendInittab`,则必须在 Python 预初始化之后、Python 初始化之前设置或调用它们。 如果 " "Python 被多次初始化,则必须在每次初始化 Python 之前调用 :c:func:`PyImport_AppendInittab` 或 " ":c:func:`PyImport_ExtendInittab`。" #: ../../c-api/init_config.rst:1311 msgid "" "The current configuration (``PyConfig`` type) is stored in " "``PyInterpreterState.config``." msgstr "当前的配置 (``PyConfig`` 类型) 保存在 ``PyInterpreterState.config`` 中。" #: ../../c-api/init_config.rst:1314 msgid "Example setting the program name::" msgstr "设置程序名称的示例::" #: ../../c-api/init_config.rst:1316 msgid "" "void init_python(void)\n" "{\n" " PyStatus status;\n" "\n" " PyConfig config;\n" " PyConfig_InitPythonConfig(&config);\n" "\n" " /* Set the program name. Implicitly preinitialize Python. */\n" " status = PyConfig_SetString(&config, &config.program_name,\n" " L\"/path/to/my_program\");\n" " if (PyStatus_Exception(status)) {\n" " goto exception;\n" " }\n" "\n" " status = Py_InitializeFromConfig(&config);\n" " if (PyStatus_Exception(status)) {\n" " goto exception;\n" " }\n" " PyConfig_Clear(&config);\n" " return;\n" "\n" "exception:\n" " PyConfig_Clear(&config);\n" " Py_ExitStatusException(status);\n" "}" msgstr "" "void init_python(void)\n" "{\n" " PyStatus status;\n" "\n" " PyConfig config;\n" " PyConfig_InitPythonConfig(&config);\n" "\n" " /* 设置程序名称。 隐式地预初始化 Python。 */\n" " status = PyConfig_SetString(&config, &config.program_name,\n" " L\"/path/to/my_program\");\n" " if (PyStatus_Exception(status)) {\n" " goto exception;\n" " }\n" "\n" " status = Py_InitializeFromConfig(&config);\n" " if (PyStatus_Exception(status)) {\n" " goto exception;\n" " }\n" " PyConfig_Clear(&config);\n" " return;\n" "\n" "exception:\n" " PyConfig_Clear(&config);\n" " Py_ExitStatusException(status);\n" "}" #: ../../c-api/init_config.rst:1342 msgid "" "More complete example modifying the default configuration, read the " "configuration, and then override some parameters. Note that since 3.11, many" " parameters are not calculated until initialization, and so values cannot be" " read from the configuration structure. Any values set before initialize is " "called will be left unchanged by initialization::" msgstr "" "更完整的示例会修改默认配置,读取配置,然后覆盖某些参数。 请注意自 3.11 " "版开始,许多参数在初始化之前不会被计算,因此无法从配置结构体中读取值。在调用初始化之前设置的任何值都将不会被初始化操作改变::" #: ../../c-api/init_config.rst:1349 msgid "" "PyStatus init_python(const char *program_name)\n" "{\n" " PyStatus status;\n" "\n" " PyConfig config;\n" " PyConfig_InitPythonConfig(&config);\n" "\n" " /* Set the program name before reading the configuration\n" " (decode byte string from the locale encoding).\n" "\n" " Implicitly preinitialize Python. */\n" " status = PyConfig_SetBytesString(&config, &config.program_name,\n" " program_name);\n" " if (PyStatus_Exception(status)) {\n" " goto done;\n" " }\n" "\n" " /* Read all configuration at once */\n" " status = PyConfig_Read(&config);\n" " if (PyStatus_Exception(status)) {\n" " goto done;\n" " }\n" "\n" " /* Specify sys.path explicitly */\n" " /* If you want to modify the default set of paths, finish\n" " initialization first and then use PySys_GetObject(\"path\") */\n" " config.module_search_paths_set = 1;\n" " status = PyWideStringList_Append(&config.module_search_paths,\n" " L\"/path/to/stdlib\");\n" " if (PyStatus_Exception(status)) {\n" " goto done;\n" " }\n" " status = PyWideStringList_Append(&config.module_search_paths,\n" " L\"/path/to/more/modules\");\n" " if (PyStatus_Exception(status)) {\n" " goto done;\n" " }\n" "\n" " /* Override executable computed by PyConfig_Read() */\n" " status = PyConfig_SetString(&config, &config.executable,\n" " L\"/path/to/my_executable\");\n" " if (PyStatus_Exception(status)) {\n" " goto done;\n" " }\n" "\n" " status = Py_InitializeFromConfig(&config);\n" "\n" "done:\n" " PyConfig_Clear(&config);\n" " return status;\n" "}" msgstr "" "PyStatus init_python(const char *program_name)\n" "{\n" " PyStatus status;\n" "\n" " PyConfig config;\n" " PyConfig_InitPythonConfig(&config);\n" "\n" " /* 在读取配置之前设置程序名称\n" " (基于语言区域的编码格式来解码字节串)。\n" "\n" " Implicitly preinitialize Python. */\n" " status = PyConfig_SetBytesString(&config, &config.program_name,\n" " program_name);\n" " if (PyStatus_Exception(status)) {\n" " goto done;\n" " }\n" "\n" " /* 一次性读取所有配置 */\n" " status = PyConfig_Read(&config);\n" " if (PyStatus_Exception(status)) {\n" " goto done;\n" " }\n" "\n" " /* 显式地指定 sys.path */\n" " /* 如果你希望修改默认的路径集合,\n" " 可先完成初始化再使用 PySys_GetObject(\"path\") */\n" " config.module_search_paths_set = 1;\n" " status = PyWideStringList_Append(&config.module_search_paths,\n" " L\"/path/to/stdlib\");\n" " if (PyStatus_Exception(status)) {\n" " goto done;\n" " }\n" " status = PyWideStringList_Append(&config.module_search_paths,\n" " L\"/path/to/more/modules\");\n" " if (PyStatus_Exception(status)) {\n" " goto done;\n" " }\n" "\n" " /* Override executable computed by PyConfig_Read() */\n" " status = PyConfig_SetString(&config, &config.executable,\n" " L\"/path/to/my_executable\");\n" " if (PyStatus_Exception(status)) {\n" " goto done;\n" " }\n" "\n" " status = Py_InitializeFromConfig(&config);\n" "\n" "done:\n" " PyConfig_Clear(&config);\n" " return status;\n" "}" #: ../../c-api/init_config.rst:1405 msgid "Isolated Configuration" msgstr "隔离配置" #: ../../c-api/init_config.rst:1407 msgid "" ":c:func:`PyPreConfig_InitIsolatedConfig` and " ":c:func:`PyConfig_InitIsolatedConfig` functions create a configuration to " "isolate Python from the system. For example, to embed Python into an " "application." msgstr "" ":c:func:`PyPreConfig_InitIsolatedConfig` 和 " ":c:func:`PyConfig_InitIsolatedConfig` 函数会创建一个配置来将 Python 与系统隔离开来。 例如,将 " "Python 嵌入到某个应用程序。" #: ../../c-api/init_config.rst:1412 msgid "" "This configuration ignores global configuration variables, environment " "variables, command line arguments (:c:member:`PyConfig.argv` is not parsed) " "and user site directory. The C standard streams (ex: ``stdout``) and the " "LC_CTYPE locale are left unchanged. Signal handlers are not installed." msgstr "" "该配置将忽略全局配置变量、环境变量、命令行参数 (:c:member:`PyConfig.argv` 将不会被解析) 和用户站点目录。 C 标准流 " "(例如 ``stdout``) 和 LC_CTYPE 语言区域将保持不变。 信号处理器将不会被安装。" #: ../../c-api/init_config.rst:1417 msgid "" "Configuration files are still used with this configuration to determine " "paths that are unspecified. Ensure :c:member:`PyConfig.home` is specified to" " avoid computing the default path configuration." msgstr "" "该配置仍然会使用配置文件来确定未被指明的路径。 请确保指定了 :c:member:`PyConfig.home` 以避免计算默认的路径配置。" #: ../../c-api/init_config.rst:1425 msgid "Python Configuration" msgstr "Python 配置" #: ../../c-api/init_config.rst:1427 msgid "" ":c:func:`PyPreConfig_InitPythonConfig` and " ":c:func:`PyConfig_InitPythonConfig` functions create a configuration to " "build a customized Python which behaves as the regular Python." msgstr "" ":c:func:`PyPreConfig_InitPythonConfig` 和 :c:func:`PyConfig_InitPythonConfig`" " 函数会创建一个配置来构建一个行为与常规 Python 相同的自定义 Python。" #: ../../c-api/init_config.rst:1431 msgid "" "Environments variables and command line arguments are used to configure " "Python, whereas global configuration variables are ignored." msgstr "环境变量和命令行参数将被用于配置 Python,而全局配置变量将被忽略。" #: ../../c-api/init_config.rst:1434 msgid "" "This function enables C locale coercion (:pep:`538`) and :ref:`Python UTF-8 " "Mode ` (:pep:`540`) depending on the LC_CTYPE locale, " ":envvar:`PYTHONUTF8` and :envvar:`PYTHONCOERCECLOCALE` environment " "variables." msgstr "" "此函数将根据 LC_CTYPE 语言区域、:envvar:`PYTHONUTF8` 和 :envvar:`PYTHONCOERCECLOCALE` " "环境变量启用 C 语言区域强制转换 (:pep:`538`) 和 :ref:`Python UTF-8 模式 ` " "(:pep:`540`)。" #: ../../c-api/init_config.rst:1443 msgid "Python Path Configuration" msgstr "Python 路径配置" #: ../../c-api/init_config.rst:1445 msgid "" ":c:type:`PyConfig` contains multiple fields for the path configuration:" msgstr ":c:type:`PyConfig` 包含多个用于路径配置的字段:" #: ../../c-api/init_config.rst:1447 msgid "Path configuration inputs:" msgstr "路径配置输入:" #: ../../c-api/init_config.rst:1449 msgid ":c:member:`PyConfig.home`" msgstr ":c:member:`PyConfig.home`" #: ../../c-api/init_config.rst:1450 msgid ":c:member:`PyConfig.platlibdir`" msgstr ":c:member:`PyConfig.platlibdir`" #: ../../c-api/init_config.rst:1451 msgid ":c:member:`PyConfig.pathconfig_warnings`" msgstr ":c:member:`PyConfig.pathconfig_warnings`" #: ../../c-api/init_config.rst:1452 msgid ":c:member:`PyConfig.program_name`" msgstr ":c:member:`PyConfig.program_name`" #: ../../c-api/init_config.rst:1453 msgid ":c:member:`PyConfig.pythonpath_env`" msgstr ":c:member:`PyConfig.pythonpath_env`" #: ../../c-api/init_config.rst:1454 msgid "current working directory: to get absolute paths" msgstr "当前工作目录:用于获取绝对路径" #: ../../c-api/init_config.rst:1455 msgid "" "``PATH`` environment variable to get the program full path (from " ":c:member:`PyConfig.program_name`)" msgstr "``PATH`` 环境变量用于获取程序的完整路径 (来自 :c:member:`PyConfig.program_name`)" #: ../../c-api/init_config.rst:1457 msgid "``__PYVENV_LAUNCHER__`` environment variable" msgstr "``__PYVENV_LAUNCHER__`` 环境变量" #: ../../c-api/init_config.rst:1458 msgid "" "(Windows only) Application paths in the registry under " "\"Software\\Python\\PythonCore\\X.Y\\PythonPath\" of HKEY_CURRENT_USER and " "HKEY_LOCAL_MACHINE (where X.Y is the Python version)." msgstr "" "(仅限 Windows only) 注册表 HKEY_CURRENT_USER 和 HKEY_LOCAL_MACHINE 的 " "\"Software\\Python\\PythonCore\\X.Y\\PythonPath\" 项下的应用程序目录(其中 X.Y 为 Python " "版本)。" #: ../../c-api/init_config.rst:1462 msgid "Path configuration output fields:" msgstr "路径配置输出字段:" #: ../../c-api/init_config.rst:1464 msgid ":c:member:`PyConfig.base_exec_prefix`" msgstr ":c:member:`PyConfig.base_exec_prefix`" #: ../../c-api/init_config.rst:1465 msgid ":c:member:`PyConfig.base_executable`" msgstr ":c:member:`PyConfig.base_executable`" #: ../../c-api/init_config.rst:1466 msgid ":c:member:`PyConfig.base_prefix`" msgstr ":c:member:`PyConfig.base_prefix`" #: ../../c-api/init_config.rst:1467 msgid ":c:member:`PyConfig.exec_prefix`" msgstr ":c:member:`PyConfig.exec_prefix`" #: ../../c-api/init_config.rst:1468 msgid ":c:member:`PyConfig.executable`" msgstr ":c:member:`PyConfig.executable`" #: ../../c-api/init_config.rst:1469 msgid "" ":c:member:`PyConfig.module_search_paths_set`, " ":c:member:`PyConfig.module_search_paths`" msgstr "" ":c:member:`PyConfig.module_search_paths_set`, " ":c:member:`PyConfig.module_search_paths`" #: ../../c-api/init_config.rst:1471 msgid ":c:member:`PyConfig.prefix`" msgstr ":c:member:`PyConfig.prefix`" #: ../../c-api/init_config.rst:1473 msgid "" "If at least one \"output field\" is not set, Python calculates the path " "configuration to fill unset fields. If " ":c:member:`~PyConfig.module_search_paths_set` is equal to ``0``, " ":c:member:`~PyConfig.module_search_paths` is overridden and " ":c:member:`~PyConfig.module_search_paths_set` is set to ``1``." msgstr "" "如果至少有一个“输出字段”未被设置,Python 就会计算路径配置来填充未设置的字段。 如果 " ":c:member:`~PyConfig.module_search_paths_set` 等于 ``0``,则 " ":c:member:`~PyConfig.module_search_paths` 将被覆盖并且 " ":c:member:`~PyConfig.module_search_paths_set` 将被设置为 ``1``。" #: ../../c-api/init_config.rst:1479 msgid "" "It is possible to completely ignore the function calculating the default " "path configuration by setting explicitly all path configuration output " "fields listed above. A string is considered as set even if it is non-empty. " "``module_search_paths`` is considered as set if ``module_search_paths_set`` " "is set to ``1``. In this case, ``module_search_paths`` will be used without " "modification." msgstr "" "通过显式地设置上述所有路径配置输出字段可以完全忽略计算默认路径配置的函数。 即使字符串不为空也会被视为已设置。 如果 " "``module_search_paths_set`` 被设为 ``1`` 则 ``module_search_paths`` 会被视为已设置。 " "在这种情况下,``module_search_paths`` 将不加修改地被使用。" #: ../../c-api/init_config.rst:1486 msgid "" "Set :c:member:`~PyConfig.pathconfig_warnings` to ``0`` to suppress warnings " "when calculating the path configuration (Unix only, Windows does not log any" " warning)." msgstr "" "将 :c:member:`~PyConfig.pathconfig_warnings` 设为 ``0`` 以便在计算路径配置时抑制警告(仅限 " "Unix,Windows 不会记录任何警告)。" #: ../../c-api/init_config.rst:1489 msgid "" "If :c:member:`~PyConfig.base_prefix` or " ":c:member:`~PyConfig.base_exec_prefix` fields are not set, they inherit " "their value from :c:member:`~PyConfig.prefix` and " ":c:member:`~PyConfig.exec_prefix` respectively." msgstr "" "如果 :c:member:`~PyConfig.base_prefix` 或 " ":c:member:`~PyConfig.base_exec_prefix` 字段未设置,它们将分别从 " ":c:member:`~PyConfig.prefix` 和 :c:member:`~PyConfig.exec_prefix` 继承其值。" #: ../../c-api/init_config.rst:1493 msgid ":c:func:`Py_RunMain` and :c:func:`Py_Main` modify :data:`sys.path`:" msgstr ":c:func:`Py_RunMain` 和 :c:func:`Py_Main` 将修改 :data:`sys.path`:" #: ../../c-api/init_config.rst:1495 msgid "" "If :c:member:`~PyConfig.run_filename` is set and is a directory which " "contains a ``__main__.py`` script, prepend " ":c:member:`~PyConfig.run_filename` to :data:`sys.path`." msgstr "" "如果 :c:member:`~PyConfig.run_filename` 已设置并且是一个包含 ``__main__.py`` 脚本的目录,则会将 " ":c:member:`~PyConfig.run_filename` 添加到 :data:`sys.path` 的开头。" #: ../../c-api/init_config.rst:1498 msgid "If :c:member:`~PyConfig.isolated` is zero:" msgstr "如果 :c:member:`~PyConfig.isolated` 为零:" #: ../../c-api/init_config.rst:1500 msgid "" "If :c:member:`~PyConfig.run_module` is set, prepend the current directory to" " :data:`sys.path`. Do nothing if the current directory cannot be read." msgstr "" "如果设置了 :c:member:`~PyConfig.run_module`,则将当前目录添加到 :data:`sys.path` 的开头。 " "如果无法读取当前目录则不执行任何操作。" #: ../../c-api/init_config.rst:1502 msgid "" "If :c:member:`~PyConfig.run_filename` is set, prepend the directory of the " "filename to :data:`sys.path`." msgstr "" "如果设置了 :c:member:`~PyConfig.run_filename`,则将文件名的目录添加到 :data:`sys.path` 的开头。" #: ../../c-api/init_config.rst:1504 msgid "Otherwise, prepend an empty string to :data:`sys.path`." msgstr "在其他情况下,则将一个空字符串添加到 :data:`sys.path` 的开头。" #: ../../c-api/init_config.rst:1506 msgid "" "If :c:member:`~PyConfig.site_import` is non-zero, :data:`sys.path` can be " "modified by the :mod:`site` module. If " ":c:member:`~PyConfig.user_site_directory` is non-zero and the user's site-" "package directory exists, the :mod:`site` module appends the user's site-" "package directory to :data:`sys.path`." msgstr "" "如果 :c:member:`~PyConfig.site_import` 为非零值,则 :data:`sys.path` 可通过 :mod:`site`" " 模块修改。 如果 :c:member:`~PyConfig.user_site_directory` 为非零值且用户的 site-package " "目录存在,则 :mod:`site` 模块会将用户的 site-package 目录附加到 :data:`sys.path`。" #: ../../c-api/init_config.rst:1512 msgid "The following configuration files are used by the path configuration:" msgstr "路径配置会使用以下配置文件:" #: ../../c-api/init_config.rst:1514 msgid "``pyvenv.cfg``" msgstr "``pyvenv.cfg``" #: ../../c-api/init_config.rst:1515 msgid "``._pth`` file (ex: ``python._pth``)" msgstr "``._pth`` 文件 (例如: ``python._pth``)" #: ../../c-api/init_config.rst:1516 msgid "``pybuilddir.txt`` (Unix only)" msgstr "``pybuilddir.txt`` (仅Unix)" #: ../../c-api/init_config.rst:1518 msgid "If a ``._pth`` file is present:" msgstr "如果存在 ``._pth`` 文件:" #: ../../c-api/init_config.rst:1520 msgid "Set :c:member:`~PyConfig.isolated` to ``1``." msgstr "将 :c:member:`~PyConfig.isolated` 设为 ``1``。" #: ../../c-api/init_config.rst:1521 msgid "Set :c:member:`~PyConfig.use_environment` to ``0``." msgstr "将 :c:member:`~PyConfig.use_environment` 设为 ``0``。" #: ../../c-api/init_config.rst:1522 msgid "Set :c:member:`~PyConfig.site_import` to ``0``." msgstr "将 :c:member:`~PyConfig.site_import` 设为 ``0``。" #: ../../c-api/init_config.rst:1523 msgid "Set :c:member:`~PyConfig.safe_path` to ``1``." msgstr "将 :c:member:`~PyConfig.safe_path` 设为 ``1``。" #: ../../c-api/init_config.rst:1525 msgid "" "The ``__PYVENV_LAUNCHER__`` environment variable is used to set " ":c:member:`PyConfig.base_executable`" msgstr "" "``__PYVENV_LAUNCHER__`` 环境变量将被用于设置 :c:member:`PyConfig.base_executable`" #: ../../c-api/init_config.rst:1530 msgid "Py_RunMain()" msgstr "Py_RunMain()" #: ../../c-api/init_config.rst:1534 msgid "" "Execute the command (:c:member:`PyConfig.run_command`), the script " "(:c:member:`PyConfig.run_filename`) or the module " "(:c:member:`PyConfig.run_module`) specified on the command line or in the " "configuration." msgstr "" "执行在命令行或配置中指定的命令 (:c:member:`PyConfig.run_command`)、脚本 " "(:c:member:`PyConfig.run_filename`) 或模块 (:c:member:`PyConfig.run_module`)。" #: ../../c-api/init_config.rst:1539 msgid "By default and when if :option:`-i` option is used, run the REPL." msgstr "在默认情况下如果使用了 :option:`-i` 选项,则运行 REPL。" #: ../../c-api/init_config.rst:1541 msgid "" "Finally, finalizes Python and returns an exit status that can be passed to " "the ``exit()`` function." msgstr "最后,终结化 Python 并返回一个可传递给 ``exit()`` 函数的退出状态。" #: ../../c-api/init_config.rst:1544 msgid "" "See :ref:`Python Configuration ` for an example of " "customized Python always running in isolated mode using " ":c:func:`Py_RunMain`." msgstr "" "请参阅 :ref:`Python 配置 ` 查看一个使用 :c:func:`Py_RunMain` " "在隔离模式下始终运行自定义 Python 的示例。" #: ../../c-api/init_config.rst:1550 msgid "Py_GetArgcArgv()" msgstr "Py_GetArgcArgv()" #: ../../c-api/init_config.rst:1554 msgid "Get the original command line arguments, before Python modified them." msgstr "在 Python 修改原始命令行参数之前,获取这些参数。" #: ../../c-api/init_config.rst:1556 msgid "See also :c:member:`PyConfig.orig_argv` member." msgstr "另请参阅 :c:member:`PyConfig.orig_argv` 成员。" #: ../../c-api/init_config.rst:1560 msgid "Multi-Phase Initialization Private Provisional API" msgstr "多阶段初始化私有暂定 API" #: ../../c-api/init_config.rst:1562 msgid "" "This section is a private provisional API introducing multi-phase " "initialization, the core feature of :pep:`432`:" msgstr "本节介绍的私有暂定 API 引入了多阶段初始化,它是 :pep:`432` 的核心特性:" #: ../../c-api/init_config.rst:1565 msgid "\"Core\" initialization phase, \"bare minimum Python\":" msgstr "“核心”初始化阶段,“最小化的基本 Python”:" #: ../../c-api/init_config.rst:1567 msgid "Builtin types;" msgstr "内置类型;" #: ../../c-api/init_config.rst:1568 msgid "Builtin exceptions;" msgstr "内置异常;" #: ../../c-api/init_config.rst:1569 msgid "Builtin and frozen modules;" msgstr "内置和已冻结模块;" #: ../../c-api/init_config.rst:1570 msgid "" "The :mod:`sys` module is only partially initialized (ex: :data:`sys.path` " "doesn't exist yet)." msgstr ":mod:`sys` 模块仅部分初始化(例如: :data:`sys.path` 尚不存在)。" #: ../../c-api/init_config.rst:1573 msgid "\"Main\" initialization phase, Python is fully initialized:" msgstr "\"主要\"初始化阶段,Python 被完全初始化:" #: ../../c-api/init_config.rst:1575 msgid "Install and configure :mod:`importlib`;" msgstr "安装并配置 :mod:`importlib`;" #: ../../c-api/init_config.rst:1576 msgid "Apply the :ref:`Path Configuration `;" msgstr "应用 :ref:`路径配置 `;" #: ../../c-api/init_config.rst:1577 msgid "Install signal handlers;" msgstr "安装信号处理器;" #: ../../c-api/init_config.rst:1578 msgid "" "Finish :mod:`sys` module initialization (ex: create :data:`sys.stdout` and " ":data:`sys.path`);" msgstr "完成 :mod:`sys` 模块初始化 (例如:创建 :data:`sys.stdout` 和 :data:`sys.path`);" #: ../../c-api/init_config.rst:1580 msgid "" "Enable optional features like :mod:`faulthandler` and :mod:`tracemalloc`;" msgstr "启用 :mod:`faulthandler` 和 :mod:`tracemalloc` 等可选功能;" #: ../../c-api/init_config.rst:1581 msgid "Import the :mod:`site` module;" msgstr "导入 :mod:`site` 模块;" #: ../../c-api/init_config.rst:1582 msgid "etc." msgstr "等等." #: ../../c-api/init_config.rst:1584 msgid "Private provisional API:" msgstr "私有临时API:" #: ../../c-api/init_config.rst:1586 msgid "" ":c:member:`PyConfig._init_main`: if set to ``0``, " ":c:func:`Py_InitializeFromConfig` stops at the \"Core\" initialization " "phase." msgstr "" ":c:member:`PyConfig._init_main`: 如果设为 " "``0``,:c:func:`Py_InitializeFromConfig` 将在“核心”初始化阶段停止。" #: ../../c-api/init_config.rst:1591 msgid "" "Move to the \"Main\" initialization phase, finish the Python initialization." msgstr "进入“主要”初始化阶段,完成 Python 初始化。" #: ../../c-api/init_config.rst:1593 msgid "" "No module is imported during the \"Core\" phase and the ``importlib`` module" " is not configured: the :ref:`Path Configuration ` is only" " applied during the \"Main\" phase. It may allow to customize Python in " "Python to override or tune the :ref:`Path Configuration `," " maybe install a custom :data:`sys.meta_path` importer or an import hook, " "etc." msgstr "" "在“核心”阶段不会导入任何模块,也不会配置 ``importlib`` 模块: :ref:`路径配置 ` " "只会在“主要”阶段期间应用。 这可能允许在 Python 中定制 Python 以覆盖或微调 :ref:`路径配置 `,也可能会安装自定义的 :data:`sys.meta_path` 导入器或导入钩子等等。" #: ../../c-api/init_config.rst:1599 msgid "" "It may become possible to calculate the :ref:`Path Configuration ` in Python, after the Core phase and before the Main phase, which is" " one of the :pep:`432` motivation." msgstr "" "在核心阶段之后主要阶段之前,将有可能在 Python 中计算 :ref:`路径配置 `,这是 :pep:`432` " "的动机之一。" #: ../../c-api/init_config.rst:1603 msgid "" "The \"Core\" phase is not properly defined: what should be and what should " "not be available at this phase is not specified yet. The API is marked as " "private and provisional: the API can be modified or even be removed anytime " "until a proper public API is designed." msgstr "" "“核心”阶段并没有完整的定义:在这一阶段什么应该可用什么不应该可用都尚未被指明。 该 API 被标记为私有和暂定的:也就是说该 API " "可以随时被修改甚至被移除直到设计出适用的公共 API。" #: ../../c-api/init_config.rst:1608 msgid "" "Example running Python code between \"Core\" and \"Main\" initialization " "phases::" msgstr "在“核心”和“主要”初始化阶段之间运行 Python 代码的示例::" #: ../../c-api/init_config.rst:1611 msgid "" "void init_python(void)\n" "{\n" " PyStatus status;\n" "\n" " PyConfig config;\n" " PyConfig_InitPythonConfig(&config);\n" " config._init_main = 0;\n" "\n" " /* ... customize 'config' configuration ... */\n" "\n" " status = Py_InitializeFromConfig(&config);\n" " PyConfig_Clear(&config);\n" " if (PyStatus_Exception(status)) {\n" " Py_ExitStatusException(status);\n" " }\n" "\n" " /* Use sys.stderr because sys.stdout is only created\n" " by _Py_InitializeMain() */\n" " int res = PyRun_SimpleString(\n" " \"import sys; \"\n" " \"print('Run Python code before _Py_InitializeMain', \"\n" " \"file=sys.stderr)\");\n" " if (res < 0) {\n" " exit(1);\n" " }\n" "\n" " /* ... put more configuration code here ... */\n" "\n" " status = _Py_InitializeMain();\n" " if (PyStatus_Exception(status)) {\n" " Py_ExitStatusException(status);\n" " }\n" "}" msgstr "" "void init_python(void)\n" "{\n" " PyStatus status;\n" "\n" " PyConfig config;\n" " PyConfig_InitPythonConfig(&config);\n" " config._init_main = 0;\n" "\n" " /* ... 自定义 'config' 配置 ... */\n" "\n" " status = Py_InitializeFromConfig(&config);\n" " PyConfig_Clear(&config);\n" " if (PyStatus_Exception(status)) {\n" " Py_ExitStatusException(status);\n" " }\n" "\n" " /* 使用 sys.stderr 因为 sys.stdout 只能由 _Py_InitializeMain() 创建 */\n" " int res = PyRun_SimpleString(\n" " \"import sys; \"\n" " \"print('Run Python code before _Py_InitializeMain', \"\n" " \"file=sys.stderr)\");\n" " if (res < 0) {\n" " exit(1);\n" " }\n" "\n" " /* ... 这里添加更多配置代码 ... */\n" "\n" " status = _Py_InitializeMain();\n" " if (PyStatus_Exception(status)) {\n" " Py_ExitStatusException(status);\n" " }\n" "}"