projects/guix·blob python-team · refs

48 lines · 1.7 KiB

1From: Tobias Geerinckx-Rice <[email protected]>
2Date: Sun, 16 Jun 2019 02:34:10 +0200
3Subject: [PATCH] gnu: dstat: Fix crash when specifying a delay.
4
5Taken verbatim from a pull request[0] that will never be merged.
6
7[0]: https://github.com/dagwieers/dstat/pull/167
8
9From 220a785321b13b6df92a536080aca6ef1cb644ad Mon Sep 17 00:00:00 2001
10From: Falko Goettsch <[email protected]>
11Date: Mon, 11 Mar 2019 20:12:49 -0700
12Subject: [PATCH] Fixed bug when specifying a delay
13
14The division in the 'loop' calculation in perform() was returning floating point values
15after the migration to Python 3, rather than rounding down. Changed to floor division.
16
17I think the floating point values kept 'loop == 0' from ever being
18true and the variables inside that conditional were never initialized,
19causing the following error when a delay other than 1 was specified:
20
21You did not select any stats, using -cdngy by default.
22Traceback (most recent call last):
23 File "/home/falko/repos/dstat/dstat", line 2825, in <module>
24 main()
25 File "/home/falko/repos/dstat/dstat", line 2684, in main
26 scheduler.run()
27 File "/home/falko/.conda/envs/python3/lib/python3.7/sched.py", line 151, in run
28 action(*argument, **kwargs)
29 File "/home/falko/repos/dstat/dstat", line 2729, in perform
30 oldcols = cols
31NameError: name 'cols' is not defined
32---
33 dstat | 2 +-
34 1 file changed, 1 insertion(+), 1 deletion(-)
35
36diff --git a/dstat b/dstat
37index 9359965..3b4980f 100755
38--- a/dstat
39+++ b/dstat
40@@ -2697,7 +2697,7 @@ def perform(update):
41
42 starttime = time.time()
43
44- loop = (update - 1 + op.delay) / op.delay
45+ loop = (update - 1 + op.delay) // op.delay
46 step = ((update - 1) % op.delay) + 1
47
48 ### Get current time (may be different from schedule) for debugging