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
This commit is contained in:
Patrick K. O'Brien
2003-04-17 19:46:46 +00:00
parent 6b0fd7830e
commit 99a5137c2d

View File

@@ -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