[issue476852] Some bad macros in abstract.h

2022-04-10 Thread admin


Change by admin :


--
github: None -> 35435

___
Python tracker 

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



[issue443775] Update to the BEGIN_ALLOW_THREADS macros

2022-04-10 Thread admin


Change by admin :


--
github: None -> 34815

___
Python tracker 

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



[issue47261] RFC: Clarify usage of macros for PySequence_Fast within the Limited C API

2022-04-08 Thread Rohit Goswami


Change by Rohit Goswami :


--
title: RFC: Clarify Limited API macros for PySequence_Fast -> RFC: Clarify 
usage of macros for PySequence_Fast within the Limited C API

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



[issue47261] RFC: Clarify Limited API macros for PySequence_Fast

2022-04-08 Thread Rohit Goswami


Rohit Goswami  added the comment:

Perhaps to be clear, there are two possibilities:
1. `PySequence_Fast` should be removed from the Limited API
2. All macros used with `PySequence_Fast` are valid for use in the context of 
the Limited API

In either case the documentation should need to be clarified.

The only situation where no changes would result is if:
- `PySequence_Fast` is part of the Limited API, but must be treated the same as 
a regular `PySequence` object
  + Since only `PySequence_Size` and other variants can be used in the context 
of the Limited API

This is actually also still confusing and should be mentioned clearly.

--

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



[issue47261] RFC: Clarify Limited API macros for PySequence_Fast

2022-04-08 Thread Rohit Goswami


Change by Rohit Goswami :


--
assignee:  -> docs@python
components: +C API, Documentation
nosy: +docs@python

___
Python tracker 

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



[issue47261] RFC: Clarify Limited API macros for PySequence_Fast

2022-04-08 Thread Rohit Goswami


New submission from Rohit Goswami :

The `current documentation`_ of the Python-C API mentions that 
``PySequence_Fast`` is part of the limited API. However, this may be a typo as 
all the functions interacting with a ``PySequence_Fast`` object are macros, 
e.g. `PySequence_Fast_GET_SIZE`, `PySequence_Fast_GET_ITEM` etc.

If this is indeed a documentation bug I'm happy to open a PR to fix this once 
consensus is reached.






.. _`current documentation` : 
https://docs.python.org/3/c-api/stable.html#contents-of-limited-api

--
messages: 416989
nosy: rgoswami
priority: normal
severity: normal
status: open
title: RFC: Clarify Limited API macros for PySequence_Fast

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-04-05 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-31 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-31 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +30286
pull_request: https://github.com/python/cpython/pull/32210

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-31 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 7fc39a21cb85163a456eab91b52e5fe85e7f7e3e by Victor Stinner in 
branch 'main':
bpo-47164: Add _PyCFunctionObject_CAST() macr (GH-32190)
https://github.com/python/cpython/commit/7fc39a21cb85163a456eab91b52e5fe85e7f7e3e


--

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-31 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f0bc69485677ae8973685866ada0982976d3878f by Victor Stinner in 
branch 'main':
bpo-47164: Add _PyCFunction_CAST() macro (GH-32192)
https://github.com/python/cpython/commit/f0bc69485677ae8973685866ada0982976d3878f


--

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-31 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset c14d7e4b816134b8e93ece4066a86d229631ce96 by Victor Stinner in 
branch 'main':
bpo-47164: Add _PyASCIIObject_CAST() macro (GH-32191)
https://github.com/python/cpython/commit/c14d7e4b816134b8e93ece4066a86d229631ce96


--

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-31 Thread STINNER Victor


STINNER Victor  added the comment:

After reading Mark's comments, I reworked my GH-32190 PR to only use the CAST 
macros in other macros, not in the C code. The CAST macros are not used in such 
code pattern:

 else if (PyCFunction_Check(func))
-return ((PyCFunctionObject*)func)->m_ml->ml_name;
+return _PyCFunctionObject_CAST(func)->m_ml->ml_name;

In fact, this change doesn't bring any value.

--

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread STINNER Victor


STINNER Victor  added the comment:

