File: 848748-exception-ignored-in-Image-del.patch

package info (click to toggle)
blockdiag 3.0.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,644 kB
  • sloc: python: 8,402; makefile: 15
file content (42 lines) | stat: -rw-r--r-- 1,996 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From: Rebecca Palmer <rebecca_palmer@zoho.com>
Subject: Fix test failure with wand 0.4.1+
Bug-Debian: https://bugs.debian.org/848748
Forwarded: no

wand 0.4.1 added an Image.destroy()
(https://sources.debian.net/src/wand/0.4.4-1/wand/image.py/#L2760) that
iterates over self.sequence (the frames of an animation) to free their
memory; this throws an exception on single images (where
self.sequence=None), but as this is called from __del__, this
exception is warned about then ignored
(https://docs.python.org/3/reference/datamodel.html#object.__del__),
and hence is not an error in normal use.

However, blockdiag tests that use capture_stderr fail on any output
containing "Traceback", including this warning message.

This patch ignores this message to allow blockdiag to build.
---
 src/blockdiag/tests/utils.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/blockdiag/tests/utils.py b/src/blockdiag/tests/utils.py
index 904f438..77c67a2 100644
--- a/src/blockdiag/tests/utils.py
+++ b/src/blockdiag/tests/utils.py
@@ -74,7 +74,14 @@ def capture_stderr(func):
 
             func(*args, **kwargs)
 
-            if re.search('(ERROR|Traceback)', sys.stderr.getvalue()):
+            filtered_stderr=re.sub(r"""Exception ignored in: <bound method Resource\.__del__ of <wand\.image\.Image: \(empty\)>>
+Traceback \(most recent call last\):
+  File "/usr/lib/python3/dist-packages/wand/resource\.py", line [0-9]+, in __del__
+    self\.destroy\(\)
+  File "/usr/lib/python3/dist-packages/wand/image\.py", line [0-9]+, in destroy
+    for i in range\(0, len\(self\.sequence\)\):
+TypeError: object of type 'NoneType' has no len\(\)""","",sys.stderr.getvalue())#this is the expected result of freeing a single image (as opposed to an animation) in wand 0.4, not a blockdiag bug - #848748
+            if re.search('(ERROR|Traceback)', filtered_stderr):
                 raise AssertionError('Caught error')
         finally:
             if sys.stderr.getvalue():