Skip to content

Commit

Permalink
pythongh-123339: Fix cases of inconsistency of __module__ and __first…
Browse files Browse the repository at this point in the history
…lineno__ 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.
  • Loading branch information
serhiy-storchaka committed Sep 2, 2024
1 parent f1a0d96 commit fa4c94a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Setting the :attr:`!__module__` attribute for a class now removes the
``__firstlineno__`` item from the type's dict, so they will no longer be
inconsistent.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix :func:`inspect.getsource` for classes in :mod:`collections.abc` and
:mod:`decimal` (for pure Python implementation) modules.
:func:`inspect.getcomments` now raises OSError instead of IndexError if the
``__firstlineno__`` value for a class is out of bound.

0 comments on commit fa4c94a

Please sign in to comment.