Skip to content

fix: Python 3.13 compatibility fixes for C extension#1

Open
ping-ke wants to merge 1 commit into
masterfrom
upgrade-py3-13
Open

fix: Python 3.13 compatibility fixes for C extension#1
ping-ke wants to merge 1 commit into
masterfrom
upgrade-py3-13

Conversation

@ping-ke
Copy link
Copy Markdown

@ping-ke ping-ke commented May 9, 2026

  • Replace distutils with setuptools in setup.py
  • Remove alloca.h include (not needed, causes issues on some platforms)
  • Use Py_ssize_t for size parameters to match Python 3 API
  • Cast string/buffer args to const char * for Py_BuildValue
  • Fix memory leaks: use ethash_light_delete instead of free(L->cache), free s and h structs after ethash_light_compute
  • Add NULL check for PyModule_Create return value

- Replace distutils with setuptools in setup.py
- Remove alloca.h include (not needed, causes issues on some platforms)
- Use Py_ssize_t for size parameters to match Python 3 API
- Cast string/buffer args to const char * for Py_BuildValue
- Fix memory leaks: use ethash_light_delete instead of free(L->cache),
  free s and h structs after ethash_light_compute
- Add NULL check for PyModule_Create return value
Comment thread src/python/core.c
PyObject * val = Py_BuildValue(PY_STRING_FORMAT, L->cache, L->cache_size);
free(L->cache);
PyObject * val = Py_BuildValue(PY_STRING_FORMAT, L->cache, (Py_ssize_t)L->cache_size);
ethash_light_delete(L);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the old version always leaks memory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants