]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-84976: Move Lib/datetime.py to Lib/_pydatetime
authorPaul Ganssle <git@m.ganssle.io>
Thu, 23 Mar 2023 14:36:47 +0000 (10:36 -0400)
committerT. Wouters <thomas@python.org>
Wed, 3 May 2023 09:09:45 +0000 (03:09 -0600)
This breaks the tests, but we are keeping it as a separate commit so
that the move operation and editing of the moved files are separate, for
a cleaner history.

Lib/_pydatetime.py [moved from Lib/datetime.py with 100% similarity]
Lib/test/datetimetester.py
Lib/test/test_datetime.py
Python/stdlib_module_names.h

similarity index 100%
rename from Lib/datetime.py
rename to Lib/_pydatetime.py
index c5eb6e7f1643ee26a5dcf8a354032095b66ec571..fb07d2a5ad9b0672cb2a1773b79ed54779296ce5 100644 (file)
@@ -39,6 +39,10 @@ except ImportError:
 
 # Needed by test_datetime
 import _strptime
+try:
+    import _pydatetime
+except ImportError:
+    pass
 #
 
 pickle_loads = {pickle.loads, pickle._loads}
@@ -92,7 +96,7 @@ class TestModule(unittest.TestCase):
         if '_Fast' in self.__class__.__name__:
             self.skipTest('Only run for Pure Python implementation')
 
-        dar = datetime_module._divide_and_round
+        dar = _pydatetime._divide_and_round
 
         self.assertEqual(dar(-10, -3), 3)
         self.assertEqual(dar(5, -2), -2)
index 7f9094fa7bd4e61dd494651cdd7ac042148c50e8..3859733a4fe65b80d8af8906e90afbae47f44cb5 100644 (file)
@@ -8,10 +8,12 @@ TESTS = 'test.datetimetester'
 
 def load_tests(loader, tests, pattern):
     try:
-        pure_tests = import_fresh_module(TESTS, fresh=['datetime', '_strptime'],
-                                        blocked=['_datetime'])
-        fast_tests = import_fresh_module(TESTS, fresh=['datetime',
-                                                    '_datetime', '_strptime'])
+        pure_tests = import_fresh_module(TESTS,
+                                         fresh=['datetime', '_pydatetime', '_strptime'],
+                                         blocked=['_datetime'])
+        fast_tests = import_fresh_module(TESTS,
+                                         fresh=['datetime', '_strptime'],
+                                         blocked=['_pydatetime'])
     finally:
         # XXX: import_fresh_module() is supposed to leave sys.module cache untouched,
         # XXX: but it does not, so we have to cleanup ourselves.
@@ -42,6 +44,8 @@ def load_tests(loader, tests, pattern):
                 cls_._save_sys_modules = sys.modules.copy()
                 sys.modules[TESTS] = module
                 sys.modules['datetime'] = module.datetime_module
+                if hasattr(module, '_pydatetime'):
+                    sys.modules['_pydatetime'] = module._pydatetime
                 sys.modules['_strptime'] = module._strptime
             @classmethod
             def tearDownClass(cls_):
index 27f42e5202e571cebb257c52e35aedf37c4c1e48..ed4a0ac2dd32de292bc397f6f6f7d43e6c8cb812 100644 (file)
@@ -56,6 +56,7 @@ static const char* _Py_stdlib_module_names[] = {
 "_posixshmem",
 "_posixsubprocess",
 "_py_abc",
+"_pydatetime",
 "_pydecimal",
 "_pyio",
 "_pylong",