Method readfp() of configparser class is removed in Python 3.12

Bug #2028001 reported by zdohnal
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
HPLIP
New
Undecided
Unassigned
hplip (Fedora)
Unknown
Unknown

Bug Description

Python 3.12 removed readfp() method, so all hplip tools/binaries give traceback, f.e.:

$ sudo /usr/lib/cups/backend/hpfax
/usr/share/hplip/base/g.py:305: SyntaxWarning: invalid escape sequence '\|'
  spinner = "\|/-\|/-"
/usr/share/hplip/base/g.py:355: SyntaxWarning: invalid escape sequence '\d'
  m = re.search('python(\d(\.\d){0,2})', ext_path) #get the python version where the .so file is found
/usr/share/hplip/base/logger.py:440: SyntaxWarning: invalid escape sequence '\<'
  elem_start = re.findall("(\<\W{0,1}\w+) ?", line)[0]
/usr/share/hplip/base/logger.py:441: SyntaxWarning: invalid escape sequence '\]'
  elem_finished = re.findall("([?|\]\]]*\>)", line)[0]
/usr/share/hplip/base/logger.py:443: SyntaxWarning: invalid escape sequence '\S'
  attrs = re.findall("(\S*?\=\".*?\")", line)
Traceback (most recent call last):
  File "/usr/lib/cups/backend/hpfax", line 86, in <module>
    from base.g import *
  File "/usr/share/hplip/base/g.py", line 240, in <module>
    sys_conf = SysConfig()
               ^^^^^^^^^^^
  File "/usr/share/hplip/base/g.py", line 185, in __init__
    ConfigBase.__init__(self, '/etc/hp/hplip.conf')
  File "/usr/share/hplip/base/g.py", line 90, in __init__
    self.read()
  File "/usr/share/hplip/base/g.py", line 131, in read
    self.conf.readfp(fp)
    ^^^^^^^^^^^^^^^^
AttributeError: 'ConfigParser' object has no attribute 'readfp'. Did you mean: 'read'?

I've switched the code to 'read_file(fp, self.filename)', which fixes it.

Patch attached.

Revision history for this message
zdohnal (zdohnal) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.