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

Newline insertion in FunctionMaker.make #23

Closed
azjps opened this issue Feb 4, 2016 · 3 comments
Closed

Newline insertion in FunctionMaker.make #23

azjps opened this issue Feb 4, 2016 · 3 comments

Comments

@azjps
Copy link

azjps commented Feb 4, 2016

Hi, I was wondering what the reason was behind removing the append of the newline in this commit. As far as I can tell, without a trailing newline python 2.7.x will raise a SyntaxError: unexpected EOF while parsing for compile("def foo(): return bar", ..) (and since its a SyntaxError, it can be pretty difficult to trace with the pdb family). Thanks

@micheles
Copy link
Owner

micheles commented Feb 5, 2016

Are you sure you are using Python 2.7? That newline was removed because needed in Python versions < 2.6 and I have dropped support for such versions in decorator 4.0.

For me it is working even without newline:

Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> dic = {}
>>> execute('def f(): pass', dic)
>>> dic['f']
<function f at 0x7f675bd9a758>

@micheles
Copy link
Owner

micheles commented Feb 6, 2016

Anyway, I have restored the newline, since it is not a big effort on my part. Please upgrade to release 4.0.7

@micheles micheles closed this as completed Feb 6, 2016
@azjps
Copy link
Author

azjps commented Feb 8, 2016

Thanks again. This error that was coming up for me was over here:

Python 2.7.6 (default, Jun  9 2015, 02:14:28) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> compile('def f(): pass', '', 'single')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "", line 1
    def f(): pass
                ^
SyntaxError: unexpected EOF while parsing

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