Skip to content

Commit 1a32545

Browse files
committed
Normalize ParamSpec __bound__ when bound is None
When creating a ParamSpec with bound=None, the runtime __bound__ attribute is set to <class 'NoneType'> instead of None. This change mirrors TypeVar.__new__ by explicitly converting Py_None to NULL before type checking, restoring the correct semantics and ensuring consistency between TypeVar and ParamSpec. Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
1 parent 19c72d2 commit 1a32545

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Objects/typevarobject.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,9 @@ paramspec_new_impl(PyTypeObject *type, PyObject *name, PyObject *bound,
13371337
PyErr_SetString(PyExc_ValueError, "Variance cannot be specified with infer_variance.");
13381338
return NULL;
13391339
}
1340+
if (Py_IsNone(bound)) {
1341+
bound = NULL;
1342+
}
13401343
if (bound != NULL) {
13411344
bound = type_check(bound, "Bound must be a type.");
13421345
if (bound == NULL) {

0 commit comments

Comments
 (0)