[issue45476] [C API] PEP 674: Disallow using macros as l-value

2022-01-27 Thread STINNER Victor


STINNER Victor  added the comment:

> * zodbpickle-2.2.0: src/zodbpickle/_pickle_33.c

Technically, zodbpickle works on Python 3.11 and is not impacted by the 
Py_SIZE() change.

_pickle_33.c redefines the Py_SIZE() macro to continue using as an l-value:
https://github.com/zopefoundation/zodbpickle/commit/8d99afcea980fc7bb2ef38aadf53300e08fc4318

I proposed a PR to use Py_SET_SIZE() explicitly:
https://github.com/zopefoundation/zodbpickle/pull/64

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2022-01-26 Thread STINNER Victor


STINNER Victor  added the comment:

> recordclass-0.16.3: lib/recordclass/_dataobject.c + code generated by Cython


I created: 
https://bitbucket.org/intellimath/recordclass/pull-requests/1/python-311-support-use-py_set_size

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2022-01-26 Thread STINNER Victor


STINNER Victor  added the comment:

> * scipy-1.7.3: scipy/_lib/boost/boost/python/object/make_instance.hpp

This is a vendored the Boost.org python module which has already been fixed in 
boost 1.78.0 (commit: January 2021) by:
https://github.com/boostorg/python/commit/500194edb7833d0627ce7a2595fec49d0aae2484

scipy should just update its scipy/_lib/boost copy.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2022-01-26 Thread STINNER Victor


STINNER Victor  added the comment:

> * guppy3-3.1.2: src/sets/bitset.c and src/sets/nodeset.c

I created: https://github.com/zhuyifei1999/guppy3/pull/40

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2022-01-26 Thread STINNER Victor


STINNER Victor  added the comment:

> pickle5-0.0.12: pickle5/_pickle.c

This project is a backport targeting Python 3.7 and older. I'm not sure if it 
makes sense to update to it to Python 3.11.

It's the same for pysha3 which targets Python <= 3.5.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2022-01-26 Thread STINNER Victor


STINNER Victor  added the comment:

> datatable-1.0.0.tar.gz

I created https://github.com/h2oai/datatable/pull/3231

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2022-01-26 Thread STINNER Victor


STINNER Victor  added the comment:

> In the PyPI top 5000, I found two projects using PyDescr_TYPE() and 
> PyDescr_NAME() as l-value: M2Crypto and mecab-python3. In both cases, it was 
> code generated by SWIG

I created bpo-46538 "[C API] Make the PyDescrObject structure opaque" to handle 
PyDescr_NAME() and PyDescr_TYPE() macros. But IMO it's not really worth it to 
make the PyDescrObject structure opaque. It's just too much work, whereas 
PyDescrObject is not performance sensitive. It's ok to continue exposing this 
structure in public for now.

I will exclude PyDescr_NAME() and PyDescr_TYPE() from the PEP 674.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-12-06 Thread STINNER Victor


STINNER Victor  added the comment:

> python-snappy-0.6.0: maybe_resize() in snappy/snappymodule.cc

I proposed a fix: https://github.com/andrix/python-snappy/pull/114

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-12-06 Thread STINNER Victor


STINNER Victor  added the comment:

> In the PyPI top 5000, I found two projects using PyDescr_TYPE() and 
> PyDescr_NAME() as l-value: M2Crypto and mecab-python3. In both cases, it was 
> code generated by SWIG

I proposed a first PR for Py_TYPE():
https://github.com/swig/swig/pull/2116

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-12-02 Thread Mark Dickinson


Change by Mark Dickinson :


--
nosy:  -mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-12-02 Thread STINNER Victor


STINNER Victor  added the comment:

> mypy-0.910

I proposed a fix: https://github.com/python/mypy/pull/11652

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-12-02 Thread STINNER Victor


STINNER Victor  added the comment:

> Naked-0.1.31

Affected code is only code generated by Cython: the project only has to 
regenerated code with a recent Cython version.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-12-02 Thread STINNER Victor


STINNER Victor  added the comment:

> pysha3-1.0.2

This module must not be used on Python 3.6 and newer which has a built-in 
support for SHA-3 hash functions. Example:

$ python3.6
Python 3.6.15 (default, Sep  5 2021, 00:00:00) 
>>> import hashlib
>>> h=hashlib.new('sha3_224'); h.update(b'hello'); print(h.hexdigest())
b87f88c72702fff1748e58b87e9141a42c0dbedc29a78cb0d4a5cd81

By the way, building pysha3 on Python 3.11 now fails with:

Modules/_sha3/backport.inc:78:10: fatal error: pystrhex.h: No such file or 
directory

The pystrhex.h header file has been removed in Python 3.11 by bpo-45434. But I 
don't think that it's worth it trying to port it to Python 3.11, if the module 
must not be used on Python 3.6 and newer.

Environment markers can be used to skip the pysha3 dependency on Python 3.6 on 
newer.

Example: "pysha3; python_version < '3.6'"

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-12-02 Thread STINNER Victor


STINNER Victor  added the comment:

> frozendict-2.1.1

If I understand correctly, this module is compatible with the PEP 674, it only 
has to copy Python 3.11 header files once Python 3.11 is released, to port the 
project to Python 3.11.

Incompatable code is not part of the "frozendict" implementation, but only in 
copies of the Python header files (Python 3.6, 3.7, 3.8, 3.9 and 3.10). For 
example, it contains the frozendict/src/3_10/cpython_src/Include/object.h 
header: copy of CPython Include/object.h file.

Source code: https://github.com/Marco-Sulla/python-frozendict

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-12-02 Thread STINNER Victor


STINNER Victor  added the comment:

> * zstd-1.5.0.2: src/python-zstd.c

I proposed a fix upstream: 
https://github.com/sergey-dryabzhinsky/python-zstd/pull/70

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-12-01 Thread STINNER Victor


STINNER Victor  added the comment:

Oops, sorry, pycurl-7.44.1 and PyGObject-3.42.0 are not affected, they only 
define Py_SET_TYPE() macro for backward compatibility. So right now, only 14 
projects are affected.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-12-01 Thread STINNER Victor


STINNER Victor  added the comment:

I updated my ./search_pypi_top_5000.py script to ignore files generated by 
Cython.

On PyPI top 5000, I only found 16 projects impacted by the PEP 674 (16/5000 = 
0.3%):

* datatable-1.0.0
* frozendict-2.1.1
* guppy3-3.1.2
* M2Crypto-0.38.0
* mecab-python3-1.0.4
* mypy-0.910
* Naked-0.1.31
* pickle5-0.0.12
* pycurl-7.44.1
* PyGObject-3.42.0
* pysha3-1.0.2
* python-snappy-0.6.0
* recordclass-0.16.3
* scipy-1.7.3
* zodbpickle-2.2.0
* zstd-1.5.0.2

I ignored manually two false positives in 3 projects:

* "#define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)" in Cython
* "* Py_TYPE(obj) = new_type must be replaced with Py_SET_TYPE(obj, new_type)": 
comment in psycopg2 and psycopg2-binary

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-11-30 Thread STINNER Victor


STINNER Victor  added the comment:

Attached pep674_regex.py generated a regex to search for code incompatible with 
the PEP 674.

To download PyPI top 5000, you can use my script:
https://github.com/vstinner/misc/blob/main/cpython/download_pypi_top.py

To grep a regex in tarball and ZIP archives, you can use the rg command:

