use default_factory for parser_options field (#5476)

* use default_factory for field parser_options

When running mitmproxy under python 3.11, the following exception
is thrown otherwise:
```
ValueError: mutable default <class 'mitmproxy.contentviews.grpc.ProtoParser.ParserOptions'> for field parser_options is not allowed: use default_factory
```

Fixes #5474.

* add changelog for mitmproxy#5474
This commit is contained in:
rathann 2022-07-23 10:15:03 +02:00 committed by GitHub
parent 156089229f
commit 55a64b7ad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -15,6 +15,8 @@
* Remove overambitious assertions in the HTTP state machine,
fix some error handling.
([#5383](https://github.com/mitmproxy/mitmproxy/issues/5383), @mhils)
* Use default_factory for parser_options.
([#5474](https://github.com/mitmproxy/mitmproxy/issues/5474), @rathann)
## 15 May 2022: mitmproxy 8.1.0

View File

@ -951,7 +951,7 @@ def format_grpc(
@dataclass
class ViewConfig:
parser_options: ProtoParser.ParserOptions = ProtoParser.ParserOptions()
parser_options: ProtoParser.ParserOptions = field(default_factory=ProtoParser.ParserOptions)
parser_rules: list[ProtoParser.ParserRule] = field(default_factory=list)