We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
RFC: Only accept delimited string in DelimitedList
`DelimitedList` accepts either a list or a delimited string (e.g. "foo,bar,baz").

I'd like to make it more strict by only accepting a delimited list. Rather than adding a `strict` parameter, I'm thinking of dropping the whole "also accept a list" feature.

Any reason to support both?

I understand it inherits from `List` because once the string is parsed, it can be deserialized as a normal list. But are there cases where you'd expect either a list or a delimited string?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/webargs/fields.py`
Content:
```
1 """Field classes.
2 
3 Includes all fields from `marshmallow.fields` in addition to a custom
4 `Nested` field and `DelimitedList`.
5 
6 All fields can optionally take a special `location` keyword argument, which
7 tells webargs where to parse the request argument from.
8 
9 .. code-block:: python
10 
11     args = {
12         "active": fields.Bool(location="query"),
13         "content_type": fields.Str(data_key="Content-Type", location="headers"),
14     }
15 
16 Note: `data_key` replaced `load_from` in marshmallow 3.
17 When using marshmallow 2, use `load_from`.
18 """
19 import marshmallow as ma
20 
21 # Expose all fields from marshmallow.fields.
22 from marshmallow.fields import *  # noqa: F40
23 from webargs.compat import MARSHMALLOW_VERSION_INFO
24 from webargs.dict2schema import dict2schema
25 
26 __all__ = ["DelimitedList"] + ma.fields.__all__
27 
28 
29 class Nested(ma.fields.Nested):
30     """Same as `marshmallow.fields.Nested`, except can be passed a dictionary as
31     the first argument, which will be converted to a `marshmallow.Schema`.
32 
33     .. note::
34 
35         The schema class here will always be `marshmallow.Schema`, regardless
36         of whether a custom schema class is set on the parser. Pass an explicit schema
37         class if necessary.
38     """
39 
40     def __init__(self, nested, *args, **kwargs):
41         if isinstance(nested, dict):
42             nested = dict2schema(nested)
43         super().__init__(nested, *args, **kwargs)
44 
45 
46 class DelimitedList(ma.fields.List):
47     """Same as `marshmallow.fields.List`, except can load from either a list or
48     a delimited string (e.g. "foo,bar,baz").
49 
50     :param Field cls_or_instance: A field class or instance.
51     :param str delimiter: Delimiter between values.
52     :param bool as_string: Dump values to string.
53     """
54 
55     delimiter = ","
56 
57     def __init__(self, cls_or_instance, delimiter=None, as_string=False, **kwargs):
58         self.delimiter = delimiter or self.delimiter
59         self.as_string = as_string
60         super().__init__(cls_or_instance, **kwargs)
61 
62     def _serialize(self, value, attr, obj):
63         ret = super()._serialize(value, attr, obj)
64         if self.as_string:
65             return self.delimiter.join(format(each) for each in ret)
66         return ret
67 
68     def _deserialize(self, value, attr, data, **kwargs):
69         try:
70             ret = (
71                 value
72                 if ma.utils.is_iterable_but_not_string(value)
73                 else value.split(self.delimiter)
74             )
75         except AttributeError:
76             if MARSHMALLOW_VERSION_INFO[0] < 3:
77                 self.fail("invalid")
78             else:
79                 raise self.make_error("invalid")
80         return super()._deserialize(ret, attr, data, **kwargs)
81
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/webargs/fields.py b/src/webargs/fields.py
--- a/src/webargs/fields.py
+++ b/src/webargs/fields.py
@@ -44,37 +44,35 @@
 
 
 class DelimitedList(ma.fields.List):
-    """Same as `marshmallow.fields.List`, except can load from either a list or
-    a delimited string (e.g. "foo,bar,baz").
+    """A field which is similar to a List, but takes its input as a delimited
+    string (e.g. "foo,bar,baz").
+
+    Like List, it can be given a nested field type which it will use to
+    de/serialize each element of the list.
 
     :param Field cls_or_instance: A field class or instance.
     :param str delimiter: Delimiter between values.
-    :param bool as_string: Dump values to string.
     """
 
+    default_error_messages = {"invalid": "Not a valid delimited list."}
     delimiter = ","
 
-    def __init__(self, cls_or_instance, delimiter=None, as_string=False, **kwargs):
+    def __init__(self, cls_or_instance, delimiter=None, **kwargs):
         self.delimiter = delimiter or self.delimiter
-        self.as_string = as_string
         super().__init__(cls_or_instance, **kwargs)
 
     def _serialize(self, value, attr, obj):
-        ret = super()._serialize(value, attr, obj)
-        if self.as_string:
-            return self.delimiter.join(format(each) for each in ret)
-        return ret
+        # serializing will start with List serialization, so that we correctly
+        # output lists of non-primitive types, e.g. DelimitedList(DateTime)
+        return self.delimiter.join(
+            format(each) for each in super()._serialize(value, attr, obj)
+        )
 
     def _deserialize(self, value, attr, data, **kwargs):
-        try:
-            ret = (
-                value
-                if ma.utils.is_iterable_but_not_string(value)
-                else value.split(self.delimiter)
-            )
-        except AttributeError:
+        # attempting to deserialize from a non-string source is an error
+        if not isinstance(value, (str, bytes)):
             if MARSHMALLOW_VERSION_INFO[0] < 3:
                 self.fail("invalid")
             else:
                 raise self.make_error("invalid")
-        return super()._deserialize(ret, attr, data, **kwargs)
+        return super()._deserialize(value.split(self.delimiter), attr, data, **kwargs)

{"golden_diff": "diff --git a/src/webargs/fields.py b/src/webargs/fields.py\n--- a/src/webargs/fields.py\n+++ b/src/webargs/fields.py\n@@ -44,37 +44,35 @@\n \n \n class DelimitedList(ma.fields.List):\n-    \"\"\"Same as `marshmallow.fields.List`, except can load from either a list or\n-    a delimited string (e.g. \"foo,bar,baz\").\n+    \"\"\"A field which is similar to a List, but takes its input as a delimited\n+    string (e.g. \"foo,bar,baz\").\n+\n+    Like List, it can be given a nested field type which it will use to\n+    de/serialize each element of the list.\n \n     :param Field cls_or_instance: A field class or instance.\n     :param str delimiter: Delimiter between values.\n-    :param bool as_string: Dump values to string.\n     \"\"\"\n \n+    default_error_messages = {\"invalid\": \"Not a valid delimited list.\"}\n     delimiter = \",\"\n \n-    def __init__(self, cls_or_instance, delimiter=None, as_string=False, **kwargs):\n+    def __init__(self, cls_or_instance, delimiter=None, **kwargs):\n         self.delimiter = delimiter or self.delimiter\n-        self.as_string = as_string\n         super().__init__(cls_or_instance, **kwargs)\n \n     def _serialize(self, value, attr, obj):\n-        ret = super()._serialize(value, attr, obj)\n-        if self.as_string:\n-            return self.delimiter.join(format(each) for each in ret)\n-        return ret\n+        # serializing will start with List serialization, so that we correctly\n+        # output lists of non-primitive types, e.g. DelimitedList(DateTime)\n+        return self.delimiter.join(\n+            format(each) for each in super()._serialize(value, attr, obj)\n+        )\n \n     def _deserialize(self, value, attr, data, **kwargs):\n-        try:\n-            ret = (\n-                value\n-                if ma.utils.is_iterable_but_not_string(value)\n-                else value.split(self.delimiter)\n-            )\n-        except AttributeError:\n+        # attempting to deserialize from a non-string source is an error\n+        if not isinstance(value, (str, bytes)):\n             if MARSHMALLOW_VERSION_INFO[0] < 3:\n                 self.fail(\"invalid\")\n             else:\n                 raise self.make_error(\"invalid\")\n-        return super()._deserialize(ret, attr, data, **kwargs)\n+        return super()._deserialize(value.split(self.delimiter), attr, data, **kwargs)\n", "issue": "RFC: Only accept delimited string in DelimitedList\n`DelimitedList` accepts either a list or a delimited string (e.g. \"foo,bar,baz\").\r\n\r\nI'd like to make it more strict by only accepting a delimited list. Rather than adding a `strict` parameter, I'm thinking of dropping the whole \"also accept a list\" feature.\r\n\r\nAny reason to support both?\r\n\r\nI understand it inherits from `List` because once the string is parsed, it can be deserialized as a normal list. But are there cases where you'd expect either a list or a delimited string?\n", "before_files": [{"content": "\"\"\"Field classes.\n\nIncludes all fields from `marshmallow.fields` in addition to a custom\n`Nested` field and `DelimitedList`.\n\nAll fields can optionally take a special `location` keyword argument, which\ntells webargs where to parse the request argument from.\n\n.. code-block:: python\n\n    args = {\n        \"active\": fields.Bool(location=\"query\"),\n        \"content_type\": fields.Str(data_key=\"Content-Type\", location=\"headers\"),\n    }\n\nNote: `data_key` replaced `load_from` in marshmallow 3.\nWhen using marshmallow 2, use `load_from`.\n\"\"\"\nimport marshmallow as ma\n\n# Expose all fields from marshmallow.fields.\nfrom marshmallow.fields import *  # noqa: F40\nfrom webargs.compat import MARSHMALLOW_VERSION_INFO\nfrom webargs.dict2schema import dict2schema\n\n__all__ = [\"DelimitedList\"] + ma.fields.__all__\n\n\nclass Nested(ma.fields.Nested):\n    \"\"\"Same as `marshmallow.fields.Nested`, except can be passed a dictionary as\n    the first argument, which will be converted to a `marshmallow.Schema`.\n\n    .. note::\n\n        The schema class here will always be `marshmallow.Schema`, regardless\n        of whether a custom schema class is set on the parser. Pass an explicit schema\n        class if necessary.\n    \"\"\"\n\n    def __init__(self, nested, *args, **kwargs):\n        if isinstance(nested, dict):\n            nested = dict2schema(nested)\n        super().__init__(nested, *args, **kwargs)\n\n\nclass DelimitedList(ma.fields.List):\n    \"\"\"Same as `marshmallow.fields.List`, except can load from either a list or\n    a delimited string (e.g. \"foo,bar,baz\").\n\n    :param Field cls_or_instance: A field class or instance.\n    :param str delimiter: Delimiter between values.\n    :param bool as_string: Dump values to string.\n    \"\"\"\n\n    delimiter = \",\"\n\n    def __init__(self, cls_or_instance, delimiter=None, as_string=False, **kwargs):\n        self.delimiter = delimiter or self.delimiter\n        self.as_string = as_string\n        super().__init__(cls_or_instance, **kwargs)\n\n    def _serialize(self, value, attr, obj):\n        ret = super()._serialize(value, attr, obj)\n        if self.as_string:\n            return self.delimiter.join(format(each) for each in ret)\n        return ret\n\n    def _deserialize(self, value, attr, data, **kwargs):\n        try:\n            ret = (\n                value\n                if ma.utils.is_iterable_but_not_string(value)\n                else value.split(self.delimiter)\n            )\n        except AttributeError:\n            if MARSHMALLOW_VERSION_INFO[0] < 3:\n                self.fail(\"invalid\")\n            else:\n                raise self.make_error(\"invalid\")\n        return super()._deserialize(ret, attr, data, **kwargs)\n", "path": "src/webargs/fields.py"}], "after_files": [{"content": "\"\"\"Field classes.\n\nIncludes all fields from `marshmallow.fields` in addition to a custom\n`Nested` field and `DelimitedList`.\n\nAll fields can optionally take a special `location` keyword argument, which\ntells webargs where to parse the request argument from.\n\n.. code-block:: python\n\n    args = {\n        \"active\": fields.Bool(location=\"query\"),\n        \"content_type\": fields.Str(data_key=\"Content-Type\", location=\"headers\"),\n    }\n\nNote: `data_key` replaced `load_from` in marshmallow 3.\nWhen using marshmallow 2, use `load_from`.\n\"\"\"\nimport marshmallow as ma\n\n# Expose all fields from marshmallow.fields.\nfrom marshmallow.fields import *  # noqa: F40\nfrom webargs.compat import MARSHMALLOW_VERSION_INFO\nfrom webargs.dict2schema import dict2schema\n\n__all__ = [\"DelimitedList\"] + ma.fields.__all__\n\n\nclass Nested(ma.fields.Nested):\n    \"\"\"Same as `marshmallow.fields.Nested`, except can be passed a dictionary as\n    the first argument, which will be converted to a `marshmallow.Schema`.\n\n    .. note::\n\n        The schema class here will always be `marshmallow.Schema`, regardless\n        of whether a custom schema class is set on the parser. Pass an explicit schema\n        class if necessary.\n    \"\"\"\n\n    def __init__(self, nested, *args, **kwargs):\n        if isinstance(nested, dict):\n            nested = dict2schema(nested)\n        super().__init__(nested, *args, **kwargs)\n\n\nclass DelimitedList(ma.fields.List):\n    \"\"\"A field which is similar to a List, but takes its input as a delimited\n    string (e.g. \"foo,bar,baz\").\n\n    Like List, it can be given a nested field type which it will use to\n    de/serialize each element of the list.\n\n    :param Field cls_or_instance: A field class or instance.\n    :param str delimiter: Delimiter between values.\n    \"\"\"\n\n    default_error_messages = {\"invalid\": \"Not a valid delimited list.\"}\n    delimiter = \",\"\n\n    def __init__(self, cls_or_instance, delimiter=None, **kwargs):\n        self.delimiter = delimiter or self.delimiter\n        super().__init__(cls_or_instance, **kwargs)\n\n    def _serialize(self, value, attr, obj):\n        # serializing will start with List serialization, so that we correctly\n        # output lists of non-primitive types, e.g. DelimitedList(DateTime)\n        return self.delimiter.join(\n            format(each) for each in super()._serialize(value, attr, obj)\n        )\n\n    def _deserialize(self, value, attr, data, **kwargs):\n        # attempting to deserialize from a non-string source is an error\n        if not isinstance(value, (str, bytes)):\n            if MARSHMALLOW_VERSION_INFO[0] < 3:\n                self.fail(\"invalid\")\n            else:\n                raise self.make_error(\"invalid\")\n        return super()._deserialize(value.split(self.delimiter), attr, data, **kwargs)\n", "path": "src/webargs/fields.py"}]}