Fallback to WARNING when logging.getLogger().level is None

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1961555
This commit is contained in:
Miro Hrončok 2021-06-07 18:56:20 +02:00
parent bcb37d55ca
commit fd9b908d0d
2 changed files with 58 additions and 1 deletions

49
435.patch Normal file
View File

@ -0,0 +1,49 @@
From e2b6c2bd05d70898cc9d81ba74ceec7417e80e27 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Mon, 7 Jun 2021 18:50:26 +0200
Subject: [PATCH] Fallback to WARNING when logging.getLogger().level is None
We see the following errors in cloud-init that this solves:
tests/unittests/test_data.py:66: in setUp
super(TestConsumeUserData, self).setUp()
cloudinit/tests/helpers.py:245: in setUp
super(FilesystemMockingTestCase, self).setUp()
cloudinit/tests/helpers.py:230: in setUp
super(ResourceUsingTestCase, self).setUp()
cloudinit/tests/helpers.py:362: in setUp
httpretty.enable()
/usr/lib/python3.9/site-packages/httpretty/core.py:1818: in enable
logger.setLevel(logging.getLogger().level)
/usr/lib64/python3.9/logging/__init__.py:1421: in setLevel
self.level = _checkLevel(level)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
level = None
def _checkLevel(level):
if isinstance(level, int):
rv = level
elif str(level) == level:
if level not in _nameToLevel:
raise ValueError("Unknown level: %r" % level)
rv = _nameToLevel[level]
else:
> raise TypeError("Level not an integer or a valid string: %r" % level)
E TypeError: Level not an integer or a valid string: None
/usr/lib64/python3.9/logging/__init__.py:201: TypeError
---
httpretty/core.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/httpretty/core.py b/httpretty/core.py
index c73700c..19715e0 100644
--- a/httpretty/core.py
+++ b/httpretty/core.py
@@ -1815,7 +1815,7 @@ def enable(cls, allow_net_connect=True, verbose=False):
if verbose:
logger.setLevel(logging.DEBUG)
else:
- logger.setLevel(logging.getLogger().level)
+ logger.setLevel(logging.getLogger().level or logging.WARNING)
def apply_patch_socket():

View File

@ -16,7 +16,7 @@
Name: python-httpretty
Version: 1.1.3
# If github_date is defined, assume a post-release snapshot
Release: 2%{?github_date:.%{github_date}git%{shortcommit}}%{?dist}
Release: 3%{?github_date:.%{github_date}git%{shortcommit}}%{?dist}
Summary: HTTP request mock tool for Python
License: MIT
@ -32,6 +32,11 @@ Patch1: python-httpretty-fakesock_getpeercert_noconnect.patch
# Remote access (these tests were skipped upstream in <= 0.9.7)
Patch2: skip-test_passthrough.patch
# Fallback to WARNING when logging.getLogger().level is None
# This fixes FTBFS in cloud-init
# https://bugzilla.redhat.com/show_bug.cgi?id=1961555
Patch3: https://github.com/gabrielfalcao/HTTPretty/pull/435.patch
BuildArch: noarch
%global _description\
@ -161,6 +166,9 @@ LANG=C.UTF-8 %{__python2} -m nose -v
%changelog
* Mon Jun 07 2021 Miro Hrončok <mhroncok@redhat.com>
- Fallback to WARNING when logging.getLogger().level is None
* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 1.1.3-2
- Rebuilt for Python 3.10