xdelta3-python icon indicating copy to clipboard operation
xdelta3-python copied to clipboard

DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats

Open vadimszzz opened this issue 4 years ago • 9 comments

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 avatar Oct 28 '21 17:10 vadimszzz

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

vadimszzz avatar Oct 28 '21 17:10 vadimszzz

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,

vadimszzz avatar Oct 28 '21 17:10 vadimszzz

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

samuelcolvin avatar Oct 28 '21 17:10 samuelcolvin

@samuelcolvin review the PR please and publish new version.

vadimszzz avatar Oct 28 '21 19:10 vadimszzz

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

samuelcolvin avatar Oct 28 '21 20:10 samuelcolvin

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.

vadimszzz avatar Nov 08 '21 21:11 vadimszzz

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.

samuelcolvin avatar Nov 08 '21 21:11 samuelcolvin

Understandable, have a nice day

vadimszzz avatar Nov 10 '21 23:11 vadimszzz

@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.

vadimszzz avatar Dec 05 '21 22:12 vadimszzz