Convert to getattro some more; also swap PyBytes_AsString for _PyUnicode_AsString when we know the input is unicode, not bytes
diff --git a/OpenSSL/crypto/x509name.c b/OpenSSL/crypto/x509name.c
index c288180..83f3c21 100644
--- a/OpenSSL/crypto/x509name.c
+++ b/OpenSSL/crypto/x509name.c
@@ -148,10 +148,11 @@
* wrong
*/
static PyObject *
-crypto_X509Name_getattr(crypto_X509NameObj *self, char *name)
+crypto_X509Name_getattro(crypto_X509NameObj *self, PyObject *nameobj)
{
int nid, len;
char *utf8string;
+ char *name = _PyUnicode_AsString(nameobj);
if ((nid = OBJ_txt2nid(name)) == NID_undef) {
/*
@@ -162,7 +163,7 @@
* See lp#314814.
*/
flush_error_queue();
- return crypto_X509Name_Type.tp_getattr((PyObject*)self, name);
+ return PyObject_GenericGetAttr((PyObject*)self, nameobj);
}
len = get_name_by_nid(self->x509_name, nid, &utf8string);
@@ -461,7 +462,7 @@
0,
(destructor)crypto_X509Name_dealloc,
NULL, /* print */
- (getattrfunc)crypto_X509Name_getattr,
+ NULL, /* getattr */
(setattrfunc)crypto_X509Name_setattr,
NULL, /* reserved */
(reprfunc)crypto_X509Name_repr,
@@ -471,7 +472,7 @@
NULL, /* hash */
NULL, /* call */
NULL, /* str */
- NULL, /* getattro */
+ (getattrofunc)crypto_X509Name_getattro, /* getattro */
NULL, /* setattro */
NULL, /* as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */