Closed Ragora closed 5 years ago
What you're doing is legal, it's the PyArg_ParseTuple() that needs fixing. I have that parsing the argument vector using "s" which is trying to take buf as a NUL-terminated string when it really needs to be reading this as a byte array where NUL is perfectly legal. Fortunately, it looks like PyArg_ParseTuple() can play along and we can use either s* or s# rather than just s. I'm going to test this locally and try to turn your example in to a test case so we don't regress on this.
OK, that was pretty easy to fix up. I've added a test case for it as well. The trick is with PyArg_ParseTuple() and using s# to read it as an array of bytes. It gives us the length, which we don't need to give to ped_geometry_write(), but whatever. Thanks for the report.
I am unable to write sectors using the Geometry object with data containing \x00 bytes. It works fine otherwise, so I suspect the binding needs some adjustments to properly handle this case?
This occurs on an Ubuntu machine running Python 2.7 (and also on Python 3.5.2).
The following code reproduces it:
The full output of the failure:
Or perhaps I'm just not supposed to use it like this?