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

Latest version has Syntax Error in core.py on Python 2.6 #48

Open
jeffp123 opened this issue Jul 16, 2015 · 2 comments
Open

Latest version has Syntax Error in core.py on Python 2.6 #48

jeffp123 opened this issue Jul 16, 2015 · 2 comments

Comments

@jeffp123
Copy link

When I import from dyn.tm.session, I get a syntax error:

Traceback (most recent call last):
  File "dyn-python-test.py", line 1, in <module>
    from dyn.tm.session import DynectSession
  File "/usr/local/lib/python2.6/site-packages/dyn/tm/session.py", line 8, in <module>
    from ..core import SessionEngine
  File "/usr/local/lib/python2.6/site-packages/dyn/core.py", line 23
    return {x: dict_obj[x] for x in dict_obj if dict_obj[x] is not None and
                             ^
SyntaxError: invalid syntax

I am using Python 2.6.5:

$ python --version
Python 2.6.5

and dyn-python-1.1.0

It looks like dict comprehension is a Python 2.7 feature:
https://www.python.org/dev/peps/pep-0274/

However, the documentation says:
"Requires Python 2.6 or higher, or the "simplejson" package."

I suspect that a simple fix would be to change that line to this:

return dict((x, dict_obj[x]) for x in dict_obj if dict_obj[x] is not None and
        not hasattr(dict_obj[x], '__call__'))

However, after doing that it looks like there are other places that are also not Python 2.6 compatible.

So, it might be best to just update the docs to let everyone know that it is not compatible with Python 2.6.

@jeffp123
Copy link
Author

This is also a problem with previous versions. I am getting this error in all releases, going back to 1.0.1, using Python 2.6:

Traceback (most recent call last):
  File "/usr/local/lib/python2.6/site-packages/dyn/__init__.py", line 16, in <module>
    __title__      = '{} version {}'.format(__name__, __version__)

Using format strings without indexes (i.e. '{0} version {1}') was introduced in Python 2.7.

@derekargueta
Copy link

derekargueta commented Jun 4, 2018

@Northover At this point in time, I think it's reasonable to move support to Python 2.7+ and update the README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants