Commit Graph

184 Commits

Author SHA1 Message Date
Raymond Hettinger db29e0fe8c SF patch #1035498: -m option to run a module as a script
(Contributed by Nick Coghlan.)
2004-10-07 06:46:25 +00:00
Martin v. Löwis 4d4dfb7a2b Patch #1011822: Display errno/strerror for inaccessible files. 2004-08-19 11:07:49 +00:00
Skip Montanaro 786ea6bc23 Add pystack definition to Misc/gdbinit with some explanation of its behavior
and add flag comments to ceval.c and main.c alerting people to the coupling
between pystack and the layout of those files.
2004-03-01 15:44:05 +00:00
Jack Jansen fb2765666f Getting rid of support for the ancient Apple MPW compiler. 2003-11-19 15:24:47 +00:00
Martin v. Löwis 6caea370ac Patch #794400: Let PYTHONSTARTUP influence the compiler flags. 2003-11-18 19:46:25 +00:00
Walter Dörwald f0dfc7ac5c Fix a bunch of typos in documentation, docstrings and comments.
(From SF patch #810751)
2003-10-20 14:01:56 +00:00
Barry Warsaw d86dcd3554 Py_Main(): Add a check for the PYTHONINSPECT environment variable
after running the script so that a program could do something like:

os.environ['PYTHONINSPECT'] = 1

to programmatically enter a prompt at the end.

(After a patch by Skip Montanaro w/ proposal by Troy Melhase
2003-06-29 17:07:06 +00:00
Martin v. Löwis 852ba7eb2a Patch #672053: Return a result from Py_Main, instead of exiting. 2003-03-30 17:09:58 +00:00
Martin v. Löwis e98922fb80 Patch #695250: Suppress COPYRIGHT if site.py is not read. Fixes #672614.
Will backport to 2.2.
2003-03-30 17:00:39 +00:00
Jack Jansen fbd861bbd3 An #endif was missing in Just's patch. Added. 2003-03-05 16:00:15 +00:00
Just van Rossum 2ac79ef9e3 removing one Mac hack and add another:
- The applet logic has been replaced to bundlebuilder's bootstrap script
- Due to Apple being extremely string about argv[0], we need a way to
  specify the actual executable name for use with sys.executable. See
  the comment embedded in the code.
2003-03-05 15:46:54 +00:00
Martin v. Löwis 7a924e6eb2 Patch #696645: Remove VMS code with uncertain authorship. 2003-03-05 14:15:21 +00:00
Jack Jansen 0a116f3a29 Squashed compiler warnings by adding casts, making sure prototypes are in
scope and looking at types.
2002-12-23 21:03:36 +00:00
Martin v. Löwis 79acb9edfa Patch #614055: Support OpenVMS. 2002-12-06 12:48:53 +00:00
Fred Drake 5134a54df9 Fix minor whitespace nit, for consistency with Python's C style rules. 2002-10-17 20:37:50 +00:00
Sjoerd Mullender 9cf424b04b On Cygwin, put stdin, stderr, and stdout in binary mode when the -u
flag is given (to mimic native Windows).
2002-08-09 13:35:18 +00:00
Jack Jansen 21ed16acbe Added one call to Py_Main(), for OSX framework builds only, that will get the
actual script to run in case we are running from an applet. If we are indeed
running an applet we skip the normal option processing leaving it all to the
applet code.

This allows us to get use the normal python binary in the Python.app bundle,
giving us all the normal command line options through PythonLauncher while
still allowing Python.app to be used as the template for building applets.

Consequently, pythonforbundle is gone, and Mac/Python/macmain.c isn't used
on OSX anymore.
2002-08-02 14:11:24 +00:00
Mark Hammond fe51c6d66e Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
for Py_Main().

Thanks to Kalle Svensson and Skip Montanaro for the patches.
2002-08-02 02:27:13 +00:00
Neal Norwitz ce233b462d Fix last checkin, can't use " inside a string 2002-07-28 13:53:05 +00:00
Martin v. Löwis 611a7101ca Patch #552812: Better description in "python -h" for -u. 2002-07-28 10:34:08 +00:00
Andrew MacIntyre 7bf6833e17 OS/2 EMX port changes (Modules part of patch #450267):
Modules/
    _hotshot.c
    dbmmodule.c
    fcntlmodule.c
    main.c
    pwdmodule.c
    readline.c
    selectmodule.c
    signalmodule.c
    termios.c
    timemodule.c
    unicodedata.c
2002-03-03 02:59:16 +00:00
Marc-André Lemburg aeff6687b5 Remove mentioning of -U option in "python -h" output. 2002-02-11 18:46:47 +00:00
Martin v. Löwis cdc4451222 Include <unistd.h> in Python.h. Fixes #500924. 2002-01-12 11:05:12 +00:00
Tim Peters 3caca2326e SF bug #488514: -Qnew needs work
Big Hammer to implement -Qnew as PEP 238 says it should work (a global
option affecting all instances of "/").

pydebug.h, main.c, pythonrun.c:  define a private _Py_QnewFlag flag, true
iff -Qnew is passed on the command line.  This should go away (as the
comments say) when true division becomes The Rule.  This is
deliberately not exposed to runtime inspection or modification:  it's
a one-way one-shot switch to pretend you're using Python 3.

ceval.c:  when _Py_QnewFlag is set, treat BINARY_DIVIDE as
BINARY_TRUE_DIVIDE.

test_{descr, generators, zipfile}.py:  fiddle so these pass under
-Qnew too.  This was just a matter of s!/!//! in test_generators and
test_zipfile.  test_descr was trickier, as testbinop() is passed
assumptions that "/" is the same as calling a "__div__" method; put
a temporary hack there to call "__truediv__" instead when the method
name is "__div__" and 1/2 evaluates to 0.5.

Three standard tests still fail under -Qnew (on Windows; somebody
please try the Linux tests with -Qnew too!  Linux runs a whole bunch
of tests Windows doesn't):
    test_augassign
    test_class
    test_coercion
I can't stay awake longer to stare at this (be my guest).  Offhand
cures weren't obvious, nor was it even obvious that cures are possible
without major hackery.

Question:  when -Qnew is in effect, should calls to __div__ magically
change into calls to __truediv__?  See "major hackery" at tail end of
last paragraph <wink>.
2001-12-06 06:23:26 +00:00
Guido van Rossum 1832de4bc0 PEP 238 documented -Qwarn as warning only for classic int or long
division, and this makes sense.  Add -Qwarnall to warn for all
classic divisions, as required by the fixdiv.py tool.
2001-09-04 03:51:09 +00:00
Guido van Rossum 61c345fa37 Rename the -D option to -Q, to avoid a Jython option name conflict. 2001-09-04 03:26:15 +00:00
Guido van Rossum 97741a3041 Oops. The -W option takes args, not -X. 2001-08-31 18:17:13 +00:00
Guido van Rossum 393661d15f Add warning mode for classic division, almost exactly as specified in
PEP 238.  Changes:

- add a new flag variable Py_DivisionWarningFlag, declared in
  pydebug.h, defined in object.c, set in main.c, and used in
  {int,long,float,complex}object.c.  When this flag is set, the
  classic division operator issues a DeprecationWarning message.

- add a new API PyRun_SimpleStringFlags() to match
  PyRun_SimpleString().  The main() function calls this so that
  commands run with -c can also benefit from -Dnew.

- While I was at it, I changed the usage message in main() somewhat:
  alphabetized the options, split it in *four* parts to fit in under
  512 bytes (not that I still believe this is necessary -- doc strings
  elsewhere are much longer), and perhaps most visibly, don't display
  the full list of options on each command line error.  Instead, the
  full list is only displayed when -h is used, and otherwise a brief
  reminder of -h is displayed.  When -h is used, write to stdout so
  that you can do `python -h | more'.

Notes:

- I don't want to use the -W option to control whether the classic
  division warning is issued or not, because the machinery to decide
  whether to display the warning or not is very expensive (it involves
  calling into the warnings.py module).  You can use -Werror to turn
  the warnings into exceptions though.

- The -Dnew option doesn't select future division for all of the
  program -- only for the __main__ module.  I don't know if I'll ever
  change this -- it would require changes to the .pyc file magic
  number to do it right, and a more global notion of compiler flags.

- You can usefully combine -Dwarn and -Dnew: this gives the __main__
  module new division, and warns about classic division everywhere
  else.
2001-08-31 17:40:15 +00:00
Neil Schemenauer 7d4bb9f179 Add -E command line switch (ignore environment variables like PYTHONHOME
and PYTHONPATH).
2001-07-23 16:30:27 +00:00
Guido van Rossum 36002d7af1 Add "help" to the things one is encouraged to type for more
information.  (I found this idea in the ActivePython 2.1 diffs.)
2001-07-18 16:59:46 +00:00
Tim Peters 5ba5866281 Part way to allowing "from __future__ import generators" to communicate
that info to code dynamically compiled *by* code compiled with generators
enabled.  Doesn't yet work because there's still no way to tell the parser
that "yield" is OK (unlike nested_scopes, the parser has its fingers in
this too).
Replaced PyEval_GetNestedScopes by a more-general
PyEval_MergeCompilerFlags.  Perhaps I should not have?  I doubted it was
*intended* to be part of the public API, so just did.
2001-07-16 02:29:45 +00:00
Marc-André Lemburg da4dbc36c1 Removed the Python version from the PYTHONHOMEHELP string. It was
still set to python2.0 ...
2001-06-12 16:13:51 +00:00
Guido van Rossum bceccf5f43 Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger 2001-04-10 22:07:43 +00:00
Jeremy Hylton bc32024769 Extend support for from __future__ import nested_scopes
If a module has a future statement enabling nested scopes, they are
also enable for the exec statement and the functions compile() and
execfile() if they occur in the module.

If Python is run with the -i option, which enters interactive mode
after executing a script, and the script it runs enables nested
scopes, they are also enabled in interactive mode.

XXX The use of -i with -c "from __future__ import nested_scopes" is
not supported.  What's the point?

To support these changes, many function variants have been added to
pythonrun.c.  All the variants names end with Flags and they take an
extra PyCompilerFlags * argument.  It is possible that this complexity
will be eliminated in a future version of the interpreter in which
nested scopes are not optional.
2001-03-22 02:47:58 +00:00
Guido van Rossum 3ed4c15a88 RISCOS changes by dschwertberger. 2001-03-02 06:18:03 +00:00
Barry Warsaw 3e13b1e48b Py_Main(): When compiled by Insure (i.e. __INSURE__ is defined), call
the internal API function to release the interned strings as the very
last thing before returning status.  This aids in memory use debugging
because it eliminates a huge source of noise from the reports.  This
is never called during normal (non-debugging) use because releasing
the interned strings slows Python's shutdown and isn't necessary
anyway because the system will always reclaim the memory.
2001-02-23 16:46:39 +00:00
Tim Peters 793de09b21 Add a line to "python -h" output about PYTHONCASEOK. 2001-02-22 00:39:47 +00:00
Guido van Rossum 47f5fdc114 Add the -W option. 2000-12-15 22:00:54 +00:00
Thomas Wouters 2cffc7d420 Move our own getopt() implementation to _PyOS_GetOpt(), and use it
regardless of whether the system getopt() does what we want. This avoids the
hassle with prototypes and externs, and the check to see if the system
getopt() does what we want. Prefix optind, optarg and opterr with _PyOS_ to
avoid name clashes. Add new include file to define the right symbols. Fix
Demo/pyserv/pyserv.c to include getopt.h itself, instead of relying on
Python to provide it.
2000-11-03 08:18:37 +00:00
Barry Warsaw 3b2aedbdc5 Py_Main(), usage(), usage_mid: Add -h and -V flags to print the usage
message and Python version number and exit immediately.  Closes patch
#101496.
2000-09-15 18:40:42 +00:00
Guido van Rossum a22865ec44 Instead of printing all 9 lines of copyright info, print
"Type \"copyright\", \"credits\" or \"license\" for more information."
2000-09-05 04:41:18 +00:00
Guido van Rossum 8586991099 REMOVED all CWI, CNRI and BeOpen copyright markings.
This should match the situation in the 1.6b1 tree.
2000-09-01 23:29:29 +00:00
Guido van Rossum 0df002c45b Add three new APIs: PyRun_AnyFileEx(), PyRun_SimpleFileEx(),
PyRun_FileEx().  These are the same as their non-Ex counterparts but
have an extra argument, a flag telling them to close the file when
done.

Then this is used by Py_Main() and execfile() to close the file after
it is parsed but before it is executed.

Adding APIs seems strange given the feature freeze but it's the only
way I see to close the bug report without incompatible changes.

[ Bug #110616 ] source file stays open after parsing is done (PR#209)
2000-08-27 19:21:52 +00:00
Fredrik Lundh 620f37723f - changed 1.5 to 2.0 in the help text
(the PYTHONHOMEHELP define)

- ANSI-fication
  (patch #100794 by Peter Schneider-Kamp)
2000-07-09 20:42:34 +00:00
Guido van Rossum ffcc3813d8 Change copyright notice - 2nd try. 2000-06-30 23:58:06 +00:00
Guido van Rossum fd71b9e9d4 Change copyright notice. 2000-06-30 23:50:40 +00:00
Barry Warsaw 57e11ae847 usage_mid: Remove the description of the -X flag; it's gone now.
Py_Main(): Remove the 'X' case.
2000-05-02 19:20:26 +00:00
Guido van Rossum c15a9a1f98 Marc-Andre Lemburg:
Added -U command line option.

With the option enabled the Python compiler interprets all "..."
strings as u"..." (same with r"..." and ur"...").
2000-05-01 17:54:33 +00:00
Guido van Rossum dc8b569155 Patch from Tim Peters to repare a the problem that tracebacks are off
by a line when Python is run with -x.
1999-04-19 17:54:19 +00:00
Guido van Rossum 01b7ced834 On Windows, -i shouldn't call set[v]buf(stdin, ...) because it screws
up the _tkinter main loop.  Not clear why; the _kbhit() call _tkinter
makes probably confuses the stdio library when buffering isn't set to
whatever it is by default.
1999-02-09 18:36:51 +00:00
Guido van Rossum 6b86a42c7f Document -OO; "unsafe" optimization that removes docstrings.
Marc-Andre Lemburg.
1999-01-28 15:07:47 +00:00
Guido van Rossum 9c1201fe39 Py_Main() must be DL_EXPORT too. 1998-12-07 14:28:47 +00:00
Guido van Rossum e7adf3eb6d Documented PYTHONOPTIMIZE; by Marc Lemburg. 1998-10-07 14:50:06 +00:00
Guido van Rossum 7c33095b6b Typo in usage message. 1998-04-13 20:28:18 +00:00
Guido van Rossum bba92ca555 Add -t option to set the Py_TabcheckFlag flag. 1998-04-10 19:39:15 +00:00
Guido van Rossum 22ffac1b1f Don't use setvbuf unless HAVE_SETVBUF is defined. 1998-03-06 15:30:39 +00:00
Guido van Rossum a075ce1618 Two changes by Jeff Rush (slightly tweaked):
- New option -x, to skip first line of script

- Use the correct platform-specific delimiter and library location in
the usage message

(Also removed two blank lines and moved one line around so that each
part of the usage message is again under 512 bytes and the whole usage
message still fits in 23 lines.)
1997-12-05 21:56:45 +00:00
Guido van Rossum 873c35c437 Take out the setlocale() call. It affects atof() and will break
floating point literals.  Need to do this differently...
1997-10-31 18:25:15 +00:00
Guido van Rossum 44c36bb114 Add call to setlocale(LC_ALL, ""). 1997-10-08 22:49:17 +00:00
Guido van Rossum 3d26cc9542 Move the "import readline" to an earlier place so it is also done when
"-i" is given.  (Yes, I know, giving in to Marc Lemburg who wanted
this :-)
1997-09-16 16:11:28 +00:00
Guido van Rossum 7922bd7382 Added -X option to suppress default import of site.py. Also split the
usage message in *three* parts under 510 bytes, for low-end ANSI
compatibility.
1997-08-29 22:34:47 +00:00
Barry Warsaw 83b6709d8e Swap the sense of the -X option vis-a-vis Py_UseClassExceptionsFlag so
that class based exceptions are enabled by default.  -X disables them
in favor of the old-style string exceptions.
1997-08-29 22:20:16 +00:00
Barry Warsaw f488af3360 Parse new command line option -X which enables exception classes. 1997-08-29 21:57:49 +00:00
Guido van Rossum 9b5dbedf43 Attempt to import readline at interactive startup. 1997-08-05 21:34:14 +00:00
Guido van Rossum 5d1770ee24 Py_Cleanup() is now Py_Finalize(). 1997-08-05 02:23:48 +00:00
Guido van Rossum 05f7c50bfd Free the malloc'ed buffer that holds the command once we're done with it.
Instead of calling Py_Exit(sts), call Py_Cleanup() and return sts.
1997-08-02 03:00:42 +00:00
Guido van Rossum 534ac094f9 Removed a bunch of extern declarations of functions that are now
properly declared in Python.h.
1997-07-19 19:51:43 +00:00
Guido van Rossum ed52aacb33 This is no longer the real main program; it now defines Py_Main(), so
it can be placed in the library.

Other, related changes:

- Moved the inspection of some environment variables to
Py_Initialize().

- Got rid of -s option.

- Moved Py_GetProgramName() and related logic to pythonrun.c; call
Py_SetProgramName() instead.

- Print the version header *after* successful initialization.
1997-07-19 19:20:32 +00:00
Guido van Rossum fe4dfc7ce3 Add platform to welcome message. 1997-05-19 18:33:01 +00:00
Guido van Rossum 03ef647847 Add PYTHONHOME to the usage message. 1997-04-30 19:48:59 +00:00
Guido van Rossum b31c7dcb43 OK, I lied. On Windows, _IOLBF seems to be the same as full
buffering, so to get the normal behavior back, I set it to
unbuffered.
1997-04-11 22:19:12 +00:00
Guido van Rossum 2a212191f8 Change in when and how stdin and stdout are set to line-buffering.
This used to be done whenever stdin was interactive.  Now we only do
it when the -i flag is given.  Also (and this is the real reason for
this fix) we explicitly allocate a buffer -- this seems to be
necessary on Windows.
1997-04-11 21:57:53 +00:00
Guido van Rossum 7614da6b87 Add -O option which sets Py_OptimizeFlag to avoid emitting SET_LINENO.
Fred: sorry, I hadn't checked these changes in.  This should fix your
tracebacks!
1997-03-03 19:14:45 +00:00
Guido van Rossum 129e91aa77 Add parentheses around && within || as gcc -Wall advises. 1997-02-14 21:00:50 +00:00
Guido van Rossum 775af91911 My version of Lee Busby's patches to make '-i' pretend stdin is a tty
even if it isn't.  Changes:

- set the global flag Py_InteractiveFlag when -i is given
- call Py_FdIsInteractive() instead of isatty()
- make stdin unbuffered, too, when using -u
- make stdin and stdout line buffered, when stdin is interactive and not -u

Note that setting the environment variable PYTHONINSPECT does not have
these extra effects of -i.  (Should it?)

Unlike Lee's changes, I don't set change the prompt to go to stderr
when -i is given.
1997-02-14 19:50:32 +00:00
Guido van Rossum 3e7ae7ab17 Fix the _setmode() patch for MS_WINDOWS: include <fcntl.h> and use
fileno(std*).
1997-01-17 22:05:38 +00:00
Guido van Rossum f22d7e2c69 On Windows, -u implies binary mode for stdin/stdout
(as well as unbuffered stdout/stderr).
1997-01-11 19:28:55 +00:00
Guido van Rossum 66a7013c5c Include unistd.h to keep gcc -Wall happy. 1996-12-09 18:46:58 +00:00
Guido van Rossum a376cc5cc8 Keep gcc -Wall happy. 1996-12-05 23:43:35 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum ac56b03f9a New style names for getprogramname and getargcargv 1996-07-21 02:33:38 +00:00
Guido van Rossum 8026febbd6 Made comment for getprogramname() more helpful. 1996-06-20 16:49:26 +00:00
Guido van Rossum 582646aecc grand renaming; added copyright to some files 1996-05-28 22:30:17 +00:00
Guido van Rossum 667d704997 Initial revision 1995-08-04 04:20:48 +00:00