mirror of
https://github.com/python/cpython.git
synced 2026-04-15 08:11:10 +00:00
* Add the c_init_default attribute which is used to initialize the C variable
if the default is not explicitly provided.
* Add the c_default_init() method which is used to derive c_default from
default if c_default is not explicitly provided.
* Explicit c_default and py_default are now almost always have precedence
over the generated value.
* Add support for bytes literals as default values.
* Improve support for str literals as default values (support non-ASCII
and non-printable characters and special characters like backslash or quotes).
* Fix support for str and bytes literals containing trigraphs, "/*" and "*/".
* Improve support for default values in converters "char" and "int(accept={str})".
* Converter "int(accept={str})" now requires 1-character string instead of
integer as default value.
* Add support for non-None default values in converter "Py_buffer": NULL,
str and bytes literals.
* Improve error handling for invalid default values.
* Rename Null to NullType for consistency.
97 lines
1.7 KiB
Python
97 lines
1.7 KiB
Python
from typing import Final
|
|
|
|
from .errors import (
|
|
ClinicError,
|
|
warn,
|
|
fail,
|
|
)
|
|
from .formatting import (
|
|
SIG_END_MARKER,
|
|
c_str_repr,
|
|
c_bytes_repr,
|
|
c_unichar_repr,
|
|
docstring_for_c_string,
|
|
format_escape,
|
|
indent_all_lines,
|
|
linear_format,
|
|
normalize_snippet,
|
|
pprint_words,
|
|
suffix_all_lines,
|
|
wrap_declarations,
|
|
wrapped_c_string_literal,
|
|
)
|
|
from .identifiers import (
|
|
ensure_legal_c_identifier,
|
|
is_legal_c_identifier,
|
|
is_legal_py_identifier,
|
|
)
|
|
from .utils import (
|
|
FormatCounterFormatter,
|
|
NULL,
|
|
NullType,
|
|
Sentinels,
|
|
VersionTuple,
|
|
compute_checksum,
|
|
create_regex,
|
|
unknown,
|
|
unspecified,
|
|
write_file,
|
|
)
|
|
|
|
|
|
__all__ = [
|
|
# Error handling
|
|
"ClinicError",
|
|
"warn",
|
|
"fail",
|
|
|
|
# Formatting helpers
|
|
"SIG_END_MARKER",
|
|
"c_str_repr",
|
|
"c_bytes_repr",
|
|
"c_unichar_repr",
|
|
"docstring_for_c_string",
|
|
"format_escape",
|
|
"indent_all_lines",
|
|
"linear_format",
|
|
"normalize_snippet",
|
|
"pprint_words",
|
|
"suffix_all_lines",
|
|
"wrap_declarations",
|
|
"wrapped_c_string_literal",
|
|
|
|
# Identifier helpers
|
|
"ensure_legal_c_identifier",
|
|
"is_legal_c_identifier",
|
|
"is_legal_py_identifier",
|
|
|
|
# Utility functions
|
|
"FormatCounterFormatter",
|
|
"NULL",
|
|
"NullType",
|
|
"Sentinels",
|
|
"VersionTuple",
|
|
"compute_checksum",
|
|
"create_regex",
|
|
"unknown",
|
|
"unspecified",
|
|
"write_file",
|
|
]
|
|
|
|
|
|
CLINIC_PREFIX: Final = "__clinic_"
|
|
CLINIC_PREFIXED_ARGS: Final = frozenset(
|
|
{
|
|
"_keywords",
|
|
"_parser",
|
|
"args",
|
|
"argsbuf",
|
|
"fastargs",
|
|
"kwargs",
|
|
"kwds",
|
|
"kwnames",
|
|
"nargs",
|
|
"noptargs",
|
|
"return_value",
|
|
}
|
|
)
|