New issue 2396: PyMemoryView_GET_BUFFER: bogus view.c__format
https://bitbucket.org/pypy/pypy/issues/2396/pymemoryview_get_buffer-bogus
Armin Rigo:
Bogus lines in cpyext/memoryview.py:
```
#!python
view.c__format = rffi.cast(rffi.UCHAR, w_obj.buf.getformat())
view.c_format = rffi.cast(rffi.CCHARP, view.c__format)
```
The first line actually takes getformat(), which is annotated as returning an
RPython *string*, not a char, and converts that string's pointer to an unsigned
char, giving nonsense. Much safer than rffi.cast() is to use ord() to convert
a char to an integer, and complain if it isn't annotated as a char.
Then the second line takes a ``char *`` to it, but that doesn't make a
null-terminated string. If the goal was to have a one-char null-terminated
string, we'd need to ensure a null character in the second position.
_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue