diff --git a/django/urls/converters.py b/django/urls/converters.py index b36cde1497..d44588174e 100644 --- a/django/urls/converters.py +++ b/django/urls/converters.py @@ -1,8 +1,5 @@ import functools import uuid -import warnings - -from django.utils.deprecation import RemovedInDjango60Warning class IntConverter: @@ -57,14 +54,7 @@ REGISTERED_CONVERTERS = {} def register_converter(converter, type_name): if type_name in REGISTERED_CONVERTERS or type_name in DEFAULT_CONVERTERS: - # RemovedInDjango60Warning: when the deprecation ends, replace with - # raise ValueError(f"Converter {type_name} is already registered.") - warnings.warn( - f"Converter {type_name!r} is already registered. Support for overriding " - "registered converters is deprecated and will be removed in Django 6.0.", - RemovedInDjango60Warning, - stacklevel=2, - ) + raise ValueError(f"Converter {type_name!r} is already registered.") REGISTERED_CONVERTERS[type_name] = converter() get_converters.cache_clear() diff --git a/docs/ref/urls.txt b/docs/ref/urls.txt index 95eb03f35a..ac55bde575 100644 --- a/docs/ref/urls.txt +++ b/docs/ref/urls.txt @@ -150,10 +150,6 @@ The ``converter`` argument is a converter class, and ``type_name`` is the converter name to use in path patterns. See :ref:`registering-custom-path-converters` for an example. -.. deprecated:: 5.1 - - Overriding existing converters is deprecated. - ================================================== ``django.conf.urls`` functions for use in URLconfs ================================================== diff --git a/docs/releases/6.0.txt b/docs/releases/6.0.txt index 5a58dcf599..d8db925fd1 100644 --- a/docs/releases/6.0.txt +++ b/docs/releases/6.0.txt @@ -271,4 +271,5 @@ to remove usage of these features. See :ref:`deprecated-features-5.1` for details on these changes, including how to remove usage of these features. -* ... +* ``django.urls.register_converter()`` no longer allows overriding existing + converters. diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt index 8e57732725..d8de9635ec 100644 --- a/docs/topics/http/urls.txt +++ b/docs/topics/http/urls.txt @@ -183,11 +183,6 @@ Register custom converter classes in your URLconf using ..., ] -.. deprecated:: 5.1 - - Overriding existing converters with ``django.urls.register_converter()`` is - deprecated. - Using regular expressions ========================= diff --git a/tests/urlpatterns/tests.py b/tests/urlpatterns/tests.py index 6c8d6470c0..5f1a45ba1f 100644 --- a/tests/urlpatterns/tests.py +++ b/tests/urlpatterns/tests.py @@ -13,8 +13,7 @@ from django.urls import ( resolve, reverse, ) -from django.urls.converters import REGISTERED_CONVERTERS, IntConverter -from django.utils.deprecation import RemovedInDjango60Warning +from django.urls.converters import IntConverter from django.views import View from .converters import Base64Converter, DynamicConverter @@ -204,35 +203,14 @@ class SimplifiedURLTests(SimpleTestCase): path("foo//", empty_view) def test_warning_override_default_converter(self): - # RemovedInDjango60Warning: when the deprecation ends, replace with - # msg = "Converter 'int' is already registered." - # with self.assertRaisesMessage(ValueError, msg): - msg = ( - "Converter 'int' is already registered. Support for overriding registered " - "converters is deprecated and will be removed in Django 6.0." - ) - try: - with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx: - register_converter(IntConverter, "int") - finally: - REGISTERED_CONVERTERS.pop("int", None) - self.assertEqual(ctx.filename, __file__) + msg = "Converter 'int' is already registered." + with self.assertRaisesMessage(ValueError, msg): + register_converter(IntConverter, "int") def test_warning_override_converter(self): - # RemovedInDjango60Warning: when the deprecation ends, replace with - # msg = "Converter 'base64' is already registered." - # with self.assertRaisesMessage(ValueError, msg): - msg = ( - "Converter 'base64' is already registered. Support for overriding " - "registered converters is deprecated and will be removed in Django 6.0." - ) - try: - with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx: - register_converter(Base64Converter, "base64") - register_converter(Base64Converter, "base64") - finally: - REGISTERED_CONVERTERS.pop("base64", None) - self.assertEqual(ctx.filename, __file__) + msg = "Converter 'base64' is already registered." + with self.assertRaisesMessage(ValueError, msg): + register_converter(Base64Converter, "base64") def test_invalid_view(self): msg = "view must be a callable or a list/tuple in the case of include()."