#31787: dumpdata/loaddata BinaryField base64 decoding fails
-----------------------------------------+------------------------
Reporter: David | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
Exporting a model with a `BinaryField` via `dumpdata` fails to reimport
via `loaddata` returning an `Incorrect padding` error. The same error
occurs with either json or xml formatted data. In the application, I can
b64 encode the field data and copy it elsewhere just fine, but there seems
to be an issue with the builtin serializer/deserializer is doing the same.
There doesn't seem to be a note anywhere about this being expected
behaviour so thought this was worth a ticket.
Stacktrace:
{{{
Traceback (most recent call last):
File "../manage.py", line 21, in <module>
main()
File "../manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/user/.env/app/local/lib/python3.6/site-
packages/django/core/management/__init__.py", line 381, in
execute_from_command_line
utility.execute()
File "/home/user/.env/app/local/lib/python3.6/site-
packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/user/.env/app/local/lib/python3.6/site-
packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/user/.env/app/local/lib/python3.6/site-
packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/home/user/.env/app/local/lib/python3.6/site-
packages/django/core/management/commands/loaddata.py", line 72, in handle
self.loaddata(fixture_labels)
File "/home/user/.env/app/local/lib/python3.6/site-
packages/django/core/management/commands/loaddata.py", line 114, in
loaddata
self.load_label(fixture_label)
File "/home/user/.env/app/local/lib/python3.6/site-
packages/django/core/management/commands/loaddata.py", line 172, in
load_label
for obj in objects:
File "/home/user/.env/app/local/lib/python3.6/site-
packages/django/core/serializers/xml_serializer.py", line 168, in __next__
return self._handle_object(node)
File "/home/user/.env/app/local/lib/python3.6/site-
packages/django/core/serializers/xml_serializer.py", line 230, in
_handle_object
value = field.to_python(getInnerText(field_node).strip())
File "/home/user/.env/app/local/lib/python3.6/site-
packages/django/db/models/fields/__init__.py", line 2306, in to_python
return memoryview(b64decode(value.encode('ascii')))
File "/home/user/.env/app/lib64/python3.6/base64.py", line 87, in
b64decode
return binascii.a2b_base64(s)
binascii.Error: Problem installing fixture '/var/www/site-
app/services/dump.xml': Incorrect padding
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31787>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.7cc3450fa426b63b3b6e645214b9fc65%40djangoproject.com.