Skip to content

Commit fa4c94a

Browse files
gh-123339: Fix cases of inconsistency of __module__ and __firstlineno__ in classes
* Setting the __module__ attribute for a class now removes the __firstlineno__ item from the type's dict. * The _collections_abc and _pydecimal modules now completely replace the collections.abc and decimal modules after importing the latters. This allows to get the source of classes and functions defined in these modules. * inspect.findsource() now checks whether the first line number for a class is out of bound.
1 parent f1a0d96 commit fa4c94a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Setting the :attr:`!__module__` attribute for a class now removes the
2+
``__firstlineno__`` item from the type's dict, so they will no longer be
3+
inconsistent.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix :func:`inspect.getsource` for classes in :mod:`collections.abc` and
2+
:mod:`decimal` (for pure Python implementation) modules.
3+
:func:`inspect.getcomments` now raises OSError instead of IndexError if the
4+
``__firstlineno__`` value for a class is out of bound.

0 commit comments

Comments
 (0)