Skip to content

[3.8] bpo-37206: fix docstring of dict.pop() #13935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2019
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
38 changes: 1 addition & 37 deletions Objects/clinic/dictobject.c.h

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

40 changes: 27 additions & 13 deletions Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2987,23 +2987,37 @@ dict_clear(PyDictObject *mp, PyObject *Py_UNUSED(ignored))
Py_RETURN_NONE;
}

/*[clinic input]
dict.pop

key: object
default: object = NULL
/
/*
We don't use Argument Clinic for dict.pop because it doesn't support
custom signature for now.
*/
PyDoc_STRVAR(dict_pop__doc__,
"D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n\
If key is not found, d is returned if given, otherwise KeyError is raised");

Remove specified key and return the corresponding value.

If key is not found, default is returned if given, otherwise KeyError is raised
[clinic start generated code]*/
#define DICT_POP_METHODDEF \
{"pop", (PyCFunction)(void(*)(void))dict_pop, METH_FASTCALL, dict_pop__doc__},

static PyObject *
dict_pop_impl(PyDictObject *self, PyObject *key, PyObject *default_value)
/*[clinic end generated code: output=3abb47b89f24c21c input=016f6a000e4e633b]*/
dict_pop(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
{
return _PyDict_Pop((PyObject*)self, key, default_value);
PyObject *return_value = NULL;
PyObject *key;
PyObject *default_value = NULL;

if (!_PyArg_CheckPositional("pop", nargs, 1, 2)) {
goto exit;
}
key = args[0];
if (nargs < 2) {
goto skip_optional;
}
default_value = args[1];
skip_optional:
return_value = _PyDict_Pop((PyObject*)self, key, default_value);

exit:
return return_value;
}

/*[clinic input]
Expand Down