message: Consistency fix: KeyError escapes newlines. To avoid garbled output, we subclass it so that it returns a multiline message.
diff: @@ -105,7 +105,6 @@ def _stack_trace_inside_mapped_code(tb, source_map):
  KNOWN_STRING_CONSTRUCTOR_ERRORS = (
  AssertionError,
  AttributeError,
  - KeyError,
  NameError,
  NotImplementedError,
  RuntimeError,
  @@ -115,6 +114,21 @@ KNOWN_STRING_CONSTRUCTOR_ERRORS = (
  )
  +# KeyError escapes newlines in strings. We create a special subclass
  +# that doesn't do that. Overriding the name for display purposes; hopefully
  +# that won't create too many surprises.
  +class MultilineMessageKeyError(KeyError):
  +
  + def __init__(self, message, original_key):
  + super(MultilineMessageKeyError, self).__init__(original_key)
  + self.__message = message
  +
  + def __str__(self):
  + return self.__message
  +
  +MultilineMessageKeyError.__name__ = KeyError.__name__
  +
  +
  class ErrorMetadataBase(object):
  """Container objects attached to exceptions in converted code.
  @@ -186,6 +200,8 @@ class ErrorMetadataBase(object):
  def create_exception(self, preferred_type):
  if preferred_type in KNOWN_STRING_CONSTRUCTOR_ERRORS:
  return preferred_type(self.get_message())
  + elif preferred_type is KeyError:
  + return MultilineMessageKeyError(self.get_message(), self.cause_message)
  return None
  def to_exception(self, preferred_type):
  