diff options
author | Bruno Alla <browniebroke@users.noreply.github.com> | 2019-06-05 20:23:11 +0100 |
---|---|---|
committer | Asif Saif Uddin <auvipy@gmail.com> | 2019-06-06 01:23:11 +0600 |
commit | e65bddb9f5cf3bcbeefba21bb1c4f0ec215d44b9 (patch) | |
tree | 9843961fc7c24ff36b6f30d755b12643f27248f7 | |
parent | 772f1d751858623225f672f4afefddd1515085b9 (diff) | |
download | kombu-e65bddb9f5cf3bcbeefba21bb1c4f0ec215d44b9.tar.gz |
Use a sentinel value as default instead of None (#1055)
The build from Celery is broken because one test tries to enable all serializers by calling `disable_insecure_serializers(allowed=None)``, but because `None` is the default value, the function fallback to the default behaviour.
Use a sentinel value as default instead of `None` should fix this.
-rw-r--r-- | kombu/serialization.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/kombu/serialization.py b/kombu/serialization.py index 6106fba8..609c68cf 100644 --- a/kombu/serialization.py +++ b/kombu/serialization.py @@ -410,8 +410,10 @@ _setupfuns = { 'application/x-msgpack': register_msgpack, } +NOTSET = object() -def enable_insecure_serializers(choices=None): + +def enable_insecure_serializers(choices=NOTSET): """Enable serializers that are considered to be unsafe. Note: @@ -419,7 +421,7 @@ def enable_insecure_serializers(choices=None): can also specify a list of serializers (by name or content type) to enable. """ - choices = ['pickle', 'yaml', 'msgpack'] if not choices else choices + choices = ['pickle', 'yaml', 'msgpack'] if choices is NOTSET else choices for choice in choices: try: registry.enable(choice) @@ -427,7 +429,7 @@ def enable_insecure_serializers(choices=None): pass -def disable_insecure_serializers(allowed=None): +def disable_insecure_serializers(allowed=NOTSET): """Disable untrusted serializers. Will disable all serializers except ``json`` @@ -438,7 +440,7 @@ def disable_insecure_serializers(allowed=None): in these formats, but consumers will not accept incoming data using the untrusted content types. """ - allowed = ['json'] if not allowed else allowed + allowed = ['json'] if allowed is NOTSET else allowed for name in registry._decoders: registry.disable(name) if allowed is not None: |