Add check_positional/no_positional arg helpers mirroring CPython (#191361)
Summary:
Introduce check_positional and no_positional in torch/_dynamo/utils.py, the
Python analogs of CPython's _PyArg_CheckPositional and _PyArg_NoPositional
(Python/getargs.c). tp_methods arity is otherwise enforced by MethodFlags
derived from a method's ml_flags, but METH_FASTCALL carries no positional
min/max (it maps to VARARGS), so handlers hand-rolled those checks via
raise_args_mismatch, whose message diverges from eager. These helpers raise
CPython's exact TypeError text and are consumed by the FASTCALL handlers
migrated in the following commits.
X-link: https://github.com/pytorch/pytorch/pull/191361
Approved by: https://github.com/hameerabbasi
ghstack dependencies: #190971
Reviewed By: huydhn
Differential Revision: D114083586
fbshipit-source-id: a65431d3e32aaaf1709be2007ae954130a797ec8
Author
generatedunixname499836121