File: 0004-Fix-Test-using-Python3.13%2B14.patch

package info (click to toggle)
python-memory-profiler 0.61-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 600 kB
  • sloc: python: 2,228; makefile: 33
file content (45 lines) | stat: -rw-r--r-- 1,528 bytes parent folder | download
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
43
44
45
Author: Andreas Tille <tille@debian.org>
Last-Update: 2026-03-13
Bug-Debian: https://bugs.debian.org/1123268
Description: Fix test/test_exit_code.py with Python3.13+14 and test_exception.py for Python1.14

--- a/memory_profiler.py
+++ b/memory_profiler.py
@@ -1247,6 +1247,10 @@ def exec_with_profiler(filename, profile
             tracemalloc.start()
         with io.open(filename, encoding='utf-8') as f:
             exec(compile(f.read(), filename, 'exec'), ns, ns)
+    except SystemExit as e:
+        raise e
+    except Exception:
+        sys.exit(1)
     finally:
         if has_tracemalloc and tracemalloc.is_tracing():
             tracemalloc.stop()
@@ -1348,6 +1352,9 @@ if __name__ == '__main__':
             exec_with_profiler(script_filename, prof, args.backend, script_args)
         else:
             run_module_with_profiler(target, prof, args.backend, script_args)
+    except SystemExit as e:
+        exit_code = e.code
+        raise e
     finally:
         if args.out_filename is not None:
             out_file = open(args.out_filename, "a")
--- a/test/test_exception.py
+++ b/test/test_exception.py
@@ -5,8 +5,9 @@ from memory_profiler import memory_usage
 def foo():
     raise NotImplementedError('Error')
 
-try:
-    out = memory_usage((foo, tuple(), {}), timeout=1)
-except NotImplementedError:
-    pass
-print('Success')
+if __name__ == '__main__':
+    try:
+        out = memory_usage((foo, tuple(), {}), timeout=1)
+    except NotImplementedError:
+        pass
+    print('Success')