def checkLineEndingsRFunction(self): from RestrictedPython.RCompile import RFunction gen = RFunction( p='', body='# testing\r\nprint "testing"\r\nreturn printed\n', name='test', filename='<test>', globals=(), ) gen.mode = 'exec' # if the source has any line ending other than \n by the time # parse() is called, then you'll get a syntax error. gen.parse()
def checkEmpty(self): rf = RFunction("", "", "issue945", "empty.py", {}) rf.parse() rf2 = RFunction("", "# still empty\n\n# by", "issue945", "empty.py", {}) rf2.parse()
def _compiler(self, *args, **kw): kw['globals'] = kw['globalize'] del kw['globalize'] gen = RFunction(*args, **kw) gen.rm = RestrictionMutator() return compileAndTuplize(gen)