equinor / segyio

Fast Python library for SEGY files.
Other
469 stars 213 forks source link

python 3.10 + segyio: SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats #526

Closed TheZappie closed 2 years ago

TheZappie commented 2 years ago

The following small example yields an error:

import segyio
import numpy as np

spec = segyio.spec()
spec.tracecount = 1
spec.samples = np.array([1,3,4])
spec.format = 5
with segyio.create('out.sgy', spec) as f:
    f.trace[0] = np.array([1,3,4])
Traceback (most recent call last):
  File "<input>", line 9, in <module>
  File "C:\ProgramData\Miniconda3\envs\ses3\lib\site-packages\segyio\trace.py", line 290, in __setitem__
    self.filehandle.puttr(self.wrapindex(i), xs)
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

The solution seems relatively simple, a one line change hopefully, see: https://stackoverflow.com/questions/70705404/systemerror-py-ssize-t-clean-macro-must-be-defined-for-formats

Tested using both: segyio 1.9.3 py310hf0c6b8f_2 conda-forge segyio 1.9.9 pypi_0 pypi

ErlendHaa commented 2 years ago

Hi,

This was fixed in 1.9.4 https://github.com/equinor/segyio/pull/490

Can you confirm that you get this with the 1.9.9 wheels from PyPI? I could not reproduce the error on my machine with 1.9.9

TheZappie commented 2 years ago

Sorry, my test was flawed, did not actually properly test it on segyio 1.9.3. The error is not there anymore in 1.9.9. Thanks for your quick reaction though.