Show More
@@ -404,7 +404,13 class Inspector: | |||||
404 | # Filename where object was defined |
|
404 | # Filename where object was defined | |
405 | binary_file = False |
|
405 | binary_file = False | |
406 | try: |
|
406 | try: | |
407 | fname = inspect.getabsfile(obj) |
|
407 | try: | |
|
408 | fname = inspect.getabsfile(obj) | |||
|
409 | except TypeError: | |||
|
410 | # For an instance, the file that matters is where its class was | |||
|
411 | # declared. | |||
|
412 | if hasattr(obj,'__class__'): | |||
|
413 | fname = inspect.getabsfile(obj.__class__) | |||
408 | if fname.endswith('<string>'): |
|
414 | if fname.endswith('<string>'): | |
409 | fname = 'Dynamically generated function. No source code available.' |
|
415 | fname = 'Dynamically generated function. No source code available.' | |
410 | if (fname.endswith('.so') or fname.endswith('.dll')): |
|
416 | if (fname.endswith('.so') or fname.endswith('.dll')): | |
@@ -432,8 +438,13 class Inspector: | |||||
432 | linecache.checkcache() |
|
438 | linecache.checkcache() | |
433 | source_success = False |
|
439 | source_success = False | |
434 | try: |
|
440 | try: | |
435 | source = self.format(getsource(obj,binary_file)) |
|
441 | try: | |
436 | if source: |
|
442 | src = getsource(obj,binary_file) | |
|
443 | except TypeError: | |||
|
444 | if hasattr(obj,'__class__'): | |||
|
445 | src = getsource(obj.__class__,binary_file) | |||
|
446 | if src is not None: | |||
|
447 | source = self.format(src) | |||
437 | out.write(header('Source:\n')+source.rstrip()) |
|
448 | out.write(header('Source:\n')+source.rstrip()) | |
438 | source_success = True |
|
449 | source_success = True | |
439 | except Exception, msg: |
|
450 | except Exception, msg: |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now