frame.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
  6. <meta property="og:title" content="Frame Objects" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/c-api/frame.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="The PyEval_GetFrame() and PyThreadState_GetFrame() functions can be used to get a frame object. See also Reflection. Internal Frames: Unless using PEP 523, you will not need this." />
  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="The PyEval_GetFrame() and PyThreadState_GetFrame() functions can be used to get a frame object. See also Reflection. Internal Frames: Unless using PEP 523, you will not need this." />
  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>Frame Objects &#8212; Python 3.12.0 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?digest=b37c26da2f7529d09fe70b41c4b2133fe4931a90" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css" />
  21. <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
  22. <script src="../_static/jquery.js"></script>
  23. <script src="../_static/underscore.js"></script>
  24. <script src="../_static/doctools.js"></script>
  25. <script src="../_static/sidebar.js"></script>
  26. <link rel="search" type="application/opensearchdescription+xml"
  27. title="Search within Python 3.12.0 documentation"
  28. href="../_static/opensearch.xml"/>
  29. <link rel="author" title="About these documents" href="../about.html" />
  30. <link rel="index" title="Index" href="../genindex.html" />
  31. <link rel="search" title="Search" href="../search.html" />
  32. <link rel="copyright" title="Copyright" href="../copyright.html" />
  33. <link rel="next" title="Generator Objects" href="gen.html" />
  34. <link rel="prev" title="Capsules" href="capsule.html" />
  35. <link rel="canonical" href="https://docs.python.org/3/c-api/frame.html" />
  36. <style>
  37. @media only screen {
  38. table.full-width-table {
  39. width: 100%;
  40. }
  41. }
  42. </style>
  43. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  44. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  45. <script type="text/javascript" src="../_static/copybutton.js"></script>
  46. <script type="text/javascript" src="../_static/menu.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="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="#">Frame Objects</a><ul>
  86. <li><a class="reference internal" href="#internal-frames">Internal Frames</a></li>
  87. </ul>
  88. </li>
  89. </ul>
  90. </div>
  91. <div>
  92. <h4>Previous topic</h4>
  93. <p class="topless"><a href="capsule.html"
  94. title="previous chapter">Capsules</a></p>
  95. </div>
  96. <div>
  97. <h4>Next topic</h4>
  98. <p class="topless"><a href="gen.html"
  99. title="next chapter">Generator Objects</a></p>
  100. </div>
  101. <div role="note" aria-label="source link">
  102. <h3>This Page</h3>
  103. <ul class="this-page-menu">
  104. <li><a href="../bugs.html">Report a Bug</a></li>
  105. <li>
  106. <a href="https://github.com/python/cpython/blob/main/Doc/c-api/frame.rst"
  107. rel="nofollow">Show Source
  108. </a>
  109. </li>
  110. </ul>
  111. </div>
  112. </nav>
  113. </div>
  114. </div>
  115. <div class="related" role="navigation" aria-label="related navigation">
  116. <h3>Navigation</h3>
  117. <ul>
  118. <li class="right" style="margin-right: 10px">
  119. <a href="../genindex.html" title="General Index"
  120. accesskey="I">index</a></li>
  121. <li class="right" >
  122. <a href="../py-modindex.html" title="Python Module Index"
  123. >modules</a> |</li>
  124. <li class="right" >
  125. <a href="gen.html" title="Generator Objects"
  126. accesskey="N">next</a> |</li>
  127. <li class="right" >
  128. <a href="capsule.html" title="Capsules"
  129. accesskey="P">previous</a> |</li>
  130. <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  131. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  132. <li class="switchers">
  133. <div class="language_switcher_placeholder"></div>
  134. <div class="version_switcher_placeholder"></div>
  135. </li>
  136. <li>
  137. </li>
  138. <li id="cpython-language-and-version">
  139. <a href="../index.html">3.12.0 Documentation</a> &#187;
  140. </li>
  141. <li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> &#187;</li>
  142. <li class="nav-item nav-item-2"><a href="concrete.html" accesskey="U">Concrete Objects Layer</a> &#187;</li>
  143. <li class="nav-item nav-item-this"><a href="">Frame Objects</a></li>
  144. <li class="right">
  145. <div class="inline-search" role="search">
  146. <form class="inline-search" action="../search.html" method="get">
  147. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  148. <input type="submit" value="Go" />
  149. </form>
  150. </div>
  151. |
  152. </li>
  153. <li class="right">
  154. <label class="theme-selector-label">
  155. Theme
  156. <select class="theme-selector" oninput="activateTheme(this.value)">
  157. <option value="auto" selected>Auto</option>
  158. <option value="light">Light</option>
  159. <option value="dark">Dark</option>
  160. </select>
  161. </label> |</li>
  162. </ul>
  163. </div>
  164. <div class="document">
  165. <div class="documentwrapper">
  166. <div class="bodywrapper">
  167. <div class="body" role="main">
  168. <section id="frame-objects">
  169. <h1>Frame Objects<a class="headerlink" href="#frame-objects" title="Permalink to this headline">¶</a></h1>
  170. <dl class="c type">
  171. <dt class="sig sig-object c" id="c.PyFrameObject">
  172. <span class="k"><span class="pre">type</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyFrameObject</span></span></span><a class="headerlink" href="#c.PyFrameObject" title="Permalink to this definition">¶</a><br /></dt>
  173. <dd><em class="stableabi"> Part of the <a class="reference internal" href="stable.html#stable"><span class="std std-ref">Limited API</span></a> (as an opaque struct).</em><p>The C structure of the objects used to describe frame objects.</p>
  174. <p>There are no public members in this structure.</p>
  175. <div class="versionchanged">
  176. <p><span class="versionmodified changed">Changed in version 3.11: </span>The members of this structure were removed from the public C API.
  177. Refer to the <a class="reference internal" href="../whatsnew/3.11.html#pyframeobject-3-11-hiding"><span class="std std-ref">What’s New entry</span></a>
  178. for details.</p>
  179. </div>
  180. </dd></dl>
  181. <p>The <a class="reference internal" href="reflection.html#c.PyEval_GetFrame" title="PyEval_GetFrame"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyEval_GetFrame()</span></code></a> and <a class="reference internal" href="init.html#c.PyThreadState_GetFrame" title="PyThreadState_GetFrame"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyThreadState_GetFrame()</span></code></a> functions
  182. can be used to get a frame object.</p>
  183. <p>See also <a class="reference internal" href="reflection.html#reflection"><span class="std std-ref">Reflection</span></a>.</p>
  184. <dl class="c var">
  185. <dt class="sig sig-object c" id="c.PyFrame_Type">
  186. <a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject"><span class="n"><span class="pre">PyTypeObject</span></span></a><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyFrame_Type</span></span></span><a class="headerlink" href="#c.PyFrame_Type" title="Permalink to this definition">¶</a><br /></dt>
  187. <dd><p>The type of frame objects.
  188. It is the same object as <a class="reference internal" href="../library/types.html#types.FrameType" title="types.FrameType"><code class="xref py py-class docutils literal notranslate"><span class="pre">types.FrameType</span></code></a> in the Python layer.</p>
  189. <div class="versionchanged">
  190. <p><span class="versionmodified changed">Changed in version 3.11: </span>Previously, this type was only available after including
  191. <code class="docutils literal notranslate"><span class="pre">&lt;frameobject.h&gt;</span></code>.</p>
  192. </div>
  193. </dd></dl>
  194. <dl class="c function">
  195. <dt class="sig sig-object c" id="c.PyFrame_Check">
  196. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyFrame_Check</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">obj</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyFrame_Check" title="Permalink to this definition">¶</a><br /></dt>
  197. <dd><p>Return non-zero if <em>obj</em> is a frame object.</p>
  198. <div class="versionchanged">
  199. <p><span class="versionmodified changed">Changed in version 3.11: </span>Previously, this function was only available after including
  200. <code class="docutils literal notranslate"><span class="pre">&lt;frameobject.h&gt;</span></code>.</p>
  201. </div>
  202. </dd></dl>
  203. <dl class="c function">
  204. <dt class="sig sig-object c" id="c.PyFrame_GetBack">
  205. <a class="reference internal" href="#c.PyFrameObject" title="PyFrameObject"><span class="n"><span class="pre">PyFrameObject</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">PyFrame_GetBack</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.PyFrameObject" title="PyFrameObject"><span class="n"><span class="pre">PyFrameObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyFrame_GetBack" title="Permalink to this definition">¶</a><br /></dt>
  206. <dd><p>Get the <em>frame</em> next outer frame.</p>
  207. <p>Return a <a class="reference internal" href="../glossary.html#term-strong-reference"><span class="xref std std-term">strong reference</span></a>, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if <em>frame</em> has no outer
  208. frame.</p>
  209. <div class="versionadded">
  210. <p><span class="versionmodified added">New in version 3.9.</span></p>
  211. </div>
  212. </dd></dl>
  213. <dl class="c function">
  214. <dt class="sig sig-object c" id="c.PyFrame_GetBuiltins">
  215. <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">PyFrame_GetBuiltins</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.PyFrameObject" title="PyFrameObject"><span class="n"><span class="pre">PyFrameObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyFrame_GetBuiltins" title="Permalink to this definition">¶</a><br /></dt>
  216. <dd><p>Get the <em>frame</em>’s <code class="docutils literal notranslate"><span class="pre">f_builtins</span></code> attribute.</p>
  217. <p>Return a <a class="reference internal" href="../glossary.html#term-strong-reference"><span class="xref std std-term">strong reference</span></a>. The result cannot be <code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</p>
  218. <div class="versionadded">
  219. <p><span class="versionmodified added">New in version 3.11.</span></p>
  220. </div>
  221. </dd></dl>
  222. <dl class="c function">
  223. <dt class="sig sig-object c" id="c.PyFrame_GetCode">
  224. <a class="reference internal" href="code.html#c.PyCodeObject" title="PyCodeObject"><span class="n"><span class="pre">PyCodeObject</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">PyFrame_GetCode</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.PyFrameObject" title="PyFrameObject"><span class="n"><span class="pre">PyFrameObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyFrame_GetCode" title="Permalink to this definition">¶</a><br /></dt>
  225. <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.10.</em><p>Get the <em>frame</em> code.</p>
  226. <p>Return a <a class="reference internal" href="../glossary.html#term-strong-reference"><span class="xref std std-term">strong reference</span></a>.</p>
  227. <p>The result (frame code) cannot be <code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</p>
  228. <div class="versionadded">
  229. <p><span class="versionmodified added">New in version 3.9.</span></p>
  230. </div>
  231. </dd></dl>
  232. <dl class="c function">
  233. <dt class="sig sig-object c" id="c.PyFrame_GetGenerator">
  234. <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">PyFrame_GetGenerator</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.PyFrameObject" title="PyFrameObject"><span class="n"><span class="pre">PyFrameObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyFrame_GetGenerator" title="Permalink to this definition">¶</a><br /></dt>
  235. <dd><p>Get the generator, coroutine, or async generator that owns this frame,
  236. or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if this frame is not owned by a generator.
  237. Does not raise an exception, even if the return value is <code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</p>
  238. <p>Return a <a class="reference internal" href="../glossary.html#term-strong-reference"><span class="xref std std-term">strong reference</span></a>, or <code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</p>
  239. <div class="versionadded">
  240. <p><span class="versionmodified added">New in version 3.11.</span></p>
  241. </div>
  242. </dd></dl>
  243. <dl class="c function">
  244. <dt class="sig sig-object c" id="c.PyFrame_GetGlobals">
  245. <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">PyFrame_GetGlobals</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.PyFrameObject" title="PyFrameObject"><span class="n"><span class="pre">PyFrameObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyFrame_GetGlobals" title="Permalink to this definition">¶</a><br /></dt>
  246. <dd><p>Get the <em>frame</em>’s <code class="docutils literal notranslate"><span class="pre">f_globals</span></code> attribute.</p>
  247. <p>Return a <a class="reference internal" href="../glossary.html#term-strong-reference"><span class="xref std std-term">strong reference</span></a>. The result cannot be <code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</p>
  248. <div class="versionadded">
  249. <p><span class="versionmodified added">New in version 3.11.</span></p>
  250. </div>
  251. </dd></dl>
  252. <dl class="c function">
  253. <dt class="sig sig-object c" id="c.PyFrame_GetLasti">
  254. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyFrame_GetLasti</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.PyFrameObject" title="PyFrameObject"><span class="n"><span class="pre">PyFrameObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyFrame_GetLasti" title="Permalink to this definition">¶</a><br /></dt>
  255. <dd><p>Get the <em>frame</em>’s <code class="docutils literal notranslate"><span class="pre">f_lasti</span></code> attribute.</p>
  256. <p>Returns -1 if <code class="docutils literal notranslate"><span class="pre">frame.f_lasti</span></code> is <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
  257. <div class="versionadded">
  258. <p><span class="versionmodified added">New in version 3.11.</span></p>
  259. </div>
  260. </dd></dl>
  261. <dl class="c function">
  262. <dt class="sig sig-object c" id="c.PyFrame_GetVar">
  263. <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">PyFrame_GetVar</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.PyFrameObject" title="PyFrameObject"><span class="n"><span class="pre">PyFrameObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</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">name</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyFrame_GetVar" title="Permalink to this definition">¶</a><br /></dt>
  264. <dd><p>Get the variable <em>name</em> of <em>frame</em>.</p>
  265. <ul class="simple">
  266. <li><p>Return a <a class="reference internal" href="../glossary.html#term-strong-reference"><span class="xref std std-term">strong reference</span></a> to the variable value on success.</p></li>
  267. <li><p>Raise <a class="reference internal" href="../library/exceptions.html#NameError" title="NameError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NameError</span></code></a> and return <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if the variable does not exist.</p></li>
  268. <li><p>Raise an exception and return <code class="docutils literal notranslate"><span class="pre">NULL</span></code> on error.</p></li>
  269. </ul>
  270. <p><em>name</em> type must be a <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>.</p>
  271. <div class="versionadded">
  272. <p><span class="versionmodified added">New in version 3.12.</span></p>
  273. </div>
  274. </dd></dl>
  275. <dl class="c function">
  276. <dt class="sig sig-object c" id="c.PyFrame_GetVarString">
  277. <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">PyFrame_GetVarString</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.PyFrameObject" title="PyFrameObject"><span class="n"><span class="pre">PyFrameObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</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">name</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyFrame_GetVarString" title="Permalink to this definition">¶</a><br /></dt>
  278. <dd><p>Similar to <a class="reference internal" href="#c.PyFrame_GetVar" title="PyFrame_GetVar"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyFrame_GetVar()</span></code></a>, but the variable name is a C string
  279. encoded in UTF-8.</p>
  280. <div class="versionadded">
  281. <p><span class="versionmodified added">New in version 3.12.</span></p>
  282. </div>
  283. </dd></dl>
  284. <dl class="c function">
  285. <dt class="sig sig-object c" id="c.PyFrame_GetLocals">
  286. <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">PyFrame_GetLocals</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.PyFrameObject" title="PyFrameObject"><span class="n"><span class="pre">PyFrameObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyFrame_GetLocals" title="Permalink to this definition">¶</a><br /></dt>
  287. <dd><p>Get the <em>frame</em>’s <code class="docutils literal notranslate"><span class="pre">f_locals</span></code> attribute (<a class="reference internal" href="../library/stdtypes.html#dict" title="dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a>).</p>
  288. <p>Return a <a class="reference internal" href="../glossary.html#term-strong-reference"><span class="xref std std-term">strong reference</span></a>.</p>
  289. <div class="versionadded">
  290. <p><span class="versionmodified added">New in version 3.11.</span></p>
  291. </div>
  292. </dd></dl>
  293. <dl class="c function">
  294. <dt class="sig sig-object c" id="c.PyFrame_GetLineNumber">
  295. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyFrame_GetLineNumber</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.PyFrameObject" title="PyFrameObject"><span class="n"><span class="pre">PyFrameObject</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.PyFrame_GetLineNumber" title="Permalink 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.10.</em><p>Return the line number that <em>frame</em> is currently executing.</p>
  297. </dd></dl>
  298. <section id="internal-frames">
  299. <h2>Internal Frames<a class="headerlink" href="#internal-frames" title="Permalink to this headline">¶</a></h2>
  300. <p>Unless using <span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-0523/"><strong>PEP 523</strong></a>, you will not need this.</p>
  301. <dl class="c struct">
  302. <dt class="sig sig-object c" id="c._PyInterpreterFrame">
  303. <span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">_PyInterpreterFrame</span></span></span><a class="headerlink" href="#c._PyInterpreterFrame" title="Permalink to this definition">¶</a><br /></dt>
  304. <dd><p>The interpreter’s internal frame representation.</p>
  305. <div class="versionadded">
  306. <p><span class="versionmodified added">New in version 3.11.</span></p>
  307. </div>
  308. </dd></dl>
  309. <dl class="c function">
  310. <dt class="sig sig-object c" id="c.PyUnstable_InterpreterFrame_GetCode">
  311. <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">PyUnstable_InterpreterFrame_GetCode</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">struct</span></span><span class="w"> </span><a class="reference internal" href="#c._PyInterpreterFrame" title="_PyInterpreterFrame"><span class="n"><span class="pre">_PyInterpreterFrame</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</span></span><span class="sig-paren">)</span><span class="p"><span class="pre">;</span></span><a class="headerlink" href="#c.PyUnstable_InterpreterFrame_GetCode" title="Permalink to this definition">¶</a><br /></dt>
  312. <dd><div class="unstable-c-api warning admonition">
  313. <em>This is <a class="reference internal" href="stable.html#unstable-c-api"><span class="std std-ref">Unstable API</span></a>. It may change without warning in minor releases.</em></div>
  314. <blockquote>
  315. <div><p>Return a <a class="reference internal" href="../glossary.html#term-strong-reference"><span class="xref std std-term">strong reference</span></a> to the code object for the frame.</p>
  316. </div></blockquote>
  317. <div class="versionadded">
  318. <p><span class="versionmodified added">New in version 3.12.</span></p>
  319. </div>
  320. </dd></dl>
  321. <dl class="c function">
  322. <dt class="sig sig-object c" id="c.PyUnstable_InterpreterFrame_GetLasti">
  323. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyUnstable_InterpreterFrame_GetLasti</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">struct</span></span><span class="w"> </span><a class="reference internal" href="#c._PyInterpreterFrame" title="_PyInterpreterFrame"><span class="n"><span class="pre">_PyInterpreterFrame</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</span></span><span class="sig-paren">)</span><span class="p"><span class="pre">;</span></span><a class="headerlink" href="#c.PyUnstable_InterpreterFrame_GetLasti" title="Permalink to this definition">¶</a><br /></dt>
  324. <dd><div class="unstable-c-api warning admonition">
  325. <em>This is <a class="reference internal" href="stable.html#unstable-c-api"><span class="std std-ref">Unstable API</span></a>. It may change without warning in minor releases.</em></div>
  326. <p>Return the byte offset into the last executed instruction.</p>
  327. <div class="versionadded">
  328. <p><span class="versionmodified added">New in version 3.12.</span></p>
  329. </div>
  330. </dd></dl>
  331. <dl class="c function">
  332. <dt class="sig sig-object c" id="c.PyUnstable_InterpreterFrame_GetLine">
  333. <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">PyUnstable_InterpreterFrame_GetLine</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">struct</span></span><span class="w"> </span><a class="reference internal" href="#c._PyInterpreterFrame" title="_PyInterpreterFrame"><span class="n"><span class="pre">_PyInterpreterFrame</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">frame</span></span><span class="sig-paren">)</span><span class="p"><span class="pre">;</span></span><a class="headerlink" href="#c.PyUnstable_InterpreterFrame_GetLine" title="Permalink to this definition">¶</a><br /></dt>
  334. <dd><div class="unstable-c-api warning admonition">
  335. <em>This is <a class="reference internal" href="stable.html#unstable-c-api"><span class="std std-ref">Unstable API</span></a>. It may change without warning in minor releases.</em></div>
  336. <p>Return the currently executing line number, or -1 if there is no line number.</p>
  337. <div class="versionadded">
  338. <p><span class="versionmodified added">New in version 3.12.</span></p>
  339. </div>
  340. </dd></dl>
  341. </section>
  342. </section>
  343. <div class="clearer"></div>
  344. </div>
  345. </div>
  346. </div>
  347. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  348. <div class="sphinxsidebarwrapper">
  349. <div>
  350. <h3><a href="../contents.html">Table of Contents</a></h3>
  351. <ul>
  352. <li><a class="reference internal" href="#">Frame Objects</a><ul>
  353. <li><a class="reference internal" href="#internal-frames">Internal Frames</a></li>
  354. </ul>
  355. </li>
  356. </ul>
  357. </div>
  358. <div>
  359. <h4>Previous topic</h4>
  360. <p class="topless"><a href="capsule.html"
  361. title="previous chapter">Capsules</a></p>
  362. </div>
  363. <div>
  364. <h4>Next topic</h4>
  365. <p class="topless"><a href="gen.html"
  366. title="next chapter">Generator Objects</a></p>
  367. </div>
  368. <div role="note" aria-label="source link">
  369. <h3>This Page</h3>
  370. <ul class="this-page-menu">
  371. <li><a href="../bugs.html">Report a Bug</a></li>
  372. <li>
  373. <a href="https://github.com/python/cpython/blob/main/Doc/c-api/frame.rst"
  374. rel="nofollow">Show Source
  375. </a>
  376. </li>
  377. </ul>
  378. </div>
  379. </div>
  380. </div>
  381. <div class="clearer"></div>
  382. </div>
  383. <div class="related" role="navigation" aria-label="related navigation">
  384. <h3>Navigation</h3>
  385. <ul>
  386. <li class="right" style="margin-right: 10px">
  387. <a href="../genindex.html" title="General Index"
  388. >index</a></li>
  389. <li class="right" >
  390. <a href="../py-modindex.html" title="Python Module Index"
  391. >modules</a> |</li>
  392. <li class="right" >
  393. <a href="gen.html" title="Generator Objects"
  394. >next</a> |</li>
  395. <li class="right" >
  396. <a href="capsule.html" title="Capsules"
  397. >previous</a> |</li>
  398. <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  399. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  400. <li class="switchers">
  401. <div class="language_switcher_placeholder"></div>
  402. <div class="version_switcher_placeholder"></div>
  403. </li>
  404. <li>
  405. </li>
  406. <li id="cpython-language-and-version">
  407. <a href="../index.html">3.12.0 Documentation</a> &#187;
  408. </li>
  409. <li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> &#187;</li>
  410. <li class="nav-item nav-item-2"><a href="concrete.html" >Concrete Objects Layer</a> &#187;</li>
  411. <li class="nav-item nav-item-this"><a href="">Frame Objects</a></li>
  412. <li class="right">
  413. <div class="inline-search" role="search">
  414. <form class="inline-search" action="../search.html" method="get">
  415. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  416. <input type="submit" value="Go" />
  417. </form>
  418. </div>
  419. |
  420. </li>
  421. <li class="right">
  422. <label class="theme-selector-label">
  423. Theme
  424. <select class="theme-selector" oninput="activateTheme(this.value)">
  425. <option value="auto" selected>Auto</option>
  426. <option value="light">Light</option>
  427. <option value="dark">Dark</option>
  428. </select>
  429. </label> |</li>
  430. </ul>
  431. </div>
  432. <div class="footer">
  433. &copy; <a href="../copyright.html">Copyright</a> 2001-2023, Python Software Foundation.
  434. <br />
  435. This page is licensed under the Python Software Foundation License Version 2.
  436. <br />
  437. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  438. <br />
  439. See <a href="/license.html">History and License</a> for more information.<br />
  440. <br />
  441. The Python Software Foundation is a non-profit corporation.
  442. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  443. <br />
  444. <br />
  445. Last updated on Oct 02, 2023.
  446. <a href="/bugs.html">Found a bug</a>?
  447. <br />
  448. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.5.0.
  449. </div>
  450. </body>
  451. </html>