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:
@@ -117,17 +117,27 @@ class Buffer:
|
|||||||
return False
|
return False
|
||||||
syspath = sys.path
|
syspath = sys.path
|
||||||
sys.path = self.syspath
|
sys.path = self.syspath
|
||||||
code = self.editor.getText()
|
text = self.editor.getText()
|
||||||
module = imp.new_module(str(self.modulename))
|
text = text.replace('\r\n', '\n')
|
||||||
namespace = module.__dict__.copy()
|
text = text.replace('\r', '\n')
|
||||||
|
name = self.modulename or self.name
|
||||||
|
module = imp.new_module(name)
|
||||||
|
newspace = module.__dict__.copy()
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
exec code in namespace
|
code = compile(text, name, 'exec')
|
||||||
except:
|
except:
|
||||||
return False
|
raise
|
||||||
|
# return False
|
||||||
|
try:
|
||||||
|
exec code in newspace
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
# return False
|
||||||
else:
|
else:
|
||||||
|
# No problems, so update the namespace.
|
||||||
self.interp.locals.clear()
|
self.interp.locals.clear()
|
||||||
self.interp.locals.update(namespace)
|
self.interp.locals.update(newspace)
|
||||||
return True
|
return True
|
||||||
finally:
|
finally:
|
||||||
sys.path = syspath
|
sys.path = syspath
|
||||||
|
Reference in New Issue
Block a user