Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mgedmin opened this issue Mar 26, 2019 · 4 comments
Closed

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

mgedmin opened this issue Mar 26, 2019 · 4 comments

Comments

@mgedmin
Copy link
Contributor

mgedmin commented Mar 26, 2019

What did you do?

Ran my test suite on Python 3.8.0a3

What did you expect to happen?

The test to pass

What actually happened?

The tests did pass, but there were new deprecation warnings from Pillow:

.../.tox/py38/lib/python3.8/site-packages/PIL/Image.py:477: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
    return encoder(mode, *args + extra)

These were introduced by https://bugs.python.org/issue36381 to warn about an upcoming Python C API change. The meaning of PY_SSIZE_T_CLEAN is described in https://python.readthedocs.io/en/stable/c-api/arg.html#strings-and-buffers.

What Pillow needs to do is:

  • find all invocations of PyArg_Parse and related functions that use # formats
    make sure the type of the length argument is a Py_ssize_t
  • #define PY_SSIZE_T_CLEAN above the #include <Python.h>.

PY_SSIZE_T_CLEAN was introduced in Python 2.5 so there shouldn't be any backwards-compatibility issues.

What are your OS, Python and Pillow versions?

  • OS: Ubuntu 18.10
  • Python: 3.8.0a3
  • Pillow: 5.4.1

Reproduction

#!/usr/bin/env python3.8
import warnings
warnings.simplefilter("once")
from PIL import Image
Image.new("RGB", (1, 1)).save("/tmp/pixel.png")
@hugovk
Copy link
Member

hugovk commented Mar 26, 2019

Please could you test with #3749?

@mgedmin
Copy link
Contributor Author

mgedmin commented Mar 26, 2019

Of course I did a search for existing issues and didn't think to check for existing pull requests.

It looks like the same issue, and the PR looks good to me (who is an absolute stranger to the Python C API).

How do I pip install a github PR into a virtualenv to test?

@mgedmin
Copy link
Contributor Author

mgedmin commented Mar 26, 2019

How do I pip install a github PR into a virtualenv to test?

What I did was clone the repo, fetch the pull/3749 ref, check it out, and .tox/py36/bin/pip install ~/src/Pillow.

The deprecation warning is gone and all my tests pass.

@radarhere radarhere added Deprecation Feature that will be removed in the future and removed Deprecation Feature that will be removed in the future labels Mar 26, 2019
@hugovk
Copy link
Member

hugovk commented Mar 26, 2019

Thanks for the report and testing, #3749 has been merged and will be in Monday's 6.0.0 release.

@hugovk hugovk closed this as completed Mar 26, 2019
aecay added a commit to sky-uk/mite that referenced this issue Aug 2, 2019
jb098 pushed a commit to sky-uk/mite that referenced this issue Aug 2, 2019
DavAnnunz pushed a commit to sky-uk/mite that referenced this issue Aug 5, 2019
* Update unit tests, add support for running under tox

* Update requirements.txt etc.

also fix an error in one of the tests

* Refactored har tests, they now work and should be clearer what they are trying to achieve

* test_runner.py: fix

* Fix for new python c api

python-pillow/Pillow#3750
shlomif added a commit to shlomif/pyperl that referenced this issue Aug 3, 2021
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

No branches or pull requests

3 participants