1 """Code for compatibility across Python versions."""
5 from imp import find_module as original_find_module
8 IS_PYTHON3 = sys.version_info >= (3, 0)
12 def find_module(fullname, path):
13 """Compatibility wrapper for imp.find_module.
15 Automatically decodes arguments of find_module, in Python3
18 if isinstance(fullname, bytes):
19 fullname = fullname.decode()
20 if isinstance(path, bytes):
22 elif isinstance(path, list):
25 if isinstance(element, bytes):
26 newpath.append(element.decode())
28 newpath.append(element)
30 return original_find_module(fullname, path)
32 # There is no 'long' type in Python3 just int
34 unicode_errors_default = 'surrogateescape'
36 find_module = original_find_module
37 unicode_errors_default = 'ignore'
39 NUM_TYPES = (int, long, float)
42 def check_async(async_, kwargs, default):
43 """Return a value of 'async' in kwargs or default when async_ is None.
45 This helper function exists for backward compatibility (See #274).
46 It shows a warning message when 'async' in kwargs is used to note users.
48 if async_ is not None:
50 elif 'async' in kwargs:
52 '"async" attribute is deprecated. Use "async_" instead.',
55 return kwargs.pop('async')