# C stable api PY\_SSIZE\_T\_CLEAN error

**URL:** <https://discuss.python.org/t/c-stable-api-py-ssize-t-clean-error/80159>\
**Category:** Python Help\
**Created:** [February 10, 2025, 10:07am UTC](https://discuss.python.org/t/c-stable-api-py-ssize-t-clean-error/80159 "2025-02-10T10:07:47Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![replabrobin](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/replabrobin/32/8686_2.png) [@replabrobin](https://discuss.python.org/u/replabrobin)\
**Post date:** [February 10, 2025, 10:07am UTC](https://discuss.python.org/t/c-stable-api-py-ssize-t-clean-error/80159/1 "2025-02-10T10:07:47Z")

</div>

I maintain an optional reportlab c extension [rl-accel · PyPI](https://pypi.org/project/rl-accel/)

It has been working fine in Python 3.7 - 3.12 when compiled as a stable api 3.7 extension.

Problems were observed using this in 3.13 and 3.14 and I was advised that changes had made some commen macros behave differently. Compiling with a later python would improve things although speed might be reduced.

I now observe the following error when using a Python 3.14/3.13 compiled extension with python \<=3.12

> File “/home/robin/devel/reportlab/reportlab/pdfbase/ttfonts.py”, line 384, in makeStream  
> checksum = calcChecksum(data)  
> ^^^^^^^^^^^^^^^^^^  
> SystemError: PY\_SSIZE\_T\_CLEAN macro must be defined for ‘#’ formats

I thing the error comes from this function

```python
static PyObject *ttfonts_calcChecksum(PyObject *module, PyObject* args)
{
	unsigned char	*data;
	Py_ssize_t dataLen;
	unsigned long	Sum = 0L;
	unsigned char	*EndPtr;
	unsigned long n;
	int leftover;

	if (!PyArg_ParseTuple(args, "s#:calcChecksum", &data, &dataLen)) return NULL;

```

The source code contains this which does define PY\_SSIZE\_T\_CLEAN

```python
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include <stdlib.h>
#include <math.h>

```

So I don’t know how to fix.

How I can get a module thet covers 3.9 - 3.14?

---

_[View the full topic](https://discuss.python.org/t/c-stable-api-py-ssize-t-clean-error/80159)._
