A compatibility wrapper for the `type` built-in function.

  In Python 2 `type` (used as a type constructor) requires the name argument to
  be a `bytes` object whereas in Python 3 it is required to be an `unicode`
  object. Since class name is human readable text rather than arbitrary stream
  of bytes, the Python 3 behaviour is considered to be the sane one.

  Once support for Python 2 is dropped all invocations of this call can be
  replaced with the `type` built-in.

  Args:
    name: A name of the type to create.
    base_classes: A tuple of base classes that the returned type is supposed to
      derive from.
    namespace: A dictionary of methods and fields that the returned type is
      supposed to contain.

  Returns:
    A new type with specified parameters.

def MakeType(name, base_classes,
             namespace):
  """A compatibility wrapper for the `type` built-in function.

  In Python 2 `type` (used as a type constructor) requires the name argument to
  be a `bytes` object whereas in Python 3 it is required to be an `unicode`
  object. Since class name is human readable text rather than arbitrary stream
  of bytes, the Python 3 behaviour is considered to be the sane one.

  Once support for Python 2 is dropped all invocations of this call can be
  replaced with the `type` built-in.

  Args:
    name: A name of the type to create.
    base_classes: A tuple of base classes that the returned type is supposed to
      derive from.
    namespace: A dictionary of methods and fields that the returned type is
      supposed to contain.

  Returns:
    A new type with specified parameters.
  """
  precondition.AssertType(name, str)

  if PY2:
    name = name.encode("ascii")

  return type(name, base_classes, namespace)