get exc_info from a given tuple, sys.exc_info() or sys.last_type etc. Ensures sys.last_type,value,traceback hold the exc_info we found, from whichever source. raises ValueError if none of these contain any information
(self, exc_tuple=None)
| 1957 | self.showtraceback((etype, value, tb), tb_offset=0) |
| 1958 | |
| 1959 | def _get_exc_info(self, exc_tuple=None): |
| 1960 | """get exc_info from a given tuple, sys.exc_info() or sys.last_type etc. |
| 1961 | |
| 1962 | Ensures sys.last_type,value,traceback hold the exc_info we found, |
| 1963 | from whichever source. |
| 1964 | |
| 1965 | raises ValueError if none of these contain any information |
| 1966 | """ |
| 1967 | if exc_tuple is None: |
| 1968 | etype, value, tb = sys.exc_info() |
| 1969 | else: |
| 1970 | etype, value, tb = exc_tuple |
| 1971 | |
| 1972 | if etype is None: |
| 1973 | if hasattr(sys, 'last_type'): |
| 1974 | etype, value, tb = sys.last_type, sys.last_value, \ |
| 1975 | sys.last_traceback |
| 1976 | |
| 1977 | if etype is None: |
| 1978 | raise ValueError("No exception to find") |
| 1979 | |
| 1980 | # Now store the exception info in sys.last_type etc. |
| 1981 | # WARNING: these variables are somewhat deprecated and not |
| 1982 | # necessarily safe to use in a threaded environment, but tools |
| 1983 | # like pdb depend on their existence, so let's set them. If we |
| 1984 | # find problems in the field, we'll need to revisit their use. |
| 1985 | sys.last_type = etype |
| 1986 | sys.last_value = value |
| 1987 | sys.last_traceback = tb |
| 1988 | |
| 1989 | return etype, value, tb |
| 1990 | |
| 1991 | def show_usage_error(self, exc): |
| 1992 | """Show a short message for UsageErrors |
no outgoing calls
no test coverage detected