pasteorg / paste

Python Paste (core) repository
Other
59 stars 47 forks source link

Test failure with Python 3.11 #72

Closed fabaff closed 1 year ago

fabaff commented 1 year ago

With Python 3.11 there is a test failure. The same test works with Python 3.10.

At first glance I would say that it's related to the DeprecationWarning.

============================= test session starts ==============================
platform linux -- Python 3.11.1, pytest-7.2.0, pluggy-1.0.0
rootdir: /build/source, configfile: setup.cfg, testpaths: tests
collected 151 items / 2 deselected / 149 selected                              

tests/test_cgiapp.py .F..                                                [  2%]
tests/test_cgitb_catcher.py ....                                         [  5%]
[...]

=================================== FAILURES ===================================
__________________________________ test_form ___________________________________

    def test_form():
        app = TestApp(CGIApplication({}, script='form.cgi', path=[data_dir]))
>       res = app.post('', params={'name': b'joe'},
                       upload_files=[('up', 'file.txt', b'x'*10000)])

tests/test_cgiapp.py:45: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
paste/fixture.py:258: in post
    return self._gen_request('POST', url, params=params, headers=headers,
paste/fixture.py:242: in _gen_request
    return self.do_request(req, status=status)
paste/wsgilib.py:351: in raw_interactive
    app_iter = application(basic_environ, start_response)
paste/lint.py:170: in lint_app
    iterator = application(environ, start_response_wrapper)
paste/cgiapp.py:100: in __call__
    proc_communicate(
paste/cgiapp.py:256: in proc_communicate
    stderr.write(six.ensure_text(data))
paste/lint.py:221: in write
    self.errors.write(s)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <paste.wsgilib.ErrorRaiser object at 0x7ffff548c9d0>
value = "/build/source/tests/cgiapp_data/form.cgi:5: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13\n  import cgi\n"

    def write(self, value):
        if not value:
            return
>       raise AssertionError(
            "No errors should be written (got: %r)" % value)
E       AssertionError: No errors should be written (got: "/build/source/tests/cgiapp_data/form.cgi:5: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13\n  import cgi\n")

paste/wsgilib.py:382: AssertionError
=============================== warnings summary ===============================
paste/request.py:20
  /build/source/paste/request.py:20: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
    import cgi

paste/cgitb_catcher.py:12
  /build/source/paste/cgitb_catcher.py:12: DeprecationWarning: 'cgitb' is deprecated and slated for removal in Python 3.13
    import cgitb

paste/urlparser.py:10
  /build/source/paste/urlparser.py:10: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
    import imp
[...]
=========================== short test summary info ============================
cdent commented 1 year ago

Hmm, yeah, good analysis.

Is this something that has come up in "real" use or instead showed up as a result of trying to package Paste with newer python versions?

My feelings these days is that anybody still using Paste should stop.

I know that isn't always possible which is why the README says what it says about "life support" and "patches accepted".

If you've got a patch in mind to fix this (that doesn't simply hide the warning :) ) I'd happily accept it and release a new version.

Otherwise it will likely take me a bit of time before I have a chance to look at it.

cdent commented 1 year ago

The actual test failure for this was fixed in 36fd9632d6ad880b24177a08435eb8e1f9b01714 by quieting warnings in the test.

However, the issue with cgi being removed in 3.13 remains the case. I'll create a separate issue for that so that people can choose to fix it if they like, but do not intend to fix it myself. My hope is that people will stop using Paste by the time cgi is removed as it used all over the place.