python-starlette fails to build with Python 3.13.0b1. ___________________________ test_debug_html[asyncio] ___________________________ test_client_factory = functools.partial(<class 'starlette.testclient.TestClient'>, backend='asyncio', backend_options={}) def test_debug_html(test_client_factory: TestClientFactory) -> None: async def app(scope: Scope, receive: Receive, send: Send) -> None: raise RuntimeError("Something went wrong") app = ServerErrorMiddleware(app, debug=True) client = test_client_factory(app, raise_server_exceptions=False) response = client.get("/", headers={"Accept": "text/html, */*"}) assert response.status_code == 500 > assert response.headers["content-type"].startswith("text/html") tests/middleware/test_errors.py:53: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = Headers({}), key = 'content-type' def __getitem__(self, key: str) -> str: """ Return a single header value. If there are multiple headers with the same key, then we concatenate them with commas. See: https://tools.ietf.org/html/rfc7230#section-3.2.2 """ normalized_key = key.lower().encode(self.encoding) items = [ header_value.decode(self.encoding) for _, header_key, header_value in self._list if header_key == normalized_key ] if items: return ", ".join(items) > raise KeyError(key) E KeyError: 'content-type' /usr/lib/python3.13/site-packages/httpx/_models.py:228: KeyError ____________________________ test_debug_html[trio] _____________________________ test_client_factory = functools.partial(<class 'starlette.testclient.TestClient'>, backend='trio', backend_options={}) def test_debug_html(test_client_factory: TestClientFactory) -> None: async def app(scope: Scope, receive: Receive, send: Send) -> None: raise RuntimeError("Something went wrong") app = ServerErrorMiddleware(app, debug=True) client = test_client_factory(app, raise_server_exceptions=False) response = client.get("/", headers={"Accept": "text/html, */*"}) assert response.status_code == 500 > assert response.headers["content-type"].startswith("text/html") tests/middleware/test_errors.py:53: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = Headers({}), key = 'content-type' def __getitem__(self, key: str) -> str: """ Return a single header value. If there are multiple headers with the same key, then we concatenate them with commas. See: https://tools.ietf.org/html/rfc7230#section-3.2.2 """ normalized_key = key.lower().encode(self.encoding) items = [ header_value.decode(self.encoding) for _, header_key, header_value in self._list if header_key == normalized_key ] if items: return ", ".join(items) > raise KeyError(key) E KeyError: 'content-type' /usr/lib/python3.13/site-packages/httpx/_models.py:228: KeyError ___________ test_gzip_ignored_for_responses_with_encoding_set[trio] ____________ cls = <class '_pytest.runner.CallInfo'> func = <function call_runtest_hook.<locals>.<lambda> at 0x7f0fd00a2840> when = 'call' reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>) @classmethod def from_call( cls, func: "Callable[[], TResult]", when: "Literal['collect', 'setup', 'call', 'teardown']", reraise: Optional[ Union[Type[BaseException], Tuple[Type[BaseException], ...]] ] = None, ) -> "CallInfo[TResult]": """Call func, wrapping the result in a CallInfo. :param func: The function to call. Called without arguments. :param when: The phase in which the function is called. :param reraise: Exception or exceptions that shall propagate if raised by the function, instead of being wrapped in the CallInfo. """ excinfo = None start = timing.time() precise_start = timing.perf_counter() try: > result: Optional[TResult] = func() /usr/lib/python3.13/site-packages/_pytest/runner.py:341: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.13/site-packages/_pytest/runner.py:262: in <lambda> lambda: ihook(item=item, **kwds), when=when, reraise=reraise /usr/lib/python3.13/site-packages/pluggy/_hooks.py:493: in __call__ return self._hookexec(self.name, self._hookimpls, kwargs, firstresult) /usr/lib/python3.13/site-packages/pluggy/_manager.py:115: in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) /usr/lib/python3.13/site-packages/_pytest/unraisableexception.py:88: in pytest_runtest_call yield from unraisable_exception_runtest_hook() _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def unraisable_exception_runtest_hook() -> Generator[None, None, None]: with catch_unraisable_exception() as cm: yield if cm.unraisable: if cm.unraisable.err_msg is not None: err_msg = cm.unraisable.err_msg else: err_msg = "Exception ignored in" msg = f"{err_msg}: {cm.unraisable.object!r}\n\n" msg += "".join( traceback.format_exception( cm.unraisable.exc_type, cm.unraisable.exc_value, cm.unraisable.exc_traceback, ) ) > warnings.warn(pytest.PytestUnraisableExceptionWarning(msg)) E pytest.PytestUnraisableExceptionWarning: Exception ignored in: <gzip on 0x7f0fd0276380> E E Traceback (most recent call last): E File "/usr/lib64/python3.13/gzip.py", line 359, in close E fileobj.write(self.compress.flush()) E ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ E ValueError: I/O operation on closed file. /usr/lib/python3.13/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning =========================== short test summary info ============================ https://docs.python.org/3.13/whatsnew/3.13.html For the build logs, see: https://copr-be.cloud.fedoraproject.org/results/@python/python3.13-b1/fedora-rawhide-x86_64/07532355-python-starlette/ For all our attempts to build python-starlette with Python 3.13, see: https://copr.fedorainfracloud.org/coprs/g/python/python3.13-b1/package/python-starlette/ 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.13: https://copr.fedorainfracloud.org/coprs/g/python/python3.13-b1/ Let us know here if you have any questions. Python 3.13 is planned to be included in Fedora 41. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13. 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.
I opened an upstream “discussion,” https://github.com/encode/starlette/discussions/2610; upstream doesn’t want issues opened without screening them through a discussion first.
Following the upstream's advice, I opened issues in the project.
*** Bug 2291931 has been marked as a duplicate of this bug. ***
Since it’s not easy to understand what needs to be patched here, reporting these tests upstream and waiting for a fix is probably the best we can do. For this reason, and since the failing tests are relatively small in number, it would seem to make sense to just skip them and move on until upstream can provide a fix. The problem is that the failures in https://github.com/encode/starlette/issues/2615 aren’t really confined to the originally-reported tests. If you skip those tests, they appear in different tests – and if you skip those, they appear in different tests – and so on, almost endlessly.
I can successfully ignore the problem by adding -W ignore::pytest.PytestUnraisableExceptionWarning to the pytest arguments. I don’t really *like* wallpapering over the problem like this, but I think in this case it is better to build a mostly-OK Starlette and unblock the many dependent packages than to wait on a proper fix.
FEDORA-2024-3c2a4b0d91 (python-starlette-0.37.2-6.fc41) has been submitted as an update to Fedora 41. https://bodhi.fedoraproject.org/updates/FEDORA-2024-3c2a4b0d91
FEDORA-2024-3c2a4b0d91 (python-starlette-0.37.2-6.fc41) has been pushed to the Fedora 41 stable repository. If problem still persists, please make note of it in this bug report.