Compare commits
4 Commits
4140f10a16
...
c56988b88f
Author | SHA1 | Date |
---|---|---|
Zackery Spytz | c56988b88f | |
Ken Jin | efb1f0918f | |
Pablo Galindo | a6d63a20df | |
Pablo Galindo | 290f5ae997 |
|
@ -289,7 +289,7 @@ variant, :attr:`~.BaseHeader.max_count` is set to 1.
|
||||||
A :class:`ParameterizedMIMEHeader` class that handles the
|
A :class:`ParameterizedMIMEHeader` class that handles the
|
||||||
:mailheader:`Content-Disposition` header.
|
:mailheader:`Content-Disposition` header.
|
||||||
|
|
||||||
.. attribute:: content-disposition
|
.. attribute:: content_disposition
|
||||||
|
|
||||||
``inline`` and ``attachment`` are the only valid values in common use.
|
``inline`` and ``attachment`` are the only valid values in common use.
|
||||||
|
|
||||||
|
|
|
@ -3021,6 +3021,7 @@ class GetUtilitiesTestCase(TestCase):
|
||||||
self.assertIs(get_origin(Callable), collections.abc.Callable)
|
self.assertIs(get_origin(Callable), collections.abc.Callable)
|
||||||
self.assertIs(get_origin(list[int]), list)
|
self.assertIs(get_origin(list[int]), list)
|
||||||
self.assertIs(get_origin(list), None)
|
self.assertIs(get_origin(list), None)
|
||||||
|
self.assertIs(get_origin(list | str), types.Union)
|
||||||
|
|
||||||
def test_get_args(self):
|
def test_get_args(self):
|
||||||
T = TypeVar('T')
|
T = TypeVar('T')
|
||||||
|
@ -3053,6 +3054,11 @@ class GetUtilitiesTestCase(TestCase):
|
||||||
self.assertEqual(get_args(collections.abc.Callable[[], str]), ([], str))
|
self.assertEqual(get_args(collections.abc.Callable[[], str]), ([], str))
|
||||||
self.assertEqual(get_args(collections.abc.Callable[[int], str]),
|
self.assertEqual(get_args(collections.abc.Callable[[int], str]),
|
||||||
get_args(Callable[[int], str]))
|
get_args(Callable[[int], str]))
|
||||||
|
P = ParamSpec('P')
|
||||||
|
self.assertEqual(get_args(Callable[P, int]), (P, int))
|
||||||
|
self.assertEqual(get_args(Callable[Concatenate[int, P], int]),
|
||||||
|
(Concatenate[int, P], int))
|
||||||
|
self.assertEqual(get_args(list | str), (list, str))
|
||||||
|
|
||||||
|
|
||||||
class CollectionsAbcTests(BaseTestCase):
|
class CollectionsAbcTests(BaseTestCase):
|
||||||
|
|
|
@ -1668,6 +1668,8 @@ def get_origin(tp):
|
||||||
return tp.__origin__
|
return tp.__origin__
|
||||||
if tp is Generic:
|
if tp is Generic:
|
||||||
return Generic
|
return Generic
|
||||||
|
if isinstance(tp, types.Union):
|
||||||
|
return types.Union
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -1686,9 +1688,13 @@ def get_args(tp):
|
||||||
return (tp.__origin__,) + tp.__metadata__
|
return (tp.__origin__,) + tp.__metadata__
|
||||||
if isinstance(tp, (_GenericAlias, GenericAlias)):
|
if isinstance(tp, (_GenericAlias, GenericAlias)):
|
||||||
res = tp.__args__
|
res = tp.__args__
|
||||||
if tp.__origin__ is collections.abc.Callable and res[0] is not Ellipsis:
|
if (tp.__origin__ is collections.abc.Callable
|
||||||
|
and not (res[0] is Ellipsis
|
||||||
|
or isinstance(res[0], (ParamSpec, _ConcatenateGenericAlias)))):
|
||||||
res = (list(res[:-1]), res[-1])
|
res = (list(res[:-1]), res[-1])
|
||||||
return res
|
return res
|
||||||
|
if isinstance(tp, types.Union):
|
||||||
|
return tp.__args__
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
:func:`typing.get_args` and :func:`typing.get_origin` now support :pep:`604`
|
||||||
|
union types and :pep:`612` additions to ``Callable``.
|
|
@ -1601,7 +1601,7 @@ pysqlite_connection_backup_impl(pysqlite_Connection *self,
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int callback_error = 0;
|
int callback_error = 0;
|
||||||
int sleep_ms = sleep * 1000.0;
|
int sleep_ms = (int)(sleep * 1000.0);
|
||||||
sqlite3 *bck_conn;
|
sqlite3 *bck_conn;
|
||||||
sqlite3_backup *bck_handle;
|
sqlite3_backup *bck_handle;
|
||||||
|
|
||||||
|
|
|
@ -1442,8 +1442,7 @@ s_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
self = alloc_func(type, 0);
|
self = alloc_func(type, 0);
|
||||||
if (self != NULL) {
|
if (self != NULL) {
|
||||||
PyStructObject *s = (PyStructObject*)self;
|
PyStructObject *s = (PyStructObject*)self;
|
||||||
Py_INCREF(Py_None);
|
s->s_format = Py_NewRef(Py_None);
|
||||||
s->s_format = Py_None;
|
|
||||||
s->s_codes = NULL;
|
s->s_codes = NULL;
|
||||||
s->s_size = -1;
|
s->s_size = -1;
|
||||||
s->s_len = -1;
|
s->s_len = -1;
|
||||||
|
|
|
@ -2302,7 +2302,7 @@ _PyUnicode_FromId(_Py_Identifier *id)
|
||||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||||
struct _Py_unicode_ids *ids = &interp->unicode.ids;
|
struct _Py_unicode_ids *ids = &interp->unicode.ids;
|
||||||
|
|
||||||
int index = _Py_atomic_size_get(&id->index);
|
Py_ssize_t index = _Py_atomic_size_get(&id->index);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
struct _Py_unicode_runtime_ids *rt_ids = &interp->runtime->unicode_ids;
|
struct _Py_unicode_runtime_ids *rt_ids = &interp->runtime->unicode_ids;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue