Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop treating namedtuple as an object when using simplejson #1297

Merged
merged 1 commit into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion kombu/utils/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ class DjangoPromise: # noqa
try:
import simplejson as json
from simplejson.decoder import JSONDecodeError as _DecodeError
_json_extra_kwargs = {'use_decimal': False}
_json_extra_kwargs = {
'use_decimal': False,
'namedtuple_as_object': False,
}
except ImportError: # pragma: no cover
import json # noqa
_json_extra_kwargs = {} # noqa
Expand Down
5 changes: 5 additions & 0 deletions t/unit/utils/test_json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import pytz

from collections import namedtuple
from datetime import datetime
from decimal import Decimal
from uuid import uuid4
Expand Down Expand Up @@ -43,6 +44,10 @@ def test_Decimal(self):
d = Decimal('3314132.13363235235324234123213213214134')
assert loads(dumps({'d': d})), {'d': str(d)}

def test_namedtuple(self):
Foo = namedtuple('Foo', ['bar'])
assert loads(dumps(Foo(123))) == [123]

def test_UUID(self):
id = uuid4()
assert loads(dumps({'u': id})), {'u': str(id)}
Expand Down