ScriptControl+Python+win32all+Procedures -- known bug?

Alex Martelli aleaxit at yahoo.com
Wed Feb 7 18:08:58 CET 2001


I'm trying to load Python as ActiveScripting compliant
language into an application that uses Microsoft
ScriptControl, but there seems to be a bug with
(whatever is it in IActiveScript that ScriptControl
uses to implement its Procedures collection...) -- or
is the application perhaps doing something wrong?  I
did manage to reproduce the problem on a toy-scale with
a tiny application that does nothing but:

1 -- instantiate a ScriptControl
2 -- set its Language property
3 -- AddCode to it a script textfile's contents
4 -- get its Procedures collection
5 -- get the Count property of said collection
6 -- get the _NewEnum property of said collection
7 -- enumerate on said _NewEnum

and it all works fine if Language is 'VBScript' (and
the textfile a correct foo.vbs script); however, with
the same application code, if Language is 'Python'
(and the textfile a correct foo.py script), steps 5
and 6 each fail (and thus 7 is not even tried) with an
HRESULT of 0x8002000b (meaning "Invalid index").

VC++6 code for steps 1-5 can be summarized as:

#import "msscript.ocx"
   ...
    MSScriptControl::IScriptControlPtr
pScr("MSScriptControl.ScriptControl");
    pScr->Language = "Python";
    pScr->AddCode("def foo():\n  pass\n");
    MSScriptControl::IScriptProcedureCollectionPtr pProcedures;
    pProcedures = pScr->Procedures;
    /* so far so good, but...: */
    printf("Number of procedures is %d\n", pProcedures->GetCount());
    /* this last line raises a _com_error C++ exception, as above
       detailed, and so does most any other attempt at doing
       anything with pProcedures. */

Is this a known bug of build 135 of ActivePython?  I
cannot find it on the ActiveState site (and thus have
submitted it there, hoping it's not a duplicate!).  Any
help/advice/workaround would be welcome, anyway!


Alex






More information about the Python-list mailing list