Bug 2276896 - rpkg fails to build with Python 3.13: 'Logger' object has no attribute 'warn'
Summary: rpkg fails to build with Python 3.13: 'Logger' object has no attribute 'warn'
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: rpkg
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Ondřej Nosek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.13
TreeView+ depends on / blocked
 
Reported: 2024-04-24 14:22 UTC by Karolina Surma
Modified: 2024-05-23 11:58 UTC (History)
6 users (show)

Fixed In Version: rpkg-1.66-18.fc41
Clone Of:
Environment:
Last Closed: 2024-05-23 11:51:32 UTC
Type: Bug
Embargoed:
mhroncok: needinfo+


Attachments (Terms of Use)

Description Karolina Surma 2024-04-24 14:22:54 UTC
rpkg fails to build with Python 3.13.0a6.

=================================== FAILURES ===================================
________________ CGILookasideCacheTestCase.test_download_failed ________________

    @functools.wraps(function)
    def inner(*args, **kwargs):
    
        attempts_all = attempts or self.attempts
        attempts_left = attempts_all
        delay = delay_between_attempts or self.delay_between_attempts
        while attempts_left > 0:
            try:
>               return function(*args, **kwargs)

../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:407: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:368: in retry_download
    curl.perform()
/usr/lib64/python3.13/unittest/mock.py:1164: in __call__
    return self._mock_call(*args, **kwargs)
