Bug 1919789 - setproctitle.getproctitle() errors with Python 3.10: SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
Summary: setproctitle.getproctitle() errors with Python 3.10: SystemError: PY_SSIZE_T_...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: python-setproctitle
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Haïkel Guémar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1902276 (view as bug list)
Depends On:
Blocks: PYTHON3.10
TreeView+ depends on / blocked
 
Reported: 2021-01-25 07:43 UTC by Tomáš Hrnčiar
Modified: 2021-02-21 06:23 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2021-01-25 07:43:17 UTC
copr-backend fails to build with Python 3.10.0a4.

=================================== FAILURES ===================================
____________________ TestCreaterepo.test_run_cmd_unsafe_ok _____________________

self = <tests.test_createrepo.TestCreaterepo object at 0x7fe258d822b0>
mc_popen = <MagicMock name='Popen' id='140610129400496'>

    def test_run_cmd_unsafe_ok(self, mc_popen):
        cmd = "foo --bar"
        mc_popen.return_value.communicate.return_value = ("stdout", "stderr")
        mc_popen.return_value.returncode = 0
    
>       assert run_cmd_unsafe(cmd, self.tmp_dir_name, lock_path="/tmp") == "stdout"

tests/test_createrepo.py:118: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

comm_str = 'foo --bar', lock_name = '/tmp/test_createrepo_1611336042.098019'
lock_path = '/tmp'

    def run_cmd_unsafe(comm_str, lock_name, lock_path="/var/lock/copr-backend"):
        # log.info("Running command: {}".format(comm_str))
        comm = split(comm_str)
>       title = getproctitle()
E       SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

copr_backend/createrepo.py:26: SystemError
_________________ TestCreaterepo.test_run_cmd_unsafe_err_popen _________________

self = <tests.test_createrepo.TestCreaterepo object at 0x7fe258bbbcd0>
mc_popen = <MagicMock name='Popen' id='140610128035552'>

    def test_run_cmd_unsafe_err_popen(self, mc_popen):
        cmd = "foo --bar"
        mc_popen.side_effect = IOError()
    
        with pytest.raises(CreateRepoError) as err:
>           run_cmd_unsafe(cmd, self.tmp_dir_name, lock_path="/tmp") == "stdout"

tests/test_createrepo.py:126: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

comm_str = 'foo --bar', lock_name = '/tmp/test_createrepo_1611336042.1865735'
lock_path = '/tmp'

    def run_cmd_unsafe(comm_str, lock_name, lock_path="/var/lock/copr-backend"):
        # log.info("Running command: {}".format(comm_str))
        comm = split(comm_str)
>       title = getproctitle()
E       SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

copr_backend/createrepo.py:26: SystemError
______________ TestCreaterepo.test_run_cmd_unsafe_err_return_code ______________

self = <tests.test_createrepo.TestCreaterepo object at 0x7fe258ccaf10>
mc_popen = <MagicMock name='Popen' id='140610129145184'>

    def test_run_cmd_unsafe_err_return_code(self, mc_popen):
        cmd = "foo --bar"
        mc_popen.return_value.communicate.return_value = ("stdout", "stderr")
        mc_popen.return_value.returncode = 1
    
    
        with pytest.raises(CreateRepoError) as err:
>           run_cmd_unsafe(cmd, self.tmp_dir_name, lock_path="/tmp") == "stdout"

tests/test_createrepo.py:139: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

comm_str = 'foo --bar', lock_name = '/tmp/test_createrepo_1611336042.2561789'
lock_path = '/tmp'

    def run_cmd_unsafe(comm_str, lock_name, lock_path="/var/lock/copr-backend"):
        # log.info("Running command: {}".format(comm_str))
        comm = split(comm_str)
>       title = getproctitle()
E       SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

copr_backend/createrepo.py:26: SystemError
______________ TestCreaterepo.test_run_cmd_unsafe_err_communicate ______________

self = <tests.test_createrepo.TestCreaterepo object at 0x7fe258cae880>
mc_popen = <MagicMock name='Popen' id='140610129030784'>

    def test_run_cmd_unsafe_err_communicate(self, mc_popen):
        cmd = "foo --bar"
        mc_handle = MagicMock()
        mc_popen.return_value = MagicMock()
        mc_handle.returncode = 0
        mc_handle.side_effect = RuntimeError()
    
        with pytest.raises(CreateRepoError) as err:
>           run_cmd_unsafe(cmd, self.tmp_dir_name, lock_path="/tmp") == "stdout"

tests/test_createrepo.py:156: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

comm_str = 'foo --bar', lock_name = '/tmp/test_createrepo_1611336042.2812111'
lock_path = '/tmp'

    def run_cmd_unsafe(comm_str, lock_name, lock_path="/var/lock/copr-backend"):
        # log.info("Running command: {}".format(comm_str))
        comm = split(comm_str)
>       title = getproctitle()
E       SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

copr_backend/createrepo.py:26: SystemError

=========================== short test summary info ============================
FAILED tests/test_createrepo.py::TestCreaterepo::test_run_cmd_unsafe_ok - Sys...
FAILED tests/test_createrepo.py::TestCreaterepo::test_run_cmd_unsafe_err_popen
FAILED tests/test_createrepo.py::TestCreaterepo::test_run_cmd_unsafe_err_return_code
FAILED tests/test_createrepo.py::TestCreaterepo::test_run_cmd_unsafe_err_communicate
======= 4 failed, 157 passed, 9 skipped, 3 warnings in 81.07s (0:01:21) ========

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/01893901-copr-backend/

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

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 Miro Hrončok 2021-01-25 09:03:44 UTC
copr-backend is pure Python, no extension modules. The error is surely coming from a compiled C API Python code that copr invokes.

I suspect setproctitle: it is an extension module and has %check commented out with a very outdated comment.

Comment 2 Pavel Raiskup 2021-01-26 08:29:52 UTC
Moving to setproctitle, easily reproducible:

$ copr mock-config @python/python3.10 fedora-rawhide-x86_64 > /tmp/x.cfg
$ mock -r /tmp/x.cfg --install python3-setproctitle
$ mock -r /tmp/x.cfg --shell
<mock-chroot> sh-5.1# python3
Python 3.10.0a4 (default, Jan 15 2021, 00:00:00) 
[GCC 11.0.0 20210119 (Red Hat 11.0.0-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import setproctitle
>>> setproctitle.getproctitle()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

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

Comment 4 Dick Marinus 2021-02-21 06:23:25 UTC
*** Bug 1902276 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.