You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

59 line
1.7 KiB

  1. import binascii
  2. from six import PY3
  3. class FormParserError(ValueError):
  4. """Base error class for our form parser."""
  5. pass
  6. class ParseError(FormParserError):
  7. """This exception (or a subclass) is raised when there is an error while
  8. parsing something.
  9. """
  10. #: This is the offset in the input data chunk (*NOT* the overall stream) in
  11. #: which the parse error occured. It will be -1 if not specified.
  12. offset = -1
  13. class MultipartParseError(ParseError):
  14. """This is a specific error that is raised when the MultipartParser detects
  15. an error while parsing.
  16. """
  17. pass
  18. class QuerystringParseError(ParseError):
  19. """This is a specific error that is raised when the QuerystringParser
  20. detects an error while parsing.
  21. """
  22. pass
  23. class DecodeError(ParseError):
  24. """This exception is raised when there is a decoding error - for example
  25. with the Base64Decoder or QuotedPrintableDecoder.
  26. """
  27. pass
  28. # On Python 3.3, IOError is the same as OSError, so we don't want to inherit
  29. # from both of them. We handle this case below.
  30. if IOError is not OSError: # pragma: no cover
  31. class FileError(FormParserError, IOError, OSError):
  32. """Exception class for problems with the File class."""
  33. pass
  34. else: # pragma: no cover
  35. class FileError(FormParserError, OSError):
  36. """Exception class for problems with the File class."""
  37. pass
  38. # We check which version of Python we're on to figure out what error we need
  39. # to catch for invalid Base64.
  40. if PY3: # pragma: no cover
  41. Base64Error = binascii.Error
  42. else: # pragma: no cover
  43. Base64Error = TypeError