gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

799 lines
76KB

  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta property="og:title" content="Operating System Utilities" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/c-api/sys.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="System Functions: These are utility functions that make functionality from the sys module accessible to C code. They all work with the current interpreter thread’s sys module’s dict, which is conta..." />
  11. <meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
  12. <meta property="og:image:alt" content="Python documentation" />
  13. <meta name="description" content="System Functions: These are utility functions that make functionality from the sys module accessible to C code. They all work with the current interpreter thread’s sys module’s dict, which is conta..." />
  14. <meta property="og:image:width" content="200" />
  15. <meta property="og:image:height" content="200" />
  16. <meta name="theme-color" content="#3776ab" />
  17. <title>Operating System Utilities &#8212; Python 3.12.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=bb723527" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=b20cc3f5" />
  21. <script src="../_static/documentation_options.js?v=2c828074"></script>
  22. <script src="../_static/doctools.js?v=888ff710"></script>
  23. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  24. <script src="../_static/sidebar.js"></script>
  25. <link rel="search" type="application/opensearchdescription+xml"
  26. title="Search within Python 3.12.3 documentation"
  27. href="../_static/opensearch.xml"/>
  28. <link rel="author" title="About these documents" href="../about.html" />
  29. <link rel="index" title="Index" href="../genindex.html" />
  30. <link rel="search" title="Search" href="../search.html" />
  31. <link rel="copyright" title="Copyright" href="../copyright.html" />
  32. <link rel="next" title="Importing Modules" href="import.html" />
  33. <link rel="prev" title="Utilities" href="utilities.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/c-api/sys.html" />
  35. <style>
  36. @media only screen {
  37. table.full-width-table {
  38. width: 100%;
  39. }
  40. }
  41. </style>
  42. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  43. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  44. <script type="text/javascript" src="../_static/copybutton.js"></script>
  45. <script type="text/javascript" src="../_static/menu.js"></script>
  46. <script type="text/javascript" src="../_static/search-focus.js"></script>
  47. <script type="text/javascript" src="../_static/themetoggle.js"></script>
  48. </head>
  49. <body>
  50. <div class="mobile-nav">
  51. <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
  52. aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
  53. <nav class="nav-content" role="navigation">
  54. <label for="menuToggler" class="toggler__label">
  55. <span></span>
  56. </label>
  57. <span class="nav-items-wrapper">
  58. <a href="https://www.python.org/" class="nav-logo">
  59. <img src="../_static/py.svg" alt="Python logo"/>
  60. </a>
  61. <span class="version_switcher_placeholder"></span>
  62. <form role="search" class="search" action="../search.html" method="get">
  63. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
  64. <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
  65. </svg>
  66. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  67. <input type="submit" value="Go"/>
  68. </form>
  69. </span>
  70. </nav>
  71. <div class="menu-wrapper">
  72. <nav class="menu" role="navigation" aria-label="main navigation">
  73. <div class="language_switcher_placeholder"></div>
  74. <label class="theme-selector-label">
  75. Theme
  76. <select class="theme-selector" oninput="activateTheme(this.value)">
  77. <option value="auto" selected>Auto</option>
  78. <option value="light">Light</option>
  79. <option value="dark">Dark</option>
  80. </select>
  81. </label>
  82. <div>
  83. <h3><a href="../contents.html">Table of Contents</a></h3>
  84. <ul>
  85. <li><a class="reference internal" href="#">Operating System Utilities</a></li>
  86. <li><a class="reference internal" href="#system-functions">System Functions</a></li>
  87. <li><a class="reference internal" href="#process-control">Process Control</a></li>
  88. </ul>
  89. </div>
  90. <div>
  91. <h4>Previous topic</h4>
  92. <p class="topless"><a href="utilities.html"
  93. title="previous chapter">Utilities</a></p>
  94. </div>
  95. <div>
  96. <h4>Next topic</h4>
  97. <p class="topless"><a href="import.html"
  98. title="next chapter">Importing Modules</a></p>
  99. </div>
  100. <div role="note" aria-label="source link">
  101. <h3>This Page</h3>
  102. <ul class="this-page-menu">
  103. <li><a href="../bugs.html">Report a Bug</a></li>
  104. <li>
  105. <a href="https://github.com/python/cpython/blob/main/Doc/c-api/sys.rst"
  106. rel="nofollow">Show Source
  107. </a>
  108. </li>
  109. </ul>
  110. </div>
  111. </nav>
  112. </div>
  113. </div>
  114. <div class="related" role="navigation" aria-label="related navigation">
  115. <h3>Navigation</h3>
  116. <ul>
  117. <li class="right" style="margin-right: 10px">
  118. <a href="../genindex.html" title="General Index"
  119. accesskey="I">index</a></li>
  120. <li class="right" >
  121. <a href="../py-modindex.html" title="Python Module Index"
  122. >modules</a> |</li>
  123. <li class="right" >
  124. <a href="import.html" title="Importing Modules"
  125. accesskey="N">next</a> |</li>
  126. <li class="right" >
  127. <a href="utilities.html" title="Utilities"
  128. accesskey="P">previous</a> |</li>
  129. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  130. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  131. <li class="switchers">
  132. <div class="language_switcher_placeholder"></div>
  133. <div class="version_switcher_placeholder"></div>
  134. </li>
  135. <li>
  136. </li>
  137. <li id="cpython-language-and-version">
  138. <a href="../index.html">3.12.3 Documentation</a> &#187;
  139. </li>
  140. <li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> &#187;</li>
  141. <li class="nav-item nav-item-2"><a href="utilities.html" accesskey="U">Utilities</a> &#187;</li>
  142. <li class="nav-item nav-item-this"><a href="">Operating System Utilities</a></li>
  143. <li class="right">
  144. <div class="inline-search" role="search">
  145. <form class="inline-search" action="../search.html" method="get">
  146. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  147. <input type="submit" value="Go" />
  148. </form>
  149. </div>
  150. |
  151. </li>
  152. <li class="right">
  153. <label class="theme-selector-label">
  154. Theme
  155. <select class="theme-selector" oninput="activateTheme(this.value)">
  156. <option value="auto" selected>Auto</option>
  157. <option value="light">Light</option>
  158. <option value="dark">Dark</option>
  159. </select>
  160. </label> |</li>
  161. </ul>
  162. </div>
  163. <div class="document">
  164. <div class="documentwrapper">
  165. <div class="bodywrapper">
  166. <div class="body" role="main">
  167. <section id="operating-system-utilities">
  168. <span id="os"></span><h1>Operating System Utilities<a class="headerlink" href="#operating-system-utilities" title="Link to this heading">¶</a></h1>
  169. <dl class="c function">
  170. <dt class="sig sig-object c" id="c.PyOS_FSPath">
  171. <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PyOS_FSPath</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">path</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyOS_FSPath" title="Link to this definition">¶</a><br /></dt>
  172. <dd><em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> since version 3.6.</em><p>Return the file system representation for <em>path</em>. If the object is a
  173. <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> or <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object, then a new
  174. <a class="reference internal" href="../glossary.html#term-strong-reference"><span class="xref std std-term">strong reference</span></a> is returned.
  175. If the object implements the <a class="reference internal" href="../library/os.html#os.PathLike" title="os.PathLike"><code class="xref py py-class docutils literal notranslate"><span class="pre">os.PathLike</span></code></a> interface,
  176. then <a class="reference internal" href="../library/os.html#os.PathLike.__fspath__" title="os.PathLike.__fspath__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__fspath__()</span></code></a> is returned as long as it is a
  177. <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> or <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object. Otherwise <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> is raised
  178. and <code class="docutils literal notranslate"><span class="pre">NULL</span></code> is returned.</p>
  179. <div class="versionadded">
  180. <p><span class="versionmodified added">New in version 3.6.</span></p>
  181. </div>
  182. </dd></dl>
  183. <dl class="c function">
  184. <dt class="sig sig-object c" id="c.Py_FdIsInteractive">
  185. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">Py_FdIsInteractive</span></span></span><span class="sig-paren">(</span><span class="n"><span class="pre">FILE</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">fp</span></span>, <span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">filename</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.Py_FdIsInteractive" title="Link to this definition">¶</a><br /></dt>
  186. <dd><p>Return true (nonzero) if the standard I/O file <em>fp</em> with name <em>filename</em> is
  187. deemed interactive. This is the case for files for which <code class="docutils literal notranslate"><span class="pre">isatty(fileno(fp))</span></code>
  188. is true. If the <a class="reference internal" href="init_config.html#c.PyConfig.interactive" title="PyConfig.interactive"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.interactive</span></code></a> is non-zero, this function
  189. also returns true if the <em>filename</em> pointer is <code class="docutils literal notranslate"><span class="pre">NULL</span></code> or if the name is equal to
  190. one of the strings <code class="docutils literal notranslate"><span class="pre">'&lt;stdin&gt;'</span></code> or <code class="docutils literal notranslate"><span class="pre">'???'</span></code>.</p>
  191. <p>This function must not be called before Python is initialized.</p>
  192. </dd></dl>
  193. <dl class="c function">
  194. <dt class="sig sig-object c" id="c.PyOS_BeforeFork">
  195. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyOS_BeforeFork</span></span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyOS_BeforeFork" title="Link to this definition">¶</a><br /></dt>
  196. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> on platforms with fork() since version 3.7.</em><p>Function to prepare some internal state before a process fork. This
  197. should be called before calling <code class="xref c c-func docutils literal notranslate"><span class="pre">fork()</span></code> or any similar function
  198. that clones the current process.
  199. Only available on systems where <code class="xref c c-func docutils literal notranslate"><span class="pre">fork()</span></code> is defined.</p>
  200. <div class="admonition warning">
  201. <p class="admonition-title">Warning</p>
  202. <p>The C <code class="xref c c-func docutils literal notranslate"><span class="pre">fork()</span></code> call should only be made from the
  203. <a class="reference internal" href="init.html#fork-and-threads"><span class="std std-ref">“main” thread</span></a> (of the
  204. <a class="reference internal" href="init.html#sub-interpreter-support"><span class="std std-ref">“main” interpreter</span></a>). The same is
  205. true for <code class="docutils literal notranslate"><span class="pre">PyOS_BeforeFork()</span></code>.</p>
  206. </div>
  207. <div class="versionadded">
  208. <p><span class="versionmodified added">New in version 3.7.</span></p>
  209. </div>
  210. </dd></dl>
  211. <dl class="c function">
  212. <dt class="sig sig-object c" id="c.PyOS_AfterFork_Parent">
  213. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyOS_AfterFork_Parent</span></span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyOS_AfterFork_Parent" title="Link to this definition">¶</a><br /></dt>
  214. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> on platforms with fork() since version 3.7.</em><p>Function to update some internal state after a process fork. This
  215. should be called from the parent process after calling <code class="xref c c-func docutils literal notranslate"><span class="pre">fork()</span></code>
  216. or any similar function that clones the current process, regardless
  217. of whether process cloning was successful.
  218. Only available on systems where <code class="xref c c-func docutils literal notranslate"><span class="pre">fork()</span></code> is defined.</p>
  219. <div class="admonition warning">
  220. <p class="admonition-title">Warning</p>
  221. <p>The C <code class="xref c c-func docutils literal notranslate"><span class="pre">fork()</span></code> call should only be made from the
  222. <a class="reference internal" href="init.html#fork-and-threads"><span class="std std-ref">“main” thread</span></a> (of the
  223. <a class="reference internal" href="init.html#sub-interpreter-support"><span class="std std-ref">“main” interpreter</span></a>). The same is
  224. true for <code class="docutils literal notranslate"><span class="pre">PyOS_AfterFork_Parent()</span></code>.</p>
  225. </div>
  226. <div class="versionadded">
  227. <p><span class="versionmodified added">New in version 3.7.</span></p>
  228. </div>
  229. </dd></dl>
  230. <dl class="c function">
  231. <dt class="sig sig-object c" id="c.PyOS_AfterFork_Child">
  232. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyOS_AfterFork_Child</span></span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyOS_AfterFork_Child" title="Link to this definition">¶</a><br /></dt>
  233. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> on platforms with fork() since version 3.7.</em><p>Function to update internal interpreter state after a process fork.
  234. This must be called from the child process after calling <code class="xref c c-func docutils literal notranslate"><span class="pre">fork()</span></code>,
  235. or any similar function that clones the current process, if there is
  236. any chance the process will call back into the Python interpreter.
  237. Only available on systems where <code class="xref c c-func docutils literal notranslate"><span class="pre">fork()</span></code> is defined.</p>
  238. <div class="admonition warning">
  239. <p class="admonition-title">Warning</p>
  240. <p>The C <code class="xref c c-func docutils literal notranslate"><span class="pre">fork()</span></code> call should only be made from the
  241. <a class="reference internal" href="init.html#fork-and-threads"><span class="std std-ref">“main” thread</span></a> (of the
  242. <a class="reference internal" href="init.html#sub-interpreter-support"><span class="std std-ref">“main” interpreter</span></a>). The same is
  243. true for <code class="docutils literal notranslate"><span class="pre">PyOS_AfterFork_Child()</span></code>.</p>
  244. </div>
  245. <div class="versionadded">
  246. <p><span class="versionmodified added">New in version 3.7.</span></p>
  247. </div>
  248. <div class="admonition seealso">
  249. <p class="admonition-title">See also</p>
  250. <p><a class="reference internal" href="../library/os.html#os.register_at_fork" title="os.register_at_fork"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.register_at_fork()</span></code></a> allows registering custom Python functions
  251. to be called by <a class="reference internal" href="#c.PyOS_BeforeFork" title="PyOS_BeforeFork"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_BeforeFork()</span></code></a>,
  252. <a class="reference internal" href="#c.PyOS_AfterFork_Parent" title="PyOS_AfterFork_Parent"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork_Parent()</span></code></a> and <a class="reference internal" href="#c.PyOS_AfterFork_Child" title="PyOS_AfterFork_Child"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork_Child()</span></code></a>.</p>
  253. </div>
  254. </dd></dl>
  255. <dl class="c function">
  256. <dt class="sig sig-object c" id="c.PyOS_AfterFork">
  257. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyOS_AfterFork</span></span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyOS_AfterFork" title="Link to this definition">¶</a><br /></dt>
  258. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> on platforms with fork().</em><p>Function to update some internal state after a process fork; this should be
  259. called in the new process if the Python interpreter will continue to be used.
  260. If a new executable is loaded into the new process, this function does not need
  261. to be called.</p>
  262. <div class="deprecated">
  263. <p><span class="versionmodified deprecated">Deprecated since version 3.7: </span>This function is superseded by <a class="reference internal" href="#c.PyOS_AfterFork_Child" title="PyOS_AfterFork_Child"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork_Child()</span></code></a>.</p>
  264. </div>
  265. </dd></dl>
  266. <dl class="c function">
  267. <dt class="sig sig-object c" id="c.PyOS_CheckStack">
  268. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyOS_CheckStack</span></span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyOS_CheckStack" title="Link to this definition">¶</a><br /></dt>
  269. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> on platforms with USE_STACKCHECK since version 3.7.</em><p id="index-0">Return true when the interpreter runs out of stack space. This is a reliable
  270. check, but is only available when <code class="xref c c-macro docutils literal notranslate"><span class="pre">USE_STACKCHECK</span></code> is defined (currently
  271. on certain versions of Windows using the Microsoft Visual C++ compiler).
  272. <code class="xref c c-macro docutils literal notranslate"><span class="pre">USE_STACKCHECK</span></code> will be defined automatically; you should never
  273. change the definition in your own code.</p>
  274. </dd></dl>
  275. <dl class="c type">
  276. <dt class="sig sig-object c" id="c.PyOS_sighandler_t">
  277. <span class="k"><span class="pre">typedef</span></span><span class="w"> </span><span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="p"><span class="pre">(</span></span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PyOS_sighandler_t</span></span></span><span class="p"><span class="pre">)</span></span><span class="p"><span class="pre">(</span></span><span class="kt"><span class="pre">int</span></span><span class="p"><span class="pre">)</span></span><a class="headerlink" href="#c.PyOS_sighandler_t" title="Link to this definition">¶</a><br /></dt>
  278. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em></dd></dl>
  279. <dl class="c function">
  280. <dt class="sig sig-object c" id="c.PyOS_getsig">
  281. <a class="reference internal" href="#c.PyOS_sighandler_t" title="PyOS_sighandler_t"><span class="n"><span class="pre">PyOS_sighandler_t</span></span></a><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyOS_getsig</span></span></span><span class="sig-paren">(</span><span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">i</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyOS_getsig" title="Link to this definition">¶</a><br /></dt>
  282. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Return the current signal handler for signal <em>i</em>. This is a thin wrapper around
  283. either <code class="xref c c-func docutils literal notranslate"><span class="pre">sigaction()</span></code> or <code class="xref c c-func docutils literal notranslate"><span class="pre">signal()</span></code>. Do not call those functions
  284. directly!</p>
  285. </dd></dl>
  286. <dl class="c function">
  287. <dt class="sig sig-object c" id="c.PyOS_setsig">
  288. <a class="reference internal" href="#c.PyOS_sighandler_t" title="PyOS_sighandler_t"><span class="n"><span class="pre">PyOS_sighandler_t</span></span></a><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyOS_setsig</span></span></span><span class="sig-paren">(</span><span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">i</span></span>, <a class="reference internal" href="#c.PyOS_sighandler_t" title="PyOS_sighandler_t"><span class="n"><span class="pre">PyOS_sighandler_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">h</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyOS_setsig" title="Link to this definition">¶</a><br /></dt>
  289. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Set the signal handler for signal <em>i</em> to be <em>h</em>; return the old signal handler.
  290. This is a thin wrapper around either <code class="xref c c-func docutils literal notranslate"><span class="pre">sigaction()</span></code> or <code class="xref c c-func docutils literal notranslate"><span class="pre">signal()</span></code>. Do
  291. not call those functions directly!</p>
  292. </dd></dl>
  293. <dl class="c function">
  294. <dt class="sig sig-object c" id="c.Py_DecodeLocale">
  295. <span class="n"><span class="pre">wchar_t</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">Py_DecodeLocale</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">arg</span></span>, <span class="n"><span class="pre">size_t</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">size</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.Py_DecodeLocale" title="Link to this definition">¶</a><br /></dt>
  296. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> since version 3.7.</em><div class="admonition warning">
  297. <p class="admonition-title">Warning</p>
  298. <p>This function should not be called directly: use the <a class="reference internal" href="init_config.html#c.PyConfig" title="PyConfig"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyConfig</span></code></a>
  299. API with the <a class="reference internal" href="init_config.html#c.PyConfig_SetBytesString" title="PyConfig_SetBytesString"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_SetBytesString()</span></code></a> function which ensures
  300. that <a class="reference internal" href="init_config.html#c-preinit"><span class="std std-ref">Python is preinitialized</span></a>.</p>
  301. <p>This function must not be called before <a class="reference internal" href="init_config.html#c-preinit"><span class="std std-ref">Python is preinitialized</span></a> and so that the LC_CTYPE locale is properly configured: see
  302. the <a class="reference internal" href="init_config.html#c.Py_PreInitialize" title="Py_PreInitialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_PreInitialize()</span></code></a> function.</p>
  303. </div>
  304. <p>Decode a byte string from the <a class="reference internal" href="../glossary.html#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and error handler</span></a>.
  305. If the error handler is <a class="reference internal" href="../library/codecs.html#surrogateescape"><span class="std std-ref">surrogateescape error handler</span></a>, undecodable bytes are decoded as characters in range
  306. U+DC80..U+DCFF; and if a byte sequence can be decoded as a surrogate
  307. character, the bytes are escaped using the surrogateescape error handler
  308. instead of decoding them.</p>
  309. <p>Return a pointer to a newly allocated wide character string, use
  310. <a class="reference internal" href="memory.html#c.PyMem_RawFree" title="PyMem_RawFree"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMem_RawFree()</span></code></a> to free the memory. If size is not <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, write
  311. the number of wide characters excluding the null character into <code class="docutils literal notranslate"><span class="pre">*size</span></code></p>
  312. <p>Return <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on decoding error or memory allocation error. If <em>size</em> is
  313. not <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, <code class="docutils literal notranslate"><span class="pre">*size</span></code> is set to <code class="docutils literal notranslate"><span class="pre">(size_t)-1</span></code> on memory error or set to
  314. <code class="docutils literal notranslate"><span class="pre">(size_t)-2</span></code> on decoding error.</p>
  315. <p>The <a class="reference internal" href="../glossary.html#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and error handler</span></a> are selected by
  316. <a class="reference internal" href="init_config.html#c.PyConfig_Read" title="PyConfig_Read"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Read()</span></code></a>: see <a class="reference internal" href="init_config.html#c.PyConfig.filesystem_encoding" title="PyConfig.filesystem_encoding"><code class="xref c c-member docutils literal notranslate"><span class="pre">filesystem_encoding</span></code></a> and
  317. <a class="reference internal" href="init_config.html#c.PyConfig.filesystem_errors" title="PyConfig.filesystem_errors"><code class="xref c c-member docutils literal notranslate"><span class="pre">filesystem_errors</span></code></a> members of <a class="reference internal" href="init_config.html#c.PyConfig" title="PyConfig"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyConfig</span></code></a>.</p>
  318. <p>Decoding errors should never happen, unless there is a bug in the C
  319. library.</p>
  320. <p>Use the <a class="reference internal" href="#c.Py_EncodeLocale" title="Py_EncodeLocale"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_EncodeLocale()</span></code></a> function to encode the character string
  321. back to a byte string.</p>
  322. <div class="admonition seealso">
  323. <p class="admonition-title">See also</p>
  324. <p>The <a class="reference internal" href="unicode.html#c.PyUnicode_DecodeFSDefaultAndSize" title="PyUnicode_DecodeFSDefaultAndSize"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_DecodeFSDefaultAndSize()</span></code></a> and
  325. <a class="reference internal" href="unicode.html#c.PyUnicode_DecodeLocaleAndSize" title="PyUnicode_DecodeLocaleAndSize"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_DecodeLocaleAndSize()</span></code></a> functions.</p>
  326. </div>
  327. <div class="versionadded">
  328. <p><span class="versionmodified added">New in version 3.5.</span></p>
  329. </div>
  330. <div class="versionchanged">
  331. <p><span class="versionmodified changed">Changed in version 3.7: </span>The function now uses the UTF-8 encoding in the <a class="reference internal" href="../library/os.html#utf8-mode"><span class="std std-ref">Python UTF-8 Mode</span></a>.</p>
  332. </div>
  333. <div class="versionchanged">
  334. <p><span class="versionmodified changed">Changed in version 3.8: </span>The function now uses the UTF-8 encoding on Windows if
  335. <a class="reference internal" href="init_config.html#c.PyPreConfig.legacy_windows_fs_encoding" title="PyPreConfig.legacy_windows_fs_encoding"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyPreConfig.legacy_windows_fs_encoding</span></code></a> is zero;</p>
  336. </div>
  337. </dd></dl>
  338. <dl class="c function">
  339. <dt class="sig sig-object c" id="c.Py_EncodeLocale">
  340. <span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">Py_EncodeLocale</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="n"><span class="pre">wchar_t</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">text</span></span>, <span class="n"><span class="pre">size_t</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">error_pos</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.Py_EncodeLocale" title="Link to this definition">¶</a><br /></dt>
  341. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> since version 3.7.</em><p>Encode a wide character string to the <a class="reference internal" href="../glossary.html#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and error
  342. handler</span></a>. If the error handler is <a class="reference internal" href="../library/codecs.html#surrogateescape"><span class="std std-ref">surrogateescape error handler</span></a>, surrogate characters in the range U+DC80..U+DCFF are
  343. converted to bytes 0x80..0xFF.</p>
  344. <p>Return a pointer to a newly allocated byte string, use <a class="reference internal" href="memory.html#c.PyMem_Free" title="PyMem_Free"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMem_Free()</span></code></a>
  345. to free the memory. Return <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on encoding error or memory allocation
  346. error.</p>
  347. <p>If error_pos is not <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, <code class="docutils literal notranslate"><span class="pre">*error_pos</span></code> is set to <code class="docutils literal notranslate"><span class="pre">(size_t)-1</span></code> on
  348. success, or set to the index of the invalid character on encoding error.</p>
  349. <p>The <a class="reference internal" href="../glossary.html#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and error handler</span></a> are selected by
  350. <a class="reference internal" href="init_config.html#c.PyConfig_Read" title="PyConfig_Read"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Read()</span></code></a>: see <a class="reference internal" href="init_config.html#c.PyConfig.filesystem_encoding" title="PyConfig.filesystem_encoding"><code class="xref c c-member docutils literal notranslate"><span class="pre">filesystem_encoding</span></code></a> and
  351. <a class="reference internal" href="init_config.html#c.PyConfig.filesystem_errors" title="PyConfig.filesystem_errors"><code class="xref c c-member docutils literal notranslate"><span class="pre">filesystem_errors</span></code></a> members of <a class="reference internal" href="init_config.html#c.PyConfig" title="PyConfig"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyConfig</span></code></a>.</p>
  352. <p>Use the <a class="reference internal" href="#c.Py_DecodeLocale" title="Py_DecodeLocale"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_DecodeLocale()</span></code></a> function to decode the bytes string back
  353. to a wide character string.</p>
  354. <div class="admonition warning">
  355. <p class="admonition-title">Warning</p>
  356. <p>This function must not be called before <a class="reference internal" href="init_config.html#c-preinit"><span class="std std-ref">Python is preinitialized</span></a> and so that the LC_CTYPE locale is properly configured: see
  357. the <a class="reference internal" href="init_config.html#c.Py_PreInitialize" title="Py_PreInitialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_PreInitialize()</span></code></a> function.</p>
  358. </div>
  359. <div class="admonition seealso">
  360. <p class="admonition-title">See also</p>
  361. <p>The <a class="reference internal" href="unicode.html#c.PyUnicode_EncodeFSDefault" title="PyUnicode_EncodeFSDefault"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_EncodeFSDefault()</span></code></a> and
  362. <a class="reference internal" href="unicode.html#c.PyUnicode_EncodeLocale" title="PyUnicode_EncodeLocale"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_EncodeLocale()</span></code></a> functions.</p>
  363. </div>
  364. <div class="versionadded">
  365. <p><span class="versionmodified added">New in version 3.5.</span></p>
  366. </div>
  367. <div class="versionchanged">
  368. <p><span class="versionmodified changed">Changed in version 3.7: </span>The function now uses the UTF-8 encoding in the <a class="reference internal" href="../library/os.html#utf8-mode"><span class="std std-ref">Python UTF-8 Mode</span></a>.</p>
  369. </div>
  370. <div class="versionchanged">
  371. <p><span class="versionmodified changed">Changed in version 3.8: </span>The function now uses the UTF-8 encoding on Windows if
  372. <a class="reference internal" href="init_config.html#c.PyPreConfig.legacy_windows_fs_encoding" title="PyPreConfig.legacy_windows_fs_encoding"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyPreConfig.legacy_windows_fs_encoding</span></code></a> is zero.</p>
  373. </div>
  374. </dd></dl>
  375. </section>
  376. <section id="system-functions">
  377. <span id="systemfunctions"></span><h1>System Functions<a class="headerlink" href="#system-functions" title="Link to this heading">¶</a></h1>
  378. <p>These are utility functions that make functionality from the <a class="reference internal" href="../library/sys.html#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> module
  379. accessible to C code. They all work with the current interpreter thread’s
  380. <a class="reference internal" href="../library/sys.html#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> module’s dict, which is contained in the internal thread state structure.</p>
  381. <dl class="c function">
  382. <dt class="sig sig-object c" id="c.PySys_GetObject">
  383. <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PySys_GetObject</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">name</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_GetObject" title="Link to this definition">¶</a><br /></dt>
  384. <dd><em class="refcount">Return value: Borrowed reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Return the object <em>name</em> from the <a class="reference internal" href="../library/sys.html#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> module or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if it does
  385. not exist, without setting an exception.</p>
  386. </dd></dl>
  387. <dl class="c function">
  388. <dt class="sig sig-object c" id="c.PySys_SetObject">
  389. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_SetObject</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">name</span></span>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">v</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_SetObject" title="Link to this definition">¶</a><br /></dt>
  390. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Set <em>name</em> in the <a class="reference internal" href="../library/sys.html#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> module to <em>v</em> unless <em>v</em> is <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, in which
  391. case <em>name</em> is deleted from the sys module. Returns <code class="docutils literal notranslate"><span class="pre">0</span></code> on success, <code class="docutils literal notranslate"><span class="pre">-1</span></code>
  392. on error.</p>
  393. </dd></dl>
  394. <dl class="c function">
  395. <dt class="sig sig-object c" id="c.PySys_ResetWarnOptions">
  396. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_ResetWarnOptions</span></span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_ResetWarnOptions" title="Link to this definition">¶</a><br /></dt>
  397. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Reset <a class="reference internal" href="../library/sys.html#sys.warnoptions" title="sys.warnoptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.warnoptions</span></code></a> to an empty list. This function may be
  398. called prior to <a class="reference internal" href="init.html#c.Py_Initialize" title="Py_Initialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Initialize()</span></code></a>.</p>
  399. </dd></dl>
  400. <dl class="c function">
  401. <dt class="sig sig-object c" id="c.PySys_AddWarnOption">
  402. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_AddWarnOption</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="n"><span class="pre">wchar_t</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">s</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_AddWarnOption" title="Link to this definition">¶</a><br /></dt>
  403. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>This API is kept for backward compatibility: setting
  404. <a class="reference internal" href="init_config.html#c.PyConfig.warnoptions" title="PyConfig.warnoptions"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.warnoptions</span></code></a> should be used instead, see <a class="reference internal" href="init_config.html#init-config"><span class="std std-ref">Python
  405. Initialization Configuration</span></a>.</p>
  406. <p>Append <em>s</em> to <a class="reference internal" href="../library/sys.html#sys.warnoptions" title="sys.warnoptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.warnoptions</span></code></a>. This function must be called prior
  407. to <a class="reference internal" href="init.html#c.Py_Initialize" title="Py_Initialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Initialize()</span></code></a> in order to affect the warnings filter list.</p>
  408. <div class="deprecated">
  409. <p><span class="versionmodified deprecated">Deprecated since version 3.11.</span></p>
  410. </div>
  411. </dd></dl>
  412. <dl class="c function">
  413. <dt class="sig sig-object c" id="c.PySys_AddWarnOptionUnicode">
  414. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_AddWarnOptionUnicode</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">unicode</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_AddWarnOptionUnicode" title="Link to this definition">¶</a><br /></dt>
  415. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>This API is kept for backward compatibility: setting
  416. <a class="reference internal" href="init_config.html#c.PyConfig.warnoptions" title="PyConfig.warnoptions"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.warnoptions</span></code></a> should be used instead, see <a class="reference internal" href="init_config.html#init-config"><span class="std std-ref">Python
  417. Initialization Configuration</span></a>.</p>
  418. <p>Append <em>unicode</em> to <a class="reference internal" href="../library/sys.html#sys.warnoptions" title="sys.warnoptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.warnoptions</span></code></a>.</p>
  419. <p>Note: this function is not currently usable from outside the CPython
  420. implementation, as it must be called prior to the implicit import of
  421. <a class="reference internal" href="../library/warnings.html#module-warnings" title="warnings: Issue warning messages and control their disposition."><code class="xref py py-mod docutils literal notranslate"><span class="pre">warnings</span></code></a> in <a class="reference internal" href="init.html#c.Py_Initialize" title="Py_Initialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Initialize()</span></code></a> to be effective, but can’t be
  422. called until enough of the runtime has been initialized to permit the
  423. creation of Unicode objects.</p>
  424. <div class="deprecated">
  425. <p><span class="versionmodified deprecated">Deprecated since version 3.11.</span></p>
  426. </div>
  427. </dd></dl>
  428. <dl class="c function">
  429. <dt class="sig sig-object c" id="c.PySys_SetPath">
  430. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_SetPath</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="n"><span class="pre">wchar_t</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">path</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_SetPath" title="Link to this definition">¶</a><br /></dt>
  431. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>This API is kept for backward compatibility: setting
  432. <a class="reference internal" href="init_config.html#c.PyConfig.module_search_paths" title="PyConfig.module_search_paths"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.module_search_paths</span></code></a> and
  433. <a class="reference internal" href="init_config.html#c.PyConfig.module_search_paths_set" title="PyConfig.module_search_paths_set"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.module_search_paths_set</span></code></a> should be used instead, see
  434. <a class="reference internal" href="init_config.html#init-config"><span class="std std-ref">Python Initialization Configuration</span></a>.</p>
  435. <p>Set <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> to a list object of paths found in <em>path</em> which should
  436. be a list of paths separated with the platform’s search path delimiter
  437. (<code class="docutils literal notranslate"><span class="pre">:</span></code> on Unix, <code class="docutils literal notranslate"><span class="pre">;</span></code> on Windows).</p>
  438. <div class="deprecated">
  439. <p><span class="versionmodified deprecated">Deprecated since version 3.11.</span></p>
  440. </div>
  441. </dd></dl>
  442. <dl class="c function">
  443. <dt class="sig sig-object c" id="c.PySys_WriteStdout">
  444. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_WriteStdout</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">format</span></span>, <span class="p"><span class="pre">...</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_WriteStdout" title="Link to this definition">¶</a><br /></dt>
  445. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Write the output string described by <em>format</em> to <a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a>. No
  446. exceptions are raised, even if truncation occurs (see below).</p>
  447. <p><em>format</em> should limit the total size of the formatted output string to
  448. 1000 bytes or less – after 1000 bytes, the output string is truncated.
  449. In particular, this means that no unrestricted “%s” formats should occur;
  450. these should be limited using “%.&lt;N&gt;s” where &lt;N&gt; is a decimal number
  451. calculated so that &lt;N&gt; plus the maximum size of other formatted text does not
  452. exceed 1000 bytes. Also watch out for “%f”, which can print hundreds of
  453. digits for very large numbers.</p>
  454. <p>If a problem occurs, or <a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a> is unset, the formatted message
  455. is written to the real (C level) <em>stdout</em>.</p>
  456. </dd></dl>
  457. <dl class="c function">
  458. <dt class="sig sig-object c" id="c.PySys_WriteStderr">
  459. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_WriteStderr</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">format</span></span>, <span class="p"><span class="pre">...</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_WriteStderr" title="Link to this definition">¶</a><br /></dt>
  460. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>As <a class="reference internal" href="#c.PySys_WriteStdout" title="PySys_WriteStdout"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_WriteStdout()</span></code></a>, but write to <a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stderr</span></code></a> or <em>stderr</em>
  461. instead.</p>
  462. </dd></dl>
  463. <dl class="c function">
  464. <dt class="sig sig-object c" id="c.PySys_FormatStdout">
  465. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_FormatStdout</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">format</span></span>, <span class="p"><span class="pre">...</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_FormatStdout" title="Link to this definition">¶</a><br /></dt>
  466. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Function similar to PySys_WriteStdout() but format the message using
  467. <a class="reference internal" href="unicode.html#c.PyUnicode_FromFormatV" title="PyUnicode_FromFormatV"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_FromFormatV()</span></code></a> and don’t truncate the message to an
  468. arbitrary length.</p>
  469. <div class="versionadded">
  470. <p><span class="versionmodified added">New in version 3.2.</span></p>
  471. </div>
  472. </dd></dl>
  473. <dl class="c function">
  474. <dt class="sig sig-object c" id="c.PySys_FormatStderr">
  475. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_FormatStderr</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">format</span></span>, <span class="p"><span class="pre">...</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_FormatStderr" title="Link to this definition">¶</a><br /></dt>
  476. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>As <a class="reference internal" href="#c.PySys_FormatStdout" title="PySys_FormatStdout"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_FormatStdout()</span></code></a>, but write to <a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stderr</span></code></a> or <em>stderr</em>
  477. instead.</p>
  478. <div class="versionadded">
  479. <p><span class="versionmodified added">New in version 3.2.</span></p>
  480. </div>
  481. </dd></dl>
  482. <dl class="c function">
  483. <dt class="sig sig-object c" id="c.PySys_AddXOption">
  484. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_AddXOption</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="n"><span class="pre">wchar_t</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">s</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_AddXOption" title="Link to this definition">¶</a><br /></dt>
  485. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> since version 3.7.</em><p>This API is kept for backward compatibility: setting
  486. <a class="reference internal" href="init_config.html#c.PyConfig.xoptions" title="PyConfig.xoptions"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.xoptions</span></code></a> should be used instead, see <a class="reference internal" href="init_config.html#init-config"><span class="std std-ref">Python
  487. Initialization Configuration</span></a>.</p>
  488. <p>Parse <em>s</em> as a set of <a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> options and add them to the current
  489. options mapping as returned by <a class="reference internal" href="#c.PySys_GetXOptions" title="PySys_GetXOptions"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_GetXOptions()</span></code></a>. This function
  490. may be called prior to <a class="reference internal" href="init.html#c.Py_Initialize" title="Py_Initialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Initialize()</span></code></a>.</p>
  491. <div class="versionadded">
  492. <p><span class="versionmodified added">New in version 3.2.</span></p>
  493. </div>
  494. <div class="deprecated">
  495. <p><span class="versionmodified deprecated">Deprecated since version 3.11.</span></p>
  496. </div>
  497. </dd></dl>
  498. <dl class="c function">
  499. <dt class="sig sig-object c" id="c.PySys_GetXOptions">
  500. <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">PySys_GetXOptions</span></span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_GetXOptions" title="Link to this definition">¶</a><br /></dt>
  501. <dd><em class="refcount">Return value: Borrowed reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a> since version 3.7.</em><p>Return the current dictionary of <a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> options, similarly to
  502. <a class="reference internal" href="../library/sys.html#sys._xoptions" title="sys._xoptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys._xoptions</span></code></a>. On error, <code class="docutils literal notranslate"><span class="pre">NULL</span></code> is returned and an exception is
  503. set.</p>
  504. <div class="versionadded">
  505. <p><span class="versionmodified added">New in version 3.2.</span></p>
  506. </div>
  507. </dd></dl>
  508. <dl class="c function">
  509. <dt class="sig sig-object c" id="c.PySys_Audit">
  510. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_Audit</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">event</span></span>, <span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">format</span></span>, <span class="p"><span class="pre">...</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_Audit" title="Link to this definition">¶</a><br /></dt>
  511. <dd><p>Raise an auditing event with any active hooks. Return zero for success
  512. and non-zero with an exception set on failure.</p>
  513. <p>If any hooks have been added, <em>format</em> and other arguments will be used
  514. to construct a tuple to pass. Apart from <code class="docutils literal notranslate"><span class="pre">N</span></code>, the same format characters
  515. as used in <a class="reference internal" href="arg.html#c.Py_BuildValue" title="Py_BuildValue"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_BuildValue()</span></code></a> are available. If the built value is not
  516. a tuple, it will be added into a single-element tuple. (The <code class="docutils literal notranslate"><span class="pre">N</span></code> format
  517. option consumes a reference, but since there is no way to know whether
  518. arguments to this function will be consumed, using it may cause reference
  519. leaks.)</p>
  520. <p>Note that <code class="docutils literal notranslate"><span class="pre">#</span></code> format characters should always be treated as
  521. <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><code class="xref c c-type docutils literal notranslate"><span class="pre">Py_ssize_t</span></code></a>, regardless of whether <code class="docutils literal notranslate"><span class="pre">PY_SSIZE_T_CLEAN</span></code> was defined.</p>
  522. <p><a class="reference internal" href="../library/sys.html#sys.audit" title="sys.audit"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.audit()</span></code></a> performs the same function from Python code.</p>
  523. <div class="versionadded">
  524. <p><span class="versionmodified added">New in version 3.8.</span></p>
  525. </div>
  526. <div class="versionchanged">
  527. <p><span class="versionmodified changed">Changed in version 3.8.2: </span>Require <a class="reference internal" href="intro.html#c.Py_ssize_t" title="Py_ssize_t"><code class="xref c c-type docutils literal notranslate"><span class="pre">Py_ssize_t</span></code></a> for <code class="docutils literal notranslate"><span class="pre">#</span></code> format characters. Previously, an
  528. unavoidable deprecation warning was raised.</p>
  529. </div>
  530. </dd></dl>
  531. <dl class="c function">
  532. <dt class="sig sig-object c" id="c.PySys_AddAuditHook">
  533. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PySys_AddAuditHook</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.Py_AuditHookFunction" title="Py_AuditHookFunction"><span class="n"><span class="pre">Py_AuditHookFunction</span></span></a><span class="w"> </span><span class="n"><span class="pre">hook</span></span>, <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">userData</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PySys_AddAuditHook" title="Link to this definition">¶</a><br /></dt>
  534. <dd><p>Append the callable <em>hook</em> to the list of active auditing hooks.
  535. Return zero on success
  536. and non-zero on failure. If the runtime has been initialized, also set an
  537. error on failure. Hooks added through this API are called for all
  538. interpreters created by the runtime.</p>
  539. <p>The <em>userData</em> pointer is passed into the hook function. Since hook
  540. functions may be called from different runtimes, this pointer should not
  541. refer directly to Python state.</p>
  542. <p>This function is safe to call before <a class="reference internal" href="init.html#c.Py_Initialize" title="Py_Initialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Initialize()</span></code></a>. When called
  543. after runtime initialization, existing audit hooks are notified and may
  544. silently abort the operation by raising an error subclassed from
  545. <a class="reference internal" href="../library/exceptions.html#Exception" title="Exception"><code class="xref py py-class docutils literal notranslate"><span class="pre">Exception</span></code></a> (other errors will not be silenced).</p>
  546. <p>The hook function is always called with the GIL held by the Python
  547. interpreter that raised the event.</p>
  548. <p>See <span class="target" id="index-1"></span><a class="pep reference external" href="https://peps.python.org/pep-0578/"><strong>PEP 578</strong></a> for a detailed description of auditing. Functions in the
  549. runtime and standard library that raise events are listed in the
  550. <a class="reference internal" href="../library/audit_events.html#audit-events"><span class="std std-ref">audit events table</span></a>.
  551. Details are in each function’s documentation.</p>
  552. <p class="audit-hook"><p>If the interpreter is initialized, this function raises an auditing event
  553. <code class="docutils literal notranslate"><span class="pre">sys.addaudithook</span></code> with no arguments. If any existing hooks raise an
  554. exception derived from <a class="reference internal" href="../library/exceptions.html#Exception" title="Exception"><code class="xref py py-class docutils literal notranslate"><span class="pre">Exception</span></code></a>, the new hook will not be
  555. added and the exception is cleared. As a result, callers cannot assume
  556. that their hook has been added unless they control all existing hooks.</p>
  557. </p>
  558. <dl class="c type">
  559. <dt class="sig sig-object c" id="c.Py_AuditHookFunction">
  560. <span class="k"><span class="pre">typedef</span></span><span class="w"> </span><span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="p"><span class="pre">(</span></span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">Py_AuditHookFunction</span></span></span><span class="p"><span class="pre">)</span></span><span class="p"><span class="pre">(</span></span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">event</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><span class="n"><span class="pre">PyObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">userData</span></span><span class="p"><span class="pre">)</span></span><a class="headerlink" href="#c.Py_AuditHookFunction" title="Link to this definition">¶</a><br /></dt>
  561. <dd><p>The type of the hook function.
  562. <em>event</em> is the C string event argument passed to <a class="reference internal" href="#c.PySys_Audit" title="PySys_Audit"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_Audit()</span></code></a>.
  563. <em>args</em> is guaranteed to be a <a class="reference internal" href="tuple.html#c.PyTupleObject" title="PyTupleObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyTupleObject</span></code></a>.
  564. <em>userData</em> is the argument passed to PySys_AddAuditHook().</p>
  565. </dd></dl>
  566. <div class="versionadded">
  567. <p><span class="versionmodified added">New in version 3.8.</span></p>
  568. </div>
  569. </dd></dl>
  570. </section>
  571. <section id="process-control">
  572. <span id="processcontrol"></span><h1>Process Control<a class="headerlink" href="#process-control" title="Link to this heading">¶</a></h1>
  573. <dl class="c function">
  574. <dt class="sig sig-object c" id="c.Py_FatalError">
  575. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">Py_FatalError</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="kt"><span class="pre">char</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">message</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.Py_FatalError" title="Link to this definition">¶</a><br /></dt>
  576. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p id="index-2">Print a fatal error message and kill the process. No cleanup is performed.
  577. This function should only be invoked when a condition is detected that would
  578. make it dangerous to continue using the Python interpreter; e.g., when the
  579. object administration appears to be corrupted. On Unix, the standard C library
  580. function <code class="xref c c-func docutils literal notranslate"><span class="pre">abort()</span></code> is called which will attempt to produce a <code class="file docutils literal notranslate"><span class="pre">core</span></code>
  581. file.</p>
  582. <p>The <code class="docutils literal notranslate"><span class="pre">Py_FatalError()</span></code> function is replaced with a macro which logs
  583. automatically the name of the current function, unless the
  584. <code class="docutils literal notranslate"><span class="pre">Py_LIMITED_API</span></code> macro is defined.</p>
  585. <div class="versionchanged">
  586. <p><span class="versionmodified changed">Changed in version 3.9: </span>Log the function name automatically.</p>
  587. </div>
  588. </dd></dl>
  589. <dl class="c function">
  590. <dt class="sig sig-object c" id="c.Py_Exit">
  591. <span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">Py_Exit</span></span></span><span class="sig-paren">(</span><span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">status</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.Py_Exit" title="Link to this definition">¶</a><br /></dt>
  592. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p id="index-3">Exit the current process. This calls <a class="reference internal" href="init.html#c.Py_FinalizeEx" title="Py_FinalizeEx"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_FinalizeEx()</span></code></a> and then calls the
  593. standard C library function <code class="docutils literal notranslate"><span class="pre">exit(status)</span></code>. If <a class="reference internal" href="init.html#c.Py_FinalizeEx" title="Py_FinalizeEx"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_FinalizeEx()</span></code></a>
  594. indicates an error, the exit status is set to 120.</p>
  595. <div class="versionchanged">
  596. <p><span class="versionmodified changed">Changed in version 3.6: </span>Errors from finalization no longer ignored.</p>
  597. </div>
  598. </dd></dl>
  599. <dl class="c function">
  600. <dt class="sig sig-object c" id="c.Py_AtExit">
  601. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">Py_AtExit</span></span></span><span class="sig-paren">(</span><span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="p"><span class="pre">(</span></span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">func</span></span><span class="p"><span class="pre">)</span></span><span class="p"><span class="pre">(</span></span><span class="p"><span class="pre">)</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.Py_AtExit" title="Link to this definition">¶</a><br /></dt>
  602. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p id="index-4">Register a cleanup function to be called by <a class="reference internal" href="init.html#c.Py_FinalizeEx" title="Py_FinalizeEx"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_FinalizeEx()</span></code></a>. The cleanup
  603. function will be called with no arguments and should return no value. At most
  604. 32 cleanup functions can be registered. When the registration is successful,
  605. <a class="reference internal" href="#c.Py_AtExit" title="Py_AtExit"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_AtExit()</span></code></a> returns <code class="docutils literal notranslate"><span class="pre">0</span></code>; on failure, it returns <code class="docutils literal notranslate"><span class="pre">-1</span></code>. The cleanup
  606. function registered last is called first. Each cleanup function will be called
  607. at most once. Since Python’s internal finalization will have completed before
  608. the cleanup function, no Python APIs should be called by <em>func</em>.</p>
  609. </dd></dl>
  610. </section>
  611. <div class="clearer"></div>
  612. </div>
  613. </div>
  614. </div>
  615. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  616. <div class="sphinxsidebarwrapper">
  617. <div>
  618. <h3><a href="../contents.html">Table of Contents</a></h3>
  619. <ul>
  620. <li><a class="reference internal" href="#">Operating System Utilities</a></li>
  621. <li><a class="reference internal" href="#system-functions">System Functions</a></li>
  622. <li><a class="reference internal" href="#process-control">Process Control</a></li>
  623. </ul>
  624. </div>
  625. <div>
  626. <h4>Previous topic</h4>
  627. <p class="topless"><a href="utilities.html"
  628. title="previous chapter">Utilities</a></p>
  629. </div>
  630. <div>
  631. <h4>Next topic</h4>
  632. <p class="topless"><a href="import.html"
  633. title="next chapter">Importing Modules</a></p>
  634. </div>
  635. <div role="note" aria-label="source link">
  636. <h3>This Page</h3>
  637. <ul class="this-page-menu">
  638. <li><a href="../bugs.html">Report a Bug</a></li>
  639. <li>
  640. <a href="https://github.com/python/cpython/blob/main/Doc/c-api/sys.rst"
  641. rel="nofollow">Show Source
  642. </a>
  643. </li>
  644. </ul>
  645. </div>
  646. </div>
  647. <div id="sidebarbutton" title="Collapse sidebar">
  648. <span>«</span>
  649. </div>
  650. </div>
  651. <div class="clearer"></div>
  652. </div>
  653. <div class="related" role="navigation" aria-label="related navigation">
  654. <h3>Navigation</h3>
  655. <ul>
  656. <li class="right" style="margin-right: 10px">
  657. <a href="../genindex.html" title="General Index"
  658. >index</a></li>
  659. <li class="right" >
  660. <a href="../py-modindex.html" title="Python Module Index"
  661. >modules</a> |</li>
  662. <li class="right" >
  663. <a href="import.html" title="Importing Modules"
  664. >next</a> |</li>
  665. <li class="right" >
  666. <a href="utilities.html" title="Utilities"
  667. >previous</a> |</li>
  668. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  669. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  670. <li class="switchers">
  671. <div class="language_switcher_placeholder"></div>
  672. <div class="version_switcher_placeholder"></div>
  673. </li>
  674. <li>
  675. </li>
  676. <li id="cpython-language-and-version">
  677. <a href="../index.html">3.12.3 Documentation</a> &#187;
  678. </li>
  679. <li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> &#187;</li>
  680. <li class="nav-item nav-item-2"><a href="utilities.html" >Utilities</a> &#187;</li>
  681. <li class="nav-item nav-item-this"><a href="">Operating System Utilities</a></li>
  682. <li class="right">
  683. <div class="inline-search" role="search">
  684. <form class="inline-search" action="../search.html" method="get">
  685. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  686. <input type="submit" value="Go" />
  687. </form>
  688. </div>
  689. |
  690. </li>
  691. <li class="right">
  692. <label class="theme-selector-label">
  693. Theme
  694. <select class="theme-selector" oninput="activateTheme(this.value)">
  695. <option value="auto" selected>Auto</option>
  696. <option value="light">Light</option>
  697. <option value="dark">Dark</option>
  698. </select>
  699. </label> |</li>
  700. </ul>
  701. </div>
  702. <div class="footer">
  703. &copy;
  704. <a href="../copyright.html">
  705. Copyright
  706. </a>
  707. 2001-2024, Python Software Foundation.
  708. <br />
  709. This page is licensed under the Python Software Foundation License Version 2.
  710. <br />
  711. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  712. <br />
  713. See <a href="/license.html">History and License</a> for more information.<br />
  714. <br />
  715. The Python Software Foundation is a non-profit corporation.
  716. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  717. <br />
  718. <br />
  719. Last updated on Apr 09, 2024 (13:47 UTC).
  720. <a href="/bugs.html">Found a bug</a>?
  721. <br />
  722. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  723. </div>
  724. </body>
  725. </html>
上海开阖软件有限公司 沪ICP备12045867号-1