Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem is <code>trace</code> method and <code>print</code> statements in the <code>win32comext\axscript\client\framework.py</code> because in the COM components writing to the <code>sys.stdout</code> or <code>sys.stderr</code> like the <code>print</code> statement causes an exception for example <code>trace("Debugging extensions (axdebug) module does not exist - debugging is disabled..")</code> at the line 572 of <code>framework.py</code> causes an exception.</p> <p>One workaround is adding <code>import win32traceutil</code> in the <code>framework.py</code>. The <code>win32traceutil</code> redirects output to <code>win32trace remote collector</code> and solve the problem without need to enabling debugging witch cause performance issues.</p> <p>Another workaround is redirecting <code>stdout</code> and <code>stderr</code> to null, you can add following code snippet at the top of <code>framework.py</code>.</p> <pre><code> f = open('nul', 'w') sys.stdout = f sys.stderr = f </code></pre> <p><strong>UPDATE: The root cause and the solution</strong></p> <p>There is already a mechanism in <code>framework.py</code> to prevent print and trace statements to raise an exception but the problem is in the <code>write</code> method of <code>SafeOutput</code> class. When tracing and debugging is not enabled, in the write method an exception occurs and <code>win32api.OutputDebugString</code> in the except clause will invoke with the wrong encoding which cause an exception. Because the <code>win32api.OutputDebugString</code> accept Unicode string not a multibyte character set (MBCS) as an argument.</p> <p>The solution:</p> <p>in the <code>win32comext\axscript\client\framework.py</code> in the <code>SafeOutput</code> class</p> <pre><code>class SafeOutput: softspace=1 def __init__(self, redir=None): if redir is None: redir = sys.stdout self.redir=redir def write(self,message): try: self.redir.write(message) except: win32api.OutputDebugString(message.encode('mbcs')) def flush(self): pass def close(self): pass </code></pre> <p>just change </p> <pre><code>win32api.OutputDebugString(message.encode('mbcs')) # ANSI Enconding </code></pre> <p>to </p> <pre><code>win32api.OutputDebugString(message) # Unicode </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload