1# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
2# For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE
3# Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt
4
5from astroid import nodes
6from astroid.brain.helpers import register_module_extender
7from astroid.builder import AstroidBuilder
8from astroid.const import PY312_PLUS
9from astroid.manager import AstroidManager
10
11
12def datetime_transform() -> nodes.Module:
13 """The datetime module was C-accelerated in Python 3.12, so use the
14 Python source."""
15 return AstroidBuilder(AstroidManager()).string_build("from _pydatetime import *")
16
17
18def register(manager: AstroidManager) -> None:
19 if PY312_PLUS:
20 register_module_extender(manager, "datetime", datetime_transform)