Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be more lenient with try/except in _showwarning #452

Closed
wants to merge 4 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions PyPDF2/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,12 +1157,8 @@ def _showwarning(message, category, filename, lineno, file=warndest, line=None):
if file is None:
file = sys.stderr
try:
# It is possible for sys.stderr to be defined as None, most commonly in the case that the script
# is being run vida pythonw.exe on Windows. In this case, just swallow the warning.
# See also https://docs.python.org/3/library/sys.html#sys.__stderr__
if file is not None:
file.write(formatWarning(message, category, filename, lineno, line))
except IOError:
file.write(formatWarning(message, category, filename, lineno, line))
MartinThoma marked this conversation as resolved.
Show resolved Hide resolved
except Exception:
pass
warnings.showwarning = _showwarning
self.strict = strict
Expand Down