Bug 1899866

Summary: python-zstd fails to build with Python 3.10: SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: python-zstdAssignee: Miro Hrončok <mhroncok>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: mhroncok, ngompa13, python-sig, thrnciar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-zstd-1.4.5.1-4.fc35 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-06-07 23:30:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1890881    

Description Tomáš Hrnčiar 2020-11-20 09:38:34 UTC
python-zstd fails to build with Python 3.10.0a2.

======================================================================
ERROR: test_compression_default_level (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 19, in test_compression_default_level
    BaseTestZSTD.helper_compression_default_level(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 71, in helper_compression_default_level
    CDATA = zstd.compress(tDATA)
SystemError: <built-in function compress> returned a result with an error set

======================================================================
ERROR: test_compression_default_level_default (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 25, in test_compression_default_level_default
    BaseTestZSTD.helper_compression_default_level_default(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 79, in helper_compression_default_level_default
    CDATA = zstd.compress(tDATA)
SystemError: <built-in function compress> returned a result with an error set

======================================================================
ERROR: test_compression_default_level_zero (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 22, in test_compression_default_level_zero
    BaseTestZSTD.helper_compression_default_level_zero(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 75, in helper_compression_default_level_zero
    CDATA = zstd.compress(tDATA)
SystemError: <built-in function compress> returned a result with an error set

======================================================================
ERROR: test_compression_level1 (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 48, in test_compression_level1
    BaseTestZSTD.helper_compression_level1(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 119, in helper_compression_level1
    self.assertEqual(DATA, zstd.decompress(zstd.compress(DATA, 1)))
TypeError: a bytes-like object is required, not 'int'

======================================================================
ERROR: test_compression_level20 (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 54, in test_compression_level20
    BaseTestZSTD.helper_compression_level20(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 133, in helper_compression_level20
    self.assertEqual(DATA, zstd.decompress(zstd.compress(DATA, 20)))
TypeError: a bytes-like object is required, not 'int'

======================================================================
ERROR: test_compression_level6 (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 51, in test_compression_level6
    BaseTestZSTD.helper_compression_level6(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 126, in helper_compression_level6
    self.assertEqual(DATA, zstd.decompress(zstd.compress(DATA, 6)))
TypeError: a bytes-like object is required, not 'int'

======================================================================
ERROR: test_compression_multi_thread_many (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 40, in test_compression_multi_thread_many
    BaseTestZSTD.helper_compression_multi_thread_many(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 104, in helper_compression_multi_thread_many
    CDATA = zstd.compress(tDATA, 6, 16)
TypeError: a bytes-like object is required, not 'int'

======================================================================
ERROR: test_compression_multi_thread_one (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 37, in test_compression_multi_thread_one
    BaseTestZSTD.helper_compression_multi_thread_one(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 100, in helper_compression_multi_thread_one
    CDATA = zstd.compress(tDATA, 6, 1)
TypeError: a bytes-like object is required, not 'int'

======================================================================
ERROR: test_compression_negative_level (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 28, in test_compression_negative_level
    BaseTestZSTD.helper_compression_negative_level(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 86, in helper_compression_negative_level
    CDATA = zstd.compress(tDATA, -1)
TypeError: a bytes-like object is required, not 'int'

======================================================================
ERROR: test_compression_negative_level_notdefault (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 31, in test_compression_negative_level_notdefault
    BaseTestZSTD.helper_compression_negative_level_notdefault(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 93, in helper_compression_negative_level_notdefault
    CDATA = zstd.compress(tDATA, -1)
TypeError: a bytes-like object is required, not 'int'

======================================================================
ERROR: test_compression_random (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 16, in test_compression_random
    BaseTestZSTD.helper_compression_random(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 68, in helper_compression_random
    self.assertEqual(DATA, zstd.loads(zstd.dumps(DATA)))
SystemError: <built-in function dumps> returned a result with an error set

======================================================================
ERROR: test_compression_wrong_level (tests.test_compress.TestZSTD)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/test_compress.py", line 34, in test_compression_wrong_level
    BaseTestZSTD.helper_compression_wrong_level(self)
  File "/builddir/build/BUILD/zstd-1.4.5.1/tests/base.py", line 97, in helper_compression_wrong_level
    self.assertRaises(zstd.Error, zstd.compress, tDATA, 100)
  File "/usr/lib64/python3.10/unittest/case.py", line 732, in assertRaises
    return context.handle('assertRaises', args, kwargs)
  File "/usr/lib64/python3.10/unittest/case.py", line 201, in handle
    callable_obj(*args, **kwargs)
TypeError: a bytes-like object is required, not 'int'

----------------------------------------------------------------------
Ran 15 tests in 0.019s

FAILED (errors=12, skipped=3)

https://docs.python.org/3.10/whatsnew/3.10.html#id2

The PY_SSIZE_T_CLEAN macro must now be defined to use PyArg_ParseTuple() and Py_BuildValue() formats which use #: es#, et#, s#, u#, y#, z#, U# and Z#. See Parsing arguments and building values and the PEP 353.
https://docs.python.org/3.10/c-api/arg.html#arg-parsing
https://www.python.org/dev/peps/pep-0353
https://bugs.python.org/issue40943

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/01773497-python-zstd/

For all our attempts to build python-zstd with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/python-zstd/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.10:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Ben Cotton 2021-02-09 15:26:24 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.

Comment 2 Miro Hrončok 2021-06-04 20:13:53 UTC
This is a mass-posted update. Sorry if it is not 100% accurate to this bugzilla.


The Python 3.10 rebuild is in progress in a Koji side tag. If you manage to fix the problem, please commit the fix in the rawhide branch, but don't build the package in regular rawhide.

You can either build the package in the side tag, with:

    $ fedpkg build --target=f35-python

Or you can the build and we will eventually build it for you.

Note that the rebuild is still in progress, so not all (build) dependencies of this package might be available right away.

Thanks.

See also https://fedoraproject.org/wiki/Changes/Python3.10

If you have general questions about the rebuild, please use this mailing list thread: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/G47SGOYIQLRDTWGOSLSWERZSSHXDEDH5/

Comment 3 Miro Hrončok 2021-06-05 21:31:36 UTC
This commit appears to adapt the code for that: https://github.com/sergey-dryabzhinsky/python-zstd/commit/428a31edcde94d2908aa8ca3439ca01a797de3a4

Update to 1.4.9.1 or newer should contain it and hopefully fix this problem.

Comment 4 Miro Hrončok 2021-06-07 22:28:50 UTC
I forgot that rpmlint is required by pytohn3-rpkg and fedora-packager. Hence this is actually more important than expected, I'll attempt to fix it.

Comment 5 Miro Hrončok 2021-06-07 22:58:36 UTC
The f35-python side tag has been merged to Rawhide. From now on, build as you would normally build.