Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,9 @@ struct _Py_global_strings {
STRUCT_FOR_ID(filter)
STRUCT_FOR_ID(filters)
STRUCT_FOR_ID(final)
STRUCT_FOR_ID(finalizer)
STRUCT_FOR_ID(find_class)
STRUCT_FOR_ID(firstiter)
STRUCT_FOR_ID(fix_imports)
STRUCT_FOR_ID(flags)
STRUCT_FOR_ID(flush)
Expand Down
2 changes: 2 additions & 0 deletions Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Lib/test/test_inspect/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -6170,11 +6170,10 @@ def test_builtins_have_signatures(self):
no_signature = {'type', 'super', 'bytearray', 'bytes',
'dict', 'frozendict', 'int', 'str'}
# These need PEP 457 groups
needs_groups = {"range", "slice", "dir", "getattr",
"next", "vars"}
needs_groups = {"range", "slice", "getattr", "next"}
no_signature |= needs_groups
# These have unrepresentable parameter default values of NULL
unsupported_signature = {"aiter", "iter"}
unsupported_signature = {"aiter", "iter", "dir", "vars"}
# These need *args support in Argument Clinic
needs_varargs = {"min", "max", "__build_class__"}
no_signature |= needs_varargs
Expand Down Expand Up @@ -6207,10 +6206,12 @@ def test_types_module_has_signatures(self):
methods_no_signature=methods_no_signature)

def test_sys_module_has_signatures(self):
no_signature = {'getsizeof', 'set_asyncgen_hooks'}
no_signature |= {name for name in ['getobjects']
if hasattr(sys, name)}
self._test_module_has_signatures(sys, no_signature)
no_signature = {name for name in ['getobjects']
if hasattr(sys, name)}
# The C default is NULL and None has other meaning
unsupported_signature = {'getsizeof', 'set_asyncgen_hooks'}
self._test_module_has_signatures(sys, no_signature,
unsupported_signature)

def test_abc_module_has_signatures(self):
import abc
Expand Down Expand Up @@ -6313,7 +6314,6 @@ def test_pwd_module_has_signatures(self):
def test_re_module_has_signatures(self):
import re
methods_no_signature = {
'Match': {'group'},
'Pattern': {'match'}, # It is now an alias for prefixmatch
}
self._test_module_has_signatures(re,
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def test_property_set_name_incorrect_args(self):
for i in (0, 1, 3):
with self.assertRaisesRegex(
TypeError,
fr'^__set_name__\(\) takes 2 positional arguments but {i} were given$'
fr'^__set_name__ expected 2 arguments?, got {i}$'
):
p.__set_name__(*([0] * i))

Expand Down
22 changes: 14 additions & 8 deletions Modules/_dbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,21 @@ dbm__enter__(PyObject *self, PyObject *Py_UNUSED(dummy))
return Py_NewRef(self);
}

/*[clinic input]
@critical_section
_dbm.dbm.__exit__

*exc_info: array

Close the database.
[clinic start generated code]*/

static PyObject *
dbm__exit__(PyObject *self, PyObject *Py_UNUSED(args))
_dbm_dbm___exit___impl(dbmobject *self, PyObject * const *exc_info,
Py_ssize_t exc_info_length)
/*[clinic end generated code: output=f9549bf513b3285d input=340d8190b6fb0f15]*/
{
PyObject *result;
dbmobject *dp = dbmobject_CAST(self);
Py_BEGIN_CRITICAL_SECTION(self);
result = _dbm_dbm_close_impl(dp);
Py_END_CRITICAL_SECTION();
return result;
return _dbm_dbm_close_impl(self);
}

static PyMethodDef dbm_methods[] = {
Expand All @@ -531,7 +537,7 @@ static PyMethodDef dbm_methods[] = {
_DBM_DBM_SETDEFAULT_METHODDEF
_DBM_DBM_CLEAR_METHODDEF
{"__enter__", dbm__enter__, METH_NOARGS, NULL},
{"__exit__", dbm__exit__, METH_VARARGS, NULL},
_DBM_DBM___EXIT___METHODDEF
{NULL, NULL} /* sentinel */
};

Expand Down
22 changes: 17 additions & 5 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#define _PY_DEC_ROUND_GUARD (MPD_ROUND_GUARD-1)
#endif

#include "clinic/_decimal.c.h"

#define MPD_SPEC_VERSION "1.70" // Highest version of the spec this complies with
// See https://speleotrove.com/decimal/decarith.html
Expand All @@ -66,8 +65,9 @@
module _decimal
class _decimal.Decimal "PyObject *" "&dec_spec"
class _decimal.Context "PyObject *" "&context_spec"
class _decimal.ContextManager "PyDecContextManagerObject *" "&ctxmanager_spec"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=a6a6c0bdf4e576ef]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=52b8c97cabc5bf05]*/

