Message211142
See this huge warning in the definition of PyDict_GetItem:
/* Note that, for historical reasons, PyDict_GetItem() suppresses all errors
* that may occur (originally dicts supported only string keys, and exceptions
* weren't possible). So, while the original intent was that a NULL return
* meant the key wasn't present, in reality it can mean that, or that an error
* (suppressed) occurred while computing the key's hash, or that some error
* (suppressed) occurred when comparing keys in the dict's internal probe
* sequence. A nasty example of the latter is when a Python-coded comparison
* function hits a stack-depth error, which can cause this to return NULL
* even if the key is present.
*/
PyObject *
PyDict_GetItem(PyObject *op, PyObject *key)
{ ... }
PyDict_GetItem() should avoided because it may hide important exceptions like KeyboardInterrupt or MemoryError.
See for example #14537 for a specific error.
By the way, the PyDict_GetItem() documentation should contain a big red warning and suggest to use PyDict_GetItemWithError() instead. |
|
Date |
User |
Action |
Args |
2014-02-13 10:44:13 | vstinner | set | recipients:
+ vstinner, serhiy.storchaka |
2014-02-13 10:44:13 | vstinner | set | messageid: <1392288253.13.0.332874319538.issue20615@psf.upfronthosting.co.za> |
2014-02-13 10:44:13 | vstinner | link | issue20615 messages |
2014-02-13 10:44:12 | vstinner | create | |
|