Skip to content

Commit 0067b08

Browse files
committed
Include a final newline in JSON dumps
Inspired by https://code.djangoproject.com/ticket/36177
1 parent f5e09b6 commit 0067b08

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

CHANGELOG.rst

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Next version
77

88
- Raised the minimum version requirements to Python 3.10 and Django 4.2.
99
- Added Django 5.2.
10+
- Changed the JSON dumps to include a final newline. This change is inspired by
11+
the same change to Django.
1012

1113

1214
0.7 (2024-10-28)

feincms3_data/data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def dump_specs(specs, *, mappers=None, objects=None):
100100
_model_queryset(spec).distinct() for spec in specs
101101
)
102102
serializer.serialize(objects, stream=stream)
103-
stream.write("}")
103+
stream.write("}\n")
104104
return stream.getvalue()
105105

106106

tests/testapp/test_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -660,5 +660,5 @@ def test_json_format(self):
660660

661661
self.assertEqual(
662662
data,
663-
'{"version": 1, "specs": [{"model": "testapp.tag"}], "objects": [{"model": "testapp.tag", "pk": 5, "fields": {"name": "Hello", "parent": null}}]}',
663+
'{"version": 1, "specs": [{"model": "testapp.tag"}], "objects": [{"model": "testapp.tag", "pk": 5, "fields": {"name": "Hello", "parent": null}}]}\n',
664664
)

0 commit comments

Comments
 (0)