Merge the rest of the trunk.

Merged revisions 46490-46494,46496,46498,46500,46506,46521,46538,46558,46563-46567,46570-46571,46583,46593,46595-46598,46604,46606,46609-46753 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r46610 | martin.v.loewis | 2006-06-03 09:42:26 +0200 (Sat, 03 Jun 2006) | 2 lines

  Updated version (win32-icons2.zip) from #1490384.
........
  r46612 | andrew.kuchling | 2006-06-03 20:09:41 +0200 (Sat, 03 Jun 2006) | 1 line

  [Bug #1472084] Fix description of do_tag
........
  r46614 | andrew.kuchling | 2006-06-03 20:33:35 +0200 (Sat, 03 Jun 2006) | 1 line

  [Bug #1475554] Strengthen text to say 'must' instead of 'should'
........
  r46616 | andrew.kuchling | 2006-06-03 20:41:28 +0200 (Sat, 03 Jun 2006) | 1 line

  [Bug #1441864] Clarify description of 'data' argument
........
  r46617 | andrew.kuchling | 2006-06-03 20:43:24 +0200 (Sat, 03 Jun 2006) | 1 line

  Minor rewording
........
  r46619 | andrew.kuchling | 2006-06-03 21:02:35 +0200 (Sat, 03 Jun 2006) | 9 lines

  [Bug #1497414] _self is a reserved word in the WATCOM 10.6 C compiler.
  Fix by renaming the variable.

  In a different module, Neal fixed it by renaming _self to self.  There's
  already a variable named 'self' here, so I used selfptr.

  (I'm committing this on a Mac without Tk, but it's a simple search-and-replace.
  <crosses fingers>, so  I'll watch the buildbots and see what happens.)
........
  r46621 | fredrik.lundh | 2006-06-03 23:56:05 +0200 (Sat, 03 Jun 2006) | 5 lines

  "_self" is a said to be a reserved word in Watcom C 10.6.  I'm
  not sure that's really standard compliant behaviour, but I guess
  we have to fix that anyway...
........
  r46622 | andrew.kuchling | 2006-06-04 00:44:42 +0200 (Sun, 04 Jun 2006) | 1 line

  Update readme
........
  r46623 | andrew.kuchling | 2006-06-04 00:59:23 +0200 (Sun, 04 Jun 2006) | 1 line

  Drop 0 parameter
........
  r46624 | andrew.kuchling | 2006-06-04 00:59:59 +0200 (Sun, 04 Jun 2006) | 1 line

  Some code tidying; use curses.wrapper
........
  r46625 | andrew.kuchling | 2006-06-04 01:02:15 +0200 (Sun, 04 Jun 2006) | 1 line

  Use True; value returned from main is unused
........
  r46626 | andrew.kuchling | 2006-06-04 01:07:21 +0200 (Sun, 04 Jun 2006) | 1 line

  Use true division, and the True value
........
  r46627 | andrew.kuchling | 2006-06-04 01:09:58 +0200 (Sun, 04 Jun 2006) | 1 line

  Docstring fix; use True
........
  r46628 | andrew.kuchling | 2006-06-04 01:15:56 +0200 (Sun, 04 Jun 2006) | 1 line

  Put code in a main() function; loosen up the spacing to match current code style
........
  r46629 | andrew.kuchling | 2006-06-04 01:39:07 +0200 (Sun, 04 Jun 2006) | 1 line

  Use functions; modernize code
........
  r46630 | andrew.kuchling | 2006-06-04 01:43:22 +0200 (Sun, 04 Jun 2006) | 1 line

  This demo requires Medusa (not just asyncore); remove it
........
  r46631 | andrew.kuchling | 2006-06-04 01:46:36 +0200 (Sun, 04 Jun 2006) | 2 lines

  Remove xmlrpc demo -- it duplicates the SimpleXMLRPCServer module.
........
  r46632 | andrew.kuchling | 2006-06-04 01:47:22 +0200 (Sun, 04 Jun 2006) | 1 line

  Remove xmlrpc/ directory
........
  r46633 | andrew.kuchling | 2006-06-04 01:51:21 +0200 (Sun, 04 Jun 2006) | 1 line

  Remove dangling reference
........
  r46634 | andrew.kuchling | 2006-06-04 01:59:36 +0200 (Sun, 04 Jun 2006) | 1 line

  Add more whitespace; use a better socket name
........
  r46635 | tim.peters | 2006-06-04 03:22:53 +0200 (Sun, 04 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46637 | tim.peters | 2006-06-04 05:26:02 +0200 (Sun, 04 Jun 2006) | 16 lines

  In a PYMALLOC_DEBUG build obmalloc adds extra debugging info
  to each allocated block.  This was using 4 bytes for each such
  piece of info regardless of platform.  This didn't really matter
  before (proof: no bug reports, and the debug-build obmalloc would
  have assert-failed if it was ever asked for a chunk of memory
  >= 2**32 bytes), since container indices were plain ints.  But after
  the Py_ssize_t changes, it's at least theoretically possible to
  allocate a list or string whose guts exceed 2**32 bytes, and the
  PYMALLOC_DEBUG routines would fail then (having only 4 bytes
  to record the originally requested size).

  Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG
  build's extra debugging fields.  This won't make any difference
  on 32-bit boxes, but will add 16 bytes to each allocation in
  a debug build on a 64-bit box.
........
  r46638 | tim.peters | 2006-06-04 05:38:04 +0200 (Sun, 04 Jun 2006) | 4 lines

  _PyObject_DebugMalloc():  The return value should add
  2*sizeof(size_t) now, not 8.  This probably accounts for
  current disasters on the 64-bit buildbot slaves.
........
  r46639 | neal.norwitz | 2006-06-04 08:19:31 +0200 (Sun, 04 Jun 2006) | 1 line

  SF #1499797, Fix for memory leak in WindowsError_str
........
  r46640 | andrew.macintyre | 2006-06-04 14:31:09 +0200 (Sun, 04 Jun 2006) | 2 lines

  Patch #1454481:  Make thread stack size runtime tunable.
........
  r46641 | andrew.macintyre | 2006-06-04 14:59:59 +0200 (Sun, 04 Jun 2006) | 2 lines

  clean up function declarations to conform to PEP-7 style.
........
  r46642 | martin.blais | 2006-06-04 15:49:49 +0200 (Sun, 04 Jun 2006) | 15 lines

  Fixes in struct and socket from merge reviews.

  - Following Guido's comments, renamed

    * pack_to -> pack_into
    * recv_buf -> recv_into
    * recvfrom_buf -> recvfrom_into

  - Made fixes to _struct.c according to Neal Norwitz comments on the checkins
    list.

  - Converted some ints into the appropriate -- I hope -- ssize_t and size_t.
........
  r46643 | ronald.oussoren | 2006-06-04 16:05:28 +0200 (Sun, 04 Jun 2006) | 3 lines

  "Import" LDFLAGS in Mac/OSX/Makefile.in to ensure pythonw gets build with
  the right compiler flags.
........
  r46644 | ronald.oussoren | 2006-06-04 16:24:59 +0200 (Sun, 04 Jun 2006) | 2 lines

  Drop Mac wrappers for the WASTE library.
........
  r46645 | tim.peters | 2006-06-04 17:49:07 +0200 (Sun, 04 Jun 2006) | 3 lines

  s_methods[]:  Stop compiler warnings by casting
  s_unpack_from to PyCFunction.
........
  r46646 | george.yoshida | 2006-06-04 19:04:12 +0200 (Sun, 04 Jun 2006) | 2 lines

  Remove a redundant word
........
  r46647 | george.yoshida | 2006-06-04 19:17:25 +0200 (Sun, 04 Jun 2006) | 2 lines

  Markup fix
........
  r46648 | martin.v.loewis | 2006-06-04 21:36:28 +0200 (Sun, 04 Jun 2006) | 2 lines

  Patch #1359618: Speed-up charmap encoder.
........
  r46649 | georg.brandl | 2006-06-04 23:46:16 +0200 (Sun, 04 Jun 2006) | 3 lines

  Repair refleaks in unicodeobject.
........
  r46650 | georg.brandl | 2006-06-04 23:56:52 +0200 (Sun, 04 Jun 2006) | 4 lines

  Patch #1346214: correctly optimize away "if 0"-style stmts
  (thanks to Neal for review)
........
  r46651 | georg.brandl | 2006-06-05 00:15:37 +0200 (Mon, 05 Jun 2006) | 2 lines

  Bug #1500293: fix memory leaks in _subprocess module.
........
  r46654 | tim.peters | 2006-06-05 01:43:53 +0200 (Mon, 05 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46655 | tim.peters | 2006-06-05 01:52:47 +0200 (Mon, 05 Jun 2006) | 16 lines

  Revert revisions:

  46640 Patch #1454481:  Make thread stack size runtime tunable.
  46647 Markup fix

  The first is causing many buildbots to fail test runs, and there
  are multiple causes with seemingly no immediate prospects for
  repairing them.  See python-dev discussion.

  Note that a branch can (and should) be created for resolving these
  problems, like

  svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH

  followed by merging rev 46647 to the new branch.
........
  r46656 | andrew.kuchling | 2006-06-05 02:08:09 +0200 (Mon, 05 Jun 2006) | 1 line

  Mention second encoding speedup
........
  r46657 | gregory.p.smith | 2006-06-05 02:31:01 +0200 (Mon, 05 Jun 2006) | 7 lines

  bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present
  in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized
  char **log_list.

  feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2.
........
  r46658 | gregory.p.smith | 2006-06-05 02:33:35 +0200 (Mon, 05 Jun 2006) | 5 lines

  fix a bug in the previous commit.  don't leak empty list on error return and
  fix the additional rare (out of memory only) bug that it was supposed to fix
  of not freeing log_list when the python allocator failed.
........
  r46660 | tim.peters | 2006-06-05 02:55:26 +0200 (Mon, 05 Jun 2006) | 9 lines

  "Flat is better than nested."

  Move the long-winded, multiply-nested -R support out
  of runtest() and into some module-level helper functions.
  This makes runtest() and the -R code easier to follow.
  That in turn allowed seeing some opportunities for code
  simplification, and made it obvious that reglog.txt
  never got closed.
........
  r46661 | hyeshik.chang | 2006-06-05 02:59:54 +0200 (Mon, 05 Jun 2006) | 3 lines

  Fix a potentially invalid memory access of CJKCodecs' shift-jis
  decoder.  (found by Neal Norwitz)
........
  r46663 | gregory.p.smith | 2006-06-05 03:39:52 +0200 (Mon, 05 Jun 2006) | 3 lines

    * support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885]
........
  r46664 | tim.peters | 2006-06-05 03:43:03 +0200 (Mon, 05 Jun 2006) | 3 lines

  Remove doctest.testmod's deprecated (in 2.4) `isprivate`
  argument.  A lot of hair went into supporting that!
........
  r46665 | tim.peters | 2006-06-05 03:47:24 +0200 (Mon, 05 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46666 | tim.peters | 2006-06-05 03:48:21 +0200 (Mon, 05 Jun 2006) | 2 lines

  Make doctest news more accurate.
........
  r46667 | gregory.p.smith | 2006-06-05 03:56:15 +0200 (Mon, 05 Jun 2006) | 3 lines

    * support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902]
........
  r46668 | gregory.p.smith | 2006-06-05 04:02:25 +0200 (Mon, 05 Jun 2006) | 3 lines

  mention the just committed bsddb changes
........
  r46671 | gregory.p.smith | 2006-06-05 19:38:04 +0200 (Mon, 05 Jun 2006) | 3 lines

    * add support for DBSequence objects [patch #1466734]
........
  r46672 | gregory.p.smith | 2006-06-05 20:20:07 +0200 (Mon, 05 Jun 2006) | 3 lines

  forgot to add this file in previous commit
........
  r46673 | tim.peters | 2006-06-05 20:36:12 +0200 (Mon, 05 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46674 | tim.peters | 2006-06-05 20:36:54 +0200 (Mon, 05 Jun 2006) | 2 lines

  Add missing svn:eol-style property to text files.
........
  r46675 | gregory.p.smith | 2006-06-05 20:48:21 +0200 (Mon, 05 Jun 2006) | 4 lines

    * fix DBCursor.pget() bug with keyword argument names when no data= is
      supplied [SF pybsddb bug #1477863]
........
  r46676 | andrew.kuchling | 2006-06-05 21:05:32 +0200 (Mon, 05 Jun 2006) | 1 line

  Remove use of Trove name, which isn't very helpful to users
........
  r46677 | andrew.kuchling | 2006-06-05 21:08:25 +0200 (Mon, 05 Jun 2006) | 1 line

  [Bug #1470026] Include link to list of classifiers
........
  r46679 | tim.peters | 2006-06-05 22:48:49 +0200 (Mon, 05 Jun 2006) | 10 lines

  Access _struct attributes directly instead of mucking with getattr.

  string_reverse():  Simplify.

  assertRaises():  Raise TestFailed on failure.

  test_unpack_from(), test_pack_into(), test_pack_into_fn():  never
  use `assert` to test for an expected result (it doesn't test anything
  when Python is run with -O).
........
  r46680 | tim.peters | 2006-06-05 22:49:27 +0200 (Mon, 05 Jun 2006) | 2 lines

  Add missing svn:eol-style property to text files.
........
  r46681 | gregory.p.smith | 2006-06-06 01:38:06 +0200 (Tue, 06 Jun 2006) | 3 lines

  add depends = ['md5.h']  to the _md5 module extension for correctness sake.
........
  r46682 | brett.cannon | 2006-06-06 01:51:55 +0200 (Tue, 06 Jun 2006) | 4 lines

  Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int.

  Closes bug #1501223.
........
  r46684 | gregory.p.smith | 2006-06-06 01:59:37 +0200 (Tue, 06 Jun 2006) | 5 lines

  - bsddb: the __len__ method of a DB object has been fixed to return correct
    results.  It could previously incorrectly return 0 in some cases.
    Fixes SF bug 1493322 (pybsddb bug 1184012).
........
  r46686 | tim.peters | 2006-06-06 02:25:07 +0200 (Tue, 06 Jun 2006) | 7 lines

  _PySys_Init():  It's rarely a good idea to size a buffer to the
  exact maximum size someone guesses is needed.  In this case, if
  we're really worried about extreme integers, then "cp%d" can
  actually need 14 bytes (2 for "cp" + 1 for \0 at the end +
  11 for -(2**31-1)).  So reserve 128 bytes instead -- nothing is
  actually saved by making a stack-local buffer tiny.
........
  r46687 | neal.norwitz | 2006-06-06 09:22:08 +0200 (Tue, 06 Jun 2006) | 1 line

  Remove unused variable (and stop compiler warning)
........
  r46688 | neal.norwitz | 2006-06-06 09:23:01 +0200 (Tue, 06 Jun 2006) | 1 line

  Fix a bunch of parameter strings
........
  r46689 | thomas.heller | 2006-06-06 13:34:33 +0200 (Tue, 06 Jun 2006) | 6 lines

  Convert CFieldObject tp_members to tp_getset, since there is no
  structmember typecode for Py_ssize_t fields.  This should fix some of
  the errors on the PPC64 debian machine (64-bit, big endian).

  Assigning to readonly fields now raises AttributeError instead of
  TypeError, so the testcase has to be changed as well.
........
  r46690 | thomas.heller | 2006-06-06 13:54:32 +0200 (Tue, 06 Jun 2006) | 1 line

  Damn - the sentinel was missing.  And fix another silly mistake.
........
  r46691 | martin.blais | 2006-06-06 14:46:55 +0200 (Tue, 06 Jun 2006) | 13 lines

  Normalized a few cases of whitespace in function declarations.

  Found them using::

    find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done
    find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done

  (I was doing this all over my own code anyway, because I'd been using spaces in
  all defs, so I thought I'd make a run on the Python code as well.  If you need
  to do such fixes in your own code, you can use xx-rename or parenregu.el within
  emacs.)
........
  r46693 | thomas.heller | 2006-06-06 17:34:18 +0200 (Tue, 06 Jun 2006) | 1 line

  Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures
........
  r46694 | tim.peters | 2006-06-06 17:50:17 +0200 (Tue, 06 Jun 2006) | 5 lines

  BSequence_set_range():  Rev 46688 ("Fix a bunch of
  parameter strings") changed this function's signature
  seemingly by mistake, which is causing buildbots to fail
  test_bsddb3.  Restored the pre-46688 signature.
........
  r46695 | tim.peters | 2006-06-06 17:52:35 +0200 (Tue, 06 Jun 2006) | 4 lines

  On python-dev Thomas Heller said these were committed
  by mistake in rev 46693, so reverting this part of
  rev 46693.
........
  r46696 | andrew.kuchling | 2006-06-06 19:10:41 +0200 (Tue, 06 Jun 2006) | 1 line

  Fix comment typo
........
  r46697 | brett.cannon | 2006-06-06 20:08:16 +0200 (Tue, 06 Jun 2006) | 2 lines

  Fix coding style guide bug.
........
  r46698 | thomas.heller | 2006-06-06 20:50:46 +0200 (Tue, 06 Jun 2006) | 2 lines

  Add a hack so that foreign functions returning float now do work on 64-bit
  big endian platforms.
........
  r46699 | thomas.heller | 2006-06-06 21:25:13 +0200 (Tue, 06 Jun 2006) | 3 lines

  Use the same big-endian hack as in _ctypes/callproc.c for callback functions.
  This fixes the callback function tests that return float.
........
  r46700 | ronald.oussoren | 2006-06-06 21:50:24 +0200 (Tue, 06 Jun 2006) | 5 lines

  * Ensure that "make altinstall" works when the tree was configured
    with --enable-framework
  * Also for --enable-framework: allow users to use --prefix to specify
    the location of the compatibility symlinks (such as /usr/local/bin/python)
........
  r46701 | ronald.oussoren | 2006-06-06 21:56:00 +0200 (Tue, 06 Jun 2006) | 3 lines

  A quick hack to ensure the right key-bindings for IDLE on osx: install patched
  configuration files during a framework install.
........
  r46702 | tim.peters | 2006-06-07 03:04:59 +0200 (Wed, 07 Jun 2006) | 4 lines

  dash_R_cleanup():  Clear filecmp._cache.  This accounts for
  different results across -R runs (at least on Windows) of
  test_filecmp.
........
  r46705 | tim.peters | 2006-06-07 08:57:51 +0200 (Wed, 07 Jun 2006) | 17 lines

  SF patch 1501987:  Remove randomness from test_exceptions,
  from ?iga Seilnacht (sorry about the name, but Firefox
  on my box can't display the first character of the name --
  the SF "Unix name" is zseil).

  This appears to cure the oddball intermittent leaks across
  runs when running test_exceptions under -R.  I'm not sure
  why, but I'm too sleepy to care ;-)

  The thrust of the SF patch was to remove randomness in the
  pickle protocol used.  I changed the patch to use
  range(pickle.HIGHEST_PROTOCOL + 1), to try both pickle and
  cPickle, and randomly mucked with other test lines to put
  statements on their own lines.

  Not a bugfix candidate (this is fiddling new-in-2.5 code).
........
  r46706 | andrew.kuchling | 2006-06-07 15:55:33 +0200 (Wed, 07 Jun 2006) | 1 line

  Add an SQLite introduction, taken from the 'What's New' text
........
  r46708 | andrew.kuchling | 2006-06-07 19:02:52 +0200 (Wed, 07 Jun 2006) | 1 line

  Mention other placeholders
........
  r46709 | andrew.kuchling | 2006-06-07 19:03:46 +0200 (Wed, 07 Jun 2006) | 1 line

  Add an item; also, escape %
........
  r46710 | andrew.kuchling | 2006-06-07 19:04:01 +0200 (Wed, 07 Jun 2006) | 1 line

  Mention other placeholders
........
  r46716 | ronald.oussoren | 2006-06-07 20:57:44 +0200 (Wed, 07 Jun 2006) | 2 lines

  Move Mac/OSX/Tools one level up
........
  r46717 | ronald.oussoren | 2006-06-07 20:58:01 +0200 (Wed, 07 Jun 2006) | 2 lines

  Move Mac/OSX/PythonLauncher one level up
........
  r46718 | ronald.oussoren | 2006-06-07 20:58:42 +0200 (Wed, 07 Jun 2006) | 2 lines

  mv Mac/OSX/BuildScript one level up
........
  r46719 | ronald.oussoren | 2006-06-07 21:02:03 +0200 (Wed, 07 Jun 2006) | 2 lines

  Move Mac/OSX/* one level up
........
  r46720 | ronald.oussoren | 2006-06-07 21:06:01 +0200 (Wed, 07 Jun 2006) | 2 lines

  And the last bit: move IDLE one level up and adjust makefiles
........
  r46723 | ronald.oussoren | 2006-06-07 21:38:53 +0200 (Wed, 07 Jun 2006) | 4 lines

  - Patch the correct version of python in the Info.plists at build time, instead
  of relying on a maintainer to update them before releases.
  - Remove the now empty Mac/OSX directory
........
  r46727 | ronald.oussoren | 2006-06-07 22:18:44 +0200 (Wed, 07 Jun 2006) | 7 lines

  * If BuildApplet.py is used as an applet it starts with a version of
    sys.exutable that isn't usuable on an #!-line. That results in generated
    applets that don't actually work. Work around this problem by resetting
    sys.executable.
  * argvemulator.py didn't work on intel macs. This patch fixes this
    (bug #1491468)
........
  r46728 | tim.peters | 2006-06-07 22:40:06 +0200 (Wed, 07 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46729 | tim.peters | 2006-06-07 22:40:54 +0200 (Wed, 07 Jun 2006) | 2 lines

  Add missing svn:eol-style property to text files.
........
  r46730 | thomas.heller | 2006-06-07 22:43:06 +0200 (Wed, 07 Jun 2006) | 7 lines

  Fix for foreign functions returning small structures on 64-bit big
  endian machines.  Should fix the remaininf failure in the PPC64
  Debian buildbot.

  Thanks to Matthias Klose for providing access to a machine to debug
  and test this.
........
  r46731 | brett.cannon | 2006-06-07 23:48:17 +0200 (Wed, 07 Jun 2006) | 2 lines

  Clarify documentation for bf_getcharbuffer.
........
  r46735 | neal.norwitz | 2006-06-08 07:12:45 +0200 (Thu, 08 Jun 2006) | 1 line

  Fix a refleak in recvfrom_into
........
  r46736 | gregory.p.smith | 2006-06-08 07:17:08 +0200 (Thu, 08 Jun 2006) | 9 lines

  - bsddb: the bsddb.dbtables Modify method now raises the proper error and
    aborts the db transaction safely when a modifier callback fails.
    Fixes SF python patch/bug #1408584.

  Also cleans up the bsddb.dbtables docstrings since thats the only
  documentation that exists for that unadvertised module.  (people
  really should really just use sqlite3)
........
  r46737 | gregory.p.smith | 2006-06-08 07:38:11 +0200 (Thu, 08 Jun 2006) | 4 lines

  * Turn the deadlock situation described in SF bug #775414 into a
    DBDeadLockError exception.
  * add the test case for my previous dbtables commit.
........
  r46738 | gregory.p.smith | 2006-06-08 07:39:54 +0200 (Thu, 08 Jun 2006) | 2 lines

  pasted set_lk_detect line in wrong spot in previous commit.  fixed.  passes tests this time.
........
  r46739 | armin.rigo | 2006-06-08 12:56:24 +0200 (Thu, 08 Jun 2006) | 6 lines

  (arre, arigo)  SF bug #1350060

  Give a consistent behavior for comparison and hashing of method objects
  (both user- and built-in methods).  Now compares the 'self' recursively.
  The hash was already asking for the hash of 'self'.
........
  r46740 | andrew.kuchling | 2006-06-08 13:56:44 +0200 (Thu, 08 Jun 2006) | 1 line

  Typo fix
........
  r46741 | georg.brandl | 2006-06-08 14:45:01 +0200 (Thu, 08 Jun 2006) | 2 lines

  Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking.
........
  r46743 | georg.brandl | 2006-06-08 14:54:13 +0200 (Thu, 08 Jun 2006) | 2 lines

  Bug #1502728: Correctly link against librt library on HP-UX.
........
  r46745 | georg.brandl | 2006-06-08 14:55:47 +0200 (Thu, 08 Jun 2006) | 3 lines

  Add news for recent bugfix.
........
  r46746 | georg.brandl | 2006-06-08 15:31:07 +0200 (Thu, 08 Jun 2006) | 4 lines

  Argh. "integer" is a very confusing word ;)
  Actually, checking for INT_MAX and INT_MIN is correct since
  the format code explicitly handles a C "int".
........
  r46748 | nick.coghlan | 2006-06-08 15:54:49 +0200 (Thu, 08 Jun 2006) | 1 line

  Add functools.update_wrapper() and functools.wraps() as described in PEP 356
........
  r46751 | georg.brandl | 2006-06-08 16:50:21 +0200 (Thu, 08 Jun 2006) | 4 lines

  Bug #1502805: don't alias file.__exit__ to file.close since the
  latter can return something that's true.
........
  r46752 | georg.brandl | 2006-06-08 16:50:53 +0200 (Thu, 08 Jun 2006) | 3 lines

  Convert test_file to unittest.
........
diff --git a/Mac/PythonLauncher/English.lproj/Credits.rtf b/Mac/PythonLauncher/English.lproj/Credits.rtf
new file mode 100644
index 0000000..930ca22
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/Credits.rtf
@@ -0,0 +1,30 @@
+{\rtf1\mac\ansicpg10000\cocoartf100
+{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\b\fs24 \cf0 Engineering:
+\f1\b0 \
+	Jack Jansen\
+\
+
+\f0\b Human Interface Design:
+\f1\b0 \
+	Jack Jansen\
+\
+
+\f0\b Testing:
+\f1\b0 \
+	Jack Jansen\
+        Pythonmac-SIG@python.org\
+\
+
+\f0\b Documentation:
+\f1\b0 \
+	Missing\
+\
+
+\f0\b With special thanks to:
+\f1\b0 \
+	Guido, of course\
+}
\ No newline at end of file
diff --git a/Mac/PythonLauncher/English.lproj/MainMenu.nib/classes.nib b/Mac/PythonLauncher/English.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 0000000..47b40ab
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/MainMenu.nib/classes.nib
@@ -0,0 +1,12 @@
+{
+    IBClasses = (
+        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
+        {
+            ACTIONS = {showPreferences = id; }; 
+            CLASS = MyAppDelegate; 
+            LANGUAGE = ObjC; 
+            SUPERCLASS = NSObject; 
+        }
+    ); 
+    IBVersion = 1; 
+}
\ No newline at end of file
diff --git a/Mac/PythonLauncher/English.lproj/MainMenu.nib/info.nib b/Mac/PythonLauncher/English.lproj/MainMenu.nib/info.nib
new file mode 100644
index 0000000..b96759a
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/MainMenu.nib/info.nib
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+	<key>IBDocumentLocation</key>
+	<string>99 33 356 240 0 0 800 578 </string>
+	<key>IBEditorPositions</key>
+	<dict>
+		<key>29</key>
+		<string>82 396 318 44 0 0 800 578 </string>
+	</dict>
+	<key>IBFramework Version</key>
+	<string>263.2</string>
+	<key>IBOpenObjects</key>
+	<array>
+		<integer>29</integer>
+	</array>
+	<key>IBSystem Version</key>
+	<string>5S66</string>
+</dict>
+</plist>
diff --git a/Mac/PythonLauncher/English.lproj/MainMenu.nib/objects.nib b/Mac/PythonLauncher/English.lproj/MainMenu.nib/objects.nib
new file mode 100644
index 0000000..532a5c8
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/MainMenu.nib/objects.nib
Binary files differ
diff --git a/Mac/PythonLauncher/English.lproj/MyDocument.nib/classes.nib b/Mac/PythonLauncher/English.lproj/MyDocument.nib/classes.nib
new file mode 100644
index 0000000..bcdc0cd
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/MyDocument.nib/classes.nib
@@ -0,0 +1,26 @@
+{
+    IBClasses = (
+        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
+        {
+            ACTIONS = {"do_apply" = id; "do_cancel" = id; "do_reset" = id; "do_run" = id; }; 
+            CLASS = MyDocument; 
+            LANGUAGE = ObjC; 
+            OUTLETS = {
+                commandline = NSTextField; 
+                debug = NSButton; 
+                honourhashbang = NSButton; 
+                inspect = NSButton; 
+                interpreter = NSTextField; 
+                nosite = NSButton; 
+                optimize = NSButton; 
+                others = NSTextField; 
+                scriptargs = NSTextField; 
+                tabs = NSButton; 
+                verbose = NSButton; 
+                "with_terminal" = NSButton; 
+            }; 
+            SUPERCLASS = NSDocument; 
+        }
+    ); 
+    IBVersion = 1; 
+}
\ No newline at end of file
diff --git a/Mac/PythonLauncher/English.lproj/MyDocument.nib/info.nib b/Mac/PythonLauncher/English.lproj/MyDocument.nib/info.nib
new file mode 100644
index 0000000..e258c72
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/MyDocument.nib/info.nib
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBDocumentLocation</key>
+	<string>398 60 356 240 0 0 1024 746 </string>
+	<key>IBFramework Version</key>
+	<string>291.0</string>
+	<key>IBOpenObjects</key>
+	<array>
+		<integer>5</integer>
+	</array>
+	<key>IBSystem Version</key>
+	<string>6L60</string>
+</dict>
+</plist>
diff --git a/Mac/PythonLauncher/English.lproj/MyDocument.nib/objects.nib b/Mac/PythonLauncher/English.lproj/MyDocument.nib/objects.nib
new file mode 100644
index 0000000..0473a31
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/MyDocument.nib/objects.nib
Binary files differ
diff --git a/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib
new file mode 100644
index 0000000..467aa8b
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib
@@ -0,0 +1,26 @@
+{
+    IBClasses = (
+        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
+        {
+            ACTIONS = {"do_apply" = id; "do_filetype" = id; "do_reset" = id; }; 
+            CLASS = PreferencesWindowController; 
+            LANGUAGE = ObjC; 
+            OUTLETS = {
+                commandline = NSTextField; 
+                debug = NSButton; 
+                filetype = NSPopUpButton; 
+                honourhashbang = NSButton; 
+                inspect = NSButton; 
+                interpreter = NSTextField; 
+                nosite = NSButton; 
+                optimize = NSButton; 
+                others = NSTextField; 
+                tabs = NSButton; 
+                verbose = NSButton; 
+                "with_terminal" = NSButton; 
+            }; 
+            SUPERCLASS = NSWindowController; 
+        }
+    ); 
+    IBVersion = 1; 
+}
\ No newline at end of file
diff --git a/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib
new file mode 100644
index 0000000..bc558f7
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBDocumentLocation</key>
+	<string>565 235 519 534 0 0 1280 1002 </string>
+	<key>IBFramework Version</key>
+	<string>364.0</string>
+	<key>IBOpenObjects</key>
+	<array>
+		<integer>5</integer>
+	</array>
+	<key>IBSystem Version</key>
+	<string>7H63</string>
+</dict>
+</plist>
diff --git a/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib
new file mode 100644
index 0000000..3dfed33
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib
Binary files differ
diff --git a/Mac/PythonLauncher/FileSettings.h b/Mac/PythonLauncher/FileSettings.h
new file mode 100755
index 0000000..d807bae
--- /dev/null
+++ b/Mac/PythonLauncher/FileSettings.h
@@ -0,0 +1,64 @@
+//
+//  FileSettings.h
+//  PythonLauncher
+//
+//  Created by Jack Jansen on Sun Jul 21 2002.
+//  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@protocol FileSettingsSource
+- (NSString *) interpreter;
+- (BOOL) honourhashbang;
+- (BOOL) debug;
+- (BOOL) verbose;
+- (BOOL) inspect;
+- (BOOL) optimize;
+- (BOOL) nosite;
+- (BOOL) tabs;
+- (NSString *) others;
+- (BOOL) with_terminal;
+- (NSString *) scriptargs;
+@end
+
+@interface FileSettings : NSObject <FileSettingsSource>
+{
+    NSString *interpreter;	// The pathname of the interpreter to use
+    NSArray *interpreters;	// List of known interpreters
+    BOOL honourhashbang;	// #! line overrides interpreter
+    BOOL debug;			// -d option: debug parser
+    BOOL verbose;		// -v option: verbose import
+    BOOL inspect;		// -i option: interactive mode after script
+    BOOL optimize;		// -O option: optimize bytecode
+    BOOL nosite;		// -S option: don't import site.py
+    BOOL tabs;			// -t option: warn about inconsistent tabs
+    NSString *others;		// other options
+    NSString *scriptargs;	// script arguments (not for preferences)
+    BOOL with_terminal;		// Run in terminal window
+
+    FileSettings *origsource;
+    NSString *prefskey;
+}
+
++ (id)getDefaultsForFileType: (NSString *)filetype;
++ (id)getFactorySettingsForFileType: (NSString *)filetype;
++ (id)newSettingsForFileType: (NSString *)filetype;
+
+//- (id)init;
+- (id)initForFileType: (NSString *)filetype;
+- (id)initForFSDefaultFileType: (NSString *)filetype;
+- (id)initForDefaultFileType: (NSString *)filetype;
+//- (id)initWithFileSettings: (FileSettings *)source;
+
+- (void)updateFromSource: (id <FileSettingsSource>)source;
+- (NSString *)commandLineForScript: (NSString *)script;
+
+//- (void)applyFactorySettingsForFileType: (NSString *)filetype;
+//- (void)saveDefaults;
+//- (void)applyUserDefaults: (NSString *)filetype;
+- (void)applyValuesFromDict: (NSDictionary *)dict;
+- (void)reset;
+- (NSArray *) interpreters;
+
+@end
diff --git a/Mac/PythonLauncher/FileSettings.m b/Mac/PythonLauncher/FileSettings.m
new file mode 100755
index 0000000..fc3937b
--- /dev/null
+++ b/Mac/PythonLauncher/FileSettings.m
@@ -0,0 +1,298 @@
+//
+//  FileSettings.m
+//  PythonLauncher
+//
+//  Created by Jack Jansen on Sun Jul 21 2002.
+//  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+//
+
+#import "FileSettings.h"
+
+@implementation FileSettings
+
++ (id)getFactorySettingsForFileType: (NSString *)filetype
+{
+    static FileSettings *fsdefault_py, *fsdefault_pyw, *fsdefault_pyc;
+    FileSettings **curdefault;
+    
+    if ([filetype isEqualToString: @"Python Script"]) {
+        curdefault = &fsdefault_py;
+    } else if ([filetype isEqualToString: @"Python GUI Script"]) {
+        curdefault = &fsdefault_pyw;
+    } else if ([filetype isEqualToString: @"Python Bytecode Document"]) {
+        curdefault = &fsdefault_pyc;
+    } else {
+        NSLog(@"Funny File Type: %@\n", filetype);
+        curdefault = &fsdefault_py;
+        filetype = @"Python Script";
+    }
+    if (!*curdefault) {
+        *curdefault = [[FileSettings new] initForFSDefaultFileType: filetype];
+    }
+    return *curdefault;
+}
+
++ (id)getDefaultsForFileType: (NSString *)filetype
+{
+    static FileSettings *default_py, *default_pyw, *default_pyc;
+    FileSettings **curdefault;
+    
+    if ([filetype isEqualToString: @"Python Script"]) {
+        curdefault = &default_py;
+    } else if ([filetype isEqualToString: @"Python GUI Script"]) {
+        curdefault = &default_pyw;
+    } else if ([filetype isEqualToString: @"Python Bytecode Document"]) {
+        curdefault = &default_pyc;
+    } else {
+        NSLog(@"Funny File Type: %@\n", filetype);
+        curdefault = &default_py;
+        filetype = @"Python Script";
+    }
+    if (!*curdefault) {
+        *curdefault = [[FileSettings new] initForDefaultFileType: filetype];
+    }
+    return *curdefault;
+}
+
++ (id)newSettingsForFileType: (NSString *)filetype
+{
+    FileSettings *cur;
+    
+    cur = [FileSettings new];
+    [cur initForFileType: filetype];
+    return [cur retain];
+}
+
+- (id)initWithFileSettings: (FileSettings *)source
+{
+    self = [super init];
+    if (!self) return self;
+    
+    interpreter = [source->interpreter retain];
+    honourhashbang = source->honourhashbang;
+    debug = source->debug;
+    verbose = source->verbose;
+    inspect = source->inspect;
+    optimize = source->optimize;
+    nosite = source->nosite;
+    tabs = source->tabs;
+    others = [source->others retain];
+    scriptargs = [source->scriptargs retain];
+    with_terminal = source->with_terminal;
+    prefskey = source->prefskey;
+    if (prefskey) [prefskey retain];
+    
+    return self;
+}
+
+- (id)initForFileType: (NSString *)filetype
+{
+    FileSettings *defaults;
+    
+    defaults = [FileSettings getDefaultsForFileType: filetype];
+    self = [self initWithFileSettings: defaults];
+    origsource = [defaults retain];
+    return self;
+}
+
+//- (id)init
+//{
+//    self = [self initForFileType: @"Python Script"];
+//    return self;
+//}
+
+- (id)initForFSDefaultFileType: (NSString *)filetype
+{
+    int i;
+    NSString *filename;
+    NSDictionary *dict;
+    static NSDictionary *factorySettings;
+    
+    self = [super init];
+    if (!self) return self;
+    
+    if (factorySettings == NULL) {
+        NSBundle *bdl = [NSBundle mainBundle];
+        NSString *path = [ bdl pathForResource: @"factorySettings"
+                ofType: @"plist"];
+        factorySettings = [[NSDictionary dictionaryWithContentsOfFile:
+            path] retain];
+        if (factorySettings == NULL) {
+            NSLog(@"Missing %@", path);
+            return NULL;
+        }
+    }
+    dict = [factorySettings objectForKey: filetype];
+    if (dict == NULL) {
+        NSLog(@"factorySettings.plist misses file type \"%@\"", filetype);
+        interpreter = [@"no default found" retain];
+        return NULL;
+    }
+    [self applyValuesFromDict: dict];
+    interpreters = [dict objectForKey: @"interpreter_list"];
+    interpreter = NULL;
+    for (i=0; i < [interpreters count]; i++) {
+        filename = [interpreters objectAtIndex: i];
+        filename = [filename stringByExpandingTildeInPath];
+        if ([[NSFileManager defaultManager] fileExistsAtPath: filename]) {
+            interpreter = [filename retain];
+            break;
+        }
+    }
+    if (interpreter == NULL)
+        interpreter = [@"no default found" retain];
+    origsource = NULL;
+    return self;
+}
+
+- (void)applyUserDefaults: (NSString *)filetype
+{
+    NSUserDefaults *defaults;
+    NSDictionary *dict;
+    
+    defaults = [NSUserDefaults standardUserDefaults];
+    dict = [defaults dictionaryForKey: filetype];
+    if (!dict)
+        return;
+    [self applyValuesFromDict: dict];
+}
+    
+- (id)initForDefaultFileType: (NSString *)filetype
+{
+    FileSettings *fsdefaults;
+    
+    fsdefaults = [FileSettings getFactorySettingsForFileType: filetype];
+    self = [self initWithFileSettings: fsdefaults];
+    if (!self) return self;
+    interpreters = [fsdefaults->interpreters retain];
+    scriptargs = [@"" retain];
+    [self applyUserDefaults: filetype];
+    prefskey = [filetype retain];
+    return self;
+}
+
+- (void)reset
+{
+    if (origsource) {
+        [self updateFromSource: origsource];
+    } else {
+        FileSettings *fsdefaults;
+        fsdefaults = [FileSettings getFactorySettingsForFileType: prefskey];
+        [self updateFromSource: fsdefaults];
+    }
+}
+
+- (void)updateFromSource: (id <FileSettingsSource>)source
+{
+    interpreter = [[source interpreter] retain];
+    honourhashbang = [source honourhashbang];
+    debug = [source debug];
+    verbose = [source verbose];
+    inspect = [source inspect];
+    optimize = [source optimize];
+    nosite = [source nosite];
+    tabs = [source tabs];
+    others = [[source others] retain];
+    scriptargs = [[source scriptargs] retain];
+    with_terminal = [source with_terminal];
+    // And if this is a user defaults object we also save the
+    // values
+    if (!origsource) {
+        NSUserDefaults *defaults;
+        NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+            interpreter, @"interpreter",
+            [NSNumber numberWithBool: honourhashbang], @"honourhashbang",
+            [NSNumber numberWithBool: debug], @"debug",
+            [NSNumber numberWithBool: verbose], @"verbose",
+            [NSNumber numberWithBool: inspect], @"inspect",
+            [NSNumber numberWithBool: optimize], @"optimize",
+            [NSNumber numberWithBool: nosite], @"nosite",
+            [NSNumber numberWithBool: nosite], @"nosite",
+            others, @"others",
+            scriptargs, @"scriptargs",
+            [NSNumber numberWithBool: with_terminal], @"with_terminal",
+            nil];
+        defaults = [NSUserDefaults standardUserDefaults];
+        [defaults setObject: dict forKey: prefskey];
+    }
+}
+
+- (void)applyValuesFromDict: (NSDictionary *)dict
+{
+    id value;
+    
+    value = [dict objectForKey: @"interpreter"];
+    if (value) interpreter = [value retain];
+    value = [dict objectForKey: @"honourhashbang"];
+    if (value) honourhashbang = [value boolValue];
+    value = [dict objectForKey: @"debug"];
+    if (value) debug = [value boolValue];
+    value = [dict objectForKey: @"verbose"];
+    if (value) verbose = [value boolValue];
+    value = [dict objectForKey: @"inspect"];
+    if (value) inspect = [value boolValue];
+    value = [dict objectForKey: @"optimize"];
+    if (value) optimize = [value boolValue];
+    value = [dict objectForKey: @"nosite"];
+    if (value) nosite = [value boolValue];
+    value = [dict objectForKey: @"nosite"];
+    if (value) tabs = [value boolValue];
+    value = [dict objectForKey: @"others"];
+    if (value) others = [value retain];
+    value = [dict objectForKey: @"scriptargs"];
+    if (value) scriptargs = [value retain];
+    value = [dict objectForKey: @"with_terminal"];
+    if (value) with_terminal = [value boolValue];
+}
+
+- (NSString *)commandLineForScript: (NSString *)script
+{
+    NSString *cur_interp = NULL;
+    char hashbangbuf[1024];
+    FILE *fp;
+    char *p;
+    
+    if (honourhashbang &&
+       (fp=fopen([script cString], "r")) &&
+       fgets(hashbangbuf, sizeof(hashbangbuf), fp) &&
+       strncmp(hashbangbuf, "#!", 2) == 0 &&
+       (p=strchr(hashbangbuf, '\n'))) {
+            *p = '\0';
+            p = hashbangbuf + 2;
+            while (*p == ' ') p++;
+            cur_interp = [NSString stringWithCString: p];
+    }
+    if (!cur_interp)
+        cur_interp = interpreter;
+        
+    return [NSString stringWithFormat:
+        @"\"%@\"%s%s%s%s%s%s %@ \"%@\" %@ %s",
+        cur_interp,
+        debug?" -d":"",
+        verbose?" -v":"",
+        inspect?" -i":"",
+        optimize?" -O":"",
+        nosite?" -S":"",
+        tabs?" -t":"",
+        others,
+        script,
+        scriptargs,
+        with_terminal? "&& echo Exit status: $? && exit 1" : " &"];
+}
+
+- (NSArray *) interpreters { return interpreters;};
+
+// FileSettingsSource protocol 
+- (NSString *) interpreter { return interpreter;};
+- (BOOL) honourhashbang { return honourhashbang; };
+- (BOOL) debug { return debug;};
+- (BOOL) verbose { return verbose;};
+- (BOOL) inspect { return inspect;};
+- (BOOL) optimize { return optimize;};
+- (BOOL) nosite { return nosite;};
+- (BOOL) tabs { return tabs;};
+- (NSString *) others { return others;};
+- (NSString *) scriptargs { return scriptargs;};
+- (BOOL) with_terminal { return with_terminal;};
+
+@end
diff --git a/Mac/PythonLauncher/Info.plist.in b/Mac/PythonLauncher/Info.plist.in
new file mode 100644
index 0000000..3c726d7
--- /dev/null
+++ b/Mac/PythonLauncher/Info.plist.in
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleDocumentTypes</key>
+	<array>
+		<dict>
+			<key>CFBundleTypeExtensions</key>
+			<array>
+				<string>py</string>
+				<string>pyw</string>
+			</array>
+			<key>CFBundleTypeIconFile</key>
+			<string>PythonSource.icns</string>
+			<key>CFBundleTypeName</key>
+			<string>Python Script</string>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>NSDocumentClass</key>
+			<string>MyDocument</string>
+		</dict>
+		<dict>
+			<key>CFBundleTypeExtensions</key>
+			<array>
+				<string>pyc</string>
+				<string>pyo</string>
+			</array>
+			<key>CFBundleTypeIconFile</key>
+			<string>PythonCompiled.icns</string>
+			<key>CFBundleTypeName</key>
+			<string>Python Bytecode Document</string>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>NSDocumentClass</key>
+			<string>MyDocument</string>
+		</dict>
+	</array>
+	<key>CFBundleExecutable</key>
+	<string>PythonLauncher</string>
+	<key>CFBundleGetInfoString</key>
+	<string>%VERSION%, © 001-2006 Python Software Foundation</string>
+	<key>CFBundleIconFile</key>
+	<string>PythonLauncher.icns</string>
+	<key>CFBundleIdentifier</key>
+	<string>org.python.PythonLauncher</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>Python Launcher</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>%VERSION%</string>
+	<key>CFBundleSignature</key>
+	<string>PytL</string>
+	<key>CFBundleVersion</key>
+	<string>%VERSION%</string>
+	<key>NSMainNibFile</key>
+	<string>MainMenu</string>
+	<key>NSPrincipalClass</key>
+	<string>NSApplication</string>
+</dict>
+</plist>
diff --git a/Mac/PythonLauncher/Makefile.in b/Mac/PythonLauncher/Makefile.in
new file mode 100644
index 0000000..b4b126c
--- /dev/null
+++ b/Mac/PythonLauncher/Makefile.in
@@ -0,0 +1,81 @@
+CC=@CC@
+LD=@CC@
+BASECFLAGS=@BASECFLAGS@
+OPT=@OPT@
+CFLAGS=$(BASECFLAGS) $(OPT)
+LDFLAGS=@LDFLAGS@
+srcdir=         @srcdir@
+VERSION=	@VERSION@
+UNIVERSALSDK=@UNIVERSALSDK@
+builddir=	../..
+
+RUNSHARED=      @RUNSHARED@
+BUILDEXE=       @BUILDEXEEXT@
+BUILDPYTHON=    $(builddir)/python$(BUILDEXE)
+
+# Deployment target selected during configure, to be checked
+# by distutils  
+MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
+@EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET
+
+BUNDLEBULDER=$(srcdir)/../../Lib/plat-mac/bundlebuilder.py
+
+PYTHONAPPSDIR=/Applications/MacPython $(VERSION)
+OBJECTS=FileSettings.o MyAppDelegate.o MyDocument.o PreferencesWindowController.o doscript.o main.o
+
+all: Python\ Launcher.app
+
+install: Python\ Launcher.app
+	test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
+	-test -d "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app" && rm -r "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app"
+	cp -r "Python Launcher.app" "$(DESTDIR)$(PYTHONAPPSDIR)"
+	touch "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app"
+
+clean:
+	rm -f *.o "Python Launcher"
+	rm -rf "Python Launcher.app"
+
+Python\ Launcher.app:  Info.plist \
+		Python\ Launcher $(srcdir)/../Icons/PythonLauncher.icns \
+		$(srcdir)/../Icons/PythonSource.icns \
+		$(srcdir)/../Icons/PythonCompiled.icns \
+		$(srcdir)/factorySettings.plist
+	rm -fr "Python Launcher.app"
+	$(RUNSHARED) $(BUILDPYTHON) $(BUNDLEBULDER) \
+		--builddir=. \
+		--name="Python Launcher" \
+		--executable="Python Launcher" \
+		--iconfile=$(srcdir)/../Icons/PythonLauncher.icns \
+		--bundle-id=org.python.PythonLauncher \
+		--resource=$(srcdir)/../Icons/PythonSource.icns \
+		--resource=$(srcdir)/../Icons/PythonCompiled.icns \
+		--resource=$(srcdir)/English.lproj \
+		--resource=$(srcdir)/factorySettings.plist \
+		--plist Info.plist \
+		build
+	find "Python Launcher.app" -name '.svn' -print0 | xargs -0 rm -r
+		
+
+FileSettings.o: $(srcdir)/FileSettings.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/FileSettings.m
+
+MyAppDelegate.o: $(srcdir)/MyAppDelegate.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyAppDelegate.m
+
+MyDocument.o: $(srcdir)/MyDocument.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyDocument.m
+
+PreferencesWindowController.o: $(srcdir)/PreferencesWindowController.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/PreferencesWindowController.m
+
+doscript.o: $(srcdir)/doscript.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/doscript.m
+
+main.o: $(srcdir)/main.m
+	$(CC) $(CFLAGS) -o $@ -c $(srcdir)/main.m
+
+Python\ Launcher: $(OBJECTS)
+	$(CC) $(LDFLAGS) -o "Python Launcher" $(OBJECTS) -framework AppKit -framework Carbon
+
+Info.plist: $(srcdir)/Info.plist.in
+	sed 's/%VERSION%/'"`$(RUNSHARED) $(BUILDPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(srcdir)/Info.plist.in > Info.plist
diff --git a/Mac/PythonLauncher/MyAppDelegate.h b/Mac/PythonLauncher/MyAppDelegate.h
new file mode 100644
index 0000000..097b541
--- /dev/null
+++ b/Mac/PythonLauncher/MyAppDelegate.h
@@ -0,0 +1,15 @@
+/* MyAppDelegate */
+
+#import <Cocoa/Cocoa.h>
+
+@interface MyAppDelegate : NSObject
+{
+    BOOL	initial_action_done;
+    BOOL	should_terminate;
+}
+- (id)init;
+- (IBAction)showPreferences:(id)sender;
+- (BOOL)shouldShowUI;
+- (BOOL)shouldTerminate;
+- (void)testFileTypeBinding;
+@end
diff --git a/Mac/PythonLauncher/MyAppDelegate.m b/Mac/PythonLauncher/MyAppDelegate.m
new file mode 100644
index 0000000..a5ba751
--- /dev/null
+++ b/Mac/PythonLauncher/MyAppDelegate.m
@@ -0,0 +1,96 @@
+#import "MyAppDelegate.h"
+#import "PreferencesWindowController.h"
+#import <Carbon/Carbon.h>
+#import <ApplicationServices/ApplicationServices.h>
+
+@implementation MyAppDelegate
+
+- (id)init
+{
+    self = [super init];
+    initial_action_done = NO;
+    should_terminate = NO;
+    return self;
+}
+
+- (IBAction)showPreferences:(id)sender
+{
+    [PreferencesWindowController getPreferencesWindow];
+}
+
+- (void)applicationDidFinishLaunching:(NSNotification *)notification
+{
+    // Test that the file mappings are correct
+    [self testFileTypeBinding];
+    // If we were opened because of a file drag or doubleclick
+    // we've set initial_action_done in shouldShowUI
+    // Otherwise we open a preferences dialog.
+    if (!initial_action_done) {
+        initial_action_done = YES;
+        [self showPreferences: self];
+    }
+}
+
+- (BOOL)shouldShowUI
+{
+    // if this call comes before applicationDidFinishLaunching: we 
+    // should terminate immedeately after starting the script.
+    if (!initial_action_done)
+        should_terminate = YES;
+    initial_action_done = YES;
+    if( GetCurrentKeyModifiers() & optionKey )
+        return YES;
+    return NO;
+}
+
+- (BOOL)shouldTerminate
+{
+    return should_terminate;
+}
+
+- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
+{
+    return NO;
+}
+
+- (void)testFileTypeBinding
+{
+    NSURL *ourUrl;
+    OSStatus err;
+    FSRef appRef;
+    NSURL *appUrl;
+    static NSString *extensions[] = { @"py", @"pyw", @"pyc", NULL};
+    NSString **ext_p;
+    int i;
+    
+    if ([[NSUserDefaults standardUserDefaults] boolForKey: @"SkipFileBindingTest"])
+        return;
+    ourUrl = [NSURL fileURLWithPath: [[NSBundle mainBundle] bundlePath]];
+    for( ext_p = extensions; *ext_p; ext_p++ ) {
+        err = LSGetApplicationForInfo(
+            kLSUnknownType,
+            kLSUnknownCreator,
+            (CFStringRef)*ext_p,
+            kLSRolesViewer,
+            &appRef,
+            (CFURLRef *)&appUrl);
+        if (err || ![appUrl isEqual: ourUrl] ) {
+            i = NSRunAlertPanel(@"File type binding",
+                @"PythonLauncher is not the default application for all " \
+                  @"Python script types. You should fix this with the " \
+                  @"Finder's \"Get Info\" command.\n\n" \
+                  @"See \"Changing the application that opens a file\" in " \
+                  @"Mac Help for details.",
+                @"OK",
+                @"Don't show this warning again",
+                NULL);
+            if ( i == 0 ) { // Don't show again
+                [[NSUserDefaults standardUserDefaults]
+                    setObject:@"YES" forKey:@"SkipFileBindingTest"];
+            }
+            return;
+        }
+    }
+}
+        
+@end
diff --git a/Mac/PythonLauncher/MyDocument.h b/Mac/PythonLauncher/MyDocument.h
new file mode 100755
index 0000000..00c1bae
--- /dev/null
+++ b/Mac/PythonLauncher/MyDocument.h
@@ -0,0 +1,41 @@
+//
+//  MyDocument.h
+//  PythonLauncher
+//
+//  Created by Jack Jansen on Fri Jul 19 2002.
+//  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+//
+
+
+#import <Cocoa/Cocoa.h>
+
+#import "FileSettings.h"
+
+@interface MyDocument : NSDocument <FileSettingsSource>
+{
+    IBOutlet NSTextField *interpreter;
+    IBOutlet NSButton *honourhashbang;
+    IBOutlet NSButton *debug;
+    IBOutlet NSButton *verbose;
+    IBOutlet NSButton *inspect;
+    IBOutlet NSButton *optimize;
+    IBOutlet NSButton *nosite;
+    IBOutlet NSButton *tabs;
+    IBOutlet NSTextField *others;
+    IBOutlet NSButton *with_terminal;
+    IBOutlet NSTextField *scriptargs;
+    IBOutlet NSTextField *commandline;
+
+    NSString *script;
+    NSString *filetype;
+    FileSettings *settings;
+}
+
+- (IBAction)do_run:(id)sender;
+- (IBAction)do_cancel:(id)sender;
+- (IBAction)do_reset:(id)sender;
+- (IBAction)do_apply:(id)sender;
+
+- (void)controlTextDidChange:(NSNotification *)aNotification;
+
+@end
diff --git a/Mac/PythonLauncher/MyDocument.m b/Mac/PythonLauncher/MyDocument.m
new file mode 100755
index 0000000..5acc2dc
--- /dev/null
+++ b/Mac/PythonLauncher/MyDocument.m
@@ -0,0 +1,175 @@
+//
+//  MyDocument.m
+//  PythonLauncher
+//
+//  Created by Jack Jansen on Fri Jul 19 2002.
+//  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+//
+
+#import "MyDocument.h"
+#import "MyAppDelegate.h"
+#import "doscript.h"
+
+@implementation MyDocument
+
+- (id)init
+{
+    self = [super init];
+    if (self) {
+    
+        // Add your subclass-specific initialization here.
+        // If an error occurs here, send a [self dealloc] message and return nil.
+        script = [@"<no script>.py" retain];
+        filetype = [@"Python Script" retain];
+        settings = NULL;
+    }
+    return self;
+}
+
+- (NSString *)windowNibName
+{
+    // Override returning the nib file name of the document
+    // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
+    return @"MyDocument";
+}
+
+- (void)close
+{
+    NSApplication *app = [NSApplication sharedApplication];
+    [super close];
+    if ([[app delegate] shouldTerminate])
+        [app terminate: self];
+}
+
+- (void)load_defaults
+{
+//    if (settings) [settings release];
+    settings = [FileSettings newSettingsForFileType: filetype];
+}
+
+- (void)update_display
+{
+//    [[self window] setTitle: script];
+    
+    [interpreter setStringValue: [settings interpreter]];
+    [honourhashbang setState: [settings honourhashbang]];
+    [debug setState: [settings debug]];
+    [verbose setState: [settings verbose]];
+    [inspect setState: [settings inspect]];
+    [optimize setState: [settings optimize]];
+    [nosite setState: [settings nosite]];
+    [tabs setState: [settings tabs]];
+    [others setStringValue: [settings others]];
+    [scriptargs setStringValue: [settings scriptargs]];
+    [with_terminal setState: [settings with_terminal]];
+    
+    [commandline setStringValue: [settings commandLineForScript: script]];
+}
+
+- (void)update_settings
+{
+    [settings updateFromSource: self];
+}
+
+- (BOOL)run
+{
+    const char *cmdline;
+    int sts;
+    
+     cmdline = [[settings commandLineForScript: script] cString];
+   if ([settings with_terminal]) {
+        sts = doscript(cmdline);
+    } else {
+        sts = system(cmdline);
+    }
+    if (sts) {
+        NSLog(@"Exit status: %d\n", sts);
+        return NO;
+    }
+    return YES;
+}
+
+- (void)windowControllerDidLoadNib:(NSWindowController *) aController
+{
+    [super windowControllerDidLoadNib:aController];
+    // Add any code here that need to be executed once the windowController has loaded the document's window.
+    [self load_defaults];
+    [self update_display];
+}
+
+- (NSData *)dataRepresentationOfType:(NSString *)aType
+{
+    // Insert code here to write your document from the given data.  You can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead.
+    return nil;
+}
+
+- (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)type;
+{
+    // Insert code here to read your document from the given data.  You can also choose to override -loadFileWrapperRepresentation:ofType: or -readFromFile:ofType: instead.
+    BOOL show_ui;
+    
+    // ask the app delegate whether we should show the UI or not. 
+    show_ui = [[[NSApplication sharedApplication] delegate] shouldShowUI];
+    [script release];
+    script = [fileName retain];
+    [filetype release];
+    filetype = [type retain];
+//    if (settings) [settings release];
+    settings = [FileSettings newSettingsForFileType: filetype];
+    if (show_ui) {
+        [self update_display];
+        return YES;
+    } else {
+        [self run];
+        [self close];
+        return NO;
+    }
+}
+
+- (IBAction)do_run:(id)sender
+{
+    [self update_settings];
+    [self update_display];
+    if ([self run])
+        [self close];
+}
+
+- (IBAction)do_cancel:(id)sender
+{
+    [self close];
+}
+
+
+- (IBAction)do_reset:(id)sender
+{
+    [settings reset];
+    [self update_display];
+}
+
+- (IBAction)do_apply:(id)sender
+{
+    [self update_settings];
+    [self update_display];
+}
+
+// FileSettingsSource protocol 
+- (NSString *) interpreter { return [interpreter stringValue];};
+- (BOOL) honourhashbang { return [honourhashbang state];};
+- (BOOL) debug { return [debug state];};
+- (BOOL) verbose { return [verbose state];};
+- (BOOL) inspect { return [inspect state];};
+- (BOOL) optimize { return [optimize state];};
+- (BOOL) nosite { return [nosite state];};
+- (BOOL) tabs { return [tabs state];};
+- (NSString *) others { return [others stringValue];};
+- (NSString *) scriptargs { return [scriptargs stringValue];};
+- (BOOL) with_terminal { return [with_terminal state];};
+
+// Delegates
+- (void)controlTextDidChange:(NSNotification *)aNotification
+{
+    [self update_settings];
+    [self update_display];
+};
+
+@end
diff --git a/Mac/PythonLauncher/PreferencesWindowController.h b/Mac/PythonLauncher/PreferencesWindowController.h
new file mode 100644
index 0000000..6346996
--- /dev/null
+++ b/Mac/PythonLauncher/PreferencesWindowController.h
@@ -0,0 +1,38 @@
+/* PreferencesWindowController */
+
+#import <Cocoa/Cocoa.h>
+
+#import "FileSettings.h"
+
+@interface PreferencesWindowController : NSWindowController <FileSettingsSource>
+{
+    IBOutlet NSPopUpButton *filetype;
+    IBOutlet NSComboBox *interpreter;
+    IBOutlet NSButton *honourhashbang;
+    IBOutlet NSButton *debug;
+    IBOutlet NSButton *verbose;
+    IBOutlet NSButton *inspect;
+    IBOutlet NSButton *optimize;
+    IBOutlet NSButton *nosite;
+    IBOutlet NSButton *tabs;
+    IBOutlet NSTextField *others;
+    IBOutlet NSButton *with_terminal;
+    IBOutlet NSTextField *commandline;
+
+    FileSettings *settings;
+}
+
++ getPreferencesWindow;
+
+- (IBAction)do_reset:(id)sender;
+- (IBAction)do_apply:(id)sender;
+- (IBAction)do_filetype:(id)sender;
+
+- (void)controlTextDidChange:(NSNotification *)aNotification;
+
+- (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString;
+- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index;
+- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox;
+
+
+@end
diff --git a/Mac/PythonLauncher/PreferencesWindowController.m b/Mac/PythonLauncher/PreferencesWindowController.m
new file mode 100644
index 0000000..311c375
--- /dev/null
+++ b/Mac/PythonLauncher/PreferencesWindowController.m
@@ -0,0 +1,121 @@
+#import "PreferencesWindowController.h"
+
+@implementation PreferencesWindowController
+
++ getPreferencesWindow
+{
+    static PreferencesWindowController *_singleton;
+    
+    if (!_singleton)
+        _singleton = [[PreferencesWindowController alloc] init];
+    [_singleton showWindow: _singleton];
+    return _singleton;
+}
+
+- (id) init
+{
+    self = [self initWithWindowNibName: @"PreferenceWindow"];
+    return self;
+}
+
+- (void)load_defaults
+{
+    NSString *title = [filetype titleOfSelectedItem];
+    
+    settings = [FileSettings getDefaultsForFileType: title];
+}
+
+- (void)update_display
+{
+//    [[self window] setTitle: script];
+    
+	[interpreter reloadData];
+    [interpreter setStringValue: [settings interpreter]];
+    [honourhashbang setState: [settings honourhashbang]];
+    [debug setState: [settings debug]];
+    [verbose setState: [settings verbose]];
+    [inspect setState: [settings inspect]];
+    [optimize setState: [settings optimize]];
+    [nosite setState: [settings nosite]];
+    [tabs setState: [settings tabs]];
+    [others setStringValue: [settings others]];
+    [with_terminal setState: [settings with_terminal]];
+    // Not scriptargs, it isn't for preferences
+    
+    [commandline setStringValue: [settings commandLineForScript: @"<your script here>"]];
+}
+
+- (void) windowDidLoad
+{
+    [super windowDidLoad];
+    [self load_defaults];
+    [self update_display];
+}
+
+- (void)update_settings
+{
+    [settings updateFromSource: self];
+}
+
+- (IBAction)do_filetype:(id)sender
+{
+    [self load_defaults];
+    [self update_display];
+}
+
+- (IBAction)do_reset:(id)sender
+{
+    [settings reset];
+    [self update_display];
+}
+
+- (IBAction)do_apply:(id)sender
+{
+    [self update_settings];
+    [self update_display];
+}
+
+// FileSettingsSource protocol 
+- (NSString *) interpreter { return [interpreter stringValue];};
+- (BOOL) honourhashbang { return [honourhashbang state]; };
+- (BOOL) debug { return [debug state];};
+- (BOOL) verbose { return [verbose state];};
+- (BOOL) inspect { return [inspect state];};
+- (BOOL) optimize { return [optimize state];};
+- (BOOL) nosite { return [nosite state];};
+- (BOOL) tabs { return [tabs state];};
+- (NSString *) others { return [others stringValue];};
+- (BOOL) with_terminal { return [with_terminal state];};
+- (NSString *) scriptargs { return @"";};
+
+// Delegates
+- (void)controlTextDidChange:(NSNotification *)aNotification
+{
+    [self update_settings];
+    [self update_display];
+};
+
+// NSComboBoxDataSource protocol
+- (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString
+{
+	NSArray *interp_list = [settings interpreters];
+    unsigned int rv = [interp_list indexOfObjectIdenticalTo: aString];
+	return rv;
+}
+
+- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index
+{
+	NSArray *interp_list = [settings interpreters];
+    id rv = [interp_list objectAtIndex: index];
+	return rv;
+}
+
+- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
+{
+	NSArray *interp_list = [settings interpreters];
+    int rv = [interp_list count];
+	return rv;
+}
+
+
+@end
diff --git a/Mac/PythonLauncher/doscript.h b/Mac/PythonLauncher/doscript.h
new file mode 100644
index 0000000..eef0b56
--- /dev/null
+++ b/Mac/PythonLauncher/doscript.h
@@ -0,0 +1,12 @@
+/*
+ *  doscript.h
+ *  PythonLauncher
+ *
+ *  Created by Jack Jansen on Wed Jul 31 2002.
+ *  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include <Carbon/Carbon.h>
+
+extern int doscript(const char *command);
\ No newline at end of file
diff --git a/Mac/PythonLauncher/doscript.m b/Mac/PythonLauncher/doscript.m
new file mode 100644
index 0000000..3e4e223
--- /dev/null
+++ b/Mac/PythonLauncher/doscript.m
@@ -0,0 +1,118 @@
+/*
+ *  doscript.c
+ *  PythonLauncher
+ *
+ *  Created by Jack Jansen on Wed Jul 31 2002.
+ *  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#import <Cocoa/Cocoa.h>
+#import <ApplicationServices/ApplicationServices.h>
+#import "doscript.h"
+
+/* I assume I could pick these up from somewhere, but where... */
+#define CREATOR 'trmx'
+
+#define ACTIVATE_CMD 'misc'
+#define ACTIVATE_SUITE 'actv'
+
+#define DOSCRIPT_CMD 'dosc'
+#define DOSCRIPT_SUITE 'core'
+#define WITHCOMMAND 'cmnd'
+
+/* ... and there's probably also a better way to do this... */
+#define START_TERMINAL "/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal &"
+
+extern int 
+doscript(const char *command)
+{
+    OSErr err;
+    AppleEvent theAEvent, theReply;
+    AEAddressDesc terminalAddress;
+    AEDesc commandDesc;
+    OSType terminalCreator = CREATOR;
+    
+    /* set up locals  */
+    AECreateDesc(typeNull, NULL, 0, &theAEvent);
+    AECreateDesc(typeNull, NULL, 0, &terminalAddress);
+    AECreateDesc(typeNull, NULL, 0, &theReply);
+    AECreateDesc(typeNull, NULL, 0, &commandDesc);
+    
+    /* create the "activate" event for Terminal */
+    err = AECreateDesc(typeApplSignature, (Ptr) &terminalCreator,
+            sizeof(terminalCreator), &terminalAddress);
+    if (err != noErr) {
+        NSLog(@"doscript: AECreateDesc: error %d\n", err);
+        goto bail;
+    }
+    err = AECreateAppleEvent(ACTIVATE_SUITE, ACTIVATE_CMD,
+            &terminalAddress, kAutoGenerateReturnID,
+            kAnyTransactionID, &theAEvent);
+    
+    if (err != noErr) {
+        NSLog(@"doscript: AECreateAppleEvent(activate): error %d\n", err);
+        goto bail;
+    }
+    /* send the event  */
+    err = AESend(&theAEvent, &theReply, kAEWaitReply,
+            kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
+    if ( err == -600 ) {
+        int count=10;
+        /* If it failed with "no such process" try to start Terminal */
+        err = system(START_TERMINAL);
+        if ( err ) {
+            NSLog(@"doscript: system(): %s\n", strerror(errno));
+            goto bail;
+        }
+        do {
+            sleep(1);
+            /* send the event again */
+            err = AESend(&theAEvent, &theReply, kAEWaitReply,
+                    kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
+        } while (err == -600 && --count > 0);
+        if ( err == -600 )
+            NSLog(@"doscript: Could not activate Terminal\n");
+    }
+    if (err != noErr) {
+        NSLog(@"doscript: AESend(activate): error %d\n", err);
+        goto bail;
+    }
+            
+    /* create the "doscript with command" event for Terminal */
+    err = AECreateAppleEvent(DOSCRIPT_SUITE, DOSCRIPT_CMD,
+            &terminalAddress, kAutoGenerateReturnID,
+            kAnyTransactionID, &theAEvent);
+    if (err != noErr) {
+        NSLog(@"doscript: AECreateAppleEvent(doscript): error %d\n", err);
+        goto bail;
+    }
+    
+    /* add the command to the apple event */
+    err = AECreateDesc(typeChar, command, strlen(command), &commandDesc);
+    if (err != noErr) {
+        NSLog(@"doscript: AECreateDesc(command): error %d\n", err);
+        goto bail;
+    }
+    err = AEPutParamDesc(&theAEvent, WITHCOMMAND, &commandDesc);
+    if (err != noErr) {
+        NSLog(@"doscript: AEPutParamDesc: error %d\n", err);
+        goto bail;
+    }
+
+    /* send the command event to Terminal.app */
+    err = AESend(&theAEvent, &theReply, kAEWaitReply,
+            kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
+    
+    if (err != noErr) {
+        NSLog(@"doscript: AESend(docommand): error %d\n", err);
+        goto bail;
+    }
+    /* clean up and leave */
+bail:
+    AEDisposeDesc(&commandDesc);
+    AEDisposeDesc(&theAEvent);
+    AEDisposeDesc(&terminalAddress);
+    AEDisposeDesc(&theReply);
+    return err;
+}
diff --git a/Mac/PythonLauncher/factorySettings.plist b/Mac/PythonLauncher/factorySettings.plist
new file mode 100644
index 0000000..1202421
--- /dev/null
+++ b/Mac/PythonLauncher/factorySettings.plist
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+        <key>Python GUI Script</key>
+        <dict>
+                <key>debug</key>
+                <false/>
+                <key>inspect</key>
+                <false/>
+                <key>interpreter_list</key>
+                <array>
+                    <string>/usr/local/bin/pythonw</string>
+                    <string>/usr/bin/pythonw</string>
+                    <string>/sw/bin/pythonw</string>
+                </array>
+                <key>honourhashbang</key>
+                <false/>
+                <key>nosite</key>
+                <false/>
+                <key>optimize</key>
+                <false/>
+                <key>others</key>
+                <string></string>
+                <key>verbose</key>
+                <false/>
+                <key>with_terminal</key>
+                <false/>
+        </dict>
+        <key>Python Script</key>
+        <dict>
+                <key>debug</key>
+                <false/>
+                <key>inspect</key>
+                <false/>
+                <key>interpreter_list</key>
+                <array>
+                    <string>/usr/local/bin/pythonw</string>
+                    <string>/usr/local/bin/python</string>
+                    <string>/usr/bin/pythonw</string>
+                    <string>/usr/bin/python</string>
+                    <string>/sw/bin/pythonw</string>
+                    <string>/sw/bin/python</string>
+                </array>
+                <key>honourhashbang</key>
+                <false/>
+                <key>nosite</key>
+                <false/>
+                <key>optimize</key>
+                <false/>
+                <key>others</key>
+                <string></string>
+                <key>verbose</key>
+                <false/>
+                <key>with_terminal</key>
+                <true/>
+        </dict>
+        <key>Python Bytecode Document</key>
+        <dict>
+                <key>debug</key>
+                <false/>
+                <key>inspect</key>
+                <false/>
+                <key>interpreter_list</key>
+                <array>
+                    <string>/usr/local/bin/pythonw</string>
+                    <string>/usr/local/bin/python</string>
+                    <string>/usr/bin/pythonw</string>
+                    <string>/usr/bin/python</string>
+                    <string>/sw/bin/pythonw</string>
+                    <string>/sw/bin/python</string>
+                </array>
+                <key>honourhashbang</key>
+                <false/>
+                 <key>nosite</key>
+                <false/>
+                <key>optimize</key>
+                <false/>
+                <key>others</key>
+                <string></string>
+                <key>verbose</key>
+                <false/>
+                <key>with_terminal</key>
+                <true/>
+        </dict>
+</dict>
+</plist>
diff --git a/Mac/PythonLauncher/main.m b/Mac/PythonLauncher/main.m
new file mode 100755
index 0000000..6841433
--- /dev/null
+++ b/Mac/PythonLauncher/main.m
@@ -0,0 +1,17 @@
+//
+//  main.m
+//  PythonLauncher
+//
+//  Created by Jack Jansen on Fri Jul 19 2002.
+//  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#include <unistd.h>
+
+int main(int argc, const char *argv[])
+{
+	char *home = getenv("HOME");
+	if (home) chdir(home);
+    return NSApplicationMain(argc, argv);
+}