# -*- coding: utf-8 -*-

import itertools
import locale
import re
from subprocess import PIPE, STDOUT, Popen


def exec_powershell(command):
    p = Popen(('powershell', command), stdout=PIPE, stdin=PIPE, stderr=STDOUT)
    return p.communicate()[0]


def parse_ps_output(content):
    for s in content.decode(locale.getpreferredencoding()).strip().split('\r\n\r\n'):
        r = re.findall(r'DisplayName\s*:\s*(.*)\r\nDisplayVersion\s*:\s*(.*)', s)
        if r:
            yield (r[0][0].strip(), r[0][1].strip())
        else:
            r = re.findall(r'DisplayName\s*:\s*(.*)', s)
            if r:
                yield (r[0].strip(), '')


def get_local_software():
    software_list = {}

    list1_b = exec_powershell('Get-ItemProperty HKLM:\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\* | Format-List DisplayName, DisplayVersion | out-string -Width 2000')
    list2_b = exec_powershell('Get-ItemProperty HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\* | Format-List DisplayName, DisplayVersion | out-string -Width 2000')
    list3_b = exec_powershell('Get-ItemProperty HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\* | Format-List DisplayName, DisplayVersion | out-string -Width 2000')

    for n, v in itertools.chain(parse_ps_output(list1_b), parse_ps_output(list2_b), parse_ps_output(list3_b)):
        software_list[n] = v

    return software_list

@@ -45,21 +45,17 @@
 %0Aimport 
-local
+r
 e%0D%0Aimpor
@@ -60,17 +60,8 @@
 ort 
-re%0D%0Afrom 
 subp
@@ -70,35 +70,8 @@
 cess
- import PIPE, STDOUT, Popen
 %0D%0A%0D%0A
@@ -111,113 +111,109 @@
     
-p = Popen(('powershell', command), stdout=PIPE, stdin=PIPE, stderr=STDOUT)%0D%0A    return p.communicate()%5B0%5D
+return subprocess.check_output(('powershell', command), encoding='oem')  # decode using OEM code page
 %0D%0A%0D%0A
@@ -270,46 +270,8 @@
 ent.
-decode(locale.getpreferredencoding()).
 stri
@@ -286,13 +286,9 @@
 t('%5C
-r%5Cn%5Cr
+n
 %5Cn')
@@ -342,10 +342,8 @@
 .*)%5C
-r%5C
 nDis
@@ -640,18 +640,16 @@
    list1
-_b
  = exec_
@@ -835,18 +835,16 @@
    list2
-_b
  = exec_
@@ -1017,18 +1017,16 @@
    list3
-_b
  = exec_
@@ -1245,18 +1245,16 @@
 ut(list1
-_b
 ), parse
@@ -1269,18 +1269,16 @@
 ut(list2
-_b
 ), parse
@@ -1297,10 +1297,8 @@
 ist3
-_b
 )):%0D

Use the 'oem' encoding instead of `locale.getpreferredencoding()` - `locale.getpreferredencoding()` will return 'utf-8' in UTF-8 mode