sudo-project / sudo

Utility to execute a command as another user
https://www.sudo.ws
Other
1.14k stars 209 forks source link

check_example_io_plugin_fails_with_python_backtrace fails with Python 3.13 due to changed backtrace format #374

Closed AdamWill closed 2 months ago

AdamWill commented 2 months ago

Python 3.13 changes the backtrace format, so instead of what the test expects to see:

Example sudo python plugin will log to /some/not/writable/directory/sudo.log
Traceback:
  File "SRC_DIR/example_io_plugin.py", line 64, in __init__
    self._open_log_file(path.join(log_path, "sudo.log"))
  File "SRC_DIR/example_io_plugin.py", line 134, in _open_log_file
    self._log_file = open(log_path, "a")

We get this:

Example sudo python plugin will log to /some/not/writable/directory/sudo.log
Traceback:
  File "SRC_DIR/example_io_plugin.py", line 64, in __init__
    self._open_log_file(path.join(log_path, "sudo.log"))
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "SRC_DIR/example_io_plugin.py", line 134, in _open_log_file
    self._log_file = open(log_path, "a")
                     ~~~~^^^^^^^^^^^^^^^

There are two obvious ways to deal with this - expect different output for Python 3.13+ and Python <= 3.12, or drop the lines containing only ~, ^ and whitespace characters before doing the comparison - but I'm not much of a C coder so I don't know how to do the second off the top of my head (I will try and figure it out, though), and I don't know if there's a 'standard' way of checking the Python version that we should use if going down that path...

millert commented 2 months ago

Thanks for the heads-up. This is fixed by 89918ca

AdamWill commented 2 months ago

oh, hey, you already had a thing. handy! thanks. :)