--- /dev/null
+.. change::
+ :tags: bug, engine
+ :tickets: 7130
+
+ Fixed issue where the deprecation warning for the :class:`.URL` constructor
+ which indicates that the :meth:`.URL.create` method should be used would
+ not emit if a full positional argument list of seven arguments were passed;
+ additionally, validation of URL arguments will now occur if the constructor
+ is called in this way, which was being skipped previously.
"""
def __new__(self, *arg, **kw):
- if not kw and len(arg) == 7:
+ if kw.pop("_new_ok", False):
return super(URL, self).__new__(self, *arg, **kw)
else:
util.warn_deprecated(
cls._assert_port(port),
cls._assert_none_str(database, "database"),
cls._str_dict(query),
+ _new_ok=True,
)
@classmethod
for key in set(self.query).difference(names)
}
),
+ _new_ok=True,
)
@util.memoized_property
)
eq_(u1, url.make_url("somedriver://user@hostname:52"))
+ def test_deprecated_constructor_all_args(self):
+ """test #7130"""
+ with testing.expect_deprecated(
+ r"Calling URL\(\) directly is deprecated and will be "
+ "disabled in a future release."
+ ):
+ u1 = url.URL(
+ "somedriver",
+ "user",
+ "secret",
+ "10.20.30.40",
+ 1234,
+ "DB",
+ {"key": "value"},
+ )
+ eq_(
+ u1,
+ url.make_url(
+ "somedriver://user:secret@10.20.30.40:1234/DB?key=value"
+ ),
+ )
+
+ @testing.requires.python3
+ def test_arg_validation_all_seven_posn(self):
+ """test #7130"""
+ with testing.expect_deprecated(
+ r"Calling URL\(\) directly is deprecated and will be "
+ "disabled in a future release."
+ ):
+
+ assert_raises_message(
+ TypeError,
+ "drivername must be a string",
+ url.URL,
+ b"somedriver",
+ "user",
+ "secret",
+ "10.20.30.40",
+ 1234,
+ "DB",
+ {"key": "value"},
+ )
+
def test_deprecated_translate_connect_args_names(self):
u = url.make_url("somedriver://user@hostname:52")