361 lines
26 KiB
HTML
361 lines
26 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
|
||
<head>
|
||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||
|
||
<title>胶囊 — Python 3.8.20 文档</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
|
||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/language_data.js"></script>
|
||
<script src="../_static/translations.js"></script>
|
||
|
||
<script src="../_static/sidebar.js"></script>
|
||
|
||
<link rel="search" type="application/opensearchdescription+xml"
|
||
title="在 Python 3.8.20 文档 中搜索"
|
||
href="../_static/opensearch.xml"/>
|
||
<link rel="author" title="关于这些文档" href="../about.html" />
|
||
<link rel="index" title="索引" href="../genindex.html" />
|
||
<link rel="search" title="搜索" href="../search.html" />
|
||
<link rel="copyright" title="版权所有" href="../copyright.html" />
|
||
<link rel="next" title="生成器对象" href="gen.html" />
|
||
<link rel="prev" title="弱引用对象" href="weakref.html" />
|
||
<link rel="canonical" href="https://docs.python.org/3/c-api/capsule.html" />
|
||
|
||
|
||
|
||
|
||
|
||
<style>
|
||
@media only screen {
|
||
table.full-width-table {
|
||
width: 100%;
|
||
}
|
||
}
|
||
</style>
|
||
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
|
||
<script type="text/javascript" src="../_static/copybutton.js"></script>
|
||
<script type="text/javascript" src="../_static/menu.js"></script>
|
||
|
||
</head>
|
||
<body>
|
||
<div class="mobile-nav">
|
||
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
|
||
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
|
||
<label for="menuToggler" class="toggler__label">
|
||
<span></span>
|
||
</label>
|
||
<nav class="nav-content" role="navigation">
|
||
<a href="https://www.python.org/" class="nav-logo">
|
||
<img src="../_static/py.svg" alt="Logo"/>
|
||
</a>
|
||
<div class="version_switcher_placeholder"></div>
|
||
<form role="search" class="search" action="../search.html" method="get">
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
|
||
<path fill-rule="nonzero"
|
||
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" fill="#444"></path>
|
||
</svg>
|
||
<input type="text" name="q" aria-label="快速搜索"/>
|
||
<input type="submit" value="转向"/>
|
||
</form>
|
||
</nav>
|
||
<div class="menu-wrapper">
|
||
<nav class="menu" role="navigation" aria-label="main navigation">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<h4>上一个主题</h4>
|
||
<p class="topless"><a href="weakref.html"
|
||
title="上一章">弱引用对象</a></p>
|
||
<h4>下一个主题</h4>
|
||
<p class="topless"><a href="gen.html"
|
||
title="下一章">生成器对象</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<h3>本页</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">报告 Bug</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.8/Doc/c-api/capsule.rst"
|
||
rel="nofollow">显示源代码
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</nav>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outdated-warning" style="padding: .5em; text-align: center; background-color: #FFBABA; color: #6A0E0E;">
|
||
这个文档所针对的是一个已不再受支持的 Python 旧版本。
|
||
你应当升级版本,并阅读
|
||
<a href="/3/c-api/capsule.html"> Python 当前稳定版本的文档</a>.
|
||
</div>
|
||
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>导航</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="总目录"
|
||
accesskey="I">索引</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python 模块索引"
|
||
>模块</a> |</li>
|
||
<li class="right" >
|
||
<a href="gen.html" title="生成器对象"
|
||
accesskey="N">下一页</a> |</li>
|
||
<li class="right" >
|
||
<a href="weakref.html" title="弱引用对象"
|
||
accesskey="P">上一页</a> |</li>
|
||
|
||
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.8.20 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >Python/C API 参考手册</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="concrete.html" accesskey="U">具体的对象层</a> »</li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
|
||
<input type="submit" value="转向" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="capsules">
|
||
<span id="id1"></span><h1>胶囊<a class="headerlink" href="#capsules" title="永久链接至标题">¶</a></h1>
|
||
<p id="index-0">有关使用这些对象的更多信息请参阅 <a class="reference internal" href="../extending/extending.html#using-capsules"><span class="std std-ref">给扩展模块提供C API</span></a>。</p>
|
||
<div class="versionadded">
|
||
<p><span class="versionmodified added">3.1 新版功能.</span></p>
|
||
</div>
|
||
<dl class="type">
|
||
<dt id="c.PyCapsule">
|
||
<code class="sig-name descname">PyCapsule</code><a class="headerlink" href="#c.PyCapsule" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>这个 <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyObject</span></code></a> 的子类型代表一个隐藏的值,适用于需要将隐藏值(作为 <code class="xref c c-type docutils literal notranslate"><span class="pre">void*</span></code> 指针)通过 Python 代码传递到其他 C 代码的 C 扩展模块。 它常常被用来让在一个模块中定义的 C 函数指针在其他模块中可用,这样就可以使用常规导入机制来访问在动态加载的模块中定义的 C API。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="type">
|
||
<dt id="c.PyCapsule_Destructor">
|
||
<code class="sig-name descname">PyCapsule_Destructor</code><a class="headerlink" href="#c.PyCapsule_Destructor" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>这种类型的一个析构器返回一个胶囊,定义如下:</p>
|
||
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="p">(</span><span class="o">*</span><span class="n">PyCapsule_Destructor</span><span class="p">)(</span><span class="n">PyObject</span><span class="w"> </span><span class="o">*</span><span class="p">);</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>参阅 <a class="reference internal" href="#c.PyCapsule_New" title="PyCapsule_New"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCapsule_New()</span></code></a> 来获取 PyCapsule_Destructor 返回值的语义。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_CheckExact">
|
||
int <code class="sig-name descname">PyCapsule_CheckExact</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *p</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_CheckExact" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>如果参数是一个 <a class="reference internal" href="#c.PyCapsule" title="PyCapsule"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyCapsule</span></code></a> 则返回 True</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_New">
|
||
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="sig-name descname">PyCapsule_New</code><span class="sig-paren">(</span>void<em> *pointer</em>, const char<em> *name</em>, <a class="reference internal" href="#c.PyCapsule_Destructor" title="PyCapsule_Destructor">PyCapsule_Destructor</a><em> destructor</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_New" title="永久链接至目标">¶</a></dt>
|
||
<dd><em class="refcount">Return value: New reference.</em><p>创建一个封装了 <em>pointer</em> 的 <a class="reference internal" href="#c.PyCapsule" title="PyCapsule"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyCapsule</span></code></a>。 <em>pointer</em> 参考可以不为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>。</p>
|
||
<p>在失败时设置一个异常并返回 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>。</p>
|
||
<p>字符串 <em>name</em> 可以是 <code class="docutils literal notranslate"><span class="pre">NULL</span></code> 或是一个指向有效的 C 字符串的指针。 如果不为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>,则此字符串必须比 capsule 长(虽然也允许在 <em>destructor</em> 中释放它。)</p>
|
||
<p>如果 <em>destructor</em> 参数不为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>,则当它被销毁时将附带 capsule 作为参数来调用。</p>
|
||
<p>如果此 capsule 将被保存为一个模块的属性,则 <em>name</em> 应当被指定为 <code class="docutils literal notranslate"><span class="pre">modulename.attributename</span></code>。 这将允许其他模块使用 <a class="reference internal" href="#c.PyCapsule_Import" title="PyCapsule_Import"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCapsule_Import()</span></code></a> 来导入此 capsule。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_GetPointer">
|
||
void* <code class="sig-name descname">PyCapsule_GetPointer</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *capsule</em>, const char<em> *name</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_GetPointer" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>提取保存在 capsule 中的 <em>pointer</em>。 在失败时设置一个异常并返回 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>。</p>
|
||
<p><em>name</em> 形参必须与保存在 capsule 中的名称进行精确比较。 如果保存在 capsule 中的名称为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>,则传入的 <em>name</em> 也必须为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>。 Python 会使用 C 函数 <code class="xref c c-func docutils literal notranslate"><span class="pre">strcmp()</span></code> 来比较 capsule 名称。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_GetDestructor">
|
||
<a class="reference internal" href="#c.PyCapsule_Destructor" title="PyCapsule_Destructor">PyCapsule_Destructor</a> <code class="sig-name descname">PyCapsule_GetDestructor</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *capsule</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_GetDestructor" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回保存为 capsule 中的当前析构器。 在失败时设置一个异常并返回 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>。</p>
|
||
<p>具有 <code class="docutils literal notranslate"><span class="pre">NULL</span></code> 析构器是合法的。 这会使得 <code class="docutils literal notranslate"><span class="pre">NULL</span></code> 返回值有些歧义;请使用 <a class="reference internal" href="#c.PyCapsule_IsValid" title="PyCapsule_IsValid"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCapsule_IsValid()</span></code></a> 或 <a class="reference internal" href="exceptions.html#c.PyErr_Occurred" title="PyErr_Occurred"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyErr_Occurred()</span></code></a> 来消除歧义。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_GetContext">
|
||
void* <code class="sig-name descname">PyCapsule_GetContext</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *capsule</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_GetContext" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回保存在 capsule 中的当前上下文。 在失败时设置一个异常并返回 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>。</p>
|
||
<p>capsule 具有 <code class="docutils literal notranslate"><span class="pre">NULL</span></code> 上下文是全法的。 这会使得 <code class="docutils literal notranslate"><span class="pre">NULL</span></code> 返回码有些歧义;请使用 <a class="reference internal" href="#c.PyCapsule_IsValid" title="PyCapsule_IsValid"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCapsule_IsValid()</span></code></a> 或 <a class="reference internal" href="exceptions.html#c.PyErr_Occurred" title="PyErr_Occurred"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyErr_Occurred()</span></code></a> 来消除歧义。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_GetName">
|
||
const char* <code class="sig-name descname">PyCapsule_GetName</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *capsule</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_GetName" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回保存在 capsule 中的当前名称。 在失败时设置一个异常并返回 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>。</p>
|
||
<p>capsule 具有 <code class="docutils literal notranslate"><span class="pre">NULL</span></code> 名称是合法的。 这会使得 <code class="docutils literal notranslate"><span class="pre">NULL</span></code> 返回码有些歧义;请使用 <a class="reference internal" href="#c.PyCapsule_IsValid" title="PyCapsule_IsValid"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCapsule_IsValid()</span></code></a> 或 <a class="reference internal" href="exceptions.html#c.PyErr_Occurred" title="PyErr_Occurred"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyErr_Occurred()</span></code></a> 来消除歧义。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_Import">
|
||
void* <code class="sig-name descname">PyCapsule_Import</code><span class="sig-paren">(</span>const char<em> *name</em>, int<em> no_block</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_Import" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>从一个模块的 capsule 属性导入指向 C 对象的指针。 <em>name</em> 形参应当指定属性的完整名称,与 <code class="docutils literal notranslate"><span class="pre">module.attribute</span></code> 中的一致。 保存在 capsule 中的 <em>name</em> 必须完全匹配此字符串。 如果 <em>no_block</em> 为真值,则以无阻塞模式导入模块 (使用 <a class="reference internal" href="import.html#c.PyImport_ImportModuleNoBlock" title="PyImport_ImportModuleNoBlock"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyImport_ImportModuleNoBlock()</span></code></a>)。 如果 <em>no_block</em> 为假值,则以传统模式导入模块 (使用 <a class="reference internal" href="import.html#c.PyImport_ImportModule" title="PyImport_ImportModule"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyImport_ImportModule()</span></code></a>)。</p>
|
||
<p>成功时返回 capsule 的内部 <em>指针</em>。 在失败时设置一个异常并返回 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_IsValid">
|
||
int <code class="sig-name descname">PyCapsule_IsValid</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *capsule</em>, const char<em> *name</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_IsValid" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>确定 <em>capsule</em> 是否是一个有效的。 有效的 capsule 必须不为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>,传递 <a class="reference internal" href="#c.PyCapsule_CheckExact" title="PyCapsule_CheckExact"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCapsule_CheckExact()</span></code></a>,在其中存储一个不为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code> 的指针,并且其内部名称与 <em>name</em> 形参相匹配。 (请参阅 <a class="reference internal" href="#c.PyCapsule_GetPointer" title="PyCapsule_GetPointer"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCapsule_GetPointer()</span></code></a> 了解如何对 capsule 名称进行比较的有关信息。)</p>
|
||
<p>换句话说,如果 <a class="reference internal" href="#c.PyCapsule_IsValid" title="PyCapsule_IsValid"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCapsule_IsValid()</span></code></a> 返回真值,则任何对访问器(以 <code class="xref c c-func docutils literal notranslate"><span class="pre">PyCapsule_Get()</span></code> 开头的任何函数)的调用都保证会成功。</p>
|
||
<p>如果对象有效并且匹配传入的名称则返回非零值。 否则返回 <code class="docutils literal notranslate"><span class="pre">0</span></code>。 此函数一定不会失败。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_SetContext">
|
||
int <code class="sig-name descname">PyCapsule_SetContext</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *capsule</em>, void<em> *context</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_SetContext" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>将 <em>capsule</em> 内部的上下文指针设为 <em>context</em>。</p>
|
||
<p>成功时返回 <code class="docutils literal notranslate"><span class="pre">0</span></code>。 失败时返回非零值并设置一个异常。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_SetDestructor">
|
||
int <code class="sig-name descname">PyCapsule_SetDestructor</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *capsule</em>, <a class="reference internal" href="#c.PyCapsule_Destructor" title="PyCapsule_Destructor">PyCapsule_Destructor</a><em> destructor</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_SetDestructor" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>将 <em>capsule</em> 内部的析构器设为 <em>destructor</em>。</p>
|
||
<p>成功时返回 <code class="docutils literal notranslate"><span class="pre">0</span></code>。 失败时返回非零值并设置一个异常。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_SetName">
|
||
int <code class="sig-name descname">PyCapsule_SetName</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *capsule</em>, const char<em> *name</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_SetName" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>将 <em>capsule</em> 内部的名称设为 <em>name</em>。 如果不为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>,则名称的存在期必须比 capsule 更长。 如果之前保存在 capsule 中的 <em>name</em> 不为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>,则不会尝试释放它。</p>
|
||
<p>成功时返回 <code class="docutils literal notranslate"><span class="pre">0</span></code>。 失败时返回非零值并设置一个异常。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="c.PyCapsule_SetPointer">
|
||
int <code class="sig-name descname">PyCapsule_SetPointer</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *capsule</em>, void<em> *pointer</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyCapsule_SetPointer" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>将 <em>capsule</em> 内部的空指针设为 <em>pointer</em>。 指针不可为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>。</p>
|
||
<p>成功时返回 <code class="docutils literal notranslate"><span class="pre">0</span></code>。 失败时返回非零值并设置一个异常。</p>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<h4>上一个主题</h4>
|
||
<p class="topless"><a href="weakref.html"
|
||
title="上一章">弱引用对象</a></p>
|
||
<h4>下一个主题</h4>
|
||
<p class="topless"><a href="gen.html"
|
||
title="下一章">生成器对象</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<h3>本页</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">报告 Bug</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.8/Doc/c-api/capsule.rst"
|
||
rel="nofollow">显示源代码
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>导航</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="总目录"
|
||
>索引</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python 模块索引"
|
||
>模块</a> |</li>
|
||
<li class="right" >
|
||
<a href="gen.html" title="生成器对象"
|
||
>下一页</a> |</li>
|
||
<li class="right" >
|
||
<a href="weakref.html" title="弱引用对象"
|
||
>上一页</a> |</li>
|
||
|
||
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.8.20 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >Python/C API 参考手册</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="concrete.html" >具体的对象层</a> »</li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
|
||
<input type="submit" value="转向" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
<div class="footer">
|
||
© <a href="../copyright.html">版权所有</a> 2001-2024, Python Software Foundation.
|
||
<br />
|
||
This page is licensed under the Python Software Foundation License Version 2.
|
||
<br />
|
||
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
|
||
<br />
|
||
|
||
<br />
|
||
|
||
The Python Software Foundation is a non-profit corporation.
|
||
<a href="https://www.python.org/psf/donations/">Please donate.</a>
|
||
<br />
|
||
<br />
|
||
|
||
最后更新于 12月 09, 2024.
|
||
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
|
||
<br />
|
||
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 2.4.4.
|
||
</div>
|
||
|
||
</body>
|
||
</html> |