Python seg faults with M2Crypto

Jeff Johnson usenet at jeffjohnson.net
Fri Nov 16 10:15:39 EST 2001


The following script causes "Segmentation fault (core dumped)" on
FreeBSD 4.3, Python 2.1.1, M2Crypto all from the ports tree.  Can
anyone else reproduce this?

-Jeff


class X:
    def _submit(self, dict, headers=[]):
        """
        Given a dict of form variables, make the HTTPS POST.
        """
        import urllib
        from M2Crypto import httpslib, SSL ## only until python 2
comes out
        data = urllib.urlencode(dict)

        h = httpslib.HTTPS(self._secureServer)
        h.putrequest('POST', "/" + self._securePage)
        h.putheader('Content-type',
'application/x-www-form-urlencoded')
        h.putheader('Content-length', '%d' % len(data))
        for head in headers:
            h.putheader(*head)
        h.endheaders()
        h.send(data)

        errcode, errmsg, headers = h.getreply()
        assert errcode==200, \
               "problem reading from %s: %s, %s" \
               % (self._secureServer, errcode, errmsg)
        fp = h.getfile()

        content = ""
        chunk = "start"
        while len(chunk) != 0:
            chunk = fp.read()
            content += chunk
        fp.close()

        return content


x = X()
x._secureServer = "secure.authorize.net"
x._securePage = "gateway/transact.dll"

d={"x_Test_Request": "TRUE"}
h=[]

#for i in  range(20):
print x._submit(d, h)



More information about the Python-list mailing list