[Python-Dev] PEP 590: vectorcall without tp_call (original) (raw)

Christian Heimes christian at cheimes.de
Wed May 29 10:00:40 EDT 2019


On 29/05/2019 15.29, Petr Viktorin wrote:

On 5/29/19 2:25 PM, Jeroen Demeyer wrote:

Hello,

I have one implementation question about vectorcall which is not specified in PEP 590: what should happen if a type implements vectorcall (i.e. PyTPFLAGSHAVEVECTORCALL is set) but doesn't set tpcall (i.e. tpcall == NULL)? I see the following possibilities: 1. Ignore this problem/assume that it won't happen. This would be bad, since callable(obj) would be False even though obj() would succeed. 2. Raise SystemError. 3. Automatically set tpcall to PyVectorcallCall. I would vote for 3 since it's the most user-friendly option. There is also no way how it could be wrong: it ensures that tpcall and vectorcall are consistent. That sounds like a good idea for PyTypeFromSpec. For static types I either wouldn't bother at all, or only check in debug  builds and fail with PyFatalError.

You could add a check to PyType_Ready() and have it either return an error or fix tp_call.

Christian



More information about the Python-Dev mailing list