Skip to content

Commit 5fd1897

Browse files
authored
gh-113317: Argument Clinic: Add libclinic.converters module (#117315)
Move the following converter classes to libclinic.converters: * PyByteArrayObject_converter * PyBytesObject_converter * Py_UNICODE_converter * Py_buffer_converter * Py_complex_converter * Py_ssize_t_converter * bool_converter * byte_converter * char_converter * defining_class_converter * double_converter * fildes_converter * float_converter * int_converter * long_converter * long_long_converter * object_converter * self_converter * short_converter * size_t_converter * slice_index_converter * str_converter * unicode_converter * unsigned_char_converter * unsigned_int_converter * unsigned_long_converter * unsigned_long_long_converter * unsigned_short_converter Move also the following classes to libclinic.converters: * buffer * robuffer * rwbuffer Move the following functions to libclinic.converters: * correct_name_for_self() * r() * str_converter_key() Move Null and NULL to libclinic.utils.
1 parent 9dae05e commit 5fd1897

File tree

7 files changed

+1259
-1215
lines changed

7 files changed

+1259
-1215
lines changed

Lib/test/test_clinic.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
test_tools.skip_if_missing('clinic')
1818
with test_tools.imports_under_tool('clinic'):
1919
import libclinic
20+
from libclinic.converters import int_converter, str_converter
2021
import clinic
2122
from clinic import DSLParser
2223

@@ -924,7 +925,7 @@ def test_param(self):
924925
self.assertEqual(2, len(function.parameters))
925926
p = function.parameters['path']
926927
self.assertEqual('path', p.name)
927-
self.assertIsInstance(p.converter, clinic.int_converter)
928+
self.assertIsInstance(p.converter, int_converter)
928929

929930
def test_param_default(self):
930931
function = self.parse_function("""
@@ -1023,7 +1024,7 @@ def test_param_no_docstring(self):
10231024
""")
10241025
self.assertEqual(3, len(function.parameters))
10251026
conv = function.parameters['something_else'].converter
1026-
self.assertIsInstance(conv, clinic.str_converter)
1027+
self.assertIsInstance(conv, str_converter)
10271028

10281029
def test_param_default_parameters_out_of_order(self):
10291030
err = (
@@ -2040,7 +2041,7 @@ def test_legacy_converters(self):
20402041
block = self.parse('module os\nos.access\n path: "s"')
20412042
module, function = block.signatures
20422043
conv = (function.parameters['path']).converter
2043-
self.assertIsInstance(conv, clinic.str_converter)
2044+
self.assertIsInstance(conv, str_converter)
20442045

20452046
def test_legacy_converters_non_string_constant_annotation(self):
20462047
err = "Annotations must be either a name, a function call, or a string"

0 commit comments

Comments
 (0)