> I've had to debug a segfault before only because the inline function 
> implicitly cast its arguments, and it was accessing a non-existent member. If 
> it were a macro it would access the struct member directly, and the compiler 
> would be able to catch that and warn me before runtime.

This is part of Python C API legacy and as I wrote, it's not going to change 
soon. The minor enhancement that we can do is to inject an assertion when 
Python is built in debug mode.

--

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread Ken Jin


Ken Jin  added the comment:

@Victor,

I'm not against (A) or any of the PRs you proposed. They look fine to me. My 
concern was with certain static inline functions (there are none here :). The 
_CAST macros have genuinely helped me debug code before.

--

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread STINNER Victor


STINNER Victor  added the comment:

GH-32192 "Add _PyCFunction_CAST() macro" is special. It's used to define 
functions in PyTypeObject.tp_methods or PyModuleDef.m_methods.

Casting a function pointer can cause issues with Control Flow Integrity (CFI) 
implemented in LLVM. The _thread module has an undefined behavior fixed by the 
commit 9eea6eaf23067880f4af3a130e3f67c9812e2f30 of bpo-33015. Previously, a 
cast ignored that the callback has no return value, whereas pthread_create() 
requires a function which as a void* return value.

To fix compiler warnings, the (PyCFunction)func cast was replaced with the 
(PyCFunction)(void(*)(void))func cast to fix bpo-bpo-33012 GCC 8 compiler 
warning:

warning: cast between incompatible function types (...)

--

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread STINNER Victor


STINNER Victor  added the comment:

Hum, there are two things and maybe we are not talking about the same thing.

* (A) Modifying macros defined in the Python C API (Include/ header files) 
doing cast on their arguments to use CAST macros
* (B) Modify C code doing casts to use CAST macros

I created this issue for (A). I propose to do (B), but this part is optional.

Mark, Ken: are you fine with (A)? Is your concern about (B)?

But modifying macros to remove the cast of their argument is out of the scope 
of this issue. As I wrote, it would add compiler warnings, something that I 
would like to avoid. See:
https://peps.python.org/pep-0670/#cast-pointer-arguments

--

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread STINNER Victor


STINNER Victor  added the comment:

> By the way, the current Python C API is not fully compatible with C++. (...)

I created bpo-47165 "[C API] Test that the Python C API is compatible with C++".

--

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread STINNER Victor


STINNER Victor  added the comment:

> I think that adding macros makes readability worse.

See the attached PRs, I can remove multiple layers of parenthesis in macros by 
using CAST macros.

> ```
> PyObject *func = ...;
> int flags = PyCFunction_GET_FLAGS(func);
> ```
>
> is dangerous.

Right.

PEP 670 proposes to remove the cast, but only in the limited C API version 3.11 
or newer. Sadly, I don't think that we can remove the cast in the general 
Python C API, it would simply add too many compiler warnings in existing C 
extensions which previously built without warnings. (See also PEP 670 
discussions on python-dev).

Currently, PyCFunction_GET_FLAGS() doesn't check its argument. The macro 
documentation is quite explicit about it:

/* Macros for direct access to these values. Type checks are *not*
   done, so use with care. */

My GH-32190 PR adds a check in debug mode. So using PyCFunction_GET_FLAGS() in 
debug mode is safer with this PR.

--

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread Ken Jin


Ken Jin  added the comment:

> tiny inline function obscures the meaning of code

Sadly I have to agree with Mark for that specific case. I've had to debug a 
segfault before only because the inline function implicitly cast its arguments, 
and it was accessing a non-existent member. If it were a macro it would access 
the struct member directly, and the compiler would be able to catch that and 
warn me before runtime.

However, for the case of _PyCFunctionObject_CAST, I'm not against it. The 
assert(PyCFunction_Check) pattern has genuinely helped me catch problems in the 
case of similar macros.

--
nosy: +kj

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +30270
pull_request: https://github.com/python/cpython/pull/32192

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +30269
pull_request: https://github.com/python/cpython/pull/32191

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread Mark Shannon


Mark Shannon  added the comment:

The problem in the example you give is the need for the cast in the first 
place. If `func` were a `PyCFunctionObject *` instead of a `PyObject *`, then 
there would be no cast.


