sphinx-contrib / spelling

A spelling checker for Sphinx-based documentation
https://sphinxcontrib-spelling.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
82 stars 48 forks source link

Clean up allocated TLS socket @ PyPI filter #226

Closed webknjaz closed 2 months ago

webknjaz commented 3 months ago

Invoking python -Werror -m sphinx -b spelling ... surfaces a resource warning related to not releasing the TLS socket that xmlrpc.client.ServerProxy() opens. There's no explicit mention of a cleanup method in the stdlib docs but there's one example with a context manager. I inspected the source code and it seems like we should either use a CM or a rather weird callable interface (xmlrpc.client.ServerProxy()('close')()). I opted for a CM.

[...]
Ignoring wiki words
Ignoring acronyms
Adding package names from PyPI to local dictionary…
Exception ignored in: <ssl.SSLSocket fd=3, family=2, type=1, proto=6, laddr=('192.168.1.114', 53560), raddr=('146.75.120.223', 443)>
Traceback (most recent call last):
  File "~/src/github/a/project/.tox/build-docs/lib/python3.12/site-packages/sphinxcontrib/spelling/builder.py", line 65, in init
    f.append(filters.PyPIFilterFactory())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ResourceWarning: unclosed <ssl.SSLSocket fd=3, family=2, type=1, proto=6, laddr=('192.168.1.114', 53560), raddr=('146.75.120.223', 443)>
Ignoring Python builtins
Ignoring importable module names
Ignoring contributor names
[...]

Disclaimer

This patch is coded in-browser on the GH UI w/ no testing. It might need some love and/or tests.

dhellmann commented 3 months ago

The change looks generally OK. The linter doesn't like the line length and some of the test jobs are failing.

webknjaz commented 3 months ago

I don't think I'll have time to work on this, just wanted to put it out there so it's not lost in my brain and forgotten ;)

webknjaz commented 2 months ago

With https://github.com/sphinx-contrib/spelling/issues/227, it doesn't make sense to fix it. XML-RPC should instead be deleted.