Skip to content

🐞 Fix Gateway.gateway_map() to find indirect Gateway subclasses - #854

Open
deronnax wants to merge 1 commit into
cherrypy:mainfrom
deronnax:fix/gateway-map-indirect-subclasses
Open

deronnax wants to merge 1 commit into
cherrypy:mainfrom
deronnax:fix/gateway-map-indirect-subclasses

Conversation

@deronnax

@deronnax deronnax commented Oct 9, 2026 •

Copy link
Copy Markdown

What kind of change does this PR introduce?

  • 🐞 bug fix
  • 🐣 feature
  • 📋 docs update
  • 📋 tests/coverage improvement
  • 📋 refactoring
  • 💥 other

What do these changes do?

While working on a PoC of Radicale with cheroot, this regression showed up.

Gateway.gateway_map() builds its version → class mapping from cls.__subclasses__(), which only returns direct subclasses:

@classmethod
def gateway_map(cls):
    return {gw.version: gw for gw in cls.__subclasses__()}

Since Gateway_u0 subclasses Gateway_10 (not Gateway directly), it is silently excluded from wsgi_gateways. As a result, setting Server.wsgi_version = ('u', 0) raises KeyError: ('u', 0), even though Gateway_u0 / WSGIGateway_u0 is documented as a supported gateway (see the docs).

This used to work when wsgi_gateways was a hardcoded dict (see 2014's fa84a5b), before the refactor to gateway_map().

The fix walks the subclass tree recursively instead of one level deep. A regression test asserts that both (1, 0) and ('u', 0) gateways are discoverable via Gateway.gateway_map().

Are there changes in behavior for the user?

Yes. Selecting WSGI version ('u', 0) works again instead of raising KeyError.

Is it a substantial burden for the maintainers to support this?

No. It is a small, localized change to gateway_map() with a focused regression test.

Related issue number

Discovered while exploring Radicale integration; no open cheroot issue yet.

Checklist

  • I wrote descriptive pull request text above
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences
  • I think the code is well written
  • Unit tests for the changes exist
  • Integration tests for the changes exist (if applicable)
  • I used the same coding conventions as the rest of the project
  • The new code doesn't generate linter offenses
  • Project documentation (in docs/) and inline docstrings reflect the changes
  • My commits each have a descriptive title and a body explaining the why
    (see good commit messages)
  • I have added a change log entry
    (can be done once the PR number is known; alternatively, you can
    use a related issue number if one exists)
  • I'm planning to squash related commits together before final merge
  • I have read the contribution guide and the
    code of conduct

@agentscanapp

agentscanapp Bot commented Oct 9, 2026

Copy link
Copy Markdown

Mixed activity

Activity patterns show a mix of organic and automated signals.

View full analysis →

Evidence
  • Rapid PRs to repository: 6 PRs opened to Pylons/waitress within 8s intervals

Last 5 PRs:

This is an automated analysis by AgentScan

@read-the-docs-community

read-the-docs-community Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 cheroot | 🛠️ Build #35594999 | 📁 Comparing bf537f4 against latest (a6283c1)

  🔍 Preview build  

4 files changed
± genindex/index.html
± history/index.html
± pkg/cheroot.server/index.html
± pkg/cheroot.test.test_wsgi/index.html

@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.25%. Comparing base (f326a75) to head (bf537f4).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #854      +/-   ##
==========================================
+ Coverage   78.20%   78.25%   +0.04%     
==========================================
  Files          41       41              
  Lines        4791     4800       +9     
  Branches      548      549       +1     
==========================================
+ Hits         3747     3756       +9     
  Misses        905      905              
  Partials      139      139              

@deronnax

deronnax commented Oct 9, 2026

Copy link
Copy Markdown
Author

AgentScan is right: I created a batch of PRs for waitress, but those are real bugs identified Claude, no AI slop. I did not intended to open the 6 altogehter, though. I closed them to reopen them one by one to not overwhelm maintainers.

deronnax added a commit to deronnax/cheroot that referenced this pull request Oct 11, 2026
Document the gateway_map regression fix for Towncrier.
@deronnax deronnax changed the title Fix Gateway.gateway_map() to find indirect Gateway subclasses 🐞 Fix Gateway.gateway_map() to find indirect Gateway subclasses Oct 11, 2026
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided A mark meaning that a new change log entry is present within the patch. label Oct 11, 2026
@deronnax
deronnax force-pushed the fix/gateway-map-indirect-subclasses branch from f7ef940 to 56bc200 Compare October 11, 2026 20:02
@deronnax
deronnax force-pushed the fix/gateway-map-indirect-subclasses branch from 56bc200 to a716b3c Compare November 2, 2026 13:11
@deronnax
deronnax marked this pull request as ready for review November 2, 2026 13:14
Gateway.gateway_map() built its version-to-class mapping from
cls.__subclasses__(), which only returns direct subclasses. Since
Gateway_u0 subclasses Gateway_10 rather than Gateway, it was silently
excluded from wsgi_gateways and Server.wsgi_version = ('u', 0) raised
KeyError even though Gateway_u0 is documented as supported.

* walk the Gateway subclass tree iteratively inside gateway_map()
* add a regression test for (1, 0) and ('u', 0) gateway discovery
* add Towncrier fragment 854.bugfix.rst
@deronnax
deronnax force-pushed the fix/gateway-map-indirect-subclasses branch from a716b3c to bf537f4 Compare November 2, 2026 21:40

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentscan:mixed-signals bot:chronographer:provided A mark meaning that a new change log entry is present within the patch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant