[pypy-issue] [issue1190] cannot convert ‘PyStringObject*’ to ‘PyObject*’ in pycryptopp

Ian Delaney tracker at bugs.pypy.org
Thu Jun 21 13:23:16 CEST 2012

New submission from Ian Delaney <della5 at iinet.com.au>:

It appears it has fallen at the 'final hurdle' in package pycryptopp of latest
version number that defies description.

c++ -march=athlon64 -pipe -fomit-frame-pointer -O2 -fPIC -I.
-I/usr/lib64/pypy1.9/include -c src/pycryptopp/_pycryptoppmodule.cpp -o
build-2.7-pypy-1.9/temp.linux-x86_64-2.7/src/pycryptopp/_pycryptoppmodule.o -w
c++ -march=athlon64 -pipe -fomit-frame-pointer -O2 -fPIC -I.
-I/usr/lib64/pypy1.9/include -c src/pycryptopp/publickey/rsamodule.cpp -o
build-2.7-pypy-1.9/temp.linux-x86_64-2.7/src/pycryptopp/publickey/rsamodule.o -w
src/pycryptopp/publickey/rsamodule.cpp: In function ‘PyObject*
SigningKey_sign(SigningKey*, PyObject*)’:
src/pycryptopp/publickey/rsamodule.cpp:185:33: error: cannot convert
‘PyStringObject*’ to ‘PyObject*’ for argument ‘1’ to ‘char*
error: command 'c++' failed with exit status 1
failed (compile phase):
 *   Building failed with PyPy 1.9 (Python 2.7) in distutils_building() function

the culprit function from the rsamodule.cpp

static PyObject *
SigningKey_sign(SigningKey *self, PyObject *msgobj) {
    const char *msg;
    Py_ssize_t msgsize;
    PyString_AsStringAndSize(msgobj, const_cast<char**>(&msg),
    assert (msgsize >= 0);

    Py_ssize_t sigsize = self->k->SignatureLength();
    PyStringObject* result =
reinterpret_cast<PyStringObject*>(PyString_FromStringAndSize(NULL, sigsize));
    if (!result)
        return NULL;
    assert (sigsize >= 0);

    AutoSeededRandomPool randpool(false);
    Py_ssize_t siglengthwritten = self->k->SignMessage(
        reinterpret_cast<const byte*>(msg),
    if (siglengthwritten < sigsize)
        fprintf(stderr, "%s: %d: %s: %s", __FILE__, __LINE__, "SigningKey_sign",
"INTERNAL ERROR: signature was shorter than expected.");
    else if (siglengthwritten > sigsize) {
        fprintf(stderr, "%s: %d: %s: %s", __FILE__, __LINE__, "SigningKey_sign",
"INTERNAL ERROR: signature was longer than expected, so invalid memory was overwr$
    assert (siglengthwritten >= 0);

    return reinterpret_cast<PyObject*>(result);

reinterpret_cast<byte*>(PyString_AS_STRING(result))); is where it bailed out

messages: 4495
nosy: idella5, pypy-issue
priority: performance bug
release: 0.9
status: chatting
title: cannot convert ‘PyStringObject*’ to ‘PyObject*’ in pycryptopp

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list