Bug 2062150

Summary: sudo fails to build with Python 3.11: Enhanced error locations in tracebacks are breaking the tests
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: sudoAssignee: Radovan Sroka <rsroka>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: alakatos, kzak, mattdm, matt.fagnani, mhroncok, robatino, rsroka, thrnciar, todd.miller, tosykora, zfridric
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sudo-1.9.11-3.p3.fc37 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-06-22 20:53:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2009537    
Bug Blocks: 2016048, 2045102    

Description Tomáš Hrnčiar 2022-03-09 10:04:05 UTC
sudo fails to build with Python 3.11.0a5.

Running test check_example_io_plugin_fails_with_python_backtrace() ... 
Expectation failed at ./regress/testhelpers.c:98:
  actual is <<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")
                     ^^^^^^^^^^^^^^^^^^^

>>: actual_content
  expected to be <<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")

>>: expected_output
Expectation failed at ./regress/check_python_examples.c:372:
  actual is <<0>>: verify_content(data.stdout_str, expected_path("check_example_io_plugin_fails_with_python_backtrace.stdout"))
  not expected to be <<0>>: 0
FAILED: testcase check_example_io_plugin_fails_with_python_backtrace() at ./regress/check_python_examples.c:1527

The output of the plugin:
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")
                     ^^^^^^^^^^^^^^^^^^^


The error output of the plugin:
Failed to construct plugin instance: [Errno 2] No such file or directory: '/some/not/writable/directory/sudo.log'
Running test check_io_plugin_callbacks_are_optional() ... 
Running test check_io_plugin_reports_error() ... 
Running test check_plugin_unload() ... 
Running test check_example_group_plugin() ... 
Running test check_example_group_plugin_is_able_to_debug() ... 
Expectation failed at ./regress/testhelpers.c:98:
  actual is <<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: 0 
>>: actual_content
  expected to be <<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: REJECT 
>>: expected_output
Expectation failed at ./regress/testhelpers.c:228:
  actual is <<0>>: verify_content(stored_str, reference_path)
  not expected to be <<0>>: 0
Expectation failed at ./regress/check_python_examples.c:513:
  actual is <<0>>: verify_log_lines(expected_path("check_example_group_plugin_is_able_to_debug.log"))
  not expected to be <<0>>: 0
FAILED: testcase check_example_group_plugin_is_able_to_debug() at ./regress/check_python_examples.c:1533

https://docs.python.org/3.11/whatsnew/3.11.html#enhanced-error-locations-in-tracebacks

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/03640716-sudo/

For all our attempts to build sudo with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/sudo/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.11:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/

Let us know here if you have any questions.

Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Todd C. Miller 2022-04-12 01:06:21 UTC
This is fixed by https://www.sudo.ws/repos/sudo/rev/f6a5d1c05b2b

Comment 2 Miro Hrončok 2022-06-22 08:31:04 UTC
*** Bug 2099967 has been marked as a duplicate of this bug. ***

Comment 3 Miro Hrončok 2022-06-22 09:01:42 UTC
I am nominating this as a beta blocker because this pulls in Python 3.10 to (at least) Fedora-KDE-Live-x86_64 making the image unnecessarily big. Now I don't know if this actually violates any criterion, but we should not ship official images with some apps using the previous Python version.

Comment 4 Miro Hrončok 2022-06-22 09:41:03 UTC
As well as Fedora-Workstation-Live-x86_64.

Comment 5 Radovan Sroka 2022-06-22 12:43:56 UTC
Hello, I'm going to fix this right now.

Comment 6 Miro Hrončok 2022-06-22 20:53:51 UTC
Thanks.