File: python3-fixes-01.patch

package info (click to toggle)
python-hpilo 4.4.3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,784 kB
  • sloc: python: 3,418; ruby: 467; makefile: 122; sh: 31
file content (28 lines) | stat: -rw-r--r-- 1,454 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
Description: Fix AttributeError for 'im_func', 'func_code' in Python 3
 Simplified the introspection logic for hpilo.Ilo methods by unifying
 Python 2 and 3 compatibility checks. This includes handling attributes
 __code__/func_code and __defaults__/func_defaults.
Bug-Debian: https://bugs.debian.org/1109265
Forwarded: https://github.com/seveas/python-hpilo/pull/302
Author: Giacomo Paviano <pavianogiacomo@gmail.com>
Reviewed-By: Andrea Pappacoda <tachi@debian.org>
Last-Update: 2025-07-22

--- a/hpilo_cli
+++ b/hpilo_cli
@@ -251,12 +251,12 @@ def hpilo_help(option, opt_str, value, parser, exitcode=0):
     else:
         if value in ilo_methods:
             import re, textwrap
-            func = getattr(hpilo.Ilo, value).im_func
-            code = func.func_code
+            func = getattr(hpilo.Ilo, value) if PY3 else getattr(hpilo.Ilo, value).im_func
+            code = func.__code__ if PY3 else func.func_code
             args = ''
             if code.co_argcount > 1:
                 args = code.co_varnames[:code.co_argcount]
-                defaults = func.func_defaults or []
+                defaults = func.__defaults__ if PY3 else func.func_defaults or []
                 args = ["%s=%s" % (x, x.upper()) for x in args[:len(args)-len(defaults)]] + \
                        ["[%s=%s]" % (x,str(y)) for x, y in zip(args[len(args)-len(defaults):], defaults) if x != 'progress']
                 args = ' ' + ' '.join(args[1:])