[Pythonmac-SIG] Patch proposition (Was: Problem when embedding classic)
Stefan Petrucha
petrucha@isnet.sk
Mon, 02 Sep 2002 14:17:52 +0200
This is a multi-part message in MIME format.
--------------5CAE4C09284F357404B0F7E1
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 7bit
Several weeks ago I had a problem with embedding Python into a third
party classic application. According to responses it had to work on 99%.
Unfortunately my case fell into the rest. As I discovered later the
problem relates to the initialization of MacPython - how it initializes
the toolbox under classic. I was forced to change the sources.
Summary: There is a new initialization function PyMac_InitEmbedded(int).
Its argument propagates into init_mac_world() and serves to decide
whether to initialize the graphics toolbox or not. I'm not sure whether
not to initialize graphics could cause some problems somewhere later
(with tkinter?), but this does not bother me currently as this is the
only way how to make it (partially?) working. The proposed change is
compatible with the whole existing codebase, just adds an additional
possibility in the (dead?) classic branch.
The attached file contains result of comparison of original and patched
files, compared from within MPW on the 2.1.1 sources. (Unfortunately I
just downloaded the 2.2.1 source so this comparison is not available
yet.)
Could it be possible to incorporate this change into mainstream?
Stefan Petrucha
--
http://www.isnet.sk/petrucha
--------------5CAE4C09284F357404B0F7E1
Content-Type: text/plain; charset=iso-8859-15;
name="differences.txt"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
filename="differences.txt"
compare :MacPython211src:Mac:Python:macmain.c :MacPython:Mac:Python:macmain.c
File #1: :MacPython211src:Mac:Python:macmain.c
File #2: :MacPython:Mac:Python:macmain.c
Nonmatching lines (File ":MacPython211src:Mac:Python:macmain.c"; Line 105; File ":MacPython:Mac:Python:macmain.c"; Line 105)
105 init_mac_world()
105 init_mac_world(int embedded)
Nonmatching lines (File ":MacPython211src:Mac:Python:macmain.c"; Line 110; File ":MacPython:Mac:Python:macmain.c"; Line 110:111)
110 InitGraf(&qd.thePort);
110 if(embedded < 2)
111 InitGraf(&qd.thePort);
Nonmatching lines (File ":MacPython211src:Mac:Python:macmain.c"; Line 256; File ":MacPython:Mac:Python:macmain.c"; Line 257)
256 init_mac_world();
257 init_mac_world(embedded);
Extra lines in 2nd before 454 in 1st (File ":MacPython211src:Mac:Python:macmain.c"; Line Æ454; File ":MacPython:Mac:Python:macmain.c"; Line 455:463)
455 PyMac_InitEmbedded(1);
456 }
457
458 /*
459 ** Hook for embedding python (new).
460 */
461 void
462 PyMac_InitEmbedded(int embedded)
463 {
Nonmatching lines (File ":MacPython211src:Mac:Python:macmain.c"; Line 457; File ":MacPython:Mac:Python:macmain.c"; Line 467)
457 init_common(&argc, &argv, 1);
467 init_common(&argc, &argv, embedded);
*** EOF on both files at the same time ***
compare :MacPython211src:Mac:Include:macglue.h :MacPython:Mac:Include:macglue.h
File #1: :MacPython211src:Mac:Include:macglue.h
File #2: :MacPython:Mac:Include:macglue.h
Extra lines in 2nd before 124 in 1st (File ":MacPython211src:Mac:Include:macglue.h"; Line Æ124; File ":MacPython:Mac:Include:macglue.h"; Line 124)
124 void PyMac_InitEmbedded(int); /* Initialize function for embedding Python */
*** EOF on both files at the same time ***
compare :MacPython211src:Mac:Build:PythonCore.exp :MacPython:Mac:Build:PythonCore.exp
File #1: :MacPython211src:Mac:Build:PythonCore.exp
File #2: :MacPython:Mac:Build:PythonCore.exp
Extra lines in 2nd before 729 in 1st (File ":MacPython211src:Mac:Build:PythonCore.exp"; Line Æ729; File ":MacPython:Mac:Build:PythonCore.exp"; Line 729)
729 PyMac_InitEmbedded
*** EOF on both files at the same time ***
--------------5CAE4C09284F357404B0F7E1--