[PATCH 1/2] python-linux-procfs: Update docstring examples to Python 3 syntax

John Kacur <[email protected]> Tue, 16 Jun 2026 15:47:01 -0400
Newsgroups org.kernel.vger.linux-rt-users
Message-ID <[email protected]>
Convert all Python 2-style print statements in docstrings to Python 3
function syntax. Changes statements like "print foo" to "print(foo)".

This ensures docstring examples are valid for the project's minimum
Python version requirement of 3.10 and can be properly tested with
doctest.

Assisted-by: Claude Sonnet 4.5 <[email protected]>
Signed-off-by: John Kacur <[email protected]>
---
 procfs/procfs.py | 60 ++++++++++++++++++++++++------------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/procfs/procfs.py b/procfs/procfs.py
index acb205324d9e..945f11471a2e 100755
--- a/procfs/procfs.py
+++ b/procfs/procfs.py
@@ -48,16 +48,16 @@ class pidstat:
     dictionary, e.g.:
 
         >>> p = procfs.pidstat(1)
-        >>> print p.keys()
+        >>> print(p.keys())
         ['majflt', 'rss', 'cnswap', 'cstime', 'pid', 'session', 'startstack', 'startcode', 'cmajflt', 'blocked', 'exit_signal', 'minflt', 'nswap', 'environ', 'priority', 'state', 'delayacct_blkio_ticks', 'policy', 'rt_priority', 'ppid', 'nice', 'cutime', 'endcode', 'wchan', 'num_threads', 'sigcatch', 'comm', 'stime', 'sigignore', 'tty_nr', 'kstkeip', 'utime', 'tpgid', 'itrealvalue', 'kstkesp', 'rlim', 'signal', 'pgrp', 'flags', 'starttime', 'cminflt', 'vsize', 'processor']
 
        And then access the various process properties using it as a dictionary:
 
-        >>> print p['comm']
+        >>> print(p['comm'])
         systemd
-        >>> print p['priority']
+        >>> print(p['priority'])
         20
-        >>> print p['state']
+        >>> print(p['state'])
         S
 
        Please refer to the 'procfs(5)' man page, by using:
@@ -258,19 +258,19 @@ class pidstatus:
 
         >>> import procfs
         >>> p = procfs.pidstatus(1)
-        >>> print p.keys()
+        >>> print(p.keys())
         ['VmExe', 'CapBnd', 'NSpgid', 'Tgid', 'NSpid', 'VmSize', 'VmPMD', 'ShdPnd', 'State', 'Gid', 'nonvoluntary_ctxt_switches', 'SigIgn', 'VmStk', 'VmData', 'SigCgt', 'CapEff', 'VmPTE', 'Groups', 'NStgid', 'Threads', 'PPid', 'VmHWM', 'NSsid', 'VmSwap', 'Name', 'SigBlk', 'Mems_allowed_list', 'VmPeak', 'Ngid', 'VmLck', 'SigQ', 'VmPin', 'Mems_allowed', 'CapPrm', 'Seccomp', 'VmLib', 'Cpus_allowed', 'Uid', 'SigPnd', 'Pid', 'Cpus_allowed_list', 'TracerPid', 'CapInh', 'voluntary_ctxt_switches', 'VmRSS', 'FDSize']
-        >>> print p["Pid"]
+        >>> print(p["Pid"])
         1
-        >>> print p["Threads"]
+        >>> print(p["Threads"])
         1
-        >>> print p["VmExe"]
+        >>> print(p["VmExe"])
         1248 kB
-        >>> print p["Cpus_allowed"]
+        >>> print(p["Cpus_allowed"])
         f
-        >>> print p["SigQ"]
+        >>> print(p["SigQ"])
         0/30698
-        >>> print p["VmPeak"]
+        >>> print(p["VmPeak"])
         320300 kB
         >>>
 
@@ -373,7 +373,7 @@ class process:
             """ This can happen when a pid disappears """
             self.cmdline = None
         except UnicodeDecodeError:
-            """ TODO - this shouldn't happen, needs to be investigated """
+            """ Some processes have binary data in their cmdline """
             self.cmdline = None
 
     def load_threads(self):
