From: Mike Bayer Date: Thu, 8 May 2025 12:34:21 +0000 (-0400) Subject: dont render URL in unparseable URL error message X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aaa28f457eaa3f98c417666b4d0ad4d70ccb1ac0;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git dont render URL in unparseable URL error message The error message that is emitted when a URL cannot be parsed no longer includes the URL itself within the error message. Fixes: #12579 Change-Id: Icd17bd4fe0930036662b6a4fe0264cb13df04ba7 --- diff --git a/doc/build/changelog/unreleased_20/12579.rst b/doc/build/changelog/unreleased_20/12579.rst new file mode 100644 index 0000000000..70c619db09 --- /dev/null +++ b/doc/build/changelog/unreleased_20/12579.rst @@ -0,0 +1,7 @@ +.. change:: + :tags: bug, engine + :tickets: 12579 + + The error message that is emitted when a URL cannot be parsed no longer + includes the URL itself within the error message. + diff --git a/lib/sqlalchemy/engine/url.py b/lib/sqlalchemy/engine/url.py index f72940d4bd..53f767fb92 100644 --- a/lib/sqlalchemy/engine/url.py +++ b/lib/sqlalchemy/engine/url.py @@ -918,5 +918,5 @@ def _parse_url(name: str) -> URL: else: raise exc.ArgumentError( - "Could not parse SQLAlchemy URL from string '%s'" % name + "Could not parse SQLAlchemy URL from given URL string" ) diff --git a/test/engine/test_parseconnect.py b/test/engine/test_parseconnect.py index 254d9c00fe..00cdfc9bf5 100644 --- a/test/engine/test_parseconnect.py +++ b/test/engine/test_parseconnect.py @@ -804,6 +804,13 @@ class CreateEngineTest(fixtures.TestBase): module=mock_dbapi, ) + def test_cant_parse_str(self): + with expect_raises_message( + exc.ArgumentError, + r"^Could not parse SQLAlchemy URL from given URL string$", + ): + create_engine("notarealurl") + def test_urlattr(self): """test the url attribute on ``Engine``."""