Making the casts explicit serves as a reminder that a type check is needed.

```
PyObject *func = ...;
int flags = PyCFunction_GET_FLAGS(func);
```

is dangerous.

```
PyObject *obj = ...;
if (PyCFunction_Check(obj)) {
PyCFunctionObject *func = (PyCFunctionObject *)obj;
int flags = func->m_ml->ml_flags;
```

is safe.

--

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread Mark Shannon


Mark Shannon  added the comment:

I think that adding macros makes readability worse.

The macro is only more readable if you already know what it does.
If you don't, then you need to look up the macro, and understand the cast in 
the macro (which is harder than understanding the original cast).


In general, I find the excessive use of macros and tiny inline function 
obscures the meaning of code, and makes it hard to reason about what the code 
is doing.

A few well chosen macros (like Py_INCREF(), etc) can definitely help 
readability, but if there are too many then anyone reading the code ends up 
having to lookup loads of macro definitions to understand the code.



Without the macro, the reader needs to parse the cast, which is admittedly a

--
nosy: +Mark.Shannon

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +30268
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/32190

___
Python tracker 

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



[issue47164] [C API] Add private "CAST" macros to clean up casts in C code

2022-03-30 Thread STINNER Victor


New submission from STINNER Victor :

Last years, I started to add "CAST" macros like:

#define _PyObject_CAST(op) ((PyObject*)(op))
#define _PyType_CAST(op) (assert(PyType_Check(op)), (PyTypeObject*)(op))

Example of usage:

#define PyObject_TypeCheck(ob, type) PyObject_TypeCheck(_PyObject_CAST(ob), 
type)

These macros avoids parenthesis. Example without CAST macro:

#define PyCFunction_GET_FLAGS(func) \
(((PyCFunctionObject *)func) -> m_ml -> ml_flags)

Currently, inline cast requires adding parenthesis:

   ((PyCFunctionObject *)func)

IMO it's more readable with a CAST macro:

#define _PyCFunction_CAST(func) ((PyCFunctionObject *)func)
#define PyCFunction_GET_FLAGS(func) \
(_PyCFunction_CAST(func)->m_ml->ml_flags)


I propose to add more CAST macros.

By the way, the current Python C API is not fully compatible with C++. 
"(type)expr" C syntax is seen as "old-style cast" in C++ which recommends 
static_cast(expr), reinterpret_cast(expr), or another kind of cast. 
But I prefer to discuss C++ in a separated issue ;-) IMO without considering 
C++, adding CAST macros is worth it for readability.

I am preparing pull requests for add CAST macros and use existing CAST macros.

--
components: C API
messages: 416350
nosy: vstinner
priority: normal
severity: normal
status: open
title: [C API] Add private "CAST" macros to clean up casts in C code
versions: Python 3.11

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



[issue45490] [C API] PEP 670: Convert macros to functions in the Python C API

2022-02-11 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset e0bcfd0e4db193743d4bafc48d10f15ae9ed7b2b by Victor Stinner in 
branch 'main':
bpo-45490: Rename static inline functions (GH-31217)
https://github.com/python/cpython/commit/e0bcfd0e4db193743d4bafc48d10f15ae9ed7b2b


--

___
Python tracker 

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



[issue45490] [C API] PEP 670: Convert macros to functions in the Python C API

2022-02-10 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

