OpenSSL.crypto builds without warnings
diff --git a/OpenSSL/crypto/crl.c b/OpenSSL/crypto/crl.c
index 8e1c135..c9abbab 100644
--- a/OpenSSL/crypto/crl.c
+++ b/OpenSSL/crypto/crl.c
@@ -172,7 +172,7 @@
return NULL;
}
buf_len = BIO_get_mem_data(bio, &temp);
- buffer = PyString_FromStringAndSize(temp, buf_len);
+ buffer = PyBytes_FromStringAndSize(temp, buf_len);
BIO_free(bio);
return buffer;
}
@@ -207,11 +207,6 @@
#undef ADD_METHOD
-static PyObject *
-crypto_CRL_getattr(crypto_CRLObj *self, char *name) {
- return Py_FindMethod(crypto_CRL_methods, (PyObject *)self, name);
-}
-
static void
crypto_CRL_dealloc(crypto_CRLObj *self) {
X509_CRL_free(self->crl);
@@ -237,14 +232,13 @@
}
PyTypeObject crypto_CRL_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"CRL",
sizeof(crypto_CRLObj),
0,
(destructor)crypto_CRL_dealloc,
NULL, /* print */
- (getattrfunc)crypto_CRL_getattr,
+ NULL, /* getattr */
NULL, /* setattr */
NULL, /* compare */
NULL, /* repr */
diff --git a/OpenSSL/crypto/netscape_spki.c b/OpenSSL/crypto/netscape_spki.c
index ada5ef6..ab3d463 100644
--- a/OpenSSL/crypto/netscape_spki.c
+++ b/OpenSSL/crypto/netscape_spki.c
@@ -149,7 +149,7 @@
return NULL;
}
- return PyInt_FromLong((long)answer);
+ return PyLong_FromLong((long)answer);
}
static char crypto_NetscapeSPKI_b64_encode_doc[] = "\n\
@@ -167,7 +167,7 @@
return NULL;
str = NETSCAPE_SPKI_b64_encode(self->netscape_spki);
- return PyString_FromString(str);
+ return PyBytes_FromString(str);
}
@@ -243,29 +243,14 @@
};
#undef ADD_METHOD
-/*
- * Find attribute
- *
- * Arguments: self - The NetscapeSPKI object
- * name - The attribute name
- * Returns: A Python object for the attribute, or NULL if something went
- * wrong
- */
-static PyObject *
-crypto_NetscapeSPKI_getattr(crypto_NetscapeSPKIObj *self, char *name)
-{
- return Py_FindMethod(crypto_NetscapeSPKI_methods, (PyObject *)self, name);
-}
-
PyTypeObject crypto_NetscapeSPKI_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"NetscapeSPKI",
sizeof(crypto_NetscapeSPKIObj),
0,
(destructor)crypto_NetscapeSPKI_dealloc,
NULL, /* print */
- (getattrfunc)crypto_NetscapeSPKI_getattr,
+ NULL, /* getattr */
NULL, /* setattr */
NULL, /* compare */
NULL, /* repr */
diff --git a/OpenSSL/crypto/pkcs12.c b/OpenSSL/crypto/pkcs12.c
index 2302242..5483e42 100644
--- a/OpenSSL/crypto/pkcs12.c
+++ b/OpenSSL/crypto/pkcs12.c
@@ -202,7 +202,7 @@
kwlist, &name))
return NULL;
- if (name != Py_None && ! PyString_CheckExact(name)) {
+ if (name != Py_None && ! PyBytes_CheckExact(name)) {
PyErr_SetString(PyExc_TypeError, "name must be a str or None");
return NULL;
}
@@ -263,7 +263,7 @@
}
}
if (self->friendlyname != Py_None) {
- friendly_name = PyString_AsString(self->friendlyname);
+ friendly_name = PyBytes_AsString(self->friendlyname);
}
p12 = PKCS12_create(passphrase, friendly_name, pkey, x509, cacerts,
@@ -278,7 +278,7 @@
bio = BIO_new(BIO_s_mem());
i2d_PKCS12_bio(bio, p12);
buf_len = BIO_get_mem_data(bio, &temp);
- buffer = PyString_FromStringAndSize(temp, buf_len);
+ buffer = PyBytes_FromStringAndSize(temp, buf_len);
BIO_free(bio);
return buffer;
}
@@ -439,20 +439,6 @@
}
/*
- * Find attribute
- *
- * Arguments: self - The PKCS12 object
- * name - The attribute name
- * Returns: A Python object for the attribute, or NULL if something went
- * wrong
- */
-static PyObject *
-crypto_PKCS12_getattr(crypto_PKCS12Obj *self, char *name)
-{
- return Py_FindMethod(crypto_PKCS12_methods, (PyObject *)self, name);
-}
-
-/*
* Call the visitproc on all contained objects.
*
* Arguments: self - The PKCS12 object
@@ -512,14 +498,13 @@
}
PyTypeObject crypto_PKCS12_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"PKCS12",
sizeof(crypto_PKCS12Obj),
0,
(destructor)crypto_PKCS12_dealloc,
NULL, /* print */
- (getattrfunc)crypto_PKCS12_getattr,
+ NULL, /* getattr */
NULL, /* setattr */
NULL, /* compare */
NULL, /* repr */
diff --git a/OpenSSL/crypto/pkcs7.c b/OpenSSL/crypto/pkcs7.c
index 1cb0813..8bfddb3 100644
--- a/OpenSSL/crypto/pkcs7.c
+++ b/OpenSSL/crypto/pkcs7.c
@@ -24,9 +24,9 @@
return NULL;
if (PKCS7_type_is_signed(self->pkcs7))
- return PyInt_FromLong(1L);
+ return PyLong_FromLong(1L);
else
- return PyInt_FromLong(0L);
+ return PyLong_FromLong(0L);
}
static char crypto_PKCS7_type_is_enveloped_doc[] = "\n\
@@ -42,9 +42,9 @@
return NULL;
if (PKCS7_type_is_enveloped(self->pkcs7))
- return PyInt_FromLong(1L);
+ return PyLong_FromLong(1L);
else
- return PyInt_FromLong(0L);
+ return PyLong_FromLong(0L);
}
static char crypto_PKCS7_type_is_signedAndEnveloped_doc[] = "\n\
@@ -60,9 +60,9 @@
return NULL;
if (PKCS7_type_is_signedAndEnveloped(self->pkcs7))
- return PyInt_FromLong(1L);
+ return PyLong_FromLong(1L);
else
- return PyInt_FromLong(0L);
+ return PyLong_FromLong(0L);
}
static char crypto_PKCS7_type_is_data_doc[] = "\n\
@@ -78,9 +78,9 @@
return NULL;
if (PKCS7_type_is_data(self->pkcs7))
- return PyInt_FromLong(1L);
+ return PyLong_FromLong(1L);
else
- return PyInt_FromLong(0L);
+ return PyLong_FromLong(0L);
}
static char crypto_PKCS7_get_type_name_doc[] = "\n\
@@ -98,7 +98,7 @@
/*
* return a string with the typename
*/
- return PyString_FromString(OBJ_nid2sn(OBJ_obj2nid(self->pkcs7->type)));
+ return PyBytes_FromString(OBJ_nid2sn(OBJ_obj2nid(self->pkcs7->type)));
}
/*
@@ -160,29 +160,14 @@
PyObject_Del(self);
}
-/*
- * Find attribute
- *
- * Arguments: self - The PKCS7 object
- * name - The attribute name
- * Returns: A Python object for the attribute, or NULL if something went
- * wrong
- */
-static PyObject *
-crypto_PKCS7_getattr(crypto_PKCS7Obj *self, char *name)
-{
- return Py_FindMethod(crypto_PKCS7_methods, (PyObject *)self, name);
-}
-
PyTypeObject crypto_PKCS7_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"PKCS7",
sizeof(crypto_PKCS7Obj),
0,
(destructor)crypto_PKCS7_dealloc,
NULL, /* print */
- (getattrfunc)crypto_PKCS7_getattr,
+ NULL, /* getattr */
NULL, /* setattr */
NULL, /* compare */
NULL, /* repr */
@@ -191,7 +176,19 @@
NULL, /* as_mapping */
NULL, /* hash */
NULL, /* call */
- NULL /* str */
+ NULL, /* str */
+ NULL, /* getattro */
+ NULL, /* setattro */
+ NULL, /* as_buffer */
+ Py_TPFLAGS_DEFAULT,
+ NULL, /* doc */
+ NULL, /* traverse */
+ NULL, /* clear */
+ NULL, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ NULL, /* tp_iter */
+ NULL, /* tp_iternext */
+ crypto_PKCS7_methods, /* tp_methods */
};
/*
diff --git a/OpenSSL/crypto/pkey.c b/OpenSSL/crypto/pkey.c
index 583a2a1..82b9e06 100644
--- a/OpenSSL/crypto/pkey.c
+++ b/OpenSSL/crypto/pkey.c
@@ -88,7 +88,7 @@
if (!PyArg_ParseTuple(args, ":bits"))
return NULL;
- return PyInt_FromLong(EVP_PKEY_bits(self->pkey));
+ return PyLong_FromLong(EVP_PKEY_bits(self->pkey));
}
static char crypto_PKey_type_doc[] = "\n\
@@ -103,7 +103,7 @@
if (!PyArg_ParseTuple(args, ":type"))
return NULL;
- return PyInt_FromLong(self->pkey->type);
+ return PyLong_FromLong(self->pkey->type);
}
@@ -196,29 +196,14 @@
PyObject_Del(self);
}
-/*
- * Find attribute
- *
- * Arguments: self - The PKey object
- * name - The attribute name
- * Returns: A Python object for the attribute, or NULL if something went
- * wrong
- */
-static PyObject *
-crypto_PKey_getattr(crypto_PKeyObj *self, char *name)
-{
- return Py_FindMethod(crypto_PKey_methods, (PyObject *)self, name);
-}
-
PyTypeObject crypto_PKey_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"OpenSSL.crypto.PKey",
sizeof(crypto_PKeyObj),
0,
(destructor)crypto_PKey_dealloc,
NULL, /* print */
- (getattrfunc)crypto_PKey_getattr,
+ NULL, /* getattr */
NULL, /* setattr */
NULL, /* compare */
NULL, /* repr */
diff --git a/OpenSSL/crypto/revoked.c b/OpenSSL/crypto/revoked.c
index 3042c4d..95cfcf4 100644
--- a/OpenSSL/crypto/revoked.c
+++ b/OpenSSL/crypto/revoked.c
@@ -36,7 +36,7 @@
list = PyList_New(0);
for (j = 0; j < NUM_REASONS; j++) {
if(crl_reasons[j]) {
- str = PyString_FromString(crl_reasons[j]);
+ str = PyBytes_FromString(crl_reasons[j]);
PyList_Append(list, str);
Py_DECREF(str);
}
@@ -66,7 +66,7 @@
/* Convert to a Python string. */
str_len = BIO_get_mem_data(bio, &tmp_str);
- str = PyString_FromStringAndSize(tmp_str, str_len);
+ str = PyBytes_FromStringAndSize(tmp_str, str_len);
/* Cleanup */
BIO_free(bio);
@@ -256,7 +256,7 @@
/* Convert to a Python string. */
str_len = BIO_get_mem_data(bio, &tmp_str);
- str = PyString_FromStringAndSize(tmp_str, str_len);
+ str = PyBytes_FromStringAndSize(tmp_str, str_len);
/* Cleanup */
BIO_free(bio);
@@ -362,11 +362,6 @@
#undef ADD_METHOD
-static PyObject *
-crypto_Revoked_getattr(crypto_RevokedObj *self, char *name) {
- return Py_FindMethod(crypto_Revoked_methods, (PyObject *)self, name);
-}
-
static void
crypto_Revoked_dealloc(crypto_RevokedObj *self) {
X509_REVOKED_free(self->revoked);
@@ -392,14 +387,13 @@
}
PyTypeObject crypto_Revoked_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"Revoked",
sizeof(crypto_RevokedObj),
0,
(destructor)crypto_Revoked_dealloc,
NULL, /* print */
- (getattrfunc)crypto_Revoked_getattr,
+ NULL, /* getattr */
NULL, /* setattr */
NULL, /* compare */
NULL, /* repr */
diff --git a/OpenSSL/crypto/x509ext.c b/OpenSSL/crypto/x509ext.c
index 90ef543..995a079 100644
--- a/OpenSSL/crypto/x509ext.c
+++ b/OpenSSL/crypto/x509ext.c
@@ -25,7 +25,7 @@
if (!PyArg_ParseTuple(args, ":get_critical"))
return NULL;
- return PyInt_FromLong(X509_EXTENSION_get_critical(self->x509_extension));
+ return PyLong_FromLong(X509_EXTENSION_get_critical(self->x509_extension));
}
static char crypto_X509Extension_get_short_name_doc[] = "\n\
@@ -47,7 +47,7 @@
obj = X509_EXTENSION_get_object(self->x509_extension);
extname = OBJ_nid2sn(OBJ_obj2nid(obj));
- return PyString_FromString(extname);
+ return PyBytes_FromString(extname);
}
@@ -214,20 +214,6 @@
}
/*
- * Find attribute
- *
- * Arguments: self - The X509Extension object
- * name - The attribute name
- * Returns: A Python object for the attribute, or NULL if something
- * went wrong.
- */
-static PyObject *
-crypto_X509Extension_getattr(crypto_X509ExtensionObj *self, char *name)
-{
- return Py_FindMethod(crypto_X509Extension_methods, (PyObject *)self, name);
-}
-
-/*
* Print a nice text representation of the certificate request.
*/
static PyObject *
@@ -246,7 +232,7 @@
}
str_len = BIO_get_mem_data(bio, &tmp_str);
- str = PyString_FromStringAndSize(tmp_str, str_len);
+ str = PyText_FromStringAndSize(tmp_str, str_len);
BIO_free(bio);
@@ -254,14 +240,13 @@
}
PyTypeObject crypto_X509Extension_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"X509Extension",
sizeof(crypto_X509ExtensionObj),
0,
(destructor)crypto_X509Extension_dealloc,
NULL, /* print */
- (getattrfunc)crypto_X509Extension_getattr,
+ NULL, /* getattr */
NULL, /* setattr (setattrfunc)crypto_X509Name_setattr, */
NULL, /* compare */
NULL, /* repr */
diff --git a/OpenSSL/crypto/x509req.c b/OpenSSL/crypto/x509req.c
index 14ae072..4237a45 100644
--- a/OpenSSL/crypto/x509req.c
+++ b/OpenSSL/crypto/x509req.c
@@ -166,7 +166,7 @@
return NULL;
}
- return PyInt_FromLong(answer);
+ return PyLong_FromLong(answer);
}
static char crypto_X509Req_add_extensions_doc[] = "\n\
@@ -357,29 +357,14 @@
}
-/*
- * Find attribute.
- *
- * Arguments: self - The X509Req object
- * name - The attribute name
- * Returns: A Python object for the attribute, or NULL if something went
- * wrong
- */
-static PyObject *
-crypto_X509Req_getattr(crypto_X509ReqObj *self, char *name)
-{
- return Py_FindMethod(crypto_X509Req_methods, (PyObject *)self, name);
-}
-
PyTypeObject crypto_X509Req_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"X509Req",
sizeof(crypto_X509ReqObj),
0,
(destructor)crypto_X509Req_dealloc,
NULL, /* print */
- (getattrfunc)crypto_X509Req_getattr,
+ NULL, /* getattr */
NULL, /* setattr */
NULL, /* compare */
NULL, /* repr */
diff --git a/OpenSSL/crypto/x509store.c b/OpenSSL/crypto/x509store.c
index 16af3b0..1452df6 100644
--- a/OpenSSL/crypto/x509store.c
+++ b/OpenSSL/crypto/x509store.c
@@ -92,36 +92,35 @@
}
-/*
- * Find attribute.
- *
- * Arguments: self - The X509Store object
- * name - The attribute name
- * Returns: A Python object for the attribute, or NULL if something went
- * wrong
- */
-static PyObject *
-crypto_X509Store_getattr(crypto_X509StoreObj *self, char *name)
-{
- return Py_FindMethod(crypto_X509Store_methods, (PyObject *)self, name);
-}
-
PyTypeObject crypto_X509Store_Type = {
- PyObject_HEAD_INIT(NULL)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"X509Store",
sizeof(crypto_X509StoreObj),
0,
(destructor)crypto_X509Store_dealloc,
NULL, /* print */
- (getattrfunc)crypto_X509Store_getattr,
+ NULL, /* getattr */
NULL, /* setattr */
NULL, /* compare */
NULL, /* repr */
NULL, /* as_number */
NULL, /* as_sequence */
NULL, /* as_mapping */
- NULL /* hash */
+ NULL, /* hash */
+ NULL, /* call */
+ NULL, /* str */
+ NULL, /* getattro */
+ NULL, /* setattro */
+ NULL, /* as_buffer */
+ Py_TPFLAGS_DEFAULT,
+ NULL, /* doc */
+ NULL, /* traverse */
+ NULL, /* clear */
+ NULL, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ NULL, /* tp_iter */
+ NULL, /* tp_iternext */
+ crypto_X509Store_methods, /* tp_methods */
};
diff --git a/OpenSSL/py3k.h b/OpenSSL/py3k.h
index dc46b43..443ad8d 100644
--- a/OpenSSL/py3k.h
+++ b/OpenSSL/py3k.h
@@ -10,6 +10,7 @@
PyInit_##name(void)
#define PyText_FromString PyUnicode_FromString
+#define PyText_FromStringAndSize PyUnicode_FromStringAndSize
#else /* (PY_VERSION_HEX >= 0x03000000) */
@@ -22,10 +23,12 @@
#define PyBytes_Size PyString_Size
#define PyBytes_Check PyString_Check
+#define PyBytes_CheckExact PyString_CheckExact
#define PyBytes_AsString PyString_AsString
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
#define PyText_FromString PyString_FromString
+#define PyText_FromStringAndSize PyString_FromStringAndSize
#define PyOpenSSL_MODINIT(name)
void \