Skip to content

Commit 1596e58

Browse files
gh-155496: Use Argument Clinic for more functions in the time module (GH-155513)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 21223c9 commit 1596e58

4 files changed

Lines changed: 975 additions & 243 deletions

File tree

‎Lib/test/test_inspect/test_inspect.py‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6378,15 +6378,10 @@ def test_thread_module_has_signatures(self):
63786378
self._test_module_has_signatures(_thread, no_signature)
63796379

63806380
def test_time_module_has_signatures(self):
6381-
no_signature = {
6382-
'asctime', 'ctime', 'get_clock_info', 'gmtime', 'localtime',
6383-
'strftime', 'strptime'
6384-
}
6385-
no_signature |= {name for name in
6386-
['clock_getres', 'clock_settime', 'clock_settime_ns',
6387-
'pthread_getcpuclockid']
6388-
if hasattr(time, name)}
6389-
self._test_module_has_signatures(time, no_signature)
6381+
no_signature = {'strftime', 'strptime'}
6382+
unsupported_signature = {'asctime'}
6383+
self._test_module_has_signatures(time, no_signature,
6384+
unsupported_signature)
63906385

63916386
def test_tokenize_module_has_signatures(self):
63926387
import tokenize

‎Lib/test/test_unittest/testmock/testhelpers.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import inspect
2-
import time
32
import types
43
import unittest
54

5+
from test.support import import_helper
6+
67
from unittest.mock import (
78
call, _Call, create_autospec, MagicMock,
89
Mock, ANY, _CallList, patch, PropertyMock, _callable
@@ -929,8 +930,10 @@ def check_data_descriptor(mock_attr):
929930

930931

931932
def test_autospec_on_bound_builtin_function(self):
932-
meth = types.MethodType(time.ctime, time.time())
933-
self.assertIsInstance(meth(), str)
933+
_testcapi = import_helper.import_module('_testcapi')
934+
# This function is defined without a signature.
935+
meth = types.MethodType(_testcapi.docstring_no_signature, object())
936+
self.assertIsNone(meth())
934937
mocked = create_autospec(meth)
935938

936939
# no signature, so no spec to check against

0 commit comments

Comments
 (0)