Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25807 closed Bug (fixed)

makemigrations failed when CharField has validators=[validate_slug]

Reported by: mrgaolei Owned by: Simon Charette
Component: Migrations Version: 1.9rc1
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Baptiste Mispelon)

Version 1.9rc1
When CharField have a validators=[validate_slug], it can not be makemigrations.

it prompt:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 150, in handle
    self.write_migration_files(changes)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 178, in write_migration_files
    migration_string = writer.as_string()
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/db/migrations/writer.py", line 167, in as_string
    operation_string, operation_imports = OperationWriter(operation).serialize()
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/db/migrations/writer.py", line 124, in serialize
    _write(arg_name, arg_value)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/db/migrations/writer.py", line 76, in _write
    arg_string, arg_imports = MigrationWriter.serialize(item)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/db/migrations/writer.py", line 353, in serialize
    item_string, item_imports = cls.serialize(item)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/db/migrations/writer.py", line 429, in serialize
    return cls.serialize_deconstructed(path, args, kwargs)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/db/migrations/writer.py", line 318, in serialize_deconstructed
    arg_string, arg_imports = cls.serialize(arg)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/db/migrations/writer.py", line 353, in serialize
    item_string, item_imports = cls.serialize(item)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/db/migrations/writer.py", line 473, in serialize
    return cls.serialize_deconstructed(*value.deconstruct())
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/db/migrations/writer.py", line 314, in serialize_deconstructed
    arg_string, arg_imports = cls.serialize(arg)
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/db/migrations/writer.py", line 512, in serialize
    for item in value:
  File "/Users/mrgaolei/Desktop/proton/venv/lib/python2.7/site-packages/django/utils/functional.py", line 205, in inner
    return func(self._wrapped, *args)
TypeError: '_sre.SRE_Pattern' object is not iterable

Change History (6)

comment:1 by Baptiste Mispelon, 9 years ago

Component: UncategorizedMigrations
Description: modified (diff)
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

I can reproduce the issue indeed (couldn't figure out how to make a testcase for it though).

Bisecting the issue points to 2bb1027d6bcdad59624a9d08701e0d2e4a9c0ba7.

Thanks.

comment:2 by Simon Charette, 9 years ago

Owner: changed from nobody to Simon Charette
Status: newassigned

comment:4 by Tim Graham, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Simon Charette <charette.s@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In cc2ca9c:

Fixed #25807 -- Instructed the migration writer about lazy objects.

Thanks to Trac alias mrgaolei for the report, Baptiste for the confirmation
and Tim for the review.

comment:6 by Simon Charette <charette.s@…>, 9 years ago

In b4a1d545:

[1.9.x] Fixed #25807 -- Instructed the migration writer about lazy objects.

Thanks to Trac alias mrgaolei for the report, Baptiste for the confirmation
and Tim for the review.

Backport of cc2ca9c550fbf8fca8684b373a3c8e3618eea08e from master

Note: See TracTickets for help on using tickets.
Back to Top