Regenerate test output with python 3.10a7

Also adjust debug tests so they pass on older python versions
This commit is contained in:
Todd C. Miller
2021-04-16 15:24:12 -06:00
parent 5ffa915c9c
commit 7c2224584d
4 changed files with 33 additions and 6 deletions

View File

@@ -295,10 +295,33 @@ py_create_string_rep(PyObject *py_object)
if (py_string != NULL) {
const char *bytes = PyUnicode_AsUTF8(py_string);
if (bytes != NULL) {
result = strdup(bytes);
/*
* Convert from old format w/ numeric value to new without it.
* Old: (<DEBUG.ERROR: 2>, 'ERROR level debug message')
* New: (DEBUG.ERROR, 'ERROR level debug message')
*/
if (bytes[0] == '(' && bytes[1] == '<') {
const char *colon = strchr(bytes + 2, ':');
if (colon != NULL && colon[1] == ' ') {
const char *cp = colon + 2;
while (isdigit((unsigned char)*cp))
cp++;
if (cp[0] == '>' && (cp[1] == ',' || cp[1] == '\0')) {
bytes += 2;
if (asprintf(&result, "(%.*s%s", (int)(colon - bytes),
bytes, cp + 1) == -1) {
result = NULL;
goto done;
}
}
}
}
if (result == NULL)
result = strdup(bytes);
}
}
done:
Py_XDECREF(py_string);
debug_return_ptr(result);
}
@@ -326,6 +349,10 @@ _py_debug_python_function(const char *class_name, const char *function_name, con
args_str = py_create_string_rep(py_args);
if (py_args_sorted != NULL)
Py_DECREF(py_args_sorted);
if (strncmp(args_str, "RC.", 3) == 0) {
/* Strip leading RC. to match python 3.10 behavior. */
memmove(args_str, args_str + 3, strlen(args_str + 3) + 1);
}
}
if (py_kwargs != NULL) {
/* Sort by key for consistent output on Python < 3.6 */

View File

@@ -1,5 +1,5 @@
sudo.debug was called with arguments: (<DEBUG.ERROR: 2>, 'My demo purpose plugin shows this ERROR level debug message')
sudo.debug was called with arguments: (<DEBUG.INFO: 6>, 'My demo purpose plugin shows this INFO level debug message')
sudo.debug was called with arguments: (DEBUG.ERROR, 'My demo purpose plugin shows this ERROR level debug message')
sudo.debug was called with arguments: (DEBUG.INFO, 'My demo purpose plugin shows this INFO level debug message')
LogHandler.emit was called
LogHandler.emit was called
sudo.options_as_dict was called with arguments: (('ModulePath=SRC_DIR/example_debugging.py', 'ClassName=DebugDemoPlugin'),)

View File

@@ -1,7 +1,7 @@
__init__ @ SRC_DIR/example_debugging.py:58 calls C function:
sudo.debug was called with arguments: (<DEBUG.ERROR: 2>, 'My demo purpose plugin shows this ERROR level debug message')
sudo.debug was called with arguments: (DEBUG.ERROR, 'My demo purpose plugin shows this ERROR level debug message')
__init__ @ SRC_DIR/example_debugging.py:63 calls C function:
sudo.debug was called with arguments: (<DEBUG.INFO: 6>, 'My demo purpose plugin shows this INFO level debug message')
sudo.debug was called with arguments: (DEBUG.INFO, 'My demo purpose plugin shows this INFO level debug message')
handle @ logging/__init__.py calls C function:
LogHandler.emit was called
handle @ logging/__init__.py calls C function:

View File

@@ -1,4 +1,4 @@
SudoGroupPlugin.__init__ was called with arguments: () [('args', ('ModulePath=SRC_DIR/example_group_plugin.py', 'ClassName=SudoGroupPlugin')), ('version', '1.0')]
SudoGroupPlugin.__init__ returned result: <example_group_plugin.SudoGroupPlugin object>
SudoGroupPlugin.query was called with arguments: ('user', 'group', ('pw_name', 'pw_passwd', 1001, 101, 'pw_gecos', 'pw_dir', 'pw_shell'))
SudoGroupPlugin.query returned result: RC.REJECT
SudoGroupPlugin.query returned result: REJECT