$ rg -zl REGEX DIRECTORY/*.{zip,gz,bz2,tgz}

Or you can try my script:
https://github.com/vstinner/misc/blob/main/cpython/search_pypi_top.py

--
Added file: https://bugs.python.org/file50462/pep674_regex.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-11-30 Thread STINNER Victor


STINNER Victor  added the comment:

In the PyPI top 5000 projects, I found 32 projects using "Py_SIZE(obj) =
new_size": 8 of them are written manually, 24 use Cython.

8 projects using "Py_SIZE(obj) = new_size":

* guppy3-3.1.2: src/sets/bitset.c and src/sets/nodeset.c
* mypy-0.910: list_resize() in mypyc/lib-rt/pythonsupport.h
* pickle5-0.0.12: pickle5/_pickle.c
* python-snappy-0.6.0: maybe_resize() in snappy/snappymodule.cc
* recordclass-0.16.3: lib/recordclass/_dataobject.c + code generated by Cython
* scipy-1.7.3: scipy/_lib/boost/boost/python/object/make_instance.hpp
* zodbpickle-2.2.0: src/zodbpickle/_pickle_33.c
* zstd-1.5.0.2: src/python-zstd.c

24 projects using "Py_SIZE(obj) = new_size" generated by an outdated Cython:

* Naked-0.1.31
* Shapely-1.8.0
* dedupe-hcluster-0.3.8
* fastdtw-0.3.4
* fuzzyset-0.0.19
* gluonnlp-0.10.0
* hdbscan-0.8.27
* jenkspy-0.2.0
* lightfm-1.16
* neobolt-1.7.17
* orderedset-2.0.3
* ptvsd-4.3.2
* py_spy-0.3.11
* pyemd-0.5.1
* pyhacrf-datamade-0.2.5
* pyjq-2.5.2
* pypcap-1.2.3
* python-crfsuite-0.9.7
* reedsolo-1.5.4
* tables-3.6.1
* thriftpy-0.3.9
* thriftrw-1.8.1
* tinycss-0.4
* triangle-20200424

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-11-30 Thread STINNER Victor


STINNER Victor  added the comment:

I found 4 projects using "Py_TYPE(obj) = new_type;" in the PyPI top 5000:

mypy-0.910:

* mypyc/lib-rt/misc_ops.c: Py_TYPE(template_) = _Type;
* mypyc/lib-rt/misc_ops.c: Py_TYPE(t) = metaclass;

recordclass-0.16.3:

* lib/recordclass/_dataobject.c: Py_TYPE(op) = type;
* lib/recordclass/_dataobject.c: Py_TYPE(op) = type;
* lib/recordclass/_litetuple.c: // Py_TYPE(ob) = _Type;

pysha3-1.0.2:

* Modules/_sha3/sha3module.c: Py_TYPE(type) = _Type;

datatable-1.0.0.tar.gz:

* src/core/python/namedtuple.cc: Py_TYPE(v) = type.v;
* src/core/python/tuple.cc: Py_TYPE(v_new) = v_type;

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-11-30 Thread STINNER Victor


STINNER Victor  added the comment:

In the PyPI top 5000, I found two projects using PyDescr_TYPE() and 
PyDescr_NAME() as l-value: M2Crypto and mecab-python3. In both cases, it was 
code generated by SWIG:

 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 4.0.2

M2Crypto-0.38.0/src/SWIG/_m2crypto_wrap.c and 
mecab-python3-1.0.4/src/MeCab/MeCab_wrap.cpp contain the function:

SWIGINTERN PyGetSetDescrObject *
SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) {

  PyGetSetDescrObject *descr;
  descr = (PyGetSetDescrObject *)PyType_GenericAlloc(SwigPyStaticVar_Type(), 0);
  assert(descr);
  Py_XINCREF(type);
  PyDescr_TYPE(descr) = type;
  PyDescr_NAME(descr) = PyString_InternFromString(getset->name);
  descr->d_getset = getset;
  if (PyDescr_NAME(descr) == NULL) {
Py_DECREF(descr);
descr = NULL;
  }
  return descr;
}

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45476] [C API] PEP 674: Disallow using macros as l-value

2021-11-30 Thread STINNER Victor


Change by STINNER Victor :


--
title: [C API] Disallow using PyFloat_AS_DOUBLE() as l-value -> [C API] PEP 
674: Disallow using macros as l-value

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com