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

Custom implementation of warnings.formatwarning removed #225

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
15 changes: 2 additions & 13 deletions PyPDF2/pdf.py
Expand Up @@ -63,7 +63,7 @@
import codecs
from .generic import *
from .utils import readNonWhitespace, readUntilWhitespace, ConvertFunctionsToVirtualList
from .utils import isString, b_, u_, ord_, chr_, str_, formatWarning
from .utils import isString, b_, u_, ord_, chr_, str_

if version_info < ( 2, 4 ):
from sets import ImmutableSet as frozenset
Expand Down Expand Up @@ -1039,18 +1039,7 @@ class PdfFileReader(object):
``warnings.py`` module with a custom implementation (defaults to
``True``).
"""
def __init__(self, stream, strict=True, warndest = None, overwriteWarnings = True):
if overwriteWarnings:
# have to dynamically override the default showwarning since there are no
# public methods that specify the 'file' parameter
def _showwarning(message, category, filename, lineno, file=warndest, line=None):
if file is None:
file = sys.stderr
try:
file.write(formatWarning(message, category, filename, lineno, line))
except IOError:
pass
warnings.showwarning = _showwarning
def __init__(self, stream, strict=True):
self.strict = strict
self.flattenedPages = None
self.resolvedObjects = {}
Expand Down
6 changes: 0 additions & 6 deletions PyPDF2/utils.py
Expand Up @@ -64,12 +64,6 @@ def isBytes(b):
return isinstance(b, bytes_type)


#custom implementation of warnings.formatwarning
def formatWarning(message, category, filename, lineno, line=None):
file = filename.replace("/", "\\").rsplit("\\", 1)[1] # find the file name
return "%s: %s [%s:%s]\n" % (category.__name__, message, file, lineno)


def readUntilWhitespace(stream, maxchars=None):
"""
Reads non-whitespace characters and returns them.
Expand Down