Since py2.7 compile() supports Win and Mac newlines. Also input in 'exec' mode does not have to end in a newline anymore.
This commit is contained in:
@@ -199,11 +199,7 @@ class RestrictedError(Exception):
|
||||
|
||||
|
||||
def compile2(code, layer):
|
||||
"""
|
||||
The ``+'\\n'`` is necessary else compile fails when code ends in a comment.
|
||||
"""
|
||||
|
||||
return compile(code.rstrip().replace('\r\n', '\n') + '\n', layer, 'exec')
|
||||
return compile(code.rstrip(), layer, 'exec')
|
||||
|
||||
|
||||
def restricted(code, environment=None, layer='Unknown'):
|
||||
|
||||
Reference in New Issue
Block a user