mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
* bpo-27578: Fix inspect.getsource() on empty file
For modules from empty files, `inspect.getsource()` now
returns an empty string, and `inspect.getsourcelines()` returns
a list of one empty string, fixing the expected invariant.
As indicated by `exec('')`, empty strings are valid Python
source code.
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
3 lines
174 B
ReStructuredText
3 lines
174 B
ReStructuredText
:func:`inspect.getsource` (and related functions) work with
|
|
empty module files, returning ``'\n'`` (or reasonable equivalent)
|
|
instead of raising ``OSError``. Patch by Kernc.
|