# Buggy code
def update(hive, key, reg_key, use_32bit):
    d_name = ""
    d_vers = ""

    d_name = __salt__["reg.read_value"](
        hive, "{0}\\{1}".format(key, reg_key), "DisplayName", use_32bit
    )["vdata"]

    d_vers = __salt__["reg.read_value"](
        hive, "{0}\\{1}".format(key, reg_key), "DisplayVersion", use_32bit
    )["vdata"]

    if d_name not in ignore_list:
        # some MS Office updates don't register a product name which means
        # their information is useless
        reg_software.update({d_name: d_vers})


# Traceback (TypeError)
2016-03-01 11:17:18 [salt.transport.zeromq][DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('c:\\salt\\conf\\pki\\minion', 'USARPADEWRK5222-Telco', 'tcp://my.public.ip:4506', 'aes')
2016-03-01 11:17:18 [salt.crypt     ][DEBUG   ] Initializing new SAuth for ('c:\\salt\\conf\\pki\\minion', 'USARPADEWRK5222-Telco', 'tcp://my.public.ip:4506')
2016-03-01 11:17:19 [salt.minion    ][TRACE   ] ret_val = None
2016-03-01 11:18:50,580 [salt.transport.mixins.auth][TRACE   ][5196] Decoding payload: {'load': 'E\xf2\xbf\x05\xf9\xaeB\xbf\x9cE\xd8P\xe2\xf8t{\xe0\xe6B\x8f1)9\xc4CDFo\x9e\xa2\x01\xa8\x02\xe2(I\x83g\xc7\xd6\xc2h\xaeq\x95\x01`\x96\xc2i\x9d1t\x923jh"\xa4I\x01\x14\xe2\x9b\xebU\x0b\xaeY\x17d\xa7\xa4=q\x80\x89\xe3\xd6\xc7m4\xba\xedu\xf2H+\xb0\x93PO\x85\xcbt/ETyQ6\xe3\xe8b\x1c\xf9\x0f\xcae\x92\xf8\xf9.\x17\xcb\'s\x8a\x0e\x8e\x19.\x05\xfe\x03\xb4\r\xf4\xbd@\x81\xae\xde0\x9co\xa1\xa3\x18W2g\xa8\xfa\xa5\xda\x06\x02t\xa0\xa9#\xe4)\x1b[\xdb\xaaS\x89\xff\n<1\x88-G\xe8r\x9c\x95\x0fj\x82NA', 'enc': 'aes'}
2016-03-01 11:18:50,596 [salt.minion      ][INFO    ][5196] User root Executing command pkg.list_pkgs with jid 20160301121944087131
2016-03-01 11:18:50,596 [salt.minion      ][DEBUG   ][5196] Command details {'tgt_type': 'glob', 'jid': '20160301121944087131', 'tgt': 'USARPADEWRK5222-Telco', 'ret': '', 'user': 'root', 'arg': [], 'fun': 'pkg.list_pkgs'}
2016-03-01 11:18:56 [salt.config    ][DEBUG   ] Reading configuration from C:\salt\conf\minion
2016-03-01 11:18:56 [salt.utils     ][TRACE   ] 'dmidecode' could not be found in the following search path: ['C:\\Program Files\\Autodesk\\Autodesk AutoCAD Map 3D 2014\\en-US', 'C:\\Program Files\\Autodesk\\Autodesk AutoCAD Map 3D 2014', 'C:\\Program Files\\Common Files\\Autodesk Shared', 'C:\\Program Files\\Optisys\\Bin', 'C:\\oracle\\product\\11.2.0\\bin', 'C:\\oracle\\product\\10.2.0\\bin', 'C:\\Windows\\system32', 'C:\\Windows', 'C:\\Windows\\System32\\Wbem', 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\', 'C:\\ProgramData\\chocolatey\\bin', '', 'C:\\salt\\bin\\lib\\site-packages\\pywin32_system32', '/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', 'C:\\salt\\bin\\lib\\site-packages\\pywin32_system32']
2016-03-01 11:18:56 [salt.utils     ][TRACE   ] 'smbios' could not be found in the following search path: ['C:\\Program Files\\Autodesk\\Autodesk AutoCAD Map 3D 2014\\en-US', 'C:\\Program Files\\Autodesk\\Autodesk AutoCAD Map 3D 2014', 'C:\\Program Files\\Common Files\\Autodesk Shared', 'C:\\Program Files\\Optisys\\Bin', 'C:\\oracle\\product\\11.2.0\\bin', 'C:\\oracle\\product\\10.2.0\\bin', 'C:\\Windows\\system32', 'C:\\Windows', 'C:\\Windows\\System32\\Wbem', 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\', 'C:\\ProgramData\\chocolatey\\bin', '', 'C:\\salt\\bin\\lib\\site-packages\\pywin32_system32', '/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', 'C:\\salt\\bin\\lib\\site-packages\\pywin32_system32']
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.hwaddr_interfaces grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.hostname grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.get_master grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.pythonversion grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.path grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.get_server_id grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.ip6 grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.ip4 grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.saltversion grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.saltpath grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.pythonexecutable grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.fqdn_ip4 grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.fqdn_ip6 grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.ip6_interfaces grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.ip4_interfaces grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.append_domain grain
2016-03-01 11:18:56 [salt.loader    ][TRACE   ] Loading core.os_data grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.zmqversion grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.saltversioninfo grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.pythonpath grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.id_ grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.locale_info grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.get_machine_id grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.ip_interfaces grain
2016-03-01 11:18:57 [salt.loaded.int.grains.disks][TRACE   ] Disk grain does not support OS
2016-03-01 11:18:57 [salt.config    ][DEBUG   ] Reading configuration from C:\salt\conf\minion
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.hwaddr_interfaces grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.hostname grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.get_master grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.pythonversion grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.path grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.get_server_id grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.ip6 grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.ip4 grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.saltversion grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.saltpath grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.pythonexecutable grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.fqdn_ip4 grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.fqdn_ip6 grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.ip6_interfaces grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.ip4_interfaces grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.append_domain grain
2016-03-01 11:18:57 [salt.loader    ][TRACE   ] Loading core.os_data grain
2016-03-01 11:18:58 [salt.loader    ][TRACE   ] Loading core.zmqversion grain
2016-03-01 11:18:58 [salt.loader    ][TRACE   ] Loading core.saltversioninfo grain
2016-03-01 11:18:58 [salt.loader    ][TRACE   ] Loading core.pythonpath grain
2016-03-01 11:18:58 [salt.loader    ][TRACE   ] Loading core.id_ grain
2016-03-01 11:18:58 [salt.loader    ][TRACE   ] Loading core.locale_info grain
2016-03-01 11:18:58 [salt.loader    ][TRACE   ] Loading core.get_machine_id grain
2016-03-01 11:18:58 [salt.loader    ][TRACE   ] Loading core.ip_interfaces grain
2016-03-01 11:18:58 [salt.loaded.int.grains.disks][TRACE   ] Disk grain does not support OS
2016-03-01 11:18:58 [salt.minion    ][INFO    ] Starting a new job with PID 7724
2016-03-01 11:18:58 [salt.loader    ][TRACE   ] Loaded win_pkg as virtual pkg
2016-03-01 11:18:58 [salt.utils.lazy][DEBUG   ] LazyLoaded pkg.list_pkgs
2016-03-01 11:18:58 [salt.utils.lazy][DEBUG   ] LazyLoaded pkg_resource.add_pkg
2016-03-01 11:18:58 [salt.minion    ][WARNING ] Passed invalid arguments to pkg.list_pkgs: sequence item 0: expected string, int found

List the packages currently installed in a dict::

{'<package_name>': '<version>'}

CLI Example:

.. code-block:: bash

salt '*' pkg.list_pkgs
salt '*' pkg.list_pkgs versions_as_list=True

Traceback (most recent call last):
File "C:\salt\bin\lib\site-packages\salt\minion.py", line 1071, in _thread_return
return_data = func(*args, **kwargs)
File "C:\salt\bin\lib\site-packages\salt\modules\win_pkg.py", line 246, in list_pkgs
__salt__['pkg_resource.stringify'](ret)
File "C:\salt\bin\lib\site-packages\salt\modules\pkg_resource.py", line 256, in stringify
pkgs[key] = ','.join(pkgs[key])
TypeError: sequence item 0: expected string, int found
2016-03-01 11:18:58 [salt.minion    ][DEBUG   ] Minion return retry timer set to 10 seconds (randomized)
2016-03-01 11:18:58 [salt.minion    ][INFO    ] Returning information for job: 20160301121944087131
2016-03-01 11:18:58 [salt.transport.zeromq][DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('c:\\salt\\conf\\pki\\minion', 'USARPADEWRK5222-Telco', 'tcp://my.public.ip:4506', 'aes')
2016-03-01 11:18:58 [salt.crypt     ][DEBUG   ] Initializing new SAuth for ('c:\\salt\\conf\\pki\\minion', 'USARPADEWRK5222-Telco', 'tcp://my.public.ip:4506')
2016-03-01 11:18:58 [salt.transport.zeromq][DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('c:\\salt\\conf\\pki\\minion', 'USARPADEWRK5222-Telco', 'tcp://my.public.ip:4506', 'clear')
2016-03-01 11:18:58 [salt.crypt     ][DEBUG   ] Decrypting the current master AES key
2016-03-01 11:18:58 [salt.crypt     ][DEBUG   ] Loaded minion key: c:\salt\conf\pki\minion\minion.pem
2016-03-01 11:19:00 [salt.minion    ][TRACE   ] ret_val = None

# Fixed code
def update(hive, key, reg_key, use_32bit):
    d_name = ""
    d_vers = ""

    d_name = __salt__["reg.read_value"](
        hive, "{0}\\{1}".format(key, reg_key), "DisplayName", use_32bit
    )["vdata"]

    d_vers = __salt__["reg.read_value"](
        hive, "{0}\\{1}".format(key, reg_key), "DisplayVersion", use_32bit
    )["vdata"]

    if d_name not in ignore_list:
        # some MS Office updates don't register a product name which means
        # their information is useless
        reg_software.update({d_name: str(d_vers)})