Same on bionic 18.04:

$  python2 --version
Python 2.7.15rc1

$ sudo hp-doctor -i
Traceback (most recent call last):
  File "/usr/bin/hp-doctor", line 42, in <module>
    check_extension_module_env('cupsext')
  File "/usr/share/hplip/base/g.py", line 340, in check_extension_module_env
    python_ver = xint((sys.version).split(' ')[0])              #find the 
current python version ; xint() to convert string to int, returns a list
  File "/usr/share/hplip/base/g.py", line 332, in xint
    return l
UnboundLocalError: local variable 'l' referenced before assignment
# Edit: pdb.set_trace()
$ sudo hp-doctor
> /usr/share/hplip/base/g.py(333)xint()
-> return l
(Pdb) ver
'2.7.15rc1'
(Pdb) ver.split('.')
['2', '7', '15rc1']
(Pdb) [int(x) for x in ver.split('.')]
*** ValueError: invalid literal for int() with base 10: '15rc1'
(Pdb) 

Code work-around:
# Convert string to int and return a list.
def xint(ver):
    try:
        l = [int(x) for x in ver.split('.')]
    except:
        l = []
        for x in ver.split('.'):
                try:
                   l.append(int(x))
                except:
                   l.append(None)
    return l

$ sudo hp-doctor
error: cupsext not present in the system. Please re-install HPLIP.

# debug info: [2, 7, None]

Solution for me is `python3 hp-doctor` instead:
$  python3 -VV
Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0]

-- 
You received this bug notification because you are a member of Desktop
Packages, which is subscribed to hplip in Ubuntu.
https://bugs.launchpad.net/bugs/1759278

Title:
  hp-doctor: UnboundLocalError: local variable 'l' referenced before
  assignment

Status in HPLIP:
  New
Status in hplip package in Ubuntu:
  Confirmed

Bug description:
  hp-doctor is trying to parse the Python version. Probably other tools
  are too.

  On Python 2, sys.version is "2.7.14+", whos parts cannot be parsed as an 
integer.
  On Python 3, sys.version is "3.6.5rc1", whos parts cannot be parsed as an 
integer.

  Neither of these will work.

  
  % hp-doctor
  Traceback (most recent call last):
    File "/usr/bin/hp-doctor", line 42, in <module>
      check_extension_module_env('cupsext')
    File "/usr/share/hplip/base/g.py", line 339, in check_extension_module_env
      python_ver = xint((sys.version).split(' ')[0])              #find the 
current python version ; xint() to convert string to int, returns a list
    File "/usr/share/hplip/base/g.py", line 331, in xint
      return l
  UnboundLocalError: local variable 'l' referenced before assignment

  
  (Note that my printer will only print "Unsupported Personality: UNKNOWN". 
This is probably an unrelated problem.)

  ProblemType: Bug
  DistroRelease: Ubuntu 18.04
  Package: hplip 3.17.10+repack0-5
  ProcVersionSignature: Ubuntu 4.15.0-13.14-generic 4.15.10
  Uname: Linux 4.15.0-13-generic x86_64
  NonfreeKernelModules: nvidia_modeset nvidia
  ApportVersion: 2.20.9-0ubuntu1
  Architecture: amd64
  Date: Tue Mar 27 14:49:56 2018
  Lpstat: Error: command ['lpstat', '-v'] failed with exit code 1: lpstat: No 
destinations added.
  MachineType: System manufacturer System Product Name
  Papersize: a4
  ProcKernelCmdLine: BOOT_IMAGE=/vmlinuz-4.15.0-13-generic.efi.signed 
root=UUID=672510b8-afb9-425f-a58d-bd325f7c987a ro rootflags=subvol=@ nofb 
kernel.sysrq=1
  SourcePackage: hplip
  UpgradeStatus: Upgraded to bionic on 2018-02-19 (35 days ago)
  dmi.bios.date: 08/13/2013
  dmi.bios.vendor: American Megatrends Inc.
  dmi.bios.version: 2104
  dmi.board.asset.tag: To be filled by O.E.M.
  dmi.board.name: P8Z77-V
  dmi.board.vendor: ASUSTeK COMPUTER INC.
  dmi.board.version: Rev 1.xx
  dmi.chassis.asset.tag: Asset-1234567890
  dmi.chassis.type: 3
  dmi.chassis.vendor: Chassis Manufacture
  dmi.chassis.version: Chassis Version
  dmi.modalias: 
dmi:bvnAmericanMegatrendsInc.:bvr2104:bd08/13/2013:svnSystemmanufacturer:pnSystemProductName:pvrSystemVersion:rvnASUSTeKCOMPUTERINC.:rnP8Z77-V:rvrRev1.xx:cvnChassisManufacture:ct3:cvrChassisVersion:
  dmi.product.family: To be filled by O.E.M.
  dmi.product.name: System Product Name
  dmi.product.version: System Version
  dmi.sys.vendor: System manufacturer

To manage notifications about this bug go to:
https://bugs.launchpad.net/hplip/+bug/1759278/+subscriptions

-- 
Mailing list: https://launchpad.net/~desktop-packages
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~desktop-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to