Skip to content

Commit ae5c666

Browse files
Merge branch 'main' into fix/152074
2 parents b286191 + 6c3da17 commit ae5c666

7 files changed

Lines changed: 23 additions & 19 deletions

File tree

Lib/test/test_fcntl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def test_fcntl_64_bit(self):
151151
except OSError as exc:
152152
if exc.errno == errno.EINVAL:
153153
self.skipTest("F_NOTIFY not available by this environment")
154+
raise
154155
fcntl.fcntl(fd, cmd, flags)
155156
finally:
156157
os.close(fd)

Lib/test/test_launcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ def test_search_major_2(self):
469469
except subprocess.CalledProcessError:
470470
if not is_installed("2.7"):
471471
raise unittest.SkipTest("requires at least one Python 2.x install")
472+
raise
472473
self.assertEqual("PythonCore", data["env.company"])
473474
self.assertStartsWith(data["env.tag"], "2.")
474475

Lib/test/test_pathlib/test_pathlib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2870,6 +2870,7 @@ def test_is_socket_true(self):
28702870
if (isinstance(e, PermissionError) or
28712871
"AF_UNIX path too long" in str(e)):
28722872
self.skipTest("cannot bind Unix socket: " + str(e))
2873+
raise
28732874
self.assertTrue(P.is_socket())
28742875
self.assertFalse(P.is_fifo())
28752876
self.assertFalse(P.is_file())

Lib/test/test_socket.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,7 @@ def testIPv6toString(self):
14271427
except OSError as e:
14281428
if e.winerror == 10022:
14291429
self.skipTest('IPv6 might not be supported')
1430+
raise
14301431

14311432
f = lambda a: inet_pton(AF_INET6, a)
14321433
assertInvalid = lambda a: self.assertRaises(
@@ -1517,6 +1518,7 @@ def testStringToIPv6(self):
15171518
except OSError as e:
15181519
if e.winerror == 10022:
15191520
self.skipTest('IPv6 might not be supported')
1521+
raise
15201522

15211523
f = lambda a: inet_ntop(AF_INET6, a)
15221524
assertInvalid = lambda a: self.assertRaises(

Lib/test/test_typing.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,11 @@ def test_infer_variance(self):
13161316
def test_bound(self):
13171317
Ts_bound = TypeVarTuple('Ts_bound', bound=int)
13181318
self.assertIs(Ts_bound.__bound__, int)
1319+
Ts_tuple_bound = TypeVarTuple('Ts_tuple_bound', bound=(int, str))
1320+
self.assertEqual(Ts_tuple_bound.__bound__, (int, str))
1321+
obj = object()
1322+
Ts_object = TypeVarTuple('Ts_object', bound=obj)
1323+
self.assertIs(Ts_object.__bound__, obj)
13191324
Ts_no_bound = TypeVarTuple('Ts_no_bound')
13201325
self.assertIsNone(Ts_no_bound.__bound__)
13211326

@@ -10534,6 +10539,17 @@ def test_paramspec_in_nested_generics(self):
1053410539
self.assertEqual(G2[[int, str], float], list[C])
1053510540
self.assertEqual(G3[[int, str], float], list[C] | int)
1053610541

10542+
def test_paramspec_bound(self):
10543+
P = ParamSpec('P', bound=[int, str])
10544+
self.assertEqual(P.__bound__, [int, str])
10545+
P2 = ParamSpec('P2', bound=(int, str))
10546+
self.assertEqual(P2.__bound__, (int, str))
10547+
obj = object()
10548+
P3 = ParamSpec('P3', bound=obj)
10549+
self.assertIs(P3.__bound__, obj)
10550+
P4 = ParamSpec('P4')
10551+
self.assertIs(P4.__bound__, None)
10552+
1053710553
def test_paramspec_gets_copied(self):
1053810554
# bpo-46581
1053910555
P = ParamSpec('P')
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Allow more types to be used in the ``bound`` argument to
2+
:class:`typing.ParamSpec` and :class:`typing.TypeVarTuple`.

Objects/typevarobject.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,20 +1340,12 @@ paramspec_new_impl(PyTypeObject *type, PyObject *name, PyObject *bound,
13401340
PyErr_SetString(PyExc_ValueError, "Variance cannot be specified with infer_variance.");
13411341
return NULL;
13421342
}
1343-
if (bound != NULL) {
1344-
bound = type_check(bound, "Bound must be a type.");
1345-
if (bound == NULL) {
1346-
return NULL;
1347-
}
1348-
}
13491343
PyObject *module = caller();
13501344
if (module == NULL) {
1351-
Py_XDECREF(bound);
13521345
return NULL;
13531346
}
13541347
PyObject *ps = (PyObject *)paramspec_alloc(
13551348
name, bound, default_value, covariant, contravariant, infer_variance, module);
1356-
Py_XDECREF(bound);
13571349
Py_DECREF(module);
13581350
return ps;
13591351
}
@@ -1634,23 +1626,12 @@ typevartuple_impl(PyTypeObject *type, PyObject *name, PyObject *bound,
16341626
PyErr_SetString(PyExc_ValueError, "Variance cannot be specified with infer_variance.");
16351627
return NULL;
16361628
}
1637-
if (Py_IsNone(bound)) {
1638-
bound = NULL;
1639-
}
1640-
if (bound != NULL) {
1641-
bound = type_check(bound, "Bound must be a type.");
1642-
if (bound == NULL) {
1643-
return NULL;
1644-
}
1645-
}
16461629
PyObject *module = caller();
16471630
if (module == NULL) {
1648-
Py_XDECREF(bound);
16491631
return NULL;
16501632
}
16511633
PyObject *result = (PyObject *)typevartuple_alloc(
16521634
name, bound, default_value, covariant, contravariant, infer_variance, module);
1653-
Py_XDECREF(bound);
16541635
Py_DECREF(module);
16551636
return result;
16561637
}

0 commit comments

Comments
 (0)