fix serious bug with CPU 100%
[rainbowstream.git] / rainbowstream / py3patch.py
1 """
2 Python 3 supports
3 """
4 import sys
5
6 # StringIO module
7 try:
8 from StringIO import StringIO, BytesIO
9 except:
10 from io import StringIO, BytesIO
11
12 # HTMLParser module
13 if sys.version[0] == "2":
14 from HTMLParser import HTMLParser
15 else:
16 from html.parser import HTMLParser
17 unescape = HTMLParser().unescape
18 # According to https://github.com/python/cpython/blob/master/Lib/html/parser.py#L547 ,
19 # in python 3.5 maybe I should use
20 # from html import unescape
21 # but it is a far-future story:)
22
23 # raw_input and map function behaviour
24 if sys.version[0] == "2":
25 lmap = lambda f, a: map(f, a)
26 else:
27 raw_input = input
28 lmap = lambda f, a: list(map(f, a))