[issue43181] Python macros don’t shield arguments

2021-03-22 Thread STINNER Victor
STINNER Victor added the comment: Me: > I don't think that PR 24533 should be backported to Python 3.8 and Python > 3.9. I prefer to avoid any risk of regression, and so only change Python 3.10. Sometimes. I'm wise :-D This change broken 2 extension modules which rely on the fact that the

[issue43181] Python macros don’t shield arguments

2021-03-15 Thread STINNER Victor
STINNER Victor added the comment: You can create a single issue, and later we will see if it's needed to split it into sub-issues. -- ___ Python tracker ___

[issue43181] Python macros don’t shield arguments

2021-03-15 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: > If possible, I would prefer to only replace macros with static inline > functions if the changes avoids clear macro pitfalls. Yes, of course. Should I create a meta issue for this, or do you prefer raising one issue pr. fix? --

[issue43181] Python macros don’t shield arguments

2021-03-15 Thread STINNER Victor
STINNER Victor added the comment: If possible, I would prefer to only replace macros with static inline functions if the changes avoids clear macro pitfalls. It's not because macros have pitfalls that we must replace them all blindly. Also, this issue is closed. At this point, I'm not

[issue43181] Python macros don’t shield arguments

2021-03-15 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: > As I wrote previously, I dislike macros. If someone is changed, I would > prefer to convert the function into a static inline function which doesn't > have macros pitfalls. Should we create a meta issue for this? Most macros are trivial, and can

[issue43181] Python macros don’t shield arguments

2021-03-11 Thread STINNER Victor
STINNER Victor added the comment: > Yet... the first argument is still unshielded, passed to a macro that expects > one single macro argument. Are you talking about the current code in the master branch or the 3.9 branch? If you are talking about the _PyObject_CAST(ob) call, would you mind

[issue43181] Python macros don’t shield arguments

2021-02-19 Thread Vitaliy
Vitaliy added the comment: Thanks for the fix, it works for my use case. (btw that was #define U(...) __VA_ARGS__ and not what I wrote). > I don't think that PR 24533 should be backported to Python 3.8 and Python > 3.9. I prefer to avoid any risk of regression, and so only change Python

[issue43181] Python macros don’t shield arguments

2021-02-15 Thread STINNER Victor
STINNER Victor added the comment: Thanks Vitaliy for the bug report and Erlend for the fix ;-) For Python 3.9 and older, a workaround is to wrap the call to PyObject_TypeCheck() with your own static inline function. -- resolution: -> fixed stage: patch review -> resolved status:

[issue43181] Python macros don’t shield arguments

2021-02-15 Thread STINNER Victor
STINNER Victor added the comment: New changeset 4bb2a1ebc569eee6f1b46ecef1965a26ae8cb76d by Erlend Egeberg Aasland in branch 'master': bpo-43181: Convert PyObject_TypeCheck to static inline function (GH-24533) https://github.com/python/cpython/commit/4bb2a1ebc569eee6f1b46ecef1965a26ae8cb76d

[issue43181] Python macros don’t shield arguments

2021-02-15 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: > I don't think that PR 24533 should be backported to Python 3.8 and Python > 3.9. I prefer to avoid any risk of regression, and so only change Python 3.10. That sounds reasonable. -- ___ Python tracker

[issue43181] Python macros don’t shield arguments

2021-02-15 Thread STINNER Victor
STINNER Victor added the comment: I don't think that PR 24533 should be backported to Python 3.8 and Python 3.9. I prefer to avoid any risk of regression, and so only change Python 3.10. -- versions: -Python 3.9 ___ Python tracker

[issue43181] Python macros don’t shield arguments

2021-02-15 Thread Erlend Egeberg Aasland
Change by Erlend Egeberg Aasland : -- keywords: +patch pull_requests: +23320 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/24533 ___ Python tracker

[issue43181] Python macros don’t shield arguments

2021-02-15 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: Silence implies consent? I'll throw up a PR, then :) -- ___ Python tracker ___ ___

[issue43181] Python macros don’t shield arguments

2021-02-11 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: > Are you interested to convert the PyObject_TypeCheck() macro to a static > inline function? I'd like to give it a shot if it's ok for you all. -- ___ Python tracker

[issue43181] Python macros don’t shield arguments

2021-02-11 Thread Erlend Egeberg Aasland
Change by Erlend Egeberg Aasland : -- nosy: +erlendaasland ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43181] Python macros don’t shield arguments

2021-02-11 Thread STINNER Victor
STINNER Victor added the comment: I'm replacing macros with static inline functions to avoid issues like this one (ex: bpo-35059). Are you interested to convert the PyObject_TypeCheck() macro to a static inline function? """ There is a lot of macros like: #define PyObject_TypeCheck(ob,

[issue43181] Python macros don’t shield arguments

2021-02-09 Thread Gregory P. Smith
Change by Gregory P. Smith : -- nosy: +vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43181] Python macros don’t shield arguments

2021-02-09 Thread Gregory P. Smith
Gregory P. Smith added the comment: This bug is valid, that macro and likely others aren't up to best practices. C macros are a PITA to get right. -- keywords: +3.9regression nosy: +gregory.p.smith stage: -> needs patch type: -> compile error versions: +Python 3.10

[issue43181] Python macros don’t shield arguments

2021-02-09 Thread William Pickard
William Pickard added the comment: This feels like it's more of an issue with the C++ compiler you're using. (I can tell it's C++ because of template syntax) -- nosy: +WildCard65 ___ Python tracker

[issue43181] Python macros don’t shield arguments

2021-02-09 Thread Vitaliy
New submission from Vitaliy : There is a lot of macros like: #define PyObject_TypeCheck(ob, tp) \ (Py_IS_TYPE(ob, tp) || PyType_IsSubtype(Py_TYPE(ob), (tp))) These work fine until an argument happen to contain a comma. That’s possible as a result of other macro’s expansion. E.g. if U(x)