Bug 2252059

Summary: python-nuheat fails to build with Python 3.13: 'Logger' object has no attribute 'warn'
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-nuheatAssignee: Fabian Affolter <mail>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 40CC: ksurma, mail, mhroncok
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-nuheat-1.0.1-3.fc41 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-09-27 12:46:10 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: 2244836    

Description Karolina Surma 2023-11-29 09:47:06 UTC
python-nuheat fails to build with Python 3.13.0a2.

=================================== FAILURES ===================================
_______________________ TestThermostat.test_get_data_401 _______________________

self = <tests.test_thermostat.TestThermostat testMethod=test_get_data_401>

    @responses.activate
    def test_get_data_401(self):
        # First request (when initializing the thermostat) is successful
        response_data = load_fixture("thermostat.json")
        responses.add(
            responses.GET,
            config.THERMOSTAT_URL,
            status=200,
            body=json.dumps(response_data),
            content_type="application/json"
        )
    
        # A later, second request throws 401 Unauthorized
        responses.add(
            responses.GET,
            config.THERMOSTAT_URL,
            status=401
        )
    
        # Attempt to reauthenticate
        auth_data = load_fixture("auth_success.json")
        responses.add(
            responses.POST,
            config.AUTH_URL,
            status=200,
            body=json.dumps(auth_data),
            content_type="application/json"
        )
    
        # Third request is successful
        responses.add(
            responses.GET,
            config.THERMOSTAT_URL,
            status=200,
            body=json.dumps(response_data),
            content_type="application/json"
        )
    
        bad_session_id = "my-bad-session"
        good_session_id = auth_data.get("SessionId")
        api = NuHeat(None, None, session_id=bad_session_id)
        serial_number = response_data.get("SerialNumber")
    
        thermostat = NuHeatThermostat(api, serial_number)
>       thermostat.get_data()

tests/test_thermostat.py:206: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
nuheat/thermostat.py:140: in get_data
    data = self._session.request(config.THERMOSTAT_URL, params=params)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <NuHeat username='None'>, url = 'https://www.mynuheat.com/api/thermostat'
method = 'GET', data = None
params = {'serialnumber': '12345', 'sessionid': 'my-bad-session'}, retry = True

    def request(self, url, method="GET", data=None, params=None, retry=True):
        """
        Make a request to the NuHeat API
    
        :param url: The URL to request
        :param method: The type of request to make (GET, POST)
        :param data: Data to be sent along with POST requests
        :param params: Querystring parameters
        :param retry: Attempt to re-authenticate and retry request if necessary
        """
        headers = config.REQUEST_HEADERS
    
        if params and self._session_id:
            params['sessionid'] = self._session_id
    
        if method == "GET":
            response = requests.get(url, headers=headers, params=params)
        elif method == "POST":
            response = requests.post(url, headers=headers, params=params, data=data)
    
        # Handle expired sessions
        if response.status_code == 401 and retry:
>           _LOGGER.warn("NuHeat APIrequest unauthorized [401]. Try to re-authenticate.")
E           AttributeError: 'Logger' object has no attribute 'warn'

nuheat/api.py:78: AttributeError
=========================== short test summary info ============================
FAILED tests/test_thermostat.py::TestThermostat::test_get_data_401 - Attribut...
========================= 1 failed, 35 passed in 0.18s =========================

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/06692224-python-nuheat/

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

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 Aoife Moloney 2024-02-15 23:06:15 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 40 development cycle.
Changing version to 40.