from backports_abc import Generator as GeneratorType # type: ignore
try:
- from inspect import isawaitable # py35+
+ # py35+
+ from inspect import isawaitable # type: ignore
except ImportError:
from backports_abc import isawaitable
except ImportError:
from tornado import escape
from tornado.log import gen_log
+from tornado.util import PY3
from tornado._locale_data import LOCALE_NAMES
# in most cases but is common with CSV files because Excel
# cannot read utf-8 files without a BOM.
encoding = 'utf-8-sig'
- try:
+ if PY3:
# python 3: csv.reader requires a file open in text mode.
# Force utf8 to avoid dependence on $LANG environment variable.
f = open(full_path, "r", encoding=encoding)
- except TypeError:
+ else:
# python 2: csv can only handle byte strings (in ascii-compatible
# encodings), which we decode below. Transcode everything into
# utf8 before passing it to csv.reader.
from tornado.util import unicode_type, basestring_type
try:
- import curses
+ import curses # type: ignore
except ImportError:
curses = None
try:
# Import the real asyncio module for py33+ first. Older versions of the
# trollius backport also use this name.
- import asyncio
+ import asyncio # type: ignore
except ImportError as e:
# Asyncio itself isn't available; see if trollius is (backport to py26+).
try:
from types import GeneratorType # type: ignore
if sys.version_info >= (3, 5):
- iscoroutine = inspect.iscoroutine
- iscoroutinefunction = inspect.iscoroutinefunction
+ iscoroutine = inspect.iscoroutine # type: ignore
+ iscoroutinefunction = inspect.iscoroutinefunction # type: ignore
else:
iscoroutine = iscoroutinefunction = lambda f: False
else:
# On python 2, prefer unittest2 when available.
try:
- import unittest2 as unittest
+ import unittest2 as unittest # type: ignore
except ImportError:
- import unittest
+ import unittest # type: ignore
_next_port = 10000