mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
Merge d4cde94721 into f9704f1d84
This commit is contained in:
commit
a7ef8c5bdf
3 changed files with 10 additions and 0 deletions
|
|
@ -10029,6 +10029,12 @@ class ParamSpecTests(BaseTestCase):
|
|||
self.assertEqual(P.__name__, 'P')
|
||||
self.assertIs(P.__module__, None)
|
||||
|
||||
def test_bound(self):
|
||||
P1 = ParamSpec("P1")
|
||||
P2 = ParamSpec("P2", bound=None)
|
||||
self.assertIs(P1.__bound__, None)
|
||||
self.assertIs(P2.__bound__, None)
|
||||
|
||||
def test_valid_uses(self):
|
||||
P = ParamSpec('P')
|
||||
T = TypeVar('T')
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Fix ``typing.ParamSpec(..., bound=None)`` so that ``__bound__`` is ``None`` instead of ``NoneType``.
|
||||
|
|
@ -1337,6 +1337,9 @@ paramspec_new_impl(PyTypeObject *type, PyObject *name, PyObject *bound,
|
|||
PyErr_SetString(PyExc_ValueError, "Variance cannot be specified with infer_variance.");
|
||||
return NULL;
|
||||
}
|
||||
if (Py_IsNone(bound)) {
|
||||
bound = NULL;
|
||||
}
|
||||
if (bound != NULL) {
|
||||
bound = type_check(bound, "Bound must be a type.");
|
||||
if (bound == NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue