Skip to content

MultiDict converts byte values to int list since version 3.1.0 #2994

@ricky-provan

Description

@ricky-provan

Since version 3.1.0, when I create a MultiDict with a bytes value as input it stores the bytes value in the MultiDict as a list of integer values. Prior to 3.1.0, this would preserve the bytes value in the MultiDict.

To reproduce, run this snippet with werkzeug installed:

from werkzeug.datastructures import MultiDict

multi_dict = MultiDict({
    'bytes_value': b'abc',
    'str_value': 'abc'
})

print(multi_dict)

Running the above on version 3.1.0 prints:
MultiDict([('bytes_value', 97), ('bytes_value', 98), ('bytes_value', 99), ('str_value', 'abc')])

Running the snippet with version 3.0.6 prints:
MultiDict([('bytes_value', b'abc'), ('str_value', 'abc')])

I expected the behaviour from 3.0.6 to be preserved in this case

Environment:

  • Python version: 3.11
  • Werkzeug version: >= 3.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions