From abd1c453fba0d3d9f77641b93b2aec6a6d02fbbe Mon Sep 17 00:00:00 2001 From: JackDandy Date: Fri, 14 Nov 2014 18:34:56 +0000 Subject: [PATCH] Remove output of source code line when warnings highlight libraries not used with IMDb. Add a new show to observe the output. Conflicts: CHANGES.md --- CHANGES.md | 1 + lib/imdb/parser/http/utils.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 169e927a..71af2bad 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ * Remove redundant references from Config / Help & Info * Fix poster preview on small poster layout * Change overhaul Config Anime to be in line with General Configuration +* Remove output of source code line when warnings highlight libraries not used with IMDb ### 0.3.0 (2014-11-12 14:30:00 UTC) diff --git a/lib/imdb/parser/http/utils.py b/lib/imdb/parser/http/utils.py index 8b4e17e3..031a4d3a 100644 --- a/lib/imdb/parser/http/utils.py +++ b/lib/imdb/parser/http/utils.py @@ -441,6 +441,12 @@ class DOMParserBase(object): self._useModule = useModule nrMods = len(useModule) _gotError = False + + # Force warnings.warn() to omit the source code line in the message + formatwarning_orig = warnings.formatwarning + warnings.formatwarning = lambda message, category, filename, lineno, line=None: \ + formatwarning_orig(message, category, filename, lineno, line='') + for idx, mod in enumerate(useModule): mod = mod.strip().lower() try: