diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-02-09 10:54:02 +0000 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-02-09 10:54:02 +0000 |
| commit | 98dd8dd02e6a005266866ab1cb4a2ec00dce0193 (patch) | |
| tree | bf871584b80ed257e50f7a5b90bbfce4ceec51b7 /django/db | |
| parent | 38b4adc6960d28483124509aa363dadbe8cc17a6 (diff) | |
Fixed #21892: RunPython no longer accepts strings
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/migrations/operations/special.py | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/django/db/migrations/operations/special.py b/django/db/migrations/operations/special.py index 65fd8125fc..8d001034ad 100644 --- a/django/db/migrations/operations/special.py +++ b/django/db/migrations/operations/special.py @@ -109,22 +109,15 @@ class RunPython(Operation): def __init__(self, code, reverse_code=None): # Forwards code - if isinstance(code, six.string_types): - # Trim any leading whitespace that is at the start of all code lines - # so users can nicely indent code in migration files - code = textwrap.dedent(code) - # Run the code through a parser first to make sure it's at least - # syntactically correct - self.code = compile(code, "<string>", "exec") - else: - self.code = code + if not callable(code): + raise ValueError("RunPython must be supplied with a callable") + self.code = code # Reverse code if reverse_code is None: self.reverse_code = None - elif isinstance(reverse_code, six.string_types): - reverse_code = textwrap.dedent(reverse_code) - self.reverse_code = compile(reverse_code, "<string>", "exec") else: + if not callable(reverse_code): + raise ValueError("RunPython must be supplied with callable arguments") self.reverse_code = reverse_code def state_forwards(self, app_label, state): |
