#25192: Can't Squash Migration that uses migrations.RunPython.noop in Python2
----------------------------+--------------------
Reporter: jpulec | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
When trying to squash a set of migrations, if one of them uses
migrations.RunPython.noop for a backwards or forward operation, a
ValueError is raised due to an attempt to serialize an unbound method. Not
sure if there should be a special check for that operation when attempting
to run squashmigrations with Python2.
Traceback:
{{{
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "/var/venv/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 338, in
execute_from_command_line
utility.execute()
File "/var/venv/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/venv/local/lib/python2.7/site-
packages/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/venv/local/lib/python2.7/site-
packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/var/venv/local/lib/python2.7/site-
packages/django/core/management/commands/squashmigrations.py", line 141,
in handle
fh.write(writer.as_string())
File "/var/venv/local/lib/python2.7/site-
packages/django/db/migrations/writer.py", line 166, in as_string
operation_string, operation_imports =
OperationWriter(operation).serialize()
File "/var/venv/local/lib/python2.7/site-
packages/django/db/migrations/writer.py", line 124, in serialize
_write(arg_name, arg_value)
File "/var/venv/local/lib/python2.7/site-
packages/django/db/migrations/writer.py", line 87, in _write
arg_string, arg_imports = MigrationWriter.serialize(_arg_value)
File "/var/venv/local/lib/python2.7/site-
packages/django/db/migrations/writer.py", line 435, in serialize
% (value.__name__, module_name, get_docs_version()))
ValueError: Could not find function noop in
django.db.migrations.operations.special.
Please note that due to Python 2 limitations, you cannot serialize unbound
method functions (e.g. a method declared and used in the same class body).
Please move the function into the main module body to use migrations.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25192>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.e3dad0aaeb22907449c51b5f372a5da2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.