[Python-checkins] python/dist/src/Mac/Lib appletrawmain.py,1.1,1.2
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
Fri, 02 Aug 2002 08:31:27 -0700
Update of /cvsroot/python/python/dist/src/Mac/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv7678
Modified Files:
appletrawmain.py
Log Message:
Hmm, in some cases we don't seem to get our scriptname in argv[0].
Cater for that by working from sys.executable.
Index: appletrawmain.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Lib/appletrawmain.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** appletrawmain.py 2 Aug 2002 14:57:43 -0000 1.1
--- appletrawmain.py 2 Aug 2002 15:31:25 -0000 1.2
***************
*** 11,21 ****
#
# Create sys.argv
#
argvemulator.ArgvCollector().mainloop()
#
! # Find the realy main program to run
#
- _dir = os.path.split(sys.argv[0])[0]
__file__ = os.path.join(_dir, '__main__.py')
if os.path.exists(__file__):
--- 11,32 ----
#
+ # Make sure we have an argv[0], and make _dir point to the Resources
+ # directory.
+ #
+ if not sys.argv or sys.argv[0][:1] == '-':
+ # Insert our (guessed) name.
+ _dir = os.path.split(sys.executable)[0] # removes "python"
+ _dir = os.path.split(_dir)[0] # Removes "MacOS"
+ _dir = os.path.join(_dir, 'Resources')
+ sys.argv.insert(0, '__rawmain__')
+ else:
+ _dir = os.path.split(sys.argv[0])[0]
+ #
# Create sys.argv
#
argvemulator.ArgvCollector().mainloop()
#
! # Find the real main program to run
#
__file__ = os.path.join(_dir, '__main__.py')
if os.path.exists(__file__):