Errors that occurred while trying to import something to document it.
| 451 | return result |
| 452 | |
| 453 | class ErrorDuringImport(Exception): |
| 454 | """Errors that occurred while trying to import something to document it.""" |
| 455 | def __init__(self, filename, exc_info): |
| 456 | if not isinstance(exc_info, tuple): |
| 457 | assert isinstance(exc_info, BaseException) |
| 458 | self.exc = type(exc_info) |
| 459 | self.value = exc_info |
| 460 | self.tb = exc_info.__traceback__ |
| 461 | else: |
| 462 | warnings.warn("A tuple value for exc_info is deprecated, use an exception instance", |
| 463 | DeprecationWarning) |
| 464 | |
| 465 | self.exc, self.value, self.tb = exc_info |
| 466 | self.filename = filename |
| 467 | |
| 468 | def __str__(self): |
| 469 | exc = self.exc.__name__ |
| 470 | return 'problem in %s - %s: %s' % (self.filename, exc, self.value) |
| 471 | |
| 472 | def importfile(path): |
| 473 | """Import a Python source file or compiled file given its path.""" |
no outgoing calls
no test coverage detected