[New-bugs-announce] [issue43435] Py_BuildValue("y#".... returns incomplete result

David Wood report at bugs.python.org
Mon Mar 8 10:31:33 EST 2021


New submission from David Wood <dwoodjunkmail at gmail.com>:

I have a c function to encrypt values which returns an array of bytes.  The function returns proper values outside of python.  When used as a python function, the result is incomplete usually 10-20% of the time.  If I add a sleep(1) call before returning from the function, my success rate goes to 100%.  While this works, it is unacceptable as it will create enormous latency in my application.

static PyObject *method_encrypt(PyObject *self, PyObject *args) {
	char *keyval, *str = NULL, output[512];
	Py_ssize_t count=0;
	PyObject *retval;

	if(!PyArg_ParseTuple(args, "ss", &str, &keyval)) {
		return NULL;
	}

	encryptBlowfishCfb(str, &count, output, keyval);

	retval = Py_BuildValue("y#", output, count);
	//sleep(1);
	return retval;
}

----------
components: C API
messages: 388268
nosy: dwoodjunkmail
priority: normal
severity: normal
status: open
title: Py_BuildValue("y#".... returns incomplete result
type: performance
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43435>
_______________________________________


More information about the New-bugs-announce mailing list