- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
出于某些原因,我必须扩展 python 的 ssl 模块。特别是我需要 C 中的第二个版本的 load_cert_chain()。
我的问题与 openssl 无关,而是如何应对“诊所”:在原始函数前面有一个 clinic-input:
/*[clinic input]
_ssl._SSLContext.load_cert_chain
certfile: object
keyfile: object = NULL
password: object = NULL
[clinic start generated code]*/
static PyObject *
_ssl__SSLContext_load_cert_chain_impl(PySSLContext *self, PyObject *certfile,
PyObject *keyfile, PyObject *password)
/*[clinic end generated code: output=9480bc1c380e2095 input=7cf9ac673cbee6fc]*/
{
PyObject *certfile_bytes = NULL, *keyfile_bytes = NULL;
pem_password_cb *orig_passwd_cb = self->ctx->default_passwd_callback;
...
到目前为止,我知道 _ssl__SSLContext_load_cert_chain_impl 是 load_cert_chain 的实现,并在 _ssl__SSLContext_load_cert_chain 中调用,它在头文件 _ssl.c.h 中定义然而,这是由诊所自动生成的 - 不是吗?
既然一切都是自动创建的,那么我从哪里开始将我的新函数 load_cert_chain2 定义为原始函数的副本?
最佳答案
澄清一些误解:
不,参数 clinic 与将 C 函数链接到 Python 函数无关!
参数 clinic 只是为 C 函数创建函数签名。在你的例子中
/*[clinic input]
_ssl._SSLContext.load_cert_chain
certfile: object
keyfile: object = NULL
password: object = NULL
_ssl__SSLContext_load_cert_chain_impl
C 函数将在签名中公开为 _ssl._SSLContext.load_cert_chain
,三个参数需要一个 python 对象
:certfile
作为位置参数,keyfile, password
作为可选参数,默认值为 NULL
。
调用函数的方式或时间与参数 clinic 无关。方法声明在 Modules/clinic/_ssl.c.h
中完成:
#define _SSL__SSLCONTEXT_LOAD_CERT_CHAIN_METHODDEF \
{"load_cert_chain", (PyCFunction)_ssl__SSLContext_load_cert_chain, METH_FASTCALL, _ssl__SSLContext_load_cert_chain__doc__}
static PyObject *
_ssl__SSLContext_load_cert_chain(PySSLContext *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
[...]
return_value = _ssl__SSLContext_load_cert_chain_impl(self, certfile, keyfile, password);
}
并且它作为方法显式添加到 Modules/_ssl.c
中的 _SSLContext
类:
static struct PyMethodDef context_methods[] = {
[...]
_SSL__SSLCONTEXT_LOAD_CERT_CHAIN_METHODDEF
[...]
{NULL, NULL} /* sentinel */
};
[...]
static PyTypeObject PySSLContext_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"_ssl._SSLContext", /*tp_name*/
sizeof(PySSLContext), /*tp_basicsize*/
[...]
context_methods, /*tp_methods*/
[...]
};
因此参数 clinic 不负责将方法分配给类。这是通过围绕 _ssl__SSLContext_load_cert_chain_impl
的包装函数 _ssl__SSLContext_load_cert_chain
完成的,并使用分配给该类的 PyMethodDef
结构分配给该类。
现在您知道没有自动生成的链接,我不知道当您想要替换该功能时这是否有帮助。我不知道您如何在不重新编译 Python 或将所有相关文件复制到您的扩展中的情况下轻松地做到这一点(争论诊所或没有诊所)。
关于python - 使用 "clinic"时如何为 python 模块创建新函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41676808/
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
您好,我在 ASM 方面遇到了一些问题。它生成一个带有字节码错误的类: Exception in thread "main" java.lang.VerifyError: Bad instructio
我在看代码from here开头有这个: ## generate data for medical example clinical.trial [1] "$ [3] "@ [5] "[[
出于某些原因,我必须扩展 python 的 ssl 模块。特别是我需要 C 中的第二个版本的 load_cert_chain()。 我的问题与 openssl 无关,而是如何应对“诊所”:在原始函数前
目前我正在从事诊所预约安排的数据库设计(在 MySQL 中)。 我对这种情况感到震惊: 如果医生在不同的时间在不同的诊所/医院工作。 例如: 周一至周四,A 医生于上午 10 点至 12 点到诊所 A
我正在使用 Ember、Ember-data 和 Rails。 当我在 Handlebars View 中创建链接时,它链接到/clinic/undefined。我试图让 View 代码创建一个看起来
我正在运行 Spring3.2.5 附带的 Pet Clinic 示例项目。 Hibernate 一切都很好,我想尝试一下 EclipseLink。这是我的business-config.xml
我如何使这种 css 样式和 jquery 像 Doctor div 一样与 Clinic div 一起工作?当我像 Doctor div 一样做 Clinic div 时Clinic div 停止但
我正在尝试从标准化为 HL7 V3 CDA 标准的 XML 文件中解析一些临床信息。 XML文件: Amlodipine Besylate 5 mg
我是一名优秀的程序员,十分优秀!