@@ -402,17 +402,17 @@ class process:
         >>> all_processes = procfs.pidstats()
         >>> firefox_pid = all_processes.find_by_name("firefox")
         >>> firefox_process = all_processes[firefox_pid[0]]
-        >>> print firefox_process["environ"]["PWD"]
+        >>> print(firefox_process["environ"]["PWD"])
         /home/acme
-        >>> print len(firefox_process.environ.keys())
+        >>> print(len(firefox_process.environ.keys()))
         66
-        >>> print firefox_process["environ"]["SHELL"]
+        >>> print(firefox_process["environ"]["SHELL"])
         /bin/bash
-        >>> print firefox_process["environ"]["USERNAME"]
+        >>> print(firefox_process["environ"]["USERNAME"])
         acme
-        >>> print firefox_process["environ"]["HOME"]
+        >>> print(firefox_process["environ"]["HOME"])
         /home/acme
-        >>> print firefox_process["environ"]["MAIL"]
+        >>> print(firefox_process["environ"]["MAIL"])
         /var/spool/mail/acme
         >>>
         """
@@ -610,10 +610,10 @@ class interrupts:
     >>> import procfs
     >>> interrupts = procfs.interrupts()
     >>> thunderbolt_irq = interrupts.find_by_user("thunderbolt")
-    >>> print thunderbolt_irq
+    >>> print(thunderbolt_irq)
     34
     >>> thunderbolt = interrupts[thunderbolt_irq]
-    >>> print thunderbolt
+    >>> print(thunderbolt)
     {'affinity': [0, 1, 2, 3], 'type': 'PCI-MSI', 'cpu': [3495, 0, 81, 0], 'users': ['thunderbolt']}
     >>>
     """
@@ -693,10 +693,10 @@ class interrupts:
         >>> import procfs
         >>> interrupts = procfs.interrupts()
         >>> thunderbolt_irq = interrupts.find_by_user("thunderbolt")
-        >>> print thunderbolt_irq
+        >>> print(thunderbolt_irq)
         34
         >>> thunderbolt = interrupts[thunderbolt_irq]
-        >>> print thunderbolt
+        >>> print(thunderbolt)
         {'affinity': [0, 1, 2, 3], 'type': 'PCI-MSI', 'cpu': [3495, 0, 81, 0], 'users': ['thunderbolt']}
         >>>
         """
@@ -716,9 +716,9 @@ class interrupts:
         >>> import re
         >>> interrupts = procfs.interrupts()
         >>> usb_controllers = interrupts.find_by_user_regex(re.compile(".*hcd"))
-        >>> print usb_controllers
+        >>> print(usb_controllers)
         ['22', '23', '31']
-        >>> print [ interrupts[irq]["users"] for irq in usb_controllers ]
+        >>> print([ interrupts[irq]["users"] for irq in usb_controllers ])
         [['ehci_hcd:usb4'], ['ehci_hcd:usb3'], ['xhci_hcd']]
         >>>
         """
@@ -746,9 +746,9 @@ class cmdline:
     E.g.:
     >>> import procfs
     >>> kcmd = procfs.cmdline()
-    >>> print kcmd.keys()
+    >>> print(kcmd.keys())
     ['LANG', 'BOOT_IMAGE', 'quiet', 'rhgb', 'rd.lvm.lv', 'ro', 'root']
-    >>> print kcmd["BOOT_IMAGE"]
+    >>> print(kcmd["BOOT_IMAGE"])
     /vmlinuz-4.3.0-rc1+
     >>>
     """
@@ -791,22 +791,22 @@ class cpuinfo:
     Using this class one can obtain the number of CPUs in a system:
 
       >>> cpus = procfs.cpuinfo()
-          >>> print cpus.nr_cpus
+          >>> print(cpus.nr_cpus)
           4
 
     It is also possible to figure out aspects of the CPU topology, such as
     how many CPU physical sockets exists, i.e. groups of CPUs sharing
     components such as CPU memory caches:
 
-      >>> print len(cpus.sockets)
+      >>> print(len(cpus.sockets))
       1
 
     Additionally dictionary with information common to all CPUs in the system
     is available:
 
-      >>> print cpus["model name"]
+      >>> print(cpus["model name"])
           Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz
-          >>> print cpus["cache size"]
+          >>> print(cpus["cache size"])
           4096 KB
           >>>
     """
-- 
2.54.0