mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
fix: throw error_already_set in py::len on failing PyObject_Length (#2575)
* Throw error_already_set in py::len on failing PyObject_Length * Fix tests to mach error message on PyPy
This commit is contained in:
@@ -424,3 +424,11 @@ def test_memoryview_from_memory():
|
||||
assert isinstance(view, memoryview)
|
||||
assert view.format == 'B'
|
||||
assert bytes(view) == b'\xff\xe1\xab\x37'
|
||||
|
||||
|
||||
def test_builtin_functions():
|
||||
assert m.get_len([i for i in range(42)]) == 42
|
||||
with pytest.raises(TypeError) as exc_info:
|
||||
m.get_len(i for i in range(42))
|
||||
assert str(exc_info.value) in ["object of type 'generator' has no len()",
|
||||
"'generator' has no length"] # PyPy
|
||||
|
||||
Reference in New Issue
Block a user