From 99a5137c2d7dadbd0602fa0416b2a4f767bd1c58 Mon Sep 17 00:00:00 2001 From: "Patrick K. O'Brien" Date: Thu, 17 Apr 2003 19:46:46 +0000 Subject: [PATCH] Fix line endings for Win and Mac. Separate compile and exec steps for better error handling. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20259 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/wxPython/py/buffer.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/wxPython/wxPython/py/buffer.py b/wxPython/wxPython/py/buffer.py index 5a5f6b9d53..640cc679f4 100644 --- a/wxPython/wxPython/py/buffer.py +++ b/wxPython/wxPython/py/buffer.py @@ -117,17 +117,27 @@ class Buffer: return False syspath = sys.path sys.path = self.syspath - code = self.editor.getText() - module = imp.new_module(str(self.modulename)) - namespace = module.__dict__.copy() + text = self.editor.getText() + text = text.replace('\r\n', '\n') + text = text.replace('\r', '\n') + name = self.modulename or self.name + module = imp.new_module(name) + newspace = module.__dict__.copy() try: try: - exec code in namespace + code = compile(text, name, 'exec') except: - return False + raise +# return False + try: + exec code in newspace + except: + raise +# return False else: + # No problems, so update the namespace. self.interp.locals.clear() - self.interp.locals.update(namespace) + self.interp.locals.update(newspace) return True finally: sys.path = syspath