M2Crypto: AttributeError: 'CSR' object has no attribute 'pkey'

Heikki Toivonen hjtoi-better-remove-before-reply at comcast.net
Sat Aug 1 14:19:13 EDT 2009


Matthias Güntert wrote:
> class CSR(object):
>     def __init__(self):
>         pass
> 
>     def create_cert_signing_request(keypair, cert_name,
> cert_extension_stack=None):

You missed self. Although this method does not seem to be using any
instance data so there isn't actually much reason to have a CSR object
unless you intend to expand it in ways that require it.

>         if cert_extension_stack != None:

A word of advice: always check equality/inequality to None with 'is',
because that way it is a straight pointer conversion which is faster and
won't cause any surprises. In other words, write the above as:

         if cert_extension_stack is not None:

-- 
  Heikki Toivonen - http://heikkitoivonen.net



More information about the Python-list mailing list