struct PyDecContextObject;
struct DecCondMap;
Expand Down Expand Up @@ -234,6 +234,8 @@ typedef struct {
PyObject *global;
} PyDecContextManagerObject;

#include "clinic/_decimal.c.h"

#define _PyDecContextManagerObject_CAST(op) ((PyDecContextManagerObject *)(op))

#undef MPD
Expand Down Expand Up @@ -2209,11 +2211,21 @@ ctxmanager_set_local(PyObject *op, PyObject *Py_UNUSED(dummy))
return Py_NewRef(self->local);
}

/*[clinic input]
_decimal.ContextManager.__exit__

*exc_info: array

Restore the global context.
[clinic start generated code]*/

static PyObject *
ctxmanager_restore_global(PyObject *op, PyObject *Py_UNUSED(args))
_decimal_ContextManager___exit___impl(PyDecContextManagerObject *self,
PyObject * const *exc_info,
Py_ssize_t exc_info_length)
/*[clinic end generated code: output=744a645b0145842d input=a86ec9080e28dff3]*/
{
PyObject *ret;
PyDecContextManagerObject *self = _PyDecContextManagerObject_CAST(op);
ret = PyDec_SetCurrentContext(PyType_GetModule(Py_TYPE(self)), self->global);
if (ret == NULL) {
return NULL;
Expand All @@ -2226,7 +2238,7 @@ ctxmanager_restore_global(PyObject *op, PyObject *Py_UNUSED(args))

static PyMethodDef ctxmanager_methods[] = {
{"__enter__", ctxmanager_set_local, METH_NOARGS, NULL},
{"__exit__", ctxmanager_restore_global, METH_VARARGS, NULL},
_DECIMAL_CONTEXTMANAGER___EXIT___METHODDEF
{NULL, NULL}
};

Expand Down
30 changes: 29 additions & 1 deletion Modules/_decimal/clinic/_decimal.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 24 additions & 16 deletions Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,33 +612,41 @@ element_get_tail(ElementObject* self)
return Py_NewRef(res);
}

static PyObject*
subelement(PyObject *self, PyObject *args, PyObject *kwds)
/*[clinic input]
_elementtree.SubElement

parent: object(subclass_of='get_elementtree_state(module)->Element_Type')
tag: object
attrib: object(subclass_of='&PyDict_Type', c_default='NULL') = {}
/
**extra: dict

Create a new subelement of the parent element.
[clinic start generated code]*/

static PyObject *
_elementtree_SubElement_impl(PyObject *module, PyObject *parent,
PyObject *tag, PyObject *attrib,
PyObject *extra)
/*[clinic end generated code: output=42e8a4ebc5db08aa input=8588fc68283cdaa0]*/
{
PyObject* elem;

elementtreestate *st = get_elementtree_state(self);
ElementObject* parent;
PyObject* tag;
PyObject* attrib = NULL;
if (!PyArg_ParseTuple(args, "O!O|O!:SubElement",
st->Element_Type, &parent, &tag,
&PyDict_Type, &attrib)) {
return NULL;
}
elementtreestate *st = get_elementtree_state(module);
ElementObject* parent_elem = (ElementObject *)parent;

if (attrib) {
/* attrib passed as positional arg */
attrib = PyDict_Copy(attrib);
if (!attrib)
return NULL;
if (kwds != NULL && PyDict_Update(attrib, kwds) < 0) {
if (PyDict_Update(attrib, extra) < 0) {
Py_DECREF(attrib);
return NULL;
}
} else if (kwds) {
} else if (PyDict_GET_SIZE(extra)) {
/* have keyword args */
attrib = get_attrib_from_keywords(kwds);
attrib = get_attrib_from_keywords(extra);
if (!attrib)
return NULL;
} else {
Expand All @@ -650,7 +658,7 @@ subelement(PyObject *self, PyObject *args, PyObject *kwds)
if (elem == NULL)
return NULL;

if (element_add_subelement(st, parent, elem) < 0) {
if (element_add_subelement(st, parent_elem, elem) < 0) {
Py_DECREF(elem);
return NULL;
}
Expand Down Expand Up @@ -4547,7 +4555,7 @@ static PyType_Spec xmlparser_spec = {
/* python module interface */

static PyMethodDef _functions[] = {
{"SubElement", _PyCFunction_CAST(subelement), METH_VARARGS | METH_KEYWORDS},
_ELEMENTTREE_SUBELEMENT_METHODDEF
_ELEMENTTREE__SET_FACTORIES_METHODDEF
{NULL, NULL}
};
Expand Down
25 changes: 21 additions & 4 deletions Modules/_functoolsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1817,14 +1817,31 @@ lru_cache_reduce(PyObject *self, PyObject *Py_UNUSED(dummy))
return PyObject_GetAttrString(self, "__qualname__");
}

/*[clinic input]
_functools._lru_cache_wrapper.__copy__
Return a copy of the wrapper, which is the wrapper itself.
[clinic start generated code]*/

static PyObject *
lru_cache_copy(PyObject *self, PyObject *Py_UNUSED(args))
_functools__lru_cache_wrapper___copy___impl(PyObject *self)
/*[clinic end generated code: output=d681851615d57391 input=41d000bde05efb2b]*/
{
return Py_NewRef(self);
}

/*[clinic input]
_functools._lru_cache_wrapper.__deepcopy__
memo: object
/
Return a deep copy of the wrapper, which is the wrapper itself.
[clinic start generated code]*/

static PyObject *
lru_cache_deepcopy(PyObject *self, PyObject *Py_UNUSED(args))
_functools__lru_cache_wrapper___deepcopy__(PyObject *self, PyObject *memo)
/*[clinic end generated code: output=3445cd9d96273c9e input=84f706565f55ce46]*/
{
return Py_NewRef(self);
}
Expand Down Expand Up @@ -1872,8 +1889,8 @@ static PyMethodDef lru_cache_methods[] = {
_FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_INFO_METHODDEF
_FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_CLEAR_METHODDEF
{"__reduce__", lru_cache_reduce, METH_NOARGS},
{"__copy__", lru_cache_copy, METH_VARARGS},
{"__deepcopy__", lru_cache_deepcopy, METH_VARARGS},
_FUNCTOOLS__LRU_CACHE_WRAPPER___COPY___METHODDEF
_FUNCTOOLS__LRU_CACHE_WRAPPER___DEEPCOPY___METHODDEF
{NULL}
};

Expand Down
21 changes: 14 additions & 7 deletions Modules/_gdbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,14 +687,21 @@ gdbm__enter__(PyObject *self, PyObject *args)
return Py_NewRef(self);
}

/*[clinic input]
@critical_section
_gdbm.gdbm.__exit__

*exc_info: array

Close the database.
[clinic start generated code]*/

static PyObject *
gdbm__exit__(PyObject *self, PyObject *args)
_gdbm_gdbm___exit___impl(gdbmobject *self, PyObject * const *exc_info,
Py_ssize_t exc_info_length)
/*[clinic end generated code: output=4bb425e091228932 input=b22b90a00b22cf18]*/
{
PyObject *result;
Py_BEGIN_CRITICAL_SECTION(self);
result = _gdbm_gdbm_close_impl((gdbmobject *)self);
Py_END_CRITICAL_SECTION();
return result;
return _gdbm_gdbm_close_impl(self);
}

static PyMethodDef gdbm_methods[] = {
Expand All @@ -708,7 +715,7 @@ static PyMethodDef gdbm_methods[] = {
_GDBM_GDBM_SETDEFAULT_METHODDEF
_GDBM_GDBM_CLEAR_METHODDEF
{"__enter__", gdbm__enter__, METH_NOARGS, NULL},
{"__exit__", gdbm__exit__, METH_VARARGS, NULL},
_GDBM_GDBM___EXIT___METHODDEF
{NULL, NULL} /* sentinel */
};

Expand Down
Loading
Loading