Commit 1e81c41d authored by Gabriel Monnerat's avatar Gabriel Monnerat

Patch PyPDF2

PyPDF2 overwrites `warning.showwarning` and this is already confirmed as a major flaw: https://github.com/mstamy2/PyPDF2/issues/67#issuecomment-34387142

But, this is never applied in PyPDF2.

To fix this issue in ERP5, we will copy the patch to our stack and apply it.

See merge request !746
parents 9db68bf6 787bc9f2
Pipeline #9382 failed with stage
in 0 seconds
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
...@@ -198,6 +198,11 @@ scripts = ...@@ -198,6 +198,11 @@ scripts =
interpreter= interpreter=
python_for_test python_for_test
# patches for eggs
patch-binary = ${patch:location}/bin/patch
PyPDF2-patches = ${:_profile_base_location_}/../../component/egg-patch/PyPDF2/0001-Custom-implementation-of-warnings.formatwarning-remo.patch#d25bb0f5dde7f3337a0a50c2f986f5c8
PyPDF2-patch-options = -p1
[git-clone-repository] [git-clone-repository]
recipe = slapos.recipe.build:gitclone recipe = slapos.recipe.build:gitclone
git-executable = ${git:location}/bin/git git-executable = ${git:location}/bin/git
...@@ -265,6 +270,9 @@ requests-toolbelt = 0.8.0 ...@@ -265,6 +270,9 @@ requests-toolbelt = 0.8.0
selenium = 3.141.0 selenium = 3.141.0
slapos.recipe.template = 4.4 slapos.recipe.template = 4.4
# Patched eggs
PyPDF2 = 1.26.0+SlapOSPatched001
# modern versions for SSL fixed support # modern versions for SSL fixed support
requests = 2.20.0 requests = 2.20.0
certifi = 2018.10.15 certifi = 2018.10.15
...@@ -291,7 +299,6 @@ backports.lzma = 0.0.13 ...@@ -291,7 +299,6 @@ backports.lzma = 0.0.13
mock = 2.0.0 mock = 2.0.0
testfixtures = 6.11 testfixtures = 6.11
funcsigs = 1.0.2 funcsigs = 1.0.2
PyPDF2 = 1.26.0
mysqlclient = 1.3.12 mysqlclient = 1.3.12
pexpect = 4.8.0 pexpect = 4.8.0
ptyprocess = 0.6.0 ptyprocess = 0.6.0
...@@ -410,7 +410,7 @@ eggs = ${neoppod:eggs} ...@@ -410,7 +410,7 @@ eggs = ${neoppod:eggs}
paramiko paramiko
ply ply
pyflakes pyflakes
pypdf2 PyPDF2
python-magic python-magic
python-memcached python-memcached
pytz pytz
...@@ -528,6 +528,8 @@ extra-paths = ...@@ -528,6 +528,8 @@ extra-paths =
# patches for eggs # patches for eggs
patch-binary = ${patch:location}/bin/patch patch-binary = ${patch:location}/bin/patch
PyPDF2-patches = ${:_profile_base_location_}/../../component/egg-patch/PyPDF2/0001-Custom-implementation-of-warnings.formatwarning-remo.patch#d25bb0f5dde7f3337a0a50c2f986f5c8
PyPDF2-patch-options = -p1
Acquisition-patches = ${:_profile_base_location_}/../../component/egg-patch/Acquisition/aq_dynamic.patch#1d9a56e9af4371f5b6951ebf217a15d7 Acquisition-patches = ${:_profile_base_location_}/../../component/egg-patch/Acquisition/aq_dynamic.patch#1d9a56e9af4371f5b6951ebf217a15d7
Acquisition-patch-options = -p1 Acquisition-patch-options = -p1
Products.DCWorkflow-patches = ${:_profile_base_location_}/../../component/egg-patch/Products.DCWorkflow/workflow_method.patch#975b49e96bae33ac8563454fe5fa9899 Products.DCWorkflow-patches = ${:_profile_base_location_}/../../component/egg-patch/Products.DCWorkflow/workflow_method.patch#975b49e96bae33ac8563454fe5fa9899
...@@ -576,6 +578,7 @@ ocropy = 1.0+SlapOSPatched001 ...@@ -576,6 +578,7 @@ ocropy = 1.0+SlapOSPatched001
pysvn = 1.7.10+SlapOSPatched002 pysvn = 1.7.10+SlapOSPatched002
python-ldap = 2.4.32+SlapOSPatched001 python-ldap = 2.4.32+SlapOSPatched001
python-magic = 0.4.12+SlapOSPatched001 python-magic = 0.4.12+SlapOSPatched001
PyPDF2 = 1.26.0+SlapOSPatched001
## https://lab.nexedi.com/nexedi/slapos/merge_requests/648 ## https://lab.nexedi.com/nexedi/slapos/merge_requests/648
pylint = 1.4.4 pylint = 1.4.4
...@@ -623,7 +626,6 @@ Products.MimetypesRegistry = 2.0.10 ...@@ -623,7 +626,6 @@ Products.MimetypesRegistry = 2.0.10
Products.PluginRegistry = 1.4 Products.PluginRegistry = 1.4
Products.TIDStorage = 5.5.0 Products.TIDStorage = 5.5.0
pyPdf = 1.13 pyPdf = 1.13
PyPDF2 = 1.26.0
PyStemmer = 1.3.0 PyStemmer = 1.3.0
PyXML = 0.8.5 PyXML = 0.8.5
Pympler = 0.4.3 Pympler = 0.4.3
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment