question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: invalid syntax in dumpscript

See original GitHub issue

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,

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mristrophcommented, 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

0reactions
yeojin-devcommented, Nov 25, 2019

Could you close this issue? I fixed. 😃 @trbs

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid Syntax in Python: Common Reasons for SyntaxError
When the interpreter encounters invalid syntax in Python code, it will raise a SyntaxError exception and provide a traceback with some helpful information...
Read more >
SyntaxError: invalid syntax on python script - Stack Overflow
When I run the same script on my Raspberry Pi, it returns a SyntaxError: invalid syntax (line 155) on the except Exception line....
Read more >
How to Fix Invalid SyntaxError in Python - Rollbar
The Python SyntaxError occurs when the interpreter encounters invalid syntax in code. Learn how to fix it.
Read more >
SyntaxError: invalid syntax - Python Morsels
Python's "invalid syntax" error message comes up often, especially when you're first learning Python. What usually causes this error and how can you...
Read more >
SyntaxError in Python: How to Handle Invalid Syntax in Python
What is a SyntaxError ? Syntax is the arrangement of words and phrases to create valid sentences in a programming language. A syntax...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found