@@ -63,7 +63,7 @@ msgstr "示例"
6363msgid ""
6464"Example of customized Python always running with the :ref:`Python "
6565"Development Mode <devmode>` enabled; return ``-1`` on error:"
66- msgstr ""
66+ msgstr "运行时始终启用 :ref:`Python 开发模式 <devmode>` 的定制版 Python 的例子;出错时将返回 ``-1``: "
6767
6868#: ../../c-api/init_config.rst:34
6969msgid ""
@@ -101,71 +101,104 @@ msgid ""
101101" }\n"
102102"}"
103103msgstr ""
104+ "int init_python(void)\n"
105+ "{\n"
106+ " PyInitConfig *config = PyInitConfig_Create();\n"
107+ " if (config == NULL) {\n"
108+ " printf(\" PYTHON INIT ERROR: memory allocation failed\\ n\" );\n"
109+ " return -1;\n"
110+ " }\n"
111+ "\n"
112+ " // 启用 Python 开发模式\n"
113+ " if (PyInitConfig_SetInt(config, \" dev_mode\" , 1) < 0) {\n"
114+ " goto error;\n"
115+ " }\n"
116+ "\n"
117+ " // 使用配置初始化 Python\n"
118+ " if (Py_InitializeFromInitConfig(config) < 0) {\n"
119+ " goto error;\n"
120+ " }\n"
121+ " PyInitConfig_Free(config);\n"
122+ " return 0;\n"
123+ "\n"
124+ "error:\n"
125+ " {\n"
126+ " // 显示错误消息\n"
127+ " //\n"
128+ " // 使用这种不常见的花括号风格,因为你不能\n"
129+ " // 将跳转目标指向变量声明。\n"
130+ " const char *err_msg;\n"
131+ " (void)PyInitConfig_GetError(config, &err_msg);\n"
132+ " printf(\" PYTHON INIT ERROR: %s\\ n\" , err_msg);\n"
133+ " PyInitConfig_Free(config);\n"
134+ " return -1;\n"
135+ " }\n"
136+ "}"
104137
105138#: ../../c-api/init_config.rst:71
106139msgid "Create Config"
107- msgstr ""
140+ msgstr "创建配置 "
108141
109142#: ../../c-api/init_config.rst:75
110143msgid "Opaque structure to configure the Python initialization."
111- msgstr ""
144+ msgstr "用于配置 Python 初始化的不透明结构体。 "
112145
113146#: ../../c-api/init_config.rst:80
114147msgid ""
115148"Create a new initialization configuration using :ref:`Isolated Configuration"
116149" <init-isolated-conf>` default values."
117- msgstr ""
150+ msgstr "使用 :ref:`隔离配置 <init-isolated-conf>` 的默认值新建一个初始化配置。 "
118151
119152#: ../../c-api/init_config.rst:83
120153msgid "It must be freed by :c:func:`PyInitConfig_Free`."
121- msgstr ""
154+ msgstr "它必须由 :c:func:`PyInitConfig_Free` 来释放。 "
122155
123156#: ../../c-api/init_config.rst:85
124157msgid "Return ``NULL`` on memory allocation failure."
125- msgstr ""
158+ msgstr "内存分配失败时返回 ``NULL``。 "
126159
127160#: ../../c-api/init_config.rst:90
128161msgid "Free memory of the initialization configuration *config*."
129- msgstr ""
162+ msgstr "释放初始化配置 *config* 的内存。 "
130163
131164#: ../../c-api/init_config.rst:92
132165msgid "If *config* is ``NULL``, no operation is performed."
133- msgstr ""
166+ msgstr "如果 *config* 为 ``NULL``,则不执行任何操作。 "
134167
135168#: ../../c-api/init_config.rst:96
136169msgid "Error Handling"
137170msgstr "错误处理"
138171
139172#: ../../c-api/init_config.rst:100
140173msgid "Get the *config* error message."
141- msgstr ""
174+ msgstr "获取 *config* 错误消息。 "
142175
143176#: ../../c-api/init_config.rst:102
144177msgid "Set *\\ *err_msg* and return ``1`` if an error is set."
145- msgstr ""
178+ msgstr "如果设置了一个错误则设置 * \\ *err_msg* 并返回 ``1``。 "
146179
147180#: ../../c-api/init_config.rst:103
148181msgid "Set *\\ *err_msg* to ``NULL`` and return ``0`` otherwise."
149- msgstr ""
182+ msgstr "在其他情况下将 * \\ *err_msg* 设为 ``NULL`` 并返回 ``0``。 "
150183
151184#: ../../c-api/init_config.rst:105
152185msgid "An error message is an UTF-8 encoded string."
153- msgstr ""
186+ msgstr "错误消息是一个 UTF-8 编码的字符串。 "
154187
155188#: ../../c-api/init_config.rst:107
156189msgid ""
157190"If *config* has an exit code, format the exit code as an error message."
158- msgstr ""
191+ msgstr "如果 *config* 具有一个退出码,则将退出码格式化为错误消息。 "
159192
160193#: ../../c-api/init_config.rst:110
161194msgid ""
162195"The error message remains valid until another ``PyInitConfig`` function is "
163196"called with *config*. The caller doesn't have to free the error message."
164- msgstr ""
197+ msgstr "错误消息将保持无效直到调用另一个 ``PyInitConfig`` 并附带 *config*。 调用方不必释放错误消息。 "
165198
166199#: ../../c-api/init_config.rst:117
167200msgid "Get the *config* exit code."
168- msgstr ""
201+ msgstr "获取 *config* 退出码。 "
169202
170203#: ../../c-api/init_config.rst:119
171204msgid "Set *\\ *exitcode* and return ``1`` if *config* has an exit code set."
0 commit comments