home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 January / Chip_2003-01_cd2.bin / convert / eJayMp3Pro / mp3pro_demo.exe / EXCEPTIONS.PYC (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-06-05  |  10.6 KB  |  266 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. """Class based built-in exception hierarchy.
  5.  
  6. New with Python 1.5, all standard built-in exceptions are now class objects by
  7. default.  This gives Python's exception handling mechanism a more
  8. object-oriented feel.  Traditionally they were string objects.  Python will
  9. fallback to string based exceptions if the interpreter is invoked with the -X
  10. option, or if some failure occurs during class exception initialization (in
  11. this case a warning will be printed).
  12.  
  13. Most existing code should continue to work with class based exceptions.  Some
  14. tricky uses of IOError may break, but the most common uses should work.
  15.  
  16. Here is a rundown of the class hierarchy.  You can change this by editing this
  17. file, but it isn't recommended because the old string based exceptions won't
  18. be kept in sync.  The class names described here are expected to be found by
  19. the bltinmodule.c file.  If you add classes here, you must modify
  20. bltinmodule.c or the exceptions won't be available in the __builtin__ module,
  21. nor will they be accessible from C.
  22.  
  23. The classes with a `*' are new since Python 1.5.  They are defined as tuples
  24. containing the derived exceptions when string-based exceptions are used.  If
  25. you define your own class based exceptions, they should be derived from
  26. Exception.
  27.  
  28. Exception(*)
  29.  |
  30.  +-- SystemExit
  31.  +-- StandardError(*)
  32.       |
  33.       +-- KeyboardInterrupt
  34.       +-- ImportError
  35.       +-- EnvironmentError(*)
  36.       |    |
  37.       |    +-- IOError
  38.       |    +-- OSError(*)
  39.       |
  40.       +-- EOFError
  41.       +-- RuntimeError
  42.       |    |
  43.       |    +-- NotImplementedError(*)
  44.       |
  45.       +-- NameError
  46.       +-- AttributeError
  47.       +-- SyntaxError
  48.       +-- TypeError
  49.       +-- AssertionError
  50.       +-- LookupError(*)
  51.       |    |
  52.       |    +-- IndexError
  53.       |    +-- KeyError
  54.       |
  55.       +-- ArithmeticError(*)
  56.       |    |
  57.       |    +-- OverflowError
  58.       |    +-- ZeroDivisionError
  59.       |    +-- FloatingPointError
  60.       |
  61.       +-- ValueError
  62.       +-- SystemError
  63.       +-- MemoryError
  64. """
  65.  
  66. class Exception:
  67.     '''Proposed base class for all exceptions.'''
  68.     
  69.     def __init__(self, *args):
  70.         self.args = args
  71.  
  72.     
  73.     def __str__(self):
  74.         if not (self.args):
  75.             return ''
  76.         elif len(self.args) == 1:
  77.             return str(self.args[0])
  78.         else:
  79.             return str(self.args)
  80.  
  81.     
  82.     def __getitem__(self, i):
  83.         return self.args[i]
  84.  
  85.  
  86.  
  87. class StandardError(Exception):
  88.     '''Base class for all standard Python exceptions.'''
  89.     pass
  90.  
  91.  
  92. class SyntaxError(StandardError):
  93.     '''Invalid syntax.'''
  94.     filename = lineno = offset = text = None
  95.     msg = ''
  96.     
  97.     def __init__(self, *args):
  98.         self.args = args
  99.         if len(self.args) >= 1:
  100.             self.msg = self.args[0]
  101.         
  102.         if len(self.args) == 2:
  103.             info = self.args[1]
  104.             
  105.             try:
  106.                 (self.filename, self.lineno, self.offset, self.text) = info
  107.             except:
  108.                 pass
  109.  
  110.         
  111.  
  112.     
  113.     def __str__(self):
  114.         return str(self.msg)
  115.  
  116.  
  117.  
  118. class EnvironmentError(StandardError):
  119.     '''Base class for I/O related errors.'''
  120.     
  121.     def __init__(self, *args):
  122.         self.args = args
  123.         self.errno = None
  124.         self.strerror = None
  125.         self.filename = None
  126.         if len(args) == 3:
  127.             (self.errno, self.strerror, self.filename) = args
  128.             self.args = args[0:2]
  129.         
  130.         if len(args) == 2:
  131.             (self.errno, self.strerror) = args
  132.         
  133.  
  134.     
  135.     def __str__(self):
  136.         if self.filename is not None:
  137.             return '[Errno %s] %s: %s' % (self.errno, self.strerror, repr(self.filename))
  138.         elif self.errno and self.strerror:
  139.             return '[Errno %s] %s' % (self.errno, self.strerror)
  140.         else:
  141.             return StandardError.__str__(self)
  142.  
  143.  
  144.  
  145. class IOError(EnvironmentError):
  146.     '''I/O operation failed.'''
  147.     pass
  148.  
  149.  
  150. class OSError(EnvironmentError):
  151.     '''OS system call failed.'''
  152.     pass
  153.  
  154.  
  155. class RuntimeError(StandardError):
  156.     '''Unspecified run-time error.'''
  157.     pass
  158.  
  159.  
  160. class NotImplementedError(RuntimeError):
  161.     """Method or function hasn't been implemented yet."""
  162.     pass
  163.  
  164.  
  165. class SystemError(StandardError):
  166.     '''Internal error in the Python interpreter.
  167.  
  168.     Please report this to the Python maintainer, along with the traceback,
  169.     the Python version, and the hardware/OS platform and version.'''
  170.     pass
  171.  
  172.  
  173. class EOFError(StandardError):
  174.     '''Read beyond end of file.'''
  175.     pass
  176.  
  177.  
  178. class ImportError(StandardError):
  179.     """Import can't find module, or can't find name in module."""
  180.     pass
  181.  
  182.  
  183. class TypeError(StandardError):
  184.     '''Inappropriate argument type.'''
  185.     pass
  186.  
  187.  
  188. class ValueError(StandardError):
  189.     '''Inappropriate argument value (of correct type).'''
  190.     pass
  191.  
  192.  
  193. class KeyboardInterrupt(StandardError):
  194.     '''Program interrupted by user.'''
  195.     pass
  196.  
  197.  
  198. class AssertionError(StandardError):
  199.     '''Assertion failed.'''
  200.     pass
  201.  
  202.  
  203. class ArithmeticError(StandardError):
  204.     '''Base class for arithmetic errors.'''
  205.     pass
  206.  
  207.  
  208. class OverflowError(ArithmeticError):
  209.     '''Result too large to be represented.'''
  210.     pass
  211.  
  212.  
  213. class FloatingPointError(ArithmeticError):
  214.     '''Floating point operation failed.'''
  215.     pass
  216.  
  217.  
  218. class ZeroDivisionError(ArithmeticError):
  219.     '''Second argument to a division or modulo operation was zero.'''
  220.     pass
  221.  
  222.  
  223. class LookupError(StandardError):
  224.     '''Base class for lookup errors.'''
  225.     pass
  226.  
  227.  
  228. class IndexError(LookupError):
  229.     '''Sequence index out of range.'''
  230.     pass
  231.  
  232.  
  233. class KeyError(LookupError):
  234.     '''Mapping key not found.'''
  235.     pass
  236.  
  237.  
  238. class AttributeError(StandardError):
  239.     '''Attribute not found.'''
  240.     pass
  241.  
  242.  
  243. class NameError(StandardError):
  244.     '''Name not found locally or globally.'''
  245.     pass
  246.  
  247.  
  248. class MemoryError(StandardError):
  249.     '''Out of memory.'''
  250.     pass
  251.  
  252.  
  253. class SystemExit(Exception):
  254.     '''Request to exit from the interpreter.'''
  255.     
  256.     def __init__(self, *args):
  257.         self.args = args
  258.         if len(args) == 0:
  259.             self.code = None
  260.         elif len(args) == 1:
  261.             self.code = args[0]
  262.         else:
  263.             self.code = args
  264.  
  265.  
  266.