Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/client
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14888/com/win32comext/axscript/client
Modified Files:
Tag: py3k
error.py pyscript.py
Log Message:
Merge various changes from trunk and py3k-integration bzr branch
Index: pyscript.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/pyscript.py,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -C2 -d -r1.11 -r1.11.2.1
*** pyscript.py 6 May 2007 12:03:51 -0000 1.11
--- pyscript.py 26 Nov 2008 07:17:39 -0000 1.11.2.1
***************
*** 8,25 ****
"""
- import framework
import winerror
import win32com
import win32api
import pythoncom
- from win32com.axscript import axscript
- import win32com.server.register
import sys
import traceback
- import scriptdispatch
import re
import win32com.client.dynamic
! from framework import RaiseAssert, trace, Exception, SCRIPTTEXT_FORCEEXECUTION, SCRIPTTEXT_ISEXPRESSION, SCRIPTTEXT_ISPERSISTENT
PyScript_CLSID = "{DF630910-1C1D-11d0-AE36-8C0F5E000000}"
--- 8,26 ----
"""
import winerror
import win32com
import win32api
import pythoncom
import sys
import traceback
import re
import win32com.client.dynamic
+ from win32com.axscript.client import framework, scriptdispatch
+ from win32com.axscript import axscript
+ import win32com.server.register
! from win32com.axscript.client.framework import \
! RaiseAssert, trace, Exception, SCRIPTTEXT_FORCEEXECUTION, \
! SCRIPTTEXT_ISEXPRESSION, SCRIPTTEXT_ISPERSISTENT
PyScript_CLSID = "{DF630910-1C1D-11d0-AE36-8C0F5E000000}"
***************
*** 41,82 ****
return "PyScript - " + framework.AXScriptCodeBlock.GetDisplayName(self)
- #
- # Restricted execution model.
- #
- import rexec
- class AXRExec(rexec.RExec):
- ok_builtin_modules = rexec.RExec.ok_builtin_modules + ('win32trace',)
-
- def __init__(self, pretendMain, hooks = None, verbose = 0):
- self.pretendMain = pretendMain
- rexec.RExec.__init__(self, hooks, verbose)
- # mods = list(self.ok_dynamic_modules)
- # mods.append("win32trace")
- # mods = tuple(mods)
- # self.ok_dynamic_modules = mods
- def make_main(self):
- if not self.modules.has_key('__main__'):
- self.modules['__main__'] = self.pretendMain
- self.pretendMain.__builtins__ = self.modules['__builtin__']
- m = self.add_module('__main__')
-
- # Classes that looks and behaves like RExec, but isnt really!
- import ihooks
- class AXNotRHooks(ihooks.Hooks):
- pass
-
- class AXNotRExec:
- def __init__(self, pretendMain, hooks = None, verbose = 0):
- self.pretendMain = pretendMain
- self.hooks = hooks or AXNotRHooks(verbose)
- self.modules = {'__main__': self.pretendMain}
-
- def add_module(self, mname):
- if self.modules.has_key(mname):
- return self.modules[mname]
- self.modules[mname] = m = self.hooks.new_module(mname)
- # m.__builtins__ = self.modules['__builtin__']
- return m
-
# There is only ever _one_ ax object - it exists in the global namespace
# for all script items.
--- 42,45 ----
***************
*** 224,228 ****
self.globalNameSpaceModule = imp.new_module("__ax_main__")
self.globalNameSpaceModule.__dict__['ax'] = AXScriptAttribute(self)
- self.rexec_env = None # will be created first time around.
self.codeBlocks = []
--- 187,190 ----
***************
*** 252,266 ****
def RegisterNamedItem(self, item):
- if self.rexec_env is None:
- # RExec is not available in 2.2+. If we get here for IE, the
- # user has explicitly run axscript_rexec, so is choosing to
- # take this risk.
- # if self.safetyOptions & (axscript.INTERFACESAFE_FOR_UNTRUSTED_DATA | axscript.INTERFACESAFE_FOR_UNTRUSTED_CALLER):
- # # Use RExec.
- # self.rexec_env = AXRExec(self.globalNameSpaceModule)
- # else:
- # DONT use RExec.
- self.rexec_env = AXNotRExec(self.globalNameSpaceModule)
-
wasReg = item.isRegistered
framework.COMScript.RegisterNamedItem(self, item)
--- 214,217 ----
***************
*** 401,406 ****
pass # ???
globalNameSpaceModule = None
-
- self.rexec_env = None
def DllRegisterServer():
--- 352,355 ----
Index: error.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/error.py,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -C2 -d -r1.9 -r1.9.2.1
*** error.py 7 May 2007 02:27:44 -0000 1.9
--- error.py 26 Nov 2008 07:17:39 -0000 1.9.2.1
***************
*** 154,173 ****
tb_top = tb
! list = ['Traceback (most recent call last):\n']
! list = list + traceback.format_list(format_items)
if exc_type==pythoncom.com_error:
desc = "%s (0x%x)" % (value[1], value[0])
if value[0]==winerror.DISP_E_EXCEPTION and value[2] and value[2][2]:
desc = value[2][2]
! list.append("COM Error: "+desc)
else:
! list = list + traceback.format_exception_only(exc_type, value)
# all items in the list are utf8 courtesy of Python magically
# converting unicode to utf8 before compilation.
! for i in range(len(list)):
! if type(list[i]) is str:
! #assert type(list[i]) is str, type(list[i])
! list[i] = list[i].decode('utf8')
! self.description = ExpandTabs(u''.join(list))
# Clear tracebacks etc.
tb = tb_top = tb_look = None
--- 154,186 ----
tb_top = tb
! bits = ['Traceback (most recent call last):\n']
! bits.extend(traceback.format_list(format_items))
if exc_type==pythoncom.com_error:
desc = "%s (0x%x)" % (value[1], value[0])
if value[0]==winerror.DISP_E_EXCEPTION and value[2] and value[2][2]:
desc = value[2][2]
! bits.append("COM Error: "+desc)
else:
! bits.extend(traceback.format_exception_only(exc_type, value))
!
! # XXX - this block appears completely bogus??? The UTF8
! # comment below is from well before py3k, so utf8 doesn't have
! # any special status in py2k. Most likely is that this was
! # simply an artifact of an invalid test (which remains - it
! # raises a RuntimeError with a *string* with extended
! # characters.)
! # Sadly, the test still fails in the same way if you raise a
! # Unicode string with an extended char. This block keeps the
! # tests passing, so it remains.
! # XXX - todo - read the above, and fix below!
!
# all items in the list are utf8 courtesy of Python magically
# converting unicode to utf8 before compilation.
! for i in xrange(len(bits)):
! if type(bits[i]) is str:
! #assert type(bits[i]) is str, type(bits[i])
! bits[i] = bits[i].decode('utf8')
!
! self.description = ExpandTabs(u''.join(bits))
# Clear tracebacks etc.
tb = tb_top = tb_look = None
|