Show More
@@ -182,11 +182,10 b" def getsource(obj, oname='') -> Union[str,None]:" | |||||
182 | except TypeError: |
|
182 | except TypeError: | |
183 | # The object itself provided no meaningful source, try looking for |
|
183 | # The object itself provided no meaningful source, try looking for | |
184 | # its class definition instead. |
|
184 | # its class definition instead. | |
185 | if hasattr(obj, '__class__'): |
|
185 | try: | |
186 | try: |
|
186 | src = inspect.getsource(obj.__class__) | |
187 | src = inspect.getsource(obj.__class__) |
|
187 | except TypeError: | |
188 |
|
|
188 | return None | |
189 | return None |
|
|||
190 |
|
189 | |||
191 | return src |
|
190 | return src | |
192 |
|
191 | |||
@@ -308,15 +307,14 b' def find_file(obj) -> str:' | |||||
308 | fname = None |
|
307 | fname = None | |
309 | try: |
|
308 | try: | |
310 | fname = inspect.getabsfile(obj) |
|
309 | fname = inspect.getabsfile(obj) | |
311 |
except |
|
310 | except TypeError: | |
312 | # For an instance, the file that matters is where its class was |
|
311 | # For an instance, the file that matters is where its class was | |
313 | # declared. |
|
312 | # declared. | |
314 | if hasattr(obj, '__class__'): |
|
313 | try: | |
315 | try: |
|
314 | fname = inspect.getabsfile(obj.__class__) | |
316 | fname = inspect.getabsfile(obj.__class__) |
|
315 | except (OSError, TypeError): | |
317 | except (OSError, TypeError): |
|
316 | # Can happen for builtins | |
318 | # Can happen for builtins |
|
317 | pass | |
319 | pass |
|
|||
320 | except: |
|
318 | except: | |
321 | pass |
|
319 | pass | |
322 | return cast_unicode(fname) |
|
320 | return cast_unicode(fname) | |
@@ -345,10 +343,7 b' def find_source_lines(obj):' | |||||
345 | lineno = inspect.getsourcelines(obj)[1] |
|
343 | lineno = inspect.getsourcelines(obj)[1] | |
346 | except TypeError: |
|
344 | except TypeError: | |
347 | # For instances, try the class object like getsource() does |
|
345 | # For instances, try the class object like getsource() does | |
348 |
|
|
346 | lineno = inspect.getsourcelines(obj.__class__)[1] | |
349 | lineno = inspect.getsourcelines(obj.__class__)[1] |
|
|||
350 | else: |
|
|||
351 | lineno = None |
|
|||
352 | except: |
|
347 | except: | |
353 | return None |
|
348 | return None | |
354 |
|
349 |
General Comments 0
You need to be logged in to leave comments.
Login now