<!-- Provide a general summary of your proposed changes in the Title field above -->
### Description
<!-- Describe your changes in detail -->
### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)
-->
This pull request is:
- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [X] A short code fix
- please include the issue number, and create an issue if none exists, which
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests. one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.
Fixes #10079
**Have a nice day!**
Closes: #10080
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10080
Pull-request-sha:
133c7d6c35a75f23089fd4b1c0438f1a4640a924
Change-Id: Ie3d998385743680756bc10fbb4f4227669d57648
--- /dev/null
+.. change::
+ :tags: bug, engine
+ :tickets: 10079
+
+ The behavior of the :func:`make_url` has been changed.
+ Now if you pass an incorrect argument type to the :func:`make_url`,
+ an ArgumentError error will be thrown.
+ Correct argument types is: str, URL
\ No newline at end of file
if isinstance(name_or_url, str):
return _parse_url(name_or_url)
+ elif not isinstance(name_or_url, URL) and not hasattr(
+ name_or_url, "_sqla_is_testing_if_this_is_a_mock_object"
+ ):
+ raise exc.ArgumentError(
+ f"Expected string or URL object, got {name_or_url!r}"
+ )
else:
return name_or_url
with expect_raises_message(TypeError, ".*immutable"):
url_obj.query["foo"] = "hoho"
+ def test_create_engine_url_invalid(self):
+ with expect_raises_message(
+ exc.ArgumentError,
+ "Expected string or URL object, got 42",
+ ):
+ create_engine(42)
+
@testing.combinations(
(
"foo1=bar1&foo2=bar2",