lbalhar / rpms / python3.5

Forked from rpms/python3.5 3 years ago
Clone
Blob Blame History Raw
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bohuslav Kabrda <bkabrda@redhat.com>
Date: Wed, 6 Nov 2013 14:58:05 +0100
Subject: [PATCH] 00188: Fix lib2to3 tests when hashlib doesn't compile
 properly

Downstream only patch that should be removed when we compile all guaranteed
hashlib algorithms properly. The problem is this:
- during tests, test_hashlib is imported and executed before test_lib2to3
- if at least one hash function has failed, trying to import it triggers an
  exception that is being caught and exception is logged:
  http://hg.python.org/cpython/file/2de806c8b070/Lib/hashlib.py#l217
- logging the exception makes logging module run basicConfig
- when lib2to3 tests are run again, lib2to3 runs basicConfig again, which
  doesn't do anything, because it was run previously
  (logging.root.handlers != []), which means that the default setup
  (most importantly logging level) is not overriden. That means that a test
  relying on this will fail (test_filename_changing_on_output_single_dir)
---
 Lib/lib2to3/main.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Lib/lib2to3/main.py b/Lib/lib2to3/main.py
index 1a1df013ad..4bd7212680 100644
--- a/Lib/lib2to3/main.py
+++ b/Lib/lib2to3/main.py
@@ -213,6 +213,7 @@ def main(fixer_pkg, args=None):
 
     # Set up logging handler
     level = logging.DEBUG if options.verbose else logging.INFO
+    logging.root.handlers = []
     logging.basicConfig(format='%(name)s: %(message)s', level=level)
     logger = logging.getLogger('lib2to3.main')