Issues #29311, #29289: Fixed and improved docstrings for dict and OrderedDict

methods.
This commit is contained in:
Serhiy Storchaka 2017-01-25 00:30:04 +02:00
parent 0105606f55
commit 78d9e58f20
5 changed files with 45 additions and 44 deletions

View file

@ -926,14 +926,12 @@ OrderedDict.fromkeys
iterable as seq: object
value: object = None
New ordered dictionary with keys from S.
If not specified, the value defaults to None.
Create a new ordered dictionary with keys from iterable and values set to value.
[clinic start generated code]*/
static PyObject *
OrderedDict_fromkeys_impl(PyTypeObject *type, PyObject *seq, PyObject *value)
/*[clinic end generated code: output=c10390d452d78d6d input=33eefc496d5eee7b]*/
/*[clinic end generated code: output=c10390d452d78d6d input=1a0476c229c597b3]*/
{
return _PyDict_FromKeys((PyObject *)type, seq, value);
}
@ -1014,13 +1012,15 @@ OrderedDict.setdefault
key: object
default: object = None
od.get(k,d), also set od[k]=d if k not in od.
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
[clinic start generated code]*/
static PyObject *
OrderedDict_setdefault_impl(PyODictObject *self, PyObject *key,
PyObject *default_value)
/*[clinic end generated code: output=97537cb7c28464b6 input=d5e940fcea7a5a67]*/
/*[clinic end generated code: output=97537cb7c28464b6 input=38e098381c1efbc6]*/
{
PyObject *result = NULL;
@ -1165,14 +1165,14 @@ OrderedDict.popitem
last: bool = True
Return (k, v) and remove a (key, value) pair.
Remove and return a (key, value) pair from the dictionary.
Pairs are returned in LIFO order if last is true or FIFO order if false.
[clinic start generated code]*/
static PyObject *
OrderedDict_popitem_impl(PyODictObject *self, int last)
/*[clinic end generated code: output=98e7d986690d49eb input=4937da2015939126]*/
/*[clinic end generated code: output=98e7d986690d49eb input=d992ac5ee8305e1a]*/
{
PyObject *key, *value, *item = NULL;
_ODictNode *node;
@ -1324,15 +1324,14 @@ OrderedDict.move_to_end
key: object
last: bool = True
"Move an existing element to the end (or beginning if last==False).
Move an existing element to the end (or beginning if last is false).
Raises KeyError if the element does not exist.
When last=True, acts like a fast version of self[key]=self.pop(key).
Raise KeyError if the element does not exist.
[clinic start generated code]*/
static PyObject *
OrderedDict_move_to_end_impl(PyODictObject *self, PyObject *key, int last)
/*[clinic end generated code: output=fafa4c5cc9b92f20 input=3b8283f7d0e15e43]*/
/*[clinic end generated code: output=fafa4c5cc9b92f20 input=d6ceff7132a2fcd7]*/
{
_ODictNode *node;