mirror of
https://github.com/python/cpython.git
synced 2025-09-03 15:31:08 +00:00
gh-94512: Fix forced arg format in AC-processed winreg (GH-94513)
This commit is contained in:
parent
21f6b4d783
commit
9b50f76fcd
2 changed files with 201 additions and 22 deletions
215
PC/clinic/winreg.c.h
generated
215
PC/clinic/winreg.c.h
generated
|
@ -287,17 +287,52 @@ winreg_CreateKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL};
|
static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL};
|
||||||
static _PyArg_Parser _parser = {"O&O&|ii:CreateKeyEx", _keywords, 0};
|
static _PyArg_Parser _parser = {NULL, _keywords, "CreateKeyEx", 0};
|
||||||
|
PyObject *argsbuf[4];
|
||||||
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
|
||||||
HKEY key;
|
HKEY key;
|
||||||
const Py_UNICODE *sub_key;
|
const Py_UNICODE *sub_key;
|
||||||
int reserved = 0;
|
int reserved = 0;
|
||||||
REGSAM access = KEY_WRITE;
|
REGSAM access = KEY_WRITE;
|
||||||
HKEY _return_value;
|
HKEY _return_value;
|
||||||
|
|
||||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf);
|
||||||
clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Opt_Converter, &sub_key, &reserved, &access)) {
|
if (!args) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
if (!clinic_HKEY_converter(args[0], &key)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (args[1] == Py_None) {
|
||||||
|
sub_key = NULL;
|
||||||
|
}
|
||||||
|
else if (PyUnicode_Check(args[1])) {
|
||||||
|
sub_key = PyUnicode_AsWideCharString(args[1], NULL);
|
||||||
|
if (sub_key == NULL) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_PyArg_BadArgument("CreateKeyEx", "argument 'sub_key'", "str or None", args[1]);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!noptargs) {
|
||||||
|
goto skip_optional_pos;
|
||||||
|
}
|
||||||
|
if (args[2]) {
|
||||||
|
reserved = _PyLong_AsInt(args[2]);
|
||||||
|
if (reserved == -1 && PyErr_Occurred()) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!--noptargs) {
|
||||||
|
goto skip_optional_pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
access = _PyLong_AsInt(args[3]);
|
||||||
|
if (access == -1 && PyErr_Occurred()) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
skip_optional_pos:
|
||||||
_return_value = winreg_CreateKeyEx_impl(module, key, sub_key, reserved, access);
|
_return_value = winreg_CreateKeyEx_impl(module, key, sub_key, reserved, access);
|
||||||
if (_return_value == NULL) {
|
if (_return_value == NULL) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -403,16 +438,46 @@ winreg_DeleteKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
static const char * const _keywords[] = {"key", "sub_key", "access", "reserved", NULL};
|
static const char * const _keywords[] = {"key", "sub_key", "access", "reserved", NULL};
|
||||||
static _PyArg_Parser _parser = {"O&O&|ii:DeleteKeyEx", _keywords, 0};
|
static _PyArg_Parser _parser = {NULL, _keywords, "DeleteKeyEx", 0};
|
||||||
|
PyObject *argsbuf[4];
|
||||||
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
|
||||||
HKEY key;
|
HKEY key;
|
||||||
const Py_UNICODE *sub_key;
|
const Py_UNICODE *sub_key;
|
||||||
REGSAM access = KEY_WOW64_64KEY;
|
REGSAM access = KEY_WOW64_64KEY;
|
||||||
int reserved = 0;
|
int reserved = 0;
|
||||||
|
|
||||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf);
|
||||||
clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Converter, &sub_key, &access, &reserved)) {
|
if (!args) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
if (!clinic_HKEY_converter(args[0], &key)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!PyUnicode_Check(args[1])) {
|
||||||
|
_PyArg_BadArgument("DeleteKeyEx", "argument 'sub_key'", "str", args[1]);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
sub_key = PyUnicode_AsWideCharString(args[1], NULL);
|
||||||
|
if (sub_key == NULL) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!noptargs) {
|
||||||
|
goto skip_optional_pos;
|
||||||
|
}
|
||||||
|
if (args[2]) {
|
||||||
|
access = _PyLong_AsInt(args[2]);
|
||||||
|
if (access == -1 && PyErr_Occurred()) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!--noptargs) {
|
||||||
|
goto skip_optional_pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reserved = _PyLong_AsInt(args[3]);
|
||||||
|
if (reserved == -1 && PyErr_Occurred()) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
skip_optional_pos:
|
||||||
return_value = winreg_DeleteKeyEx_impl(module, key, sub_key, access, reserved);
|
return_value = winreg_DeleteKeyEx_impl(module, key, sub_key, access, reserved);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
@ -754,17 +819,52 @@ winreg_OpenKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL};
|
static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL};
|
||||||
static _PyArg_Parser _parser = {"O&O&|ii:OpenKey", _keywords, 0};
|
static _PyArg_Parser _parser = {NULL, _keywords, "OpenKey", 0};
|
||||||
|
PyObject *argsbuf[4];
|
||||||
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
|
||||||
HKEY key;
|
HKEY key;
|
||||||
const Py_UNICODE *sub_key;
|
const Py_UNICODE *sub_key;
|
||||||
int reserved = 0;
|
int reserved = 0;
|
||||||
REGSAM access = KEY_READ;
|
REGSAM access = KEY_READ;
|
||||||
HKEY _return_value;
|
HKEY _return_value;
|
||||||
|
|
||||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf);
|
||||||
clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Opt_Converter, &sub_key, &reserved, &access)) {
|
if (!args) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
if (!clinic_HKEY_converter(args[0], &key)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (args[1] == Py_None) {
|
||||||
|
sub_key = NULL;
|
||||||
|
}
|
||||||
|
else if (PyUnicode_Check(args[1])) {
|
||||||
|
sub_key = PyUnicode_AsWideCharString(args[1], NULL);
|
||||||
|
if (sub_key == NULL) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_PyArg_BadArgument("OpenKey", "argument 'sub_key'", "str or None", args[1]);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!noptargs) {
|
||||||
|
goto skip_optional_pos;
|
||||||
|
}
|
||||||
|
if (args[2]) {
|
||||||
|
reserved = _PyLong_AsInt(args[2]);
|
||||||
|
if (reserved == -1 && PyErr_Occurred()) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!--noptargs) {
|
||||||
|
goto skip_optional_pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
access = _PyLong_AsInt(args[3]);
|
||||||
|
if (access == -1 && PyErr_Occurred()) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
skip_optional_pos:
|
||||||
_return_value = winreg_OpenKey_impl(module, key, sub_key, reserved, access);
|
_return_value = winreg_OpenKey_impl(module, key, sub_key, reserved, access);
|
||||||
if (_return_value == NULL) {
|
if (_return_value == NULL) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -809,17 +909,52 @@ winreg_OpenKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL};
|
static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL};
|
||||||
static _PyArg_Parser _parser = {"O&O&|ii:OpenKeyEx", _keywords, 0};
|
static _PyArg_Parser _parser = {NULL, _keywords, "OpenKeyEx", 0};
|
||||||
|
PyObject *argsbuf[4];
|
||||||
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
|
||||||
HKEY key;
|
HKEY key;
|
||||||
const Py_UNICODE *sub_key;
|
const Py_UNICODE *sub_key;
|
||||||
int reserved = 0;
|
int reserved = 0;
|
||||||
REGSAM access = KEY_READ;
|
REGSAM access = KEY_READ;
|
||||||
HKEY _return_value;
|
HKEY _return_value;
|
||||||
|
|
||||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf);
|
||||||
clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Opt_Converter, &sub_key, &reserved, &access)) {
|
if (!args) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
if (!clinic_HKEY_converter(args[0], &key)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (args[1] == Py_None) {
|
||||||
|
sub_key = NULL;
|
||||||
|
}
|
||||||
|
else if (PyUnicode_Check(args[1])) {
|
||||||
|
sub_key = PyUnicode_AsWideCharString(args[1], NULL);
|
||||||
|
if (sub_key == NULL) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_PyArg_BadArgument("OpenKeyEx", "argument 'sub_key'", "str or None", args[1]);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!noptargs) {
|
||||||
|
goto skip_optional_pos;
|
||||||
|
}
|
||||||
|
if (args[2]) {
|
||||||
|
reserved = _PyLong_AsInt(args[2]);
|
||||||
|
if (reserved == -1 && PyErr_Occurred()) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!--noptargs) {
|
||||||
|
goto skip_optional_pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
access = _PyLong_AsInt(args[3]);
|
||||||
|
if (access == -1 && PyErr_Occurred()) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
skip_optional_pos:
|
||||||
_return_value = winreg_OpenKeyEx_impl(module, key, sub_key, reserved, access);
|
_return_value = winreg_OpenKeyEx_impl(module, key, sub_key, reserved, access);
|
||||||
if (_return_value == NULL) {
|
if (_return_value == NULL) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -1086,10 +1221,36 @@ winreg_SetValue(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
||||||
DWORD type;
|
DWORD type;
|
||||||
PyObject *value_obj;
|
PyObject *value_obj;
|
||||||
|
|
||||||
if (!_PyArg_ParseStack(args, nargs, "O&O&kU:SetValue",
|
if (!_PyArg_CheckPositional("SetValue", nargs, 4, 4)) {
|
||||||
clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Opt_Converter, &sub_key, &type, &value_obj)) {
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
if (!clinic_HKEY_converter(args[0], &key)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (args[1] == Py_None) {
|
||||||
|
sub_key = NULL;
|
||||||
|
}
|
||||||
|
else if (PyUnicode_Check(args[1])) {
|
||||||
|
sub_key = PyUnicode_AsWideCharString(args[1], NULL);
|
||||||
|
if (sub_key == NULL) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_PyArg_BadArgument("SetValue", "argument 2", "str or None", args[1]);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!_PyLong_UnsignedLong_Converter(args[2], &type)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (!PyUnicode_Check(args[3])) {
|
||||||
|
_PyArg_BadArgument("SetValue", "argument 4", "str", args[3]);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (PyUnicode_READY(args[3]) == -1) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
value_obj = args[3];
|
||||||
return_value = winreg_SetValue_impl(module, key, sub_key, type, value_obj);
|
return_value = winreg_SetValue_impl(module, key, sub_key, type, value_obj);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
@ -1160,10 +1321,30 @@ winreg_SetValueEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
||||||
DWORD type;
|
DWORD type;
|
||||||
PyObject *value;
|
PyObject *value;
|
||||||
|
|
||||||
if (!_PyArg_ParseStack(args, nargs, "O&O&OkO:SetValueEx",
|
if (!_PyArg_CheckPositional("SetValueEx", nargs, 5, 5)) {
|
||||||
clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Opt_Converter, &value_name, &reserved, &type, &value)) {
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
if (!clinic_HKEY_converter(args[0], &key)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
if (args[1] == Py_None) {
|
||||||
|
value_name = NULL;
|
||||||
|
}
|
||||||
|
else if (PyUnicode_Check(args[1])) {
|
||||||
|
value_name = PyUnicode_AsWideCharString(args[1], NULL);
|
||||||
|
if (value_name == NULL) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_PyArg_BadArgument("SetValueEx", "argument 2", "str or None", args[1]);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
reserved = args[2];
|
||||||
|
if (!_PyLong_UnsignedLong_Converter(args[3], &type)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
value = args[4];
|
||||||
return_value = winreg_SetValueEx_impl(module, key, value_name, reserved, type, value);
|
return_value = winreg_SetValueEx_impl(module, key, value_name, reserved, type, value);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
@ -1274,4 +1455,4 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg)
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=9782b1630b59e201 input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=504fc17ae25a7c75 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -217,13 +217,11 @@ class winreg.HKEYType "PyHKEYObject *" "&PyHKEY_Type"
|
||||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=4c964eba3bf914d6]*/
|
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=4c964eba3bf914d6]*/
|
||||||
|
|
||||||
/*[python input]
|
/*[python input]
|
||||||
class REGSAM_converter(CConverter):
|
class REGSAM_converter(int_converter):
|
||||||
type = 'REGSAM'
|
type = 'REGSAM'
|
||||||
format_unit = 'i'
|
|
||||||
|
|
||||||
class DWORD_converter(CConverter):
|
class DWORD_converter(unsigned_long_converter):
|
||||||
type = 'DWORD'
|
type = 'DWORD'
|
||||||
format_unit = 'k'
|
|
||||||
|
|
||||||
class HKEY_converter(CConverter):
|
class HKEY_converter(CConverter):
|
||||||
type = 'HKEY'
|
type = 'HKEY'
|
||||||
|
@ -249,7 +247,7 @@ class self_return_converter(CReturnConverter):
|
||||||
data.return_conversion.append(
|
data.return_conversion.append(
|
||||||
'return_value = (PyObject *)_return_value;\n')
|
'return_value = (PyObject *)_return_value;\n')
|
||||||
[python start generated code]*/
|
[python start generated code]*/
|
||||||
/*[python end generated code: output=da39a3ee5e6b4b0d input=22f7aedc6d68e80e]*/
|
/*[python end generated code: output=da39a3ee5e6b4b0d input=2ebb7a4922d408d6]*/
|
||||||
|
|
||||||
#include "clinic/winreg.c.h"
|
#include "clinic/winreg.c.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue