Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: invalid syntax in dumpscript #1230

Open
martinvol opened this issue Aug 2, 2018 · 6 comments

Comments

@martinvol
Copy link

commented Aug 2, 2018

After generating a dumpscrip, I called it somewhere else and I got a syntax error. I'm aware this is not the way the documentation suggest for running the script, but the syntax error shouldn't be there anyway, I didn't try but it would also fail doing ./manage.py runscript out

python out.py

  File "out.txt", line 136
    pictures_picture_3.owner_user =  importer.locate_object(User, "id", User, "id", 1, {'id': 1, 'password': 'XXXX', 'last_login': datetime.datetime(2018, 7, 30, 3, 19, 37, 885214, tzinfo=<UTC>), 'is_superuser': True, 'first_name': 'Martín', 'last_name': 'Volpe', 'is_staff': True, 'is_active': True, 'date_joined': datetime.datetime(2010, 1, 11, 21, 45, 36, tzinfo=<UTC>), 'email': 'XX@gmail.com', 'slug': 'martinvol'} )
                                                                                                                                                   ^
SyntaxError: invalid syntax

The error is with tzinfo=<UTC>

Django 2.0.7
django-extensions 2.0.7
Pyton 3.6.4

If you are struggling with the error yourself, you can walk around generating the user manually (if it doesn't exist yet) and replace

owner_user = importer.locate_object(User, "id", User, "id", 1, {'id': 1, 'password': 'XXXX', 'last_login': datetime.datetime(2018, 7, 30, 3, 19, 37, 885214, tzinfo=<UTC>), 'is_superuser': True, 'first_name': 'Martín', 'last_name': 'Volpe', 'is_staff': True, 'is_active': True, 'date_joined': datetime.datetime(2010, 1, 11, 21, 45, 36, tzinfo=<UTC>), 'email': 'XX@gmail.com', 'slug': 'martinvol'} )

with:

owner_user = User.objects.get(email='XX@gmail.com')

Best,

@trbs

This comment has been minimized.

Copy link
Member

commented Aug 2, 2018

Seems an error in serializing those datetime's. In other places it's serialized as:

"dateutil.parser.parse(\"%s\")" % value.isoformat()

This is probably the best way to do it here as well.

You think you can create a PR for this or at least a PR that creates a test in the testsuite that fails on the current behavior ? (eg: asserting that the output does not contain )

@the-bionic

This comment has been minimized.

Copy link

commented Sep 5, 2018

Happy to pick this up as a new contributor. But I am having a hard time reproducing the error.

@trbs

This comment has been minimized.

Copy link
Member

commented Sep 5, 2018

@the-bionic awesome ! I hope @martinvol can help create a reproducible test case.

@bravetheheat

This comment has been minimized.

Copy link

commented Oct 12, 2018

Having this error as well.

@martinvol

This comment has been minimized.

Copy link
Author

commented Oct 12, 2018

@mristroph

This comment has been minimized.

Copy link

commented May 30, 2019

I consider this a bug in pytz, not django-extensions. Root cause here is that repr(pytz.utc) is "<UTC>", which can't be eval'ed.

See here: https://bugs.launchpad.net/pytz/+bug/1709127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.