[pypy-issue] Issue #3098: PyPy3.6 7.2.0 error when calling PyDict_GetItem when second argument is an unhashable type (C extension) (pypy/pypy)

Michael Seifert issues-reply at bitbucket.org
Wed Oct 16 13:45:11 EDT 2019


New issue 3098: PyPy3.6 7.2.0 error when calling PyDict_GetItem when second argument is an unhashable type (C extension)
https://bitbucket.org/pypy/pypy/issues/3098/pypy36-720-error-when-calling

Michael Seifert:

Example \(extremely minified\):

```c
PyObject * SomeFunc(PyObject *m, PyObject *args)
{
    PyObject *tmp;
    PyObject *op1;
    op1 = PyDict_New();
    if (op1 == NULL) { return NULL; }
    tmp = PyDict_GetItem(op1, o);
    if (tmp == NULL) { PyErr_SetString(PyExc_KeyError, "could not find key"); }
    return tmp;
}
```

This fails for example with:

```
>>>> some_func([])
Error in cpyext, CPython compatibility layer:
The function PyDict_GetItem was not supposed to fail
Fatal error in cpyext, CPython compatibility layer, calling PyDict_GetItem
Either report a bug or consider not using this particular extension
<SystemError object at 0x6c23cbb8>
RPython traceback:
  File "pypy_module_cpyext_1.c", line 2333, in wrapper_second_level__star_2_37
  File "pypy_module_cpyext_1.c", line 40310, in not_supposed_to_fail
```

and similar for `some_func({}, {})`. I believe this fails when the value not hashable \(`some_func(1)` works correctly\).

I encountered this with Windows and Max OS-X with PyPy 3.6 Version 7.2.0 \(but not in PyPy 3.5 7.0.0 - I haven’t tested other versions or other OS\).




More information about the pypy-issue mailing list