samuelcolvin / xdelta3-python

Fast delta encoding in python using xdelta3
Other
34 stars 15 forks source link

DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats #13

Open vadimszzz opened 2 years ago

vadimszzz commented 2 years ago

Running

with open(ramdisk['path'], "rb") as original, \
       open(f"{ramdisk['path']}.im4p", "rb") as new_file, \
       open(f"{bundle}/{ramdisk['name'][:-4]}.asr.delta", "wb") as delta:
       delta.write(xdelta3.encode(original.read(), new_file.read()))

results in

/Users/x/.pyenv/versions/3.9.0/lib/python3.9/site-packages/xdelta3/main.py:89: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
  return _xdelta3.execute(new_value, original, flags, 0)
/Users/x/.pyenv/versions/3.9.0/lib/python3.9/site-packages/xdelta3/main.py:89: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
  return _xdelta3.execute(new_value, original, flags, 0)
/Users/x/.pyenv/versions/3.9.0/lib/python3.9/site-packages/xdelta3/main.py:89: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
  return _xdelta3.execute(new_value, original, flags, 0)

View this issue for details: https://github.com/python-pillow/Pillow/issues/3750

Please update code to remove warnings

vadimszzz commented 2 years ago

The meaning of PY_SSIZE_T_CLEAN is described in https://python.readthedocs.io/en/stable/c-api/arg.html#strings-and-buffers.

vadimszzz commented 2 years ago

To fix this issue define PY_SSIZE_T_CLEAN before including python.h:

#define NOT_MAIN 1
#define PY_SSIZE_T_CLEAN

#include "xdelta3.h"
#include "xdelta3.c"
#include <Python.h>

You will also need to change the type passed to '#' formats from int to Py_ssize_t,

samuelcolvin commented 2 years ago

I'm not using this library at the moment, feel free to submit a PR.

vadimszzz commented 2 years ago

@samuelcolvin review the PR please and publish new version.

samuelcolvin commented 2 years ago

Thanks, I'll look at soon as I can.

vadimszzz commented 2 years ago

Hello! dude! Looks like I need to switch to another diff library, you forgot about your project. It doesn't work starting from Python 3.10 because of current issue.

samuelcolvin commented 2 years ago

Hi "dude", no I didn't forget about my project. I have a baby, am CTO of a PLC and maintain numerous open soccer projects. I don't have time to review, merge and deploy every pull request quickly.

By all means use another library.

vadimszzz commented 2 years ago

Understandable, have a nice day

vadimszzz commented 2 years ago

@samuelcolvin transfer ownership of the repository and pip project to me please if you don't want to maintain it. 30 days passed... My jabber: vadimszzz[at]xmpp.is.