Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twisted.web generates deprecation warnings internally #12172

Open
twm opened this issue May 6, 2024 · 4 comments
Open

twisted.web generates deprecation warnings internally #12172

twm opened this issue May 6, 2024 · 4 comments
Labels

Comments

@twm
Copy link
Contributor

twm commented May 6, 2024

Describe the incorrect behavior you saw

The twisted.web tests fail when DeprecationWarning is made an error.

FAILED (skips=4, errors=22, successes=541)
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/_synctest.py", line 1071, in run
    warnings.warn_explicit(**w)
builtins.DeprecationWarning: Passing method to twisted.internet.ssl.CertificateOptions was deprecated in Twisted 17.1.0. Please use a combination of insecurelyLowerMinimumTo, raiseMinimumTo, and lowerMaximumSecurityTo instead, as Twisted will correctly configure the method.

twisted.web.test.test_agent.WebClientContextFactoryTests.test_returnsContext
twisted.web.test.test_agent.WebClientContextFactoryTests.test_setsTrustRootOnContextToDefaultTrustRoot
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_cgi.py", line 17, in <module>
    from twisted.web import client, http, http_headers, resource, server, twcgi
  File ".../src/twisted/web/twcgi.py", line 20, in <module>
    from twisted.web import http, resource, server, static
  File ".../src/twisted/web/static.py", line 35, in <module>
    dangerousPathError = resource._UnsafeNoResource("Invalid request URL.")
  File ".../src/twisted/python/deprecate.py", line 296, in deprecatedFunction
    warn(warningString, DeprecationWarning, stacklevel=2)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_cgi
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_distrib.py", line 29, in <module>
    from twisted.web import client, distrib, resource, server, static
  File ".../src/twisted/web/distrib.py", line 28, in <module>
    from twisted.web import http, resource, server, static, util
  File ".../src/twisted/web/static.py", line 35, in <module>
    dangerousPathError = resource._UnsafeNoResource("Invalid request URL.")
  File ".../src/twisted/python/deprecate.py", line 296, in deprecatedFunction
    warn(warningString, DeprecationWarning, stacklevel=2)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_distrib
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_domhelpers.py", line 13, in <module>
    from twisted.web import domhelpers, microdom
  File ".../src/twisted/web/domhelpers.py", line 15, in <module>
    from twisted.web import microdom
  File ".../src/twisted/web/microdom.py", line 38, in <module>
    warnings.warn(warningString, DeprecationWarning, stacklevel=3)
builtins.DeprecationWarning: twisted.web.microdom was deprecated at Twisted 23.10.0

twisted.web.test.test_domhelpers
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_http.py", line 182, in <module>
    class LoopbackHTTPClient(http.HTTPClient):
  File ".../src/twisted/python/deprecate.py", line 478, in __getattribute__
    value = deprecatedAttribute.get()
  File ".../src/twisted/python/deprecate.py", line 533, in get
    warn(message, DeprecationWarning, stacklevel=3)
builtins.DeprecationWarning: twisted.web.http.HTTPClient was deprecated in Twisted NEXT: Use twisted.web.client.Agent instead.

twisted.web.test.test_http
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_http2.py", line 21, in <module>
    from twisted.web.test.test_http import (
  File ".../src/twisted/web/test/test_http.py", line 182, in <module>
    class LoopbackHTTPClient(http.HTTPClient):
  File ".../src/twisted/python/deprecate.py", line 478, in __getattribute__
    value = deprecatedAttribute.get()
  File ".../src/twisted/python/deprecate.py", line 533, in get
    warn(message, DeprecationWarning, stacklevel=3)
builtins.DeprecationWarning: twisted.web.http.HTTPClient was deprecated in Twisted NEXT: Use twisted.web.client.Agent instead.

twisted.web.test.test_http2
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_httpauth.py", line 33, in <module>
    from twisted.web.static import Data
  File ".../src/twisted/web/static.py", line 35, in <module>
    dangerousPathError = resource._UnsafeNoResource("Invalid request URL.")
  File ".../src/twisted/python/deprecate.py", line 296, in deprecatedFunction
    warn(warningString, DeprecationWarning, stacklevel=2)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_httpauth
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_proxy.py", line 10, in <module>
    from twisted.web.proxy import (
  File ".../src/twisted/web/proxy.py", line 26, in <module>
    from twisted.web.http import _QUEUED_SENTINEL, HTTPChannel, HTTPClient, Request
  File ".../src/twisted/python/deprecate.py", line 478, in __getattribute__
    value = deprecatedAttribute.get()
  File ".../src/twisted/python/deprecate.py", line 533, in get
    warn(message, DeprecationWarning, stacklevel=3)
builtins.DeprecationWarning: twisted.web.http.HTTPClient was deprecated in Twisted NEXT: Use twisted.web.client.Agent instead.

twisted.web.test.test_proxy
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/_synctest.py", line 1071, in run
    warnings.warn_explicit(**w)
builtins.DeprecationWarning: twisted.web.resource._UnsafeErrorPage.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.errorPage instead, which properly escapes HTML. instead

twisted.web.test.test_resource.ErrorPageTests.test_errorPageRendering
twisted.web.test.test_resource.ErrorPageTests.test_getChild
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/_synctest.py", line 1071, in run
    warnings.warn_explicit(**w)
builtins.DeprecationWarning: twisted.web.resource._UnsafeForbiddenResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.forbidden instead, which properly escapes HTML. instead

twisted.web.test.test_resource.ErrorPageTests.test_forbiddenResourceRendering
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/_synctest.py", line 1071, in run
    warnings.warn_explicit(**w)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_resource.ErrorPageTests.test_noResourceRendering
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_script.py", line 14, in <module>
    from twisted.web.script import PythonScript, ResourceScriptDirectory
  File ".../src/twisted/web/script.py", line 17, in <module>
    from twisted.web import http, resource, server, static, util
  File ".../src/twisted/web/static.py", line 35, in <module>
    dangerousPathError = resource._UnsafeNoResource("Invalid request URL.")
  File ".../src/twisted/python/deprecate.py", line 296, in deprecatedFunction
    warn(warningString, DeprecationWarning, stacklevel=2)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_script
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_static.py", line 25, in <module>
    from twisted.web import http, resource, script, static
  File ".../src/twisted/web/script.py", line 17, in <module>
    from twisted.web import http, resource, server, static, util
  File ".../src/twisted/web/static.py", line 35, in <module>
    dangerousPathError = resource._UnsafeNoResource("Invalid request URL.")
  File ".../src/twisted/python/deprecate.py", line 296, in deprecatedFunction
    warn(warningString, DeprecationWarning, stacklevel=2)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_static
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_tap.py", line 22, in <module>
    from twisted.web import demo
  File ".../src/twisted/web/demo.py", line 9, in <module>
    from twisted.web import static
  File ".../src/twisted/web/static.py", line 35, in <module>
    dangerousPathError = resource._UnsafeNoResource("Invalid request URL.")
  File ".../src/twisted/python/deprecate.py", line 296, in deprecatedFunction
    warn(warningString, DeprecationWarning, stacklevel=2)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_tap
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_template.py", line 38, in <module>
    from twisted.web.test.test_web import DummyRequest
  File ".../src/twisted/web/test/test_web.py", line 28, in <module>
    from twisted.web.static import Data
  File ".../src/twisted/web/static.py", line 35, in <module>
    dangerousPathError = resource._UnsafeNoResource("Invalid request URL.")
  File ".../src/twisted/python/deprecate.py", line 296, in deprecatedFunction
    warn(warningString, DeprecationWarning, stacklevel=2)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_template
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_vhost.py", line 14, in <module>
    from twisted.web.static import Data
  File ".../src/twisted/web/static.py", line 35, in <module>
    dangerousPathError = resource._UnsafeNoResource("Invalid request URL.")
  File ".../src/twisted/python/deprecate.py", line 296, in deprecatedFunction
    warn(warningString, DeprecationWarning, stacklevel=2)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_vhost
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_web.py", line 28, in <module>
    from twisted.web.static import Data
  File ".../src/twisted/web/static.py", line 35, in <module>
    dangerousPathError = resource._UnsafeNoResource("Invalid request URL.")
  File ".../src/twisted/python/deprecate.py", line 296, in deprecatedFunction
    warn(warningString, DeprecationWarning, stacklevel=2)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_web
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_wsgi.py", line 29, in <module>
    from twisted.web.test.test_web import DummyChannel
  File ".../src/twisted/web/test/test_web.py", line 28, in <module>
    from twisted.web.static import Data
  File ".../src/twisted/web/static.py", line 35, in <module>
    dangerousPathError = resource._UnsafeNoResource("Invalid request URL.")
  File ".../src/twisted/python/deprecate.py", line 296, in deprecatedFunction
    warn(warningString, DeprecationWarning, stacklevel=2)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_wsgi
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_xml.py", line 16, in <module>
    from twisted.web import domhelpers, microdom, sux
  File ".../src/twisted/web/domhelpers.py", line 15, in <module>
    from twisted.web import microdom
  File ".../src/twisted/web/microdom.py", line 38, in <module>
    warnings.warn(warningString, DeprecationWarning, stacklevel=3)
builtins.DeprecationWarning: twisted.web.microdom was deprecated at Twisted 23.10.0

twisted.web.test.test_xml
===============================================================================
[ERROR]
Traceback (most recent call last):
  File ".../src/twisted/trial/runner.py", line 616, in loadPackage
    module = modinfo.load()
  File ".../src/twisted/python/modules.py", line 393, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File ".../src/twisted/python/reflect.py", line 297, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File ".../src/twisted/python/reflect.py", line 238, in _importAndCheckStack
    return __import__(importName)
  File ".../src/twisted/web/test/test_xmlrpc.py", line 27, in <module>
    from twisted.web import client, http, server, static, xmlrpc
  File ".../src/twisted/web/static.py", line 35, in <module>
    dangerousPathError = resource._UnsafeNoResource("Invalid request URL.")
  File ".../src/twisted/python/deprecate.py", line 296, in deprecatedFunction
    warn(warningString, DeprecationWarning, stacklevel=2)
builtins.DeprecationWarning: twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead

twisted.web.test.test_xmlrpc
-------------------------------------------------------------------------------
Ran 561 tests in 3.771s

FAILED (skips=4, errors=22, successes=541)

Describe how to cause this behavior

Run the tests like:

.tox/alldeps-nocov/bin/python -Werror::DeprecationWarning -m twisted.trial twisted.web

Describe the correct behavior you'd like to see

Twisted should not generate deprecation warnings internally (see also #6348).

Also, the deliberate warnings should not be mangled like "twisted.web.resource._UnsafeNoResource.__init__ was deprecated in Twisted 22.10.0; please use Use twisted.web.pages.notFound instead, which properly escapes HTML. instead".

@twm twm added the bug label May 6, 2024
@glyph
Copy link
Member

glyph commented May 6, 2024

the deliberate warnings should be mangled like

I hope you mean "should not be mangled like"?

@twm
Copy link
Contributor Author

twm commented May 6, 2024

the deliberate warnings should be mangled like

I hope you mean "should not be mangled like"?

Indeed I did! Fixed.

@adiroiban
Copy link
Member

Thanks.

I feel like we need some support from trial to catch all warnings and have an option to fail on warnings.

I think that something like this is availabe in pytest.

I tried to search the GitHub Issues but I could not find any existing ticket/issue for trial for such a feature.

Do you think it would help ?

@twm
Copy link
Contributor Author

twm commented May 12, 2024

@adiroiban I think that #6348 is that ticket. Before we can enforce this in CI we have a lot of cleanup to do, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants