18 from .platform
import IRONPYTHON, PY2
23 from StringIO
import StringIO
27 if hasattr(cls,
'__unicode__'):
28 cls.__str__ =
lambda self:
unicode(self).encode(
'UTF-8')
32 from io
import StringIO
36 if hasattr(cls,
'__unicode__'):
37 cls.__str__ =
lambda self: self.__unicode__()
38 if hasattr(cls,
'__nonzero__'):
39 cls.__bool__ =
lambda self: self.__nonzero__()
50 class metaclass(
type):
51 def __new__(cls, name, this_bases, d):
52 return meta(name, bases, d)
53 return type.__new__(metaclass,
'temporary_class', (), {})
61 if hasattr(stream,
'buffer')
and stream.buffer
is None:
63 return hasattr(stream,
'isatty')
and stream.isatty()
67 from ctypes
import windll
72 _HANDLE_IDS = {sys.__stdout__ : -11, sys.__stderr__ : -12}
79 if stream
not in _HANDLE_IDS:
81 handle = windll.kernel32.GetStdHandle(_HANDLE_IDS[stream])
82 return windll.kernel32.GetFileType(handle) == _CONSOLE_TYPE
unicode
Exceptions and return codes used internally.
def with_metaclass(meta, *bases)
Create a base class with a metaclass.