gh-123339: Fix cases of inconsistency of __module__ and __firstlineno__ in classes (GH-123613)

* 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 them. 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.
This commit is contained in:
Serhiy Storchaka 2024-09-28 20:51:49 +03:00 committed by GitHub
parent dc12237ab0
commit 69a4063ca5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 110 additions and 12 deletions

View file

@ -103,6 +103,7 @@ try:
from _decimal import __version__ # noqa: F401
from _decimal import __libmpdec_version__ # noqa: F401
except ImportError:
from _pydecimal import *
from _pydecimal import __version__ # noqa: F401
from _pydecimal import __libmpdec_version__ # noqa: F401
import _pydecimal
import sys
_pydecimal.__doc__ = __doc__
sys.modules[__name__] = _pydecimal