I made a list of macros that reuse their argument some time around 
February/March 2021. (Each macro is squashed into a single line for some reason 
I can't remember.) See attachment, or check out the gist version:

https://gist.github.com/erlend-aasland/a7ca3cff95b136e272ff5b03447aff21

--
Added file: https://bugs.python.org/file50616/macros-that-reuse-args.txt

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



[issue45490] [C API] PEP 670: Convert macros to functions in the Python C API

2022-02-08 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29391
pull_request: https://github.com/python/cpython/pull/31221

___
Python tracker 

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



[issue45490] [C API] PEP 670: Convert macros to functions in the Python C API

2022-02-08 Thread STINNER Victor


STINNER Victor  added the comment:

I will use this issue to track changes related to PEP 670.

--
title: [meta][C API] Avoid C macro pitfalls and usage of static inline 
functions -> [C API]  PEP 670: Convert macros to functions in the Python C API

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f20ca766fe404a20daea29230f161a0eb71bb489 by Victor Stinner in 
branch 'main':
bpo-46670: Fix #ifdef in sha3module.c (GH-31180)
https://github.com/python/cpython/commit/f20ca766fe404a20daea29230f161a0eb71bb489


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 7d8b69e1d1f125454d8cec81ff0dee72f2bef957 by Victor Stinner in 
branch 'main':
bpo-46670: Remove unused macros in the Python directory (GH-31192)
https://github.com/python/cpython/commit/7d8b69e1d1f125454d8cec81ff0dee72f2bef957


--

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 760349198dbd8771629753e096a885c1aa28a1ca by Victor Stinner in 
branch 'main':
bpo-46670: Remove unused macros in the Objects directory (GH-31193)
https://github.com/python/cpython/commit/760349198dbd8771629753e096a885c1aa28a1ca


--

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 4f1d3f33dd8b37a151b73533f18b08b0500223e5 by Victor Stinner in 
branch 'main':
 bpo-46670: Remove unused macros in the Modules directory (GH-31194)
https://github.com/python/cpython/commit/4f1d3f33dd8b37a151b73533f18b08b0500223e5


--

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 4b603f628207b380a8a2f22d7ff5d2dbb0853e2e by Victor Stinner in 
branch 'main':
bpo-46670: Remove unused macros in ceval.c (GH-31196)
https://github.com/python/cpython/commit/4b603f628207b380a8a2f22d7ff5d2dbb0853e2e


--
nosy: +Mark.Shannon

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29366
pull_request: https://github.com/python/cpython/pull/31196

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


STINNER Victor  added the comment:

-Wexpansion-to-defined and -Wunused-macros options are also interesting.

--

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29364
pull_request: https://github.com/python/cpython/pull/31194

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29363
pull_request: https://github.com/python/cpython/pull/31193

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29362
pull_request: https://github.com/python/cpython/pull/31192

___
Python tracker 

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



[issue20342] Endianness not detected correctly due to AC_RUN_IFELSE macros

2022-02-07 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

I'll leave it open, nothing about this should be ppc64 vs ppc64el specific. Our 
cross compilation story has historically been not great.  

Building for a target of one endianness from a build host of other 
endianness... sounds like exactly one of many kinds of thing that we might have 
a mess with until someone can confirm.  (I'm not setup with a big endian 
toolchain to build for a qemu target right now so I can't easily confirm)

--

___
Python tracker 

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



[issue20342] Endianness not detected correctly due to AC_RUN_IFELSE macros

2022-02-07 Thread Yury V. Zaytsev


Yury V. Zaytsev  added the comment:

Well, the machine that I had the problem on does no longer exist and I'm not 
sure whether this is a generic POWER issue.

The problem was that I had to cross-compile Python on one generation of POWER 
machines for another POWER chip using its own special toolchain. I can't tell 
whether Python build system was doing something wrong, or else whether it was a 
problem with the toolchain. In theory, both are valid options.

Also, I can't test whether the current version of Python has this problem or 
not with this particular chip / toolchain anymore. Maybe someone who has 
interest in POWER could try to cross-compile from AMD64 to POWER and check 
whether the result is still subtly broken... this should be much easier, and if 
there is a genuine problem with Python build system, it will probably expose it 
just as well.

--

___
Python tracker 

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



[issue20342] Endianness not detected correctly due to AC_RUN_IFELSE macros

2022-02-07 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

any idea if this is still relevant?

--
components: +Cross-Build
nosy: +Alex.Willmer, gregory.p.smith

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset b556f53785cb9ad8cc088ad8c10efee91fe3da58 by Victor Stinner in 
branch 'main':
bpo-46670: Test if a macro is defined, not its value (GH-31178)
https://github.com/python/cpython/commit/b556f53785cb9ad8cc088ad8c10efee91fe3da58


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29351
pull_request: https://github.com/python/cpython/pull/31180

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 097f74a5a37e2a8a26d529cede456ede7011b66f by Victor Stinner in 
branch 'main':
bpo-46670: Define all macros for stringlib (GH-31176)
https://github.com/python/cpython/commit/097f74a5a37e2a8a26d529cede456ede7011b66f


--

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 16f96a4cf9ab1e91e6e8e18232378bc4b42bb796 by Victor Stinner in 
branch 'main':
bpo-46670: Remove unused get_frame_state() function (GH-31177)
https://github.com/python/cpython/commit/16f96a4cf9ab1e91e6e8e18232378bc4b42bb796


--

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29350
pull_request: https://github.com/python/cpython/pull/31179

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29349
pull_request: https://github.com/python/cpython/pull/31178

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29348
pull_request: https://github.com/python/cpython/pull/31177

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +29347
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31176

___
Python tracker 

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



[issue46670] Build Python with -Wundef: don't use undefined macros

2022-02-06 Thread STINNER Victor


New submission from STINNER Victor :

Building Python with "gcc -Wundef" emits many warnings about usage of undefined 
macros. If a macro is not defined, it is equal to 0.

The problem is that a macro can be undefined because of a missing #include, or 
because of a typo in its name, or because "#ifdef MACRO" should be used instead 
of "#if MACRO". It can hide bugs.

I plan to fix these warnings.

--
components: Build
messages: 412690
nosy: vstinner
priority: normal
severity: normal
status: open
title: Build Python with -Wundef: don't use undefined macros
versions: Python 3.11

___
Python tracker 
<https://bugs.python.org/issue46670>
___
___
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 (Py_TYPE and Py_SIZE) as l-value

2022-01-27 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 
<https://bugs.python.org/issue45476>
___
___
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-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 
<https://bugs.python.org/issue45476>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46253] C API documentation of Py_UNICODE_* character properties macros use Py_UNICODE instead of Py_UCS4

2022-01-11 Thread miss-islington


miss-islington  added the comment:


New changeset 238a36b753affd373a315b81a5024aed7ebf6479 by Miss Islington (bot) 
in branch '3.9':
closes bpo-46253: Change Py_UNICODE to Py_UCS4 in the C API docs to match the 
current source code (GH-30387)
https://github.com/python/cpython/commit/238a36b753affd373a315b81a5024aed7ebf6479


--

___
Python tracker 

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



[issue46253] C API documentation of Py_UNICODE_* character properties macros use Py_UNICODE instead of Py_UCS4

2022-01-11 Thread miss-islington


miss-islington  added the comment:


New changeset 4cfb10979d74b8513ec751b81454709f38e3b51a by Miss Islington (bot) 
in branch '3.10':
closes bpo-46253: Change Py_UNICODE to Py_UCS4 in the C API docs to match the 
current source code (GH-30387)
https://github.com/python/cpython/commit/4cfb10979d74b8513ec751b81454709f38e3b51a


--

___
Python tracker 

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



[issue46253] C API documentation of Py_UNICODE_* character properties macros use Py_UNICODE instead of Py_UCS4

2022-01-11 Thread miss-islington


Change by miss-islington :


--
pull_requests: +28735
pull_request: https://github.com/python/cpython/pull/30534

___
Python tracker 

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



[issue46253] C API documentation of Py_UNICODE_* character properties macros use Py_UNICODE instead of Py_UCS4

2022-01-11 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset 43c5c1369cb21f08a1dc1d63923c3586b883e3e8 by Julian Gilbey in 
branch 'main':
closes bpo-46253: Change Py_UNICODE to Py_UCS4 in the C API docs to match the 
current source code (GH-30387)
https://github.com/python/cpython/commit/43c5c1369cb21f08a1dc1d63923c3586b883e3e8


--
nosy: +benjamin.peterson
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue46253] C API documentation of Py_UNICODE_* character properties macros use Py_UNICODE instead of Py_UCS4

2022-01-11 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +28734
pull_request: https://github.com/python/cpython/pull/30533

___
Python tracker 

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



[issue46253] C API documentation of Py_UNICODE_* character properties macros use Py_UNICODE instead of Py_UCS4

2022-01-03 Thread Julian Gilbey


Change by Julian Gilbey :


--
keywords: +patch
pull_requests: +28595
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30387

___
Python tracker 

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



[issue46253] C API documentation of Py_UNICODE_* character properties macros use Py_UNICODE instead of Py_UCS4

2022-01-03 Thread Julian Gilbey


New submission from Julian Gilbey :

The documentation at 
https://docs.python.org/3/c-api/unicode.html?highlight=isalpha#unicode-character-properties
 lists a series of macros such as Py_UNICODE_ISSPACE(Py_UNICODE ch).  However, 
the input type for these macros was changed from Py_UNICODE to Py_UCS4 in 
commit 324ac65cebf4b0141b946452a2604715f1ca7010 on Wed Aug 18 20:44:58 2010 
+, but it seems that the documentation has never been updated.  The fix 
should be easy; I'll make a PR for it.

--
assignee: docs@python
components: Documentation
messages: 409649
nosy: docs@python, juliangilbey
priority: normal
severity: normal
status: open
title: C API documentation of Py_UNICODE_* character properties macros use 
Py_UNICODE instead of Py_UCS4
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 
<https://bugs.python.org/issue46253>
___
___
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 
<https://bugs.python.org/issue45476>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-19 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset 7e44dc0ba768451f287a541cd1c85f7d87a41561 by Christian Heimes in 
branch 'main':
bpo-45573: Move mandatory core modules to Modules/Setup.bootstrap (GH-29616)
https://github.com/python/cpython/commit/7e44dc0ba768451f287a541cd1c85f7d87a41561


--

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-19 Thread Christian Heimes


Christian Heimes  added the comment:

Erlend implemented pkg-config for sqlite3 in bpo-45774. Thanks to his tireless 
effort we now have a blue print how to port other checks to optional pkg-config 
lookup.

--
superseder:  -> Detect SQLite in configure.ac

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-18 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset e4bb22fabbea72776b377733047e0f32e0388059 by Christian Heimes in 
branch 'main':
bpo-45573: Add Modules/Setup.stdlib with conditional modules (GH-29615)
https://github.com/python/cpython/commit/e4bb22fabbea72776b377733047e0f32e0388059


--

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-18 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +27852
pull_request: https://github.com/python/cpython/pull/29616

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-18 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +27851
pull_request: https://github.com/python/cpython/pull/29615

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-18 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset 5275e59c0c1b26226608e6c7c2548c26192d6575 by Christian Heimes in 
branch 'main':
bpo-45573: check for ossaudiodev in configure (GH-29614)
https://github.com/python/cpython/commit/5275e59c0c1b26226608e6c7c2548c26192d6575


--

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-18 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +27850
pull_request: https://github.com/python/cpython/pull/29614

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-18 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset 25ecc040d007a55e4b5c30fa739054b52c1aacac by Christian Heimes in 
branch 'main':
bpo-45573: Introduce extension module flags in Makefile (GH-29594)
https://github.com/python/cpython/commit/25ecc040d007a55e4b5c30fa739054b52c1aacac


--

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-17 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +27837
pull_request: https://github.com/python/cpython/pull/29594

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-15 Thread Brett Cannon


Brett Cannon  added the comment:

> Is traditional cross-compiling work still useful these days anyway?

Yes for things like WebAssembly where there is no equivalent of an emulated CPU 
under QEMU.

--

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-14 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset c3997865f24d9491318b401ae8e46d27332aca25 by Christian Heimes in 
branch 'main':
bpo-45573: Use Makefile's dependencies in setup.py (GH-29559)
https://github.com/python/cpython/commit/c3997865f24d9491318b401ae8e46d27332aca25


--

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-14 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +27807
pull_request: https://github.com/python/cpython/pull/29559

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-12 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +27784
pull_request: https://github.com/python/cpython/pull/29534

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-10 Thread Christian Heimes


Christian Heimes  added the comment:

gdbmmodule and dbmmodule need special treatment anyway. macOS has dbm-API build 
into libc. Linux has either libgdbm_compat, libndbm, or libdb. The 
--with-dbmliborder makes it even more interesting. Users can override in which 
order they want to probe for gdbm, ndbm, and libdb. We have to keep the 
"manual" library and header checks.

Cross-compilation with pkg-config uses a trivial wrapper script, 
https://autotools.io/pkgconfig/cross-compiling.html . The build system has to 
create and provide a script with correct sysroot setting.

Is traditional cross-compiling work still useful these days anyway? Emulation 
has made big leaps in the last decade. Emulated cross compiling with qemu has 
become widespread. It also has the big advantage that you can run the test 
suite on the emulated hardware and verify that your binaries work. AFAIK 
Fedora's build system uses qemu for a bunch of hardware targets.

--

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-10 Thread Ned Deily


Ned Deily  added the comment:

SGTM,2

This all sounds great. I think a goal here should be to remove all header and 
lib file searching from setup.py as that has always been a bug magnet. Perhaps 
one workaround for those libs that don't (yet) provide .pc files would be for 
us to supply reasonable default .pc for them, if possible, so that most 
builders wouldn't have to set the MODULE_xxx_*FLAGS variables while still 
removing the header/lib file searching from setup.py? Also it would be great to 
document how using pkg-config works in generic cross-compiling cases; we should 
strive to make at least the most common cases just work with minimal tweaking 
of configure arguments.

--

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-10 Thread Brett Cannon


Brett Cannon  added the comment:

SGTM!

--

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-10 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
nosy: +erlendaasland

___
Python tracker 

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



[issue45573] Use pkg-config autoconf macros to detect flags for Modules/Setup

2021-11-10 Thread Christian Heimes


Christian Heimes  added the comment:

We can detect majority of our dependencies with pkg-config. The use of 
pkg-config has some benefits:

* Distro's provide the .pc files in their -dev / -devel packages. The presence 
of a .pc file indicates that all development dependencies are available.

* pkg-config does the right thing for non-standard include and libraries 
directories as well as multiarch builds. In case a library or header is not on 
the default search path, pkg-config returns necessary -I and -L flags.

* At least the pkgconf implementation of pkg-config standard search /usr/local 
and ~/.local/ directories for .pc files. Cases like 
https://github.com/python/cpython/pull/29507 are handled correctly. On FreeBSD 
"pkgconf sqlite3 --cflags --libs" returns "-I/usr/local/include 
-L/usr/local/lib -lsqlite3".

* pkg-config understands dependencies. For example "pkg-config --libs tk" 
returns linker flags for TK *and* TCL.

* pkg-config can check for module version, e.g. "pkg-config sqlite3 
--atleast-version=3.7.15"


pkg-config modules:

  readline, libedit
  ncursesw, ncurses, panel, tinfo
  sqlite3
  zlib
  bzip2
  liblzma
  expat
  uuid (Linux's util-linux uuid)
  libffi
  libnsl, libtirpc
  libcrypt
  tcl, tk
  openssl, libssl, libcrypto
  
modules / libraries without pkg-config modules:

  decimal: libmpdec
  gdbm: gdbm
  dbm: gdbm_compat, ndbm, libdb (bdb)


To simplify use of flags in Modules/Setup, I propose to add two make variables 
for each module that needs cflags and ldflags:

  f"MODULE_{ext.name.upper()}_CFLAGS"
  f"MODULE_{ext.name.upper()}_LDFLAGS"

e.g. for the _ssl module:

  MODULE__SSL_CFLAGS=
  MODULE__SSL_LDFLAGS=-lssl -lcrypto

Then use the flags from Makefile in setup.py:

def update_extension_flags(self, ext):
name = ext.name.upper()
cflags = sysconfig.get_config_var(f"MODULE_{name}_CFLAGS")
if cflags:
ext.extra_compile_args.extend(shlex.split(cflags))
ldflags = sysconfig.get_config_var(f"MODULE_{name}_LDFLAGS")
if ldflags:
ext.extra_link_args.extend(shlex.split(ldflags))
return ext

Finally update Modules/makesetup to use the new variables, too.

--

___
Python tracker 

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



  1   2   3   4   5   6   7   8   >