Kaydet (Commit) d3881b02 authored tarafından Neal Norwitz's avatar Neal Norwitz

Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment

üst 80af59cb
...@@ -764,7 +764,7 @@ dict_print(register dictobject *mp, register FILE *fp, register int flags) ...@@ -764,7 +764,7 @@ dict_print(register dictobject *mp, register FILE *fp, register int flags)
register Py_ssize_t i; register Py_ssize_t i;
register Py_ssize_t any; register Py_ssize_t any;
i = (int)Py_ReprEnter((PyObject*)mp); i = Py_SAFE_DOWNCAST(Py_ReprEnter((PyObject*)mp), Py_ssize_t, int);
if (i != 0) { if (i != 0) {
if (i < 0) if (i < 0)
return i; return i;
...@@ -1172,14 +1172,14 @@ PyDict_MergeFromSeq2(PyObject *d, PyObject *seq2, int override) ...@@ -1172,14 +1172,14 @@ PyDict_MergeFromSeq2(PyObject *d, PyObject *seq2, int override)
if (PyErr_ExceptionMatches(PyExc_TypeError)) if (PyErr_ExceptionMatches(PyExc_TypeError))
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"cannot convert dictionary update " "cannot convert dictionary update "
"sequence element #%d to a sequence", "sequence element #%zd to a sequence",
i); i);
goto Fail; goto Fail;
} }
n = PySequence_Fast_GET_SIZE(fast); n = PySequence_Fast_GET_SIZE(fast);
if (n != 2) { if (n != 2) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"dictionary update sequence element #%d " "dictionary update sequence element #%zd "
"has length %zd; 2 is required", "has length %zd; 2 is required",
i, n); i, n);
goto Fail; goto Fail;
...@@ -1205,7 +1205,7 @@ Fail: ...@@ -1205,7 +1205,7 @@ Fail:
i = -1; i = -1;
Return: Return:
Py_DECREF(it); Py_DECREF(it);
return (int)i; return Py_SAFE_DOWNCAST(i, Py_ssize_t, int);
} }
int int
...@@ -1411,7 +1411,7 @@ characterize(dictobject *a, dictobject *b, PyObject **pval) ...@@ -1411,7 +1411,7 @@ characterize(dictobject *a, dictobject *b, PyObject **pval)
* find its associated value anymore; or * find its associated value anymore; or
* maybe it is but the compare deleted the * maybe it is but the compare deleted the
* a[thiskey] entry. * a[thiskey] entry.
| */ */
Py_DECREF(thiskey); Py_DECREF(thiskey);
continue; continue;
} }
...@@ -1711,7 +1711,7 @@ dict_popitem(dictobject *mp) ...@@ -1711,7 +1711,7 @@ dict_popitem(dictobject *mp)
* field of slot 0 to hold a search finger: * field of slot 0 to hold a search finger:
* If slot 0 has a value, use slot 0. * If slot 0 has a value, use slot 0.
* Else slot 0 is being used to hold a search finger, * Else slot 0 is being used to hold a search finger,
| * and we use its hash value as the first index to look. * and we use its hash value as the first index to look.
*/ */
ep = &mp->ma_table[0]; ep = &mp->ma_table[0];
if (ep->me_value == NULL) { if (ep->me_value == NULL) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment