Bug 2081670

Summary: python-cherrypy fails to build with Python 3.11: AssertionError: Error page does not contain '\n raise ValueError()\nValueError' in traceback
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: python-cherrypyAssignee: Miro Hrončok <mhroncok>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dradez, igor.raits, jcaratza, mhroncok, mrunge, python-sig, thrnciar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-cherrypy-18.6.1-5.fc37 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-06-16 22:27:35 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:    
Bug Blocks: 2016048    

Description Tomáš Hrnčiar 2022-05-04 10:43:00 UTC
python-cherrypy fails to build with Python 3.11.0a7.

To reproduce this failure one needs to backport this patch[0] for cherrypy and use patched python-jaraco-text(available in python3.11 COPR)[1].

[0] https://github.com/cherrypy/cherrypy/pull/1945
[1] https://src.fedoraproject.org/rpms/python-jaraco-text/pull-request/2

=================================== FAILURES ===================================
_____________________ RequestObjectTests.testErrorHandling _____________________

self = <cherrypy.test.test_request_obj.RequestObjectTests testMethod=testErrorHandling>

    def testErrorHandling(self):
        self.getPage('/error/missing')
        self.assertStatus(404)
        self.assertErrorPage(404, "The path '/error/missing' was not found.")
    
        ignore = helper.webtest.ignored_exceptions
        ignore.append(ValueError)
        try:
            valerr = '\n    raise ValueError()\nValueError'
            self.getPage('/error/page_method')
>           self.assertErrorPage(500, pattern=valerr)

ignore     = []
self       = <cherrypy.test.test_request_obj.RequestObjectTests testMethod=testErrorHandling>
valerr     = '\n    raise ValueError()\nValueError'

cherrypy/test/test_request_obj.py:562: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cherrypy/test/helper.py:356: in assertErrorPage
    self._handlewebError(msg % repr(pattern))
        epage      = b'<!DOCTYPE\\ html\\ PUBLIC\\\n"\\-//W3C//DTD\\ XHTML\\ 1\\.0\\ Transitional//EN"\\\n"http://www\\.w3\\.org/TR/xhtml1/...rg">CherryPy\\ 18\\.6\\.1</a>\\\n\\ \\ \\ \\ \\ \\ </span>\\\n\\ \\ \\ \\ </div>\\\n\\ \\ \\ \\ </body>\\\n</html>\\\n'
        esc        = <function CPWebCase.assertErrorPage.<locals>.esc at 0x7fa5e201b2e0>
        m          = <re.Match object; span=(0, 1735), match=b'<!DOCTYPE html PUBLIC\n"-//W3C//DTD XHTML 1.0 Tr>
        message    = None
        msg        = 'Error page does not contain %s in traceback'
        page       = b'<!DOCTYPE html PUBLIC\n"-//W3C//DTD XHTML 1.0 Transitional//EN"\n"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona...   Powered by <a href="http://www.cherrypy.org">CherryPy 18.6.1</a>\n      </span>\n    </div>\n    </body>\n</html>\n'
        pattern    = '\n    raise ValueError()\nValueError'
        self       = <cherrypy.test.test_request_obj.RequestObjectTests testMethod=testErrorHandling>
        status     = 500
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <cherrypy.test.test_request_obj.RequestObjectTests testMethod=testErrorHandling>
msg = "Error page does not contain '\\n    raise ValueError()\\nValueError' in traceback"

    def _handlewebError(self, msg):  # noqa: C901  # FIXME
        print('')
        print('    ERROR: %s' % msg)
    
        if not self.interactive:
>           raise self.failureException(msg)
E           AssertionError: Error page does not contain '\n    raise ValueError()\nValueError' in traceback

msg        = "Error page does not contain '\\n    raise ValueError()\\nValueError' in traceback"
self       = <cherrypy.test.test_request_obj.RequestObjectTests testMethod=testErrorHandling>

/usr/lib/python3.11/site-packages/cheroot/test/webtest.py:259: AssertionError
----------------------------- Captured stdout call -----------------------------

    ERROR: Error page does not contain '\n    raise ValueError()\nValueError' in traceback
------------------------------ Captured log call -------------------------------
INFO     cherrypy.access.140350438129808:_cplogging.py:283 127.0.0.1 - - [04/May/2022:10:00:12] "GET /error/missing HTTP/1.1" 404 1495 "" ""
ERROR    cherrypy.error.140350438129808:_cplogging.py:213 [04/May/2022:10:00:12] HTTP 
Traceback (most recent call last):
  File "/builddir/build/BUILD/CherryPy-18.6.1/cherrypy/_cprequest.py", line 638, in respond
    self._do_respond(path_info)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/CherryPy-18.6.1/cherrypy/_cprequest.py", line 697, in _do_respond
    response.body = self.handler()
                    ^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/CherryPy-18.6.1/cherrypy/lib/encoding.py", line 223, in __call__
    self.body = self.oldhandler(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/CherryPy-18.6.1/cherrypy/_cpdispatch.py", line 54, in __call__
    return self.callable(*self.args, **self.kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/CherryPy-18.6.1/cherrypy/test/test_request_obj.py", line 182, in page_method
    raise ValueError()
    ^^^^^^^^^^^^^^^^^^
ValueError
INFO     cherrypy.access.140350438129808:_cplogging.py:283 127.0.0.1 - - [04/May/2022:10:00:12] "GET /error/page_method HTTP/1.1" 500 1735 "" ""
___________________________ ToolTests.testHookErrors ___________________________

self = <cherrypy.test.test_tools.ToolTests testMethod=testHookErrors>

    def testHookErrors(self):
        self.getPage('/demo/?id=1')
        # If body is "razdrez", then on_end_request is being called too early.
        self.assertBody('A horrorshow lomtick of cherry 3.14159')
        # If this fails, then on_end_request isn't being called at all.
        time.sleep(0.1)
        self.getPage('/demo/ended/1')
        self.assertBody('True')
    
        valerr = '\n    raise ValueError()\nValueError'
        self.getPage('/demo/err?id=3')
        # If body is "razdrez", then on_end_request is being called too early.
>       self.assertErrorPage(502, pattern=valerr)

self       = <cherrypy.test.test_tools.ToolTests testMethod=testHookErrors>
valerr     = '\n    raise ValueError()\nValueError'

cherrypy/test/test_tools.py:278: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cherrypy/test/helper.py:356: in assertErrorPage
    self._handlewebError(msg % repr(pattern))
        epage      = b'<!DOCTYPE\\ html\\ PUBLIC\\\n"\\-//W3C//DTD\\ XHTML\\ 1\\.0\\ Transitional//EN"\\\n"http://www\\.w3\\.org/TR/xhtml1/...rg">CherryPy\\ 18\\.6\\.1</a>\\\n\\ \\ \\ \\ \\ \\ </span>\\\n\\ \\ \\ \\ </div>\\\n\\ \\ \\ \\ </body>\\\n</html>\\\n'
        esc        = <function CPWebCase.assertErrorPage.<locals>.esc at 0x7fa5e20acc20>
        m          = <re.Match object; span=(0, 1650), match=b'<!DOCTYPE html PUBLIC\n"-//W3C//DTD XHTML 1.0 Tr>
        message    = None
        msg        = 'Error page does not contain %s in traceback'
        page       = b'<!DOCTYPE html PUBLIC\n"-//W3C//DTD XHTML 1.0 Transitional//EN"\n"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona...   Powered by <a href="http://www.cherrypy.org">CherryPy 18.6.1</a>\n      </span>\n    </div>\n    </body>\n</html>\n'
        pattern    = '\n    raise ValueError()\nValueError'
        self       = <cherrypy.test.test_tools.ToolTests testMethod=testHookErrors>
        status     = 502
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <cherrypy.test.test_tools.ToolTests testMethod=testHookErrors>
msg = "Error page does not contain '\\n    raise ValueError()\\nValueError' in traceback"

    def _handlewebError(self, msg):  # noqa: C901  # FIXME
        print('')
        print('    ERROR: %s' % msg)
    
        if not self.interactive:
>           raise self.failureException(msg)
E           AssertionError: Error page does not contain '\n    raise ValueError()\nValueError' in traceback

msg        = "Error page does not contain '\\n    raise ValueError()\\nValueError' in traceback"
self       = <cherrypy.test.test_tools.ToolTests testMethod=testHookErrors>

/usr/lib/python3.11/site-packages/cheroot/test/webtest.py:259: AssertionError
----------------------------- Captured stdout call -----------------------------

    ERROR: Error page does not contain '\n    raise ValueError()\nValueError' in traceback
------------------------------ Captured log call -------------------------------
INFO     cherrypy.access.140350438831312:_cplogging.py:283 127.0.0.1 - - [04/May/2022:10:00:40] "GET /demo/?id=1 HTTP/1.1" 200 38 "" ""
INFO     cherrypy.access.140350438831312:_cplogging.py:283 127.0.0.1 - - [04/May/2022:10:00:40] "GET /demo/ended/1 HTTP/1.1" 200 4 "" ""
ERROR    cherrypy.error.140350438831312:_cplogging.py:213 [04/May/2022:10:00:40] HTTP 
Traceback (most recent call last):
  File "/builddir/build/BUILD/CherryPy-18.6.1/cherrypy/_cprequest.py", line 638, in respond
    self._do_respond(path_info)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/CherryPy-18.6.1/cherrypy/_cprequest.py", line 697, in _do_respond
    response.body = self.handler()
                    ^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/CherryPy-18.6.1/cherrypy/lib/encoding.py", line 223, in __call__
    self.body = self.oldhandler(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/CherryPy-18.6.1/cherrypy/_cpdispatch.py", line 54, in __call__
    return self.callable(*self.args, **self.kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/CherryPy-18.6.1/cherrypy/test/test_tools.py", line 204, in err
    raise ValueError()
    ^^^^^^^^^^^^^^^^^^
ValueError
INFO     cherrypy.access.140350438831312:_cplogging.py:283 127.0.0.1 - - [04/May/2022:10:00:40] "GET /demo/err?id=3 HTTP/1.1" 502 1650 "" ""
- generated xml file: /builddir/build/BUILD/CherryPy-18.6.1/.test-results/pytest/results.xml -
============================= slowest 10 durations =============================
10.52s call     cherrypy/test/test_http.py::HTTPTests::test_post_filename_with_special_characters
8.10s call     cherrypy/test/test_caching.py::CacheTest::test_antistampede
5.92s call     cherrypy/test/test_states.py::ServerStateTests::test_4_Autoreload
4.80s call     cherrypy/test/test_states.py::SignalHandlingTests::test_SIGHUP_daemonized
4.01s call     cherrypy/test/test_conn.py::PipelineTests::test_HTTP11_Timeout_after_request
4.00s call     cherrypy/test/test_conn.py::PipelineTests::test_HTTP11_Timeout
3.77s call     cherrypy/test/test_states.py::SignalHandlingTests::test_SIGTERM
2.80s call     cherrypy/test/test_states.py::PluginTests::test_daemonize
2.01s call     cherrypy/test/test_states.py::test_safe_wait_INADDR_ANY
2.00s call     cherrypy/test/test_http.py::HTTPTests::test_no_content_length
=========================== short test summary info ============================
SKIPPED [1] cherrypy/test/helper.py:321: skipped (not running HTTPS)...
SKIPPED [2] cherrypy/test/test_routes.py:22: Install routes to test RoutesDispatcher code
XPASS cherrypy/test/test_caching.py::CacheTest::test_antistampede #1536
FAILED cherrypy/test/test_request_obj.py::RequestObjectTests::testErrorHandling
FAILED cherrypy/test/test_tools.py::ToolTests::testHookErrors - AssertionErro...
= 2 failed, 260 passed, 3 skipped, 1 deselected, 1 xpassed in 99.30s (0:01:39) =

https://docs.python.org/3.11/whatsnew/3.11.html

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

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

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.