Debian Codegraph @

Tools/build/stable_abi.py

raw
1 """Check the stable ABI manifest or generate files from it
2
3 By default, the tool only checks existing files/libraries.
4 Pass --generate to recreate auto-generated files instead.
5
6 For actions that take a FILENAME, the filename can be left out to use a default
7 (relative to the manifest file, as they appear in the CPython codebase).
8 """
9
10 import argparse
11 import csv
12 import dataclasses
13 import difflib
14 import io
15 import os
16 import os.path
17 import pprint
18 import re
19 import subprocess
20 import sys
21 import sysconfig
22 import textwrap
23 import tomllib
24 from functools import partial
25 from pathlib import Path
26
27 SCRIPT_NAME = 'Tools/build/stable_abi.py'
28 MISSING = object()
29
30 EXCLUDED_HEADERS = {
31 "bytes_methods.h",
32 "cellobject.h",
33 "classobject.h",
34 "code.h",
35 "compile.h",
36 "datetime.h",
37 "dtoa.h",
38 "frameobject.h",
39 "genobject.h",
40 "longintrepr.h",
41 "parsetok.h",
42 "pyatomic.h",
43 "token.h",
44 "ucnhash.h",
45 }
46 MACOS = (sys.platform == "darwin")
47 UNIXY = MACOS or (sys.platform == "linux") # XXX should this be "not Windows"?
48
49
50 # The stable ABI manifest (Misc/stable_abi.toml) exists only to fill the
51 # following dataclasses.
52 # Feel free to change its syntax (and the `parse_manifest` function)
53 # to better serve that purpose (while keeping it human-readable).
54
55 class Manifest:
56 """Collection of `ABIItem`s forming the stable ABI/limited API."""
57 def __init__(self):
58 self.contents = {}
59
60 def add(self, item):
61 if item.name in self.contents:
62 # We assume that stable ABI items do not share names,
63 # even if they're different kinds (e.g. function vs. macro).
64 raise ValueError(f'duplicate ABI item {item.name}')
65 self.contents[item.name] = item
66
67 def select(self, kinds, *, include_abi_only=True, ifdef=None):
68 """Yield selected items of the manifest
69
70 kinds: set of requested kinds, e.g. {'function', 'macro'}
71 include_abi_only: if True (default), include all items of the
72 stable ABI.
73 If False, include only items from the limited API
74 (i.e. items people should use today)
75 ifdef: set of feature macros (e.g. {'HAVE_FORK', 'MS_WINDOWS'}).
76 If None (default), items are not filtered by this. (This is
77 different from the empty set, which filters out all such
78 conditional items.)
79 """
80 for name, item in sorted(self.contents.items()):
81 if item.kind not in kinds:
82 continue
83 if item.abi_only and not include_abi_only:
84 continue
85 if (ifdef is not None
86 and item.ifdef is not None
87 and item.ifdef not in ifdef):
88 continue
89 yield item
90
91 def dump(self):
92 """Yield lines to recreate the manifest file (sans comments/newlines)"""
93 for item in self.contents.values():
94 fields = dataclasses.fields(item)
95 yield f"[{item.kind}.{item.name}]"
96 for field in fields:
97 if field.name in {'name', 'value', 'kind'}:
98 continue
99 value = getattr(item, field.name)
100 if value == field.default:
101 pass
102 elif value is True:
103 yield f" {field.name} = true"
104 elif value:
105 yield f" {field.name} = {value!r}"
106
107
108 itemclasses = {}
109 def itemclass(kind):
110 """Register the decorated class in `itemclasses`"""
111 def decorator(cls):
112 itemclasses[kind] = cls
113 return cls
114 return decorator
115
116 @itemclass('function')
117 @itemclass('macro')
118 @itemclass('data')
119 @itemclass('const')
120 @itemclass('typedef')
121 @dataclasses.dataclass
122 class ABIItem:
123 """Information on one item (function, macro, struct, etc.)"""
124
125 name: str
126 kind: str
127 added: str = None
128 abi_only: bool = False
129 ifdef: str = None
130
131 @itemclass('feature_macro')
132 @dataclasses.dataclass(kw_only=True)
133 class FeatureMacro(ABIItem):
134 name: str
135 doc: str
136 windows: bool = False
137 abi_only: bool = True
138
139 @itemclass('struct')
140 @dataclasses.dataclass(kw_only=True)
141 class Struct(ABIItem):
142 struct_abi_kind: str
143 members: list = None
144
145
146 def parse_manifest(file):
147 """Parse the given file (iterable of lines) to a Manifest"""
148
149 manifest = Manifest()
150
151 data = tomllib.load(file)
152
153 for kind, itemclass in itemclasses.items():
154 for name, item_data in data[kind].items():
155 try:
156 item = itemclass(name=name, kind=kind, **item_data)
157 manifest.add(item)
158 except BaseException as exc:
159 exc.add_note(f'in {kind} {name}')
160 raise
161
162 return manifest
163
164 # The tool can run individual "actions".
165 # Most actions are "generators", which generate a single file from the
166 # manifest. (Checking works by generating a temp file & comparing.)
167 # Other actions, like "--unixy-check", don't work on a single file.
168
169 generators = []
170 def generator(var_name, default_path):
171 """Decorates a file generator: function that writes to a file"""
172 def _decorator(func):
173 func.var_name = var_name
174 func.arg_name = '--' + var_name.replace('_', '-')
175 func.default_path = default_path
176 generators.append(func)
177 return func
178 return _decorator
179
180
181 @generator("python3dll", 'PC/python3dll.c')
182 def gen_python3dll(manifest, args, outfile):
183 """Generate/check the source for the Windows stable ABI library"""
184 write = partial(print, file=outfile)
185 content = f"""\
186 /* Re-export stable Python ABI */
187
188 /* Generated by {SCRIPT_NAME} */
189 """
190 content += r"""
191 #ifdef _M_IX86
192 #define DECORATE "_"
193 #else
194 #define DECORATE
195 #endif
196
197 #define EXPORT_FUNC(name) \
198 __pragma(comment(linker, "/EXPORT:" DECORATE #name "=" PYTHON_DLL_NAME "." #name))
199 #define EXPORT_DATA(name) \
200 __pragma(comment(linker, "/EXPORT:" DECORATE #name "=" PYTHON_DLL_NAME "." #name ",DATA"))
201 """
202 write(textwrap.dedent(content))
203
204 def sort_key(item):
205 return item.name.lower()
206
207 windows_feature_macros = {
208 item.name for item in manifest.select({'feature_macro'}) if item.windows
209 }
210 for item in sorted(
211 manifest.select(
212 {'function'},
213 include_abi_only=True,
214 ifdef=windows_feature_macros),
215 key=sort_key):
216 write(f'EXPORT_FUNC({item.name})')
217
218 write()
219
220 for item in sorted(
221 manifest.select(
222 {'data'},
223 include_abi_only=True,
224 ifdef=windows_feature_macros),
225 key=sort_key):
226 write(f'EXPORT_DATA({item.name})')
227
228 ITEM_KIND_TO_DOC_ROLE = {
229 'function': 'func',
230 'data': 'data',
231 'struct': 'type',
232 'macro': 'macro',
233 'const': 'macro',
234 'typedef': 'type',
235 }
236
237 @generator("doc_list", 'Doc/data/stable_abi.dat')
238 def gen_doc_annotations(manifest, args, outfile):
239 """Generate/check the stable ABI list for documentation annotations
240
241 See ``StableABIEntry`` in ``Doc/tools/extensions/c_annotations.py``
242 for a description of each field.
243 """
244 writer = csv.DictWriter(
245 outfile,
246 ['role', 'name', 'added', 'ifdef_note', 'struct_abi_kind'],
247 lineterminator='\n')
248 writer.writeheader()
249 kinds = set(ITEM_KIND_TO_DOC_ROLE)
250 for item in manifest.select(kinds, include_abi_only=False):
251 if item.ifdef:
252 ifdef_note = manifest.contents[item.ifdef].doc
253 else:
254 ifdef_note = None
255 row = {
256 'role': ITEM_KIND_TO_DOC_ROLE[item.kind],
257 'name': item.name,
258 'added': item.added,
259 'ifdef_note': ifdef_note,
260 }
261 rows = [row]
262 if item.kind == 'struct':
263 row['struct_abi_kind'] = item.struct_abi_kind
264 for member_name in item.members or ():
265 rows.append({
266 'role': 'member',
267 'name': f'{item.name}.{member_name}',
268 'added': item.added,
269 })
270 writer.writerows(rows)
271
272 @generator("ctypes_test", 'Lib/test/test_stable_abi_ctypes.py')
273 def gen_ctypes_test(manifest, args, outfile):
274 """Generate/check the ctypes-based test for exported symbols"""
275 write = partial(print, file=outfile)
276 write(textwrap.dedent(f'''\
277 # Generated by {SCRIPT_NAME}
278
279 """Test that all symbols of the Stable ABI are accessible using ctypes
280 """
281
282 import sys
283 import unittest
284 from test.support.import_helper import import_module
285 try:
286 from _testcapi import get_feature_macros
287 except ImportError:
288 raise unittest.SkipTest("requires _testcapi")
289
290 feature_macros = get_feature_macros()
291
292 # Stable ABI is incompatible with Py_TRACE_REFS builds due to PyObject
293 # layout differences.
294 # See https://github.com/python/cpython/issues/88299#issuecomment-1113366226
295 if feature_macros['Py_TRACE_REFS']:
296 raise unittest.SkipTest("incompatible with Py_TRACE_REFS.")
297
298 ctypes_test = import_module('ctypes')
299
300 class TestStableABIAvailability(unittest.TestCase):
301 def test_available_symbols(self):
302
303 for symbol_name in SYMBOL_NAMES:
304 with self.subTest(symbol_name):
305 ctypes_test.pythonapi[symbol_name]
306
307 def test_feature_macros(self):
308 self.assertEqual(
309 set(get_feature_macros()), EXPECTED_FEATURE_MACROS)
310
311 # The feature macros for Windows are used in creating the DLL
312 # definition, so they must be known on all platforms.
313 # If we are on Windows, we check that the hardcoded data matches
314 # the reality.
315 @unittest.skipIf(sys.platform != "win32", "Windows specific test")
316 def test_windows_feature_macros(self):
317 for name, value in WINDOWS_FEATURE_MACROS.items():
318 if value != 'maybe':
319 with self.subTest(name):
320 self.assertEqual(feature_macros[name], value)
321
322 SYMBOL_NAMES = (
323 '''))
324 items = manifest.select(
325 {'function', 'data'},
326 include_abi_only=True,
327 )
328 feature_macros = list(manifest.select({'feature_macro'}))
329 optional_items = {m.name: [] for m in feature_macros}
330 for item in items:
331 if item.ifdef:
332 optional_items[item.ifdef].append(item.name)
333 else:
334 write(f' "{item.name}",')
335 write(")")
336 for ifdef, names in optional_items.items():
337 write(f"if feature_macros[{ifdef!r}]:")
338 write(f" SYMBOL_NAMES += (")
339 for name in names:
340 write(f" {name!r},")
341 write(" )")
342 write("")
343 feature_names = sorted(m.name for m in feature_macros)
344 write(f"EXPECTED_FEATURE_MACROS = set({pprint.pformat(feature_names)})")
345
346 windows_feature_macros = {m.name: m.windows for m in feature_macros}
347 write(f"WINDOWS_FEATURE_MACROS = {pprint.pformat(windows_feature_macros)}")
348
349
350 @generator("testcapi_feature_macros", 'Modules/_testcapi_feature_macros.inc')
351 def gen_testcapi_feature_macros(manifest, args, outfile):
352 """Generate/check the stable ABI list for documentation annotations"""
353 write = partial(print, file=outfile)
354 write(f'// Generated by {SCRIPT_NAME}')
355 write()
356 write('// Add an entry in dict `result` for each Stable ABI feature macro.')
357 write()
358 for macro in manifest.select({'feature_macro'}):
359 name = macro.name
360 write(f'#ifdef {name}')
361 write(f' res = PyDict_SetItemString(result, "{name}", Py_True);')
362 write('#else')
363 write(f' res = PyDict_SetItemString(result, "{name}", Py_False);')
364 write('#endif')
365 write('if (res) {')
366 write(' Py_DECREF(result); return NULL;')
367 write('}')
368 write()
369
370
371 def generate_or_check(manifest, args, path, func):
372 """Generate/check a file with a single generator
373
374 Return True if successful; False if a comparison failed.
375 """
376
377 outfile = io.StringIO()
378 func(manifest, args, outfile)
379 generated = outfile.getvalue()
380 existing = path.read_text()
381
382 if generated != existing:
383 if args.generate:
384 path.write_text(generated)
385 else:
386 print(f'File {path} differs from expected!')
387 diff = difflib.unified_diff(
388 generated.splitlines(), existing.splitlines(),
389 str(path), '<expected>',
390 lineterm='',
391 )
392 for line in diff:
393 print(line)
394 return False
395 return True
396
397
398 def do_unixy_check(manifest, args):
399 """Check headers & library using "Unixy" tools (GCC/clang, binutils)"""
400 okay = True
401
402 # Get all macros first: we'll need feature macros like HAVE_FORK and
403 # MS_WINDOWS for everything else
404 present_macros = gcc_get_limited_api_macros(['Include/Python.h'])
405 feature_macros = {m.name for m in manifest.select({'feature_macro'})}
406 feature_macros &= present_macros
407
408 # Check that we have all needed macros
409 expected_macros = {item.name for item in manifest.select({'macro'})}
410 missing_macros = expected_macros - present_macros
411 okay &= _report_unexpected_items(
412 missing_macros,
413 'Some macros from are not defined from "Include/Python.h" '
414 'with Py_LIMITED_API:')
415
416 expected_symbols = {item.name for item in manifest.select(
417 {'function', 'data'}, include_abi_only=True, ifdef=feature_macros,
418 )}
419
420 # Check the static library (*.a)
421 LIBRARY = sysconfig.get_config_var("LIBRARY")
422 if not LIBRARY:
423 raise Exception("failed to get LIBRARY variable from sysconfig")
424 if os.path.exists(LIBRARY):
425 okay &= binutils_check_library(
426 manifest, LIBRARY, expected_symbols, dynamic=False)
427
428 # Check the dynamic library (*.so)
429 LDLIBRARY = sysconfig.get_config_var("LDLIBRARY")
430 if not LDLIBRARY:
431 raise Exception("failed to get LDLIBRARY variable from sysconfig")
432 okay &= binutils_check_library(
433 manifest, LDLIBRARY, expected_symbols, dynamic=False)
434
435 # Check definitions in the header files
436 expected_defs = {item.name for item in manifest.select(
437 {'function', 'data'}, include_abi_only=False, ifdef=feature_macros,
438 )}
439 found_defs = gcc_get_limited_api_definitions(['Include/Python.h'])
440 missing_defs = expected_defs - found_defs
441 okay &= _report_unexpected_items(
442 missing_defs,
443 'Some expected declarations were not declared in '
444 '"Include/Python.h" with Py_LIMITED_API:')
445
446 # Some Limited API macros are defined in terms of private symbols.
447 # These are not part of Limited API (even though they're defined with
448 # Py_LIMITED_API). They must be part of the Stable ABI, though.
449 private_symbols = {n for n in expected_symbols if n.startswith('_')}
450 extra_defs = found_defs - expected_defs - private_symbols
451 okay &= _report_unexpected_items(
452 extra_defs,
453 'Some extra declarations were found in "Include/Python.h" '
454 'with Py_LIMITED_API:')
455
456 return okay
457
458
459 def _report_unexpected_items(items, msg):
460 """If there are any `items`, report them using "msg" and return false"""
461 if items:
462 print(msg, file=sys.stderr)
463 for item in sorted(items):
464 print(' -', item, file=sys.stderr)
465 return False
466 return True
467
468
469 def binutils_get_exported_symbols(library, dynamic=False):
470 """Retrieve exported symbols using the nm(1) tool from binutils"""
471 # Only look at dynamic symbols
472 args = ["nm", "--no-sort"]
473 if dynamic:
474 args.append("--dynamic")
475 args.append(library)
476 proc = subprocess.run(args, stdout=subprocess.PIPE, text=True)
477 if proc.returncode:
478 sys.stdout.write(proc.stdout)
479 sys.exit(proc.returncode)
480
481 stdout = proc.stdout.rstrip()
482 if not stdout:
483 raise Exception("command output is empty")
484
485 for line in stdout.splitlines():
486 # Split line '0000000000001b80 D PyTextIOWrapper_Type'
487 if not line:
488 continue
489
490 parts = line.split(maxsplit=2)
491 if len(parts) < 3:
492 continue
493
494 symbol = parts[-1]
495 if MACOS and symbol.startswith("_"):
496 yield symbol[1:]
497 else:
498 yield symbol
499
500
501 def binutils_check_library(manifest, library, expected_symbols, dynamic):
502 """Check that library exports all expected_symbols"""
503 available_symbols = set(binutils_get_exported_symbols(library, dynamic))
504 missing_symbols = expected_symbols - available_symbols
505 if missing_symbols:
506 print(textwrap.dedent(f"""\
507 Some symbols from the limited API are missing from {library}:
508 {', '.join(missing_symbols)}
509
510 This error means that there are some missing symbols among the
511 ones exported in the library.
512 This normally means that some symbol, function implementation or
513 a prototype belonging to a symbol in the limited API has been
514 deleted or is missing.
515 """), file=sys.stderr)
516 return False
517 return True
518
519
520 def gcc_get_limited_api_macros(headers):
521 """Get all limited API macros from headers.
522
523 Runs the preprocessor over all the header files in "Include" setting
524 "-DPy_LIMITED_API" to the correct value for the running version of the
525 interpreter and extracting all macro definitions (via adding -dM to the
526 compiler arguments).
527
528 Requires Python built with a GCC-compatible compiler. (clang might work)
529 """
530
531 api_hexversion = sys.version_info.major << 24 | sys.version_info.minor << 16
532
533 preprocessor_output_with_macros = subprocess.check_output(
534 sysconfig.get_config_var("CC").split()
535 + [
536 # Prevent the expansion of the exported macros so we can
537 # capture them later
538 "-DSIZEOF_WCHAR_T=4", # The actual value is not important
539 f"-DPy_LIMITED_API={api_hexversion}",
540 "-I.",
541 "-I./Include",
542 "-dM",
543 "-E",
544 ]
545 + [str(file) for file in headers],
546 text=True,
547 )
548
549 return set(re.findall(r"#define (\w+)", preprocessor_output_with_macros))
550
551
552 def gcc_get_limited_api_definitions(headers):
553 """Get all limited API definitions from headers.
554
555 Run the preprocessor over all the header files in "Include" setting
556 "-DPy_LIMITED_API" to the correct value for the running version of the
557 interpreter.
558
559 The limited API symbols will be extracted from the output of this command
560 as it includes the prototypes and definitions of all the exported symbols
561 that are in the limited api.
562
563 This function does *NOT* extract the macros defined on the limited API
564
565 Requires Python built with a GCC-compatible compiler. (clang might work)
566 """
567 api_hexversion = sys.version_info.major << 24 | sys.version_info.minor << 16
568 preprocessor_output = subprocess.check_output(
569 sysconfig.get_config_var("CC").split()
570 + [
571 # Prevent the expansion of the exported macros so we can capture
572 # them later
573 "-DPyAPI_FUNC=__PyAPI_FUNC",
574 "-DPyAPI_DATA=__PyAPI_DATA",
575 "-DEXPORT_DATA=__EXPORT_DATA",
576 "-D_Py_NO_RETURN=",
577 "-DSIZEOF_WCHAR_T=4", # The actual value is not important
578 f"-DPy_LIMITED_API={api_hexversion}",
579 "-I.",
580 "-I./Include",
581 "-E",
582 ]
583 + [str(file) for file in headers],
584 text=True,
585 stderr=subprocess.DEVNULL,
586 )
587 stable_functions = set(
588 re.findall(r"__PyAPI_FUNC\(.*?\)\s*(.*?)\s*\(", preprocessor_output)
589 )
590 stable_exported_data = set(
591 re.findall(r"__EXPORT_DATA\((.*?)\)", preprocessor_output)
592 )
593 stable_data = set(
594 re.findall(r"__PyAPI_DATA\(.*?\)[\s\*\(]*([^);]*)\)?.*;", preprocessor_output)
595 )
596 return stable_data | stable_exported_data | stable_functions
597
598 def check_private_names(manifest):
599 """Ensure limited API doesn't contain private names
600
601 Names prefixed by an underscore are private by definition.
602 """
603 for name, item in manifest.contents.items():
604 if name.startswith('_') and not item.abi_only:
605 raise ValueError(
606 f'`{name}` is private (underscore-prefixed) and should be '
607 'removed from the stable ABI list or marked `abi_only`')
608
609 def check_dump(manifest, filename):
610 """Check that manifest.dump() corresponds to the data.
611
612 Mainly useful when debugging this script.
613 """
614 dumped = tomllib.loads('\n'.join(manifest.dump()))
615 with filename.open('rb') as file:
616 from_file = tomllib.load(file)
617 if dumped != from_file:
618 print('Dump differs from loaded data!', file=sys.stderr)
619 diff = difflib.unified_diff(
620 pprint.pformat(dumped).splitlines(),
621 pprint.pformat(from_file).splitlines(),
622 '<dumped>', str(filename),
623 lineterm='',
624 )
625 for line in diff:
626 print(line, file=sys.stderr)
627 return False
628 else:
629 return True
630
631 def main():
632 parser = argparse.ArgumentParser(
633 description=__doc__,
634 formatter_class=argparse.RawDescriptionHelpFormatter,
635 )
636 parser.add_argument(
637 "file", type=Path, metavar='FILE',
638 help="file with the stable abi manifest",
639 )
640 parser.add_argument(
641 "--generate", action='store_true',
642 help="generate file(s), rather than just checking them",
643 )
644 parser.add_argument(
645 "--generate-all", action='store_true',
646 help="as --generate, but generate all file(s) using default filenames."
647 " (unlike --all, does not run any extra checks)",
648 )
649 parser.add_argument(
650 "-a", "--all", action='store_true',
651 help="run all available checks using default filenames",
652 )
653 parser.add_argument(
654 "-l", "--list", action='store_true',
655 help="list available generators and their default filenames; then exit",
656 )
657 parser.add_argument(
658 "--dump", action='store_true',
659 help="dump the manifest contents (used for debugging the parser)",
660 )
661
662 actions_group = parser.add_argument_group('actions')
663 for gen in generators:
664 actions_group.add_argument(
665 gen.arg_name, dest=gen.var_name,
666 type=str, nargs="?", default=MISSING,
667 metavar='FILENAME',
668 help=gen.__doc__,
669 )
670 actions_group.add_argument(
671 '--unixy-check', action='store_true',
672 help=do_unixy_check.__doc__,
673 )
674 args = parser.parse_args()
675
676 base_path = args.file.parent.parent
677
678 if args.list:
679 for gen in generators:
680 print(f'{gen.arg_name}: {base_path / gen.default_path}')
681 sys.exit(0)
682
683 run_all_generators = args.generate_all
684
685 if args.generate_all:
686 args.generate = True
687
688 if args.all:
689 run_all_generators = True
690 if UNIXY:
691 args.unixy_check = True
692
693 try:
694 file = args.file.open('rb')
695 except FileNotFoundError as err:
696 if args.file.suffix == '.txt':
697 # Provide a better error message
698 suggestion = args.file.with_suffix('.toml')
699 raise FileNotFoundError(
700 f'{args.file} not found. Did you mean {suggestion} ?') from err
701 raise
702 with file:
703 manifest = parse_manifest(file)
704
705 check_private_names(manifest)
706
707 # Remember results of all actions (as booleans).
708 # At the end we'll check that at least one action was run,
709 # and also fail if any are false.
710 results = {}
711
712 if args.dump:
713 for line in manifest.dump():
714 print(line)
715 results['dump'] = check_dump(manifest, args.file)
716
717 for gen in generators:
718 filename = getattr(args, gen.var_name)
719 if filename is None or (run_all_generators and filename is MISSING):
720 filename = base_path / gen.default_path
721 elif filename is MISSING:
722 continue
723
724 results[gen.var_name] = generate_or_check(manifest, args, filename, gen)
725
726 if args.unixy_check:
727 results['unixy_check'] = do_unixy_check(manifest, args)
728
729 if not results:
730 if args.generate:
731 parser.error('No file specified. Use --help for usage.')
732 parser.error('No check specified. Use --help for usage.')
733
734 failed_results = [name for name, result in results.items() if not result]
735
736 if failed_results:
737 raise Exception(f"""
738 These checks related to the stable ABI did not succeed:
739 {', '.join(failed_results)}
740
741 If you see diffs in the output, files derived from the stable
742 ABI manifest the were not regenerated.
743 Run `make regen-limited-abi` to fix this.
744
745 Otherwise, see the error(s) above.
746
747 The stable ABI manifest is at: {args.file}
748 Note that there is a process to follow when modifying it.
749
750 You can read more about the limited API and its contracts at:
751
752 https://docs.python.org/3/c-api/stable.html
753
754 And in PEP 384:
755
756 https://peps.python.org/pep-0384/
757 """)
758
759
760 if __name__ == "__main__":
761 main()