current_buffer in unicode wrapper
[rainbowstream.git] / rainbowstream / py3patch.py
... / ...
CommitLineData
1"""
2 Python 3 supports
3"""
4import sys
5
6# StringIO module
7try:
8 from StringIO import StringIO, BytesIO
9except:
10 from io import StringIO, BytesIO
11
12# HTMLParser module
13if sys.version[0] == "2":
14 from HTMLParser import HTMLParser
15else:
16 from html.parser import HTMLParser
17unescape = 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
24if sys.version[0] == "2":
25 lmap = lambda f, a: map(f, a)
26 unc = lambda x: x.decode('utf-8')
27else:
28 raw_input = input
29 lmap = lambda f, a: list(map(f, a))
30 unc = lambda x: x