/usr/lib64/python3.13/unittest/mock.py:1168: in _mock_call
    return self._execute_mock_call(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <MagicMock name='Curl().perform' id='139884342316736'>, args = ()
kwargs = {}, effect = error('Could not resolve host: example.com')

    def _execute_mock_call(self, /, *args, **kwargs):
        # separate from _increment_mock_call so that awaited functions are
        # executed separately from their call, also AsyncMock overrides this method
    
        effect = self.side_effect
        if effect is not None:
            if _is_exception(effect):
>               raise effect
E               pycurl.error: Could not resolve host: example.com

/usr/lib64/python3.13/unittest/mock.py:1223: error

During handling of the above exception, another exception occurred:

self = <test_lookaside.CGILookasideCacheTestCase testMethod=test_download_failed>
mock_curl = <MagicMock name='Curl' id='139884342316400'>

    @mock.patch('pyrpkg.lookaside.pycurl.Curl')
    def test_download_failed(self, mock_curl):
        curl = mock_curl.return_value
        curl.perform.side_effect = pycurl.error(
            'Could not resolve host: example.com')
    
        with open(self.filename, 'wb') as f:
            f.write(b'content')
    
        hash = hashlib.sha512(b'content').hexdigest()
        outfile = os.path.join(self.workdir, 'pyrpkg-0.0.tar.xz')
    
        lc = CGILookasideCache('sha512', 'http://example.com', '_')
>       self.assertRaises(DownloadError, lc.download, 'pyrpkg',
                          'pyrpkg-0.0.tar.xz', hash, outfile)

tests/test_lookaside.py:213: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:186: in download
    status, tstamp = self.retry(raises=DownloadError)(self.retry_download)(c, outfile)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    @functools.wraps(function)
    def inner(*args, **kwargs):
    
        attempts_all = attempts or self.attempts
        attempts_left = attempts_all
        delay = delay_between_attempts or self.delay_between_attempts
        while attempts_left > 0:
            try:
                return function(*args, **kwargs)
            except wait_on as e:
>               self.log.warn("Network error: %s" % (e))
E               AttributeError: 'Logger' object has no attribute 'warn'

../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:409: AttributeError
________ CGILookasideCacheTestCase.test_remote_file_exists_check_failed ________

    @functools.wraps(function)
    def inner(*args, **kwargs):
    
        attempts_all = attempts or self.attempts
        attempts_left = attempts_all
        delay = delay_between_attempts or self.delay_between_attempts
        while attempts_left > 0:
            try:
>               return function(*args, **kwargs)

../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:407: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:381: in retry_remote_file_exists
    curl.perform()
/usr/lib64/python3.13/unittest/mock.py:1164: in __call__
    return self._mock_call(*args, **kwargs)
/usr/lib64/python3.13/unittest/mock.py:1168: in _mock_call
    return self._execute_mock_call(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <MagicMock name='Curl().perform' id='139884356710960'>, args = ()
kwargs = {}, effect = error('Could not resolve host: example.com')

    def _execute_mock_call(self, /, *args, **kwargs):
        # separate from _increment_mock_call so that awaited functions are
        # executed separately from their call, also AsyncMock overrides this method
    
        effect = self.side_effect
        if effect is not None:
            if _is_exception(effect):
>               raise effect
E               pycurl.error: Could not resolve host: example.com

/usr/lib64/python3.13/unittest/mock.py:1223: error

During handling of the above exception, another exception occurred:

self = <test_lookaside.CGILookasideCacheTestCase testMethod=test_remote_file_exists_check_failed>
mock_curl = <MagicMock name='Curl' id='139884349360512'>

    @mock.patch('pyrpkg.lookaside.pycurl.Curl')
    def test_remote_file_exists_check_failed(self, mock_curl):
        curl = mock_curl.return_value
        curl.perform.side_effect = pycurl.error(
            'Could not resolve host: example.com')
    
        lc = CGILookasideCache('_', '_', '_')
>       self.assertRaises(UploadError, lc.remote_file_exists, 'pyrpkg',
                          'pyrpkg-0.tar.xz', 'thehash')

tests/test_lookaside.py:431: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:274: in remote_file_exists
    status, output = self.retry(raises=UploadError)(self.retry_remote_file_exists)(c)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    @functools.wraps(function)
    def inner(*args, **kwargs):
    
        attempts_all = attempts or self.attempts
        attempts_left = attempts_all
        delay = delay_between_attempts or self.delay_between_attempts
        while attempts_left > 0:
            try:
                return function(*args, **kwargs)
            except wait_on as e:
>               self.log.warn("Network error: %s" % (e))
E               AttributeError: 'Logger' object has no attribute 'warn'

../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:409: AttributeError
_________________ CGILookasideCacheTestCase.test_upload_failed _________________

    @functools.wraps(function)
    def inner(*args, **kwargs):
    
        attempts_all = attempts or self.attempts
        attempts_left = attempts_all
        delay = delay_between_attempts or self.delay_between_attempts
        while attempts_left > 0:
            try:
>               return function(*args, **kwargs)

../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:407: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:389: in retry_upload
    curl.perform()
/usr/lib64/python3.13/unittest/mock.py:1164: in __call__
    return self._mock_call(*args, **kwargs)
/usr/lib64/python3.13/unittest/mock.py:1168: in _mock_call
    return self._execute_mock_call(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <MagicMock name='Curl().perform' id='139884343378000'>, args = ()
kwargs = {}, effect = error('Could not resolve host: example.com')

    def _execute_mock_call(self, /, *args, **kwargs):
        # separate from _increment_mock_call so that awaited functions are
        # executed separately from their call, also AsyncMock overrides this method
    
        effect = self.side_effect
        if effect is not None:
            if _is_exception(effect):
>               raise effect
E               pycurl.error: Could not resolve host: example.com

/usr/lib64/python3.13/unittest/mock.py:1223: error

During handling of the above exception, another exception occurred:

self = <test_lookaside.CGILookasideCacheTestCase testMethod=test_upload_failed>
mock_curl = <MagicMock name='Curl' id='139884335432432'>

    @mock.patch('os.stat', new=mock_stat)
    @mock.patch('pyrpkg.lookaside.pycurl.Curl')
    def test_upload_failed(self, mock_curl):
        curl = mock_curl.return_value
        curl.perform.side_effect = pycurl.error(
            'Could not resolve host: example.com')
    
        lc = CGILookasideCache('_', '_', '_')
    
        with mock.patch.object(lc, 'remote_file_exists', lambda *x: False):
>           self.assertRaises(UploadError, lc.upload, 'pyrpkg',
                              'pyrpkg-0.tar.xz', 'thehash')

tests/test_lookaside.py:599: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:351: in upload
    status, output = self.retry(raises=UploadError)(self.retry_upload)(c)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    @functools.wraps(function)
    def inner(*args, **kwargs):
    
        attempts_all = attempts or self.attempts
        attempts_left = attempts_all
        delay = delay_between_attempts or self.delay_between_attempts
        while attempts_left > 0:
            try:
                return function(*args, **kwargs)
            except wait_on as e:
>               self.log.warn("Network error: %s" % (e))
E               AttributeError: 'Logger' object has no attribute 'warn'

../../BUILDROOT/rpkg-1.66-17.fc41.x86_64/usr/lib/python3.13/site-packages/pyrpkg/lookaside.py:409: AttributeError

=========================== short test summary info ============================
FAILED tests/test_lookaside.py::CGILookasideCacheTestCase::test_download_failed
FAILED tests/test_lookaside.py::CGILookasideCacheTestCase::test_remote_file_exists_check_failed
FAILED tests/test_lookaside.py::CGILookasideCacheTestCase::test_upload_failed
============ 3 failed, 403 passed, 1 skipped, 7 warnings in 17.49s =============


According to https://docs.python.org/3.13/whatsnew/3.13.html:

logging: Remove undocumented and untested Logger.warn() and LoggerAdapter.warn() methods and logging.warn() function.
Deprecated since Python 3.3, they were aliases to the logging.Logger.warning() method,
logging.LoggerAdapter.warning() method and logging.warning() function.
(Contributed by Victor Stinner in gh-105376.)


https://docs.python.org/3.13/whatsnew/3.13.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/07345623-rpkg/

For all our attempts to build rpkg with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/rpkg/

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.13:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
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 Karolina Surma 2024-05-06 10:08:54 UTC
This has apparently been fixed in https://pagure.io/rpkg/c/13623dbfc85ad5200db677dec70095d7d72e76c1?branch=master
I'm not sure whether you'll prefer to create the new release of rpkg for Fedora 41 or just patch the line. In the latter case I'll send a PR.

Comment 3 Fedora Update System 2024-05-23 11:49:24 UTC
FEDORA-2024-cf0fffe3f5 (rpkg-1.66-18.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-cf0fffe3f5

Comment 4 Fedora Update System 2024-05-23 11:51:32 UTC
FEDORA-2024-cf0fffe3f5 (rpkg-1.66-18.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.


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