import socket
import subprocess
import sys
+import itertools
try:
except ImportError: # Python 2
import htmlentitydefs as compat_html_entities
-try:
- import html.parser as compat_html_parser
-except ImportError: # Python 2
- import HTMLParser as compat_html_parser
-
try:
import http.client as compat_http_client
except ImportError: # Python 2
try:
if not item:
raise ValueError
+ if not re.match('[0-9a-fA-F][0-9a-fA-F]',item[:2]):
+ raise ValueError
pct_sequence += item[:2].decode('hex')
rest = item[2:]
if not rest:
pass
return _terminal_size(columns, lines)
+try:
+ itertools.count(start=0, step=1)
+ compat_itertools_count = itertools.count
+except TypeError: # Python 2.6
+ def compat_itertools_count(start=0, step=1):
+ n = start
+ while True:
+ yield n
+ n += step
__all__ = [
'compat_HTTPError',
'compat_getenv',
'compat_getpass',
'compat_html_entities',
- 'compat_html_parser',
'compat_http_client',
'compat_http_server',
+ 'compat_itertools_count',
'compat_kwargs',
'compat_ord',
'compat_parse_qs',