Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PyPDF2 must not overwrite showwarning because it breaks ERP5. ERP5 already overwrites it properly py-pdf/pypdf#67 (comment)
- Loading branch information
Gabriel Monnerat
committed
May 7, 2020
1 parent
b0b86ec
commit 787bc9f
Showing
3 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
component/egg-patch/PyPDF2/0001-Custom-implementation-of-warnings.formatwarning-remo.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
From f8ef2a193edf565d61aa628232f0e46e55a6aa6f Mon Sep 17 00:00:00 2001 | ||
From: Pavel Brych <pavel@brych.cz> | ||
Date: Thu, 3 Sep 2015 08:04:53 +0200 | ||
Subject: [PATCH] Custom implementation of warnings.formatwarning removed | ||
|
||
--- | ||
PyPDF2/pdf.py | 15 ++------------- | ||
PyPDF2/utils.py | 6 ------ | ||
2 files changed, 2 insertions(+), 19 deletions(-) | ||
|
||
diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py | ||
index f54680a..3554f40 100644 | ||
--- a/PyPDF2/pdf.py | ||
+++ b/PyPDF2/pdf.py | ||
@@ -63,7 +63,7 @@ import warnings | ||
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 | ||
@@ -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 = {} | ||
diff --git a/PyPDF2/utils.py b/PyPDF2/utils.py | ||
index 718a875..7bcb9ce 100644 | ||
--- a/PyPDF2/utils.py | ||
+++ b/PyPDF2/utils.py | ||
@@ -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. | ||
-- | ||
2.23.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters