Commit Graph

87 Commits

Author SHA1 Message Date
Barry Warsaw 3d05b1a0ae initmain(): Nailed a memory leak. bimod must be DECREF'd! 1999-01-29 21:30:22 +00:00
Barry Warsaw c80baa3365 err_input(): Nailed a small memory leak. If the error is E_INTR, the
v temporary variable was never decref'd.  Test this by starting up the
interpreter, hitting C-c, then immediately exiting.

Same potential leak can occur if error is E_NOMEM, since the return is
done in the case block.  Added Py_XDECREF(v); to both blocks, just
before the return.
1999-01-27 16:39:40 +00:00
Guido van Rossum 2c1f6be38e Hack for Windows so that if (1) the exit status is nonzero and (2) we
think we have our own DOS box (i.e. we're not started from a command
line shell), we print a message and wait for the user to hit a key
before the DOS box is closed.

The hacky heuristic for determining whether we have our *own* DOS box
(due to Mark Hammond) is to test whether we're on line zero...
1999-01-08 15:56:28 +00:00
Guido van Rossum 2edcf0d71c Move the prototype for dump_counts() to before where it is used.
(This only applies when COUNT_ALLOCS is defined.)
1998-12-15 16:12:00 +00:00
Guido van Rossum 562f5b1480 Support PYTHONOPTIMIZE variable; by Marc Lemburg. 1998-10-07 14:50:42 +00:00
Guido van Rossum 49b560698b Renamed thread.h to pythread.h. 1998-10-01 20:42:43 +00:00
Guido van Rossum 2dcfc9618d On second though, NEXITFUNCS should be defined here and not in
pystate.h; pystate.h doesn't use it (I thought I wanted to move the
array there but that won't work).
1998-10-01 16:01:57 +00:00
Guido van Rossum 93d27547d0 Remove redundant definition of NEXITFUNCS.
(Reported by Jeff Rush.)
1998-09-28 22:15:37 +00:00
Guido van Rossum 53195c1a83 Don't release the interpreter lock around PyParser_ParseFile().
It is needed so that tokenizer.c can use PySys_WriteStderr().
1998-08-27 19:14:49 +00:00
Guido van Rossum 0ba353608f Add DebugBreak() call to Py_FatalError() for Mark Hammond (only on
Win32 in Debug mode).
1998-08-13 13:33:16 +00:00
Guido van Rossum 560e8adef7 Translate E_INDENT to the clearest error message I can think of. 1998-04-10 19:43:42 +00:00
Guido van Rossum bf02fb28d9 Make sure that the message "Error in sys.exitfunc:" goes to sys.stderr
and not to C's stderr.
1998-04-03 21:12:12 +00:00
Guido van Rossum 0829c754bb Fix the handling of errors in Py_FlushLine() in a few places.
(Basically, the error is cleared...  Like almost everywhere else...)
1998-02-28 04:31:39 +00:00
Guido van Rossum a61691e4e9 Ehm, three unrelated changes.
- Add Py_FrozenFlag, intended to suppress error messages fron
getpath.c in frozen binaries.

- Add Py_GetPythonHome() and Py_SetPythonHome(), intended to allow
embedders to force a different PYTHONHOME.

- Add new interface PyErr_PrintEx(flag); same as PyErr_Print() but
flag determines whether sys.last_* are set or not.  PyErr_Print()
now simply calls PyErr_PrintEx(1).
1998-02-06 22:27:24 +00:00
Guido van Rossum 4cc462e85b It seems obvious that when Py_Finalize() decides that there's nothing
to do, it should not call sys.exitfunc either...
1998-01-19 22:00:38 +00:00
Guido van Rossum 1707aad27c Changed the finalization order again so that the reference count
printing (when Py_DEBUG is defined) happens while there's still a
current thread...
1997-12-08 23:43:45 +00:00
Guido van Rossum ddc3fb5734 Apply str() to sys.ps1 or sys.ps2 before using them as a prompt, so
you can assign an object whose str() evaluates to the current
directory (or whatever).
1997-11-25 20:58:13 +00:00
Guido van Rossum 858cb73bb2 Two changes (here we go again :-( ).
1) The __builtins__ variable in the __main__ module is set to the
__builtin__ module instead of its __dict__.

2) Get rid of the SIGHUP and SIGTERM handlers.  They can't be made to
work reliably when threads may be in use, they are Unix specific, and
Python programmers can now program this functionality is a safer way
using the signal module.
1997-11-19 16:15:37 +00:00
Guido van Rossum 4a1f39a26b Undo half of the previous change :-(
Setting interp->builtins to the __builtin__ module instead of to its
dictionary had the unfortunate side effect of always running in
restricted execution mode :-(

I will check in a different way of setting __main__.__builtins__ to
the __builtin__ module later.

Also, there was a typo -- a comment was unfinished, and as a result
some finalizations were not being executed.

In Bart Simpson style,

I Will Not Check In Untested Changes.
I Will Not Check In Untested Changes.
I Will Not Check In Untested Changes.
I Will Not Check In Untested Changes.
I Will Not Check In Untested Changes.
I Will Not Check In Untested Changes.
I Will Not Check In Untested Changes.
I Will Not Check In Untested Changes.
I Will Not Check In Untested Changes.
I Will Not Check In Untested Changes.
1997-11-04 19:36:18 +00:00
Guido van Rossum 3a44e1b9fb Two independent changes (alas):
- The interp->builtins variable (and hence, __main__.__builtins__) is
once again initialized to the built-in *module* instead of its
dictionary.

- The finalization order is once again changed.  Signals are finalized
relatively early, because (1) it DECREF's the signal handlers, and if
a signal handler happens to be a bound method, deleting it could cause
problems when there's no current thread around, and (2) we don't want
to risk executing signal handlers during finalization.
1997-11-03 21:58:47 +00:00
Guido van Rossum 999e5e921e Initialize Py_UseClassExceptionsFlag to 1. 1997-10-03 19:46:02 +00:00
Guido van Rossum aa9606f45a Fix small omission: with all the new code, sys.exit(None) would print
"None"; this should be equivalent to sys.exit(0).
1997-10-03 13:53:28 +00:00
Barry Warsaw 963b871e86 Py_Initialize(): move the call to _PyImport_FixupExtension() to after
the phase 2 init of the __builtin__ module, so that multiple
interpreters will get the right exceptions.
1997-09-18 16:42:02 +00:00
Barry Warsaw 2f5f6a2595 PyErr_Print(): When printing a class exception, try to dig out the
__module__ string and if found, print <module>.<class>, unless
<module> == "exceptions".
1997-09-16 21:42:03 +00:00
Guido van Rossum d6bf45bcf6 Fixed some details of printing the str() of an exception. This fixes
a core dump when __str__() returns a non-string, and plugs a memory
leak as well: the result of PyObject_Str() was never DECREFed.
1997-09-05 19:11:53 +00:00
Guido van Rossum dcc0c13f74 Two independent changes (oops):
- Changed semantics for initialized flag (again); forget the ref
counting, forget the fatal errors -- redundant calls to
Py_Initialize() or Py_Finalize() calls are simply ignored.

- Automatically import site.py on initialization, unless a flag is set
not to do this by main().
1997-08-29 22:32:42 +00:00
Barry Warsaw 035574d755 Added Py_UseClassExceptionsFlag, the variable containing the state of
the -X command line option.

Py_Initialize(): Handle the two phase initialization of the built-in
module.

Py_Finalize(): Handle the two phase finalization of the built-in
module.

parse_syntax_error(): New function which parses syntax errors that
PyErr_Print() will catch.  This correctly parses such errors
regardless of whether PyExc_SyntaxError is an old-style string
exception or new-fangled class exception.

PyErr_Print(): Many changes:

    1. Normalize the exception.

    2. Handle SystemExit exceptions which might be class based.  Digs
       the exit code out of the "code" attribute.  String based
       SystemExit is handled the same as before.

    3. Handle SyntaxError exceptions which might be class based.  Digs
       the various information bits out of the instance's attributes
       (see parse_syntax_error() for details).  String based
       SyntaxError still works too.

    4. Don't write the `:' after the exception if the exception is
       class based and has an empty string str() value.
1997-08-29 22:07:17 +00:00
Barry Warsaw 36b8f945e7 PyErr_Print(): Use PyErr_GivenExceptionMatches() instead of pointer
compares to test for SystemExit and SyntaxError.
1997-08-26 18:09:48 +00:00
Guido van Rossum e3c0d5eb34 Added new Py_IsInitalized() API function to test the 'initialized' flag. 1997-08-22 04:20:13 +00:00
Guido van Rossum aa61505fd2 Use a counter instead of a Boolean to check for initialized; n calls
to Py_Initialize will be undone by n calls to Py_Uninitialize.
1997-08-20 22:40:18 +00:00
Guido van Rossum cc283f56a7 Merge Py_Cleanup() into Py_Finalize(). Call the various small Fini()
functions.
1997-08-05 02:22:03 +00:00
Guido van Rossum 25ce566661 The last of the mass checkins for separate (sub)interpreters.
Everything should now work again.

See the comments for the .h files mass checkin (e.g. pystate.h) for
more detail.
1997-08-02 03:10:38 +00:00
Guido van Rossum ad6dfda9af Moved some stuff here from main.c (part of a big restructuring - wait
for more!).

- The global flags that can be set from environment variables are now
set in Py_Initialize (except the silly Py_SuppressPrint, which no
longer exists).  This saves duplicate code in frozenmain.c and main.c.

- Py_GetProgramName() is now here; added Py_SetProgramName().  An
embedding program should no longer provide Py_GetProgramName(),
instead it should call Py_SetProgramName() *before* calling
Py_Initialize().
1997-07-19 19:17:22 +00:00
Guido van Rossum 296b4751e1 Can't return 0 from void function... 1997-05-23 00:19:20 +00:00
Guido van Rossum 78a1ed3d70 Py_FlushLine and PyFile_WriteString now return error indicators
instead of calling PyErr_Clear().  Add checking of those errors.
1997-05-22 22:35:04 +00:00
Guido van Rossum 23c9446d9a Added a space in an error message 1997-05-22 20:21:30 +00:00
Guido van Rossum b05a5c7698 Instead of importing graminit.h whenever one of the three grammar 'root'
symbols is needed, define these in Python.h with a Py_ prefix.
1997-05-07 17:46:13 +00:00
Guido van Rossum 478e718aca Keep MS compiler happy: use (int)strlen() when comparing; make sure
not to use kill().
1997-05-06 15:24:59 +00:00
Guido van Rossum a027efa5bf Massive changes for separate thread state management.
All per-thread globals are moved into a struct which is manipulated
separately.
1997-05-05 20:56:21 +00:00
Guido van Rossum 2a7f58de1c Allow passing a .pyo file.
Print correct name in fatal error from PyErr_Print.
1997-04-02 05:28:38 +00:00
Guido van Rossum 82598051e6 Greatly renamed. Not a very thorough job -- I'm going to restructure
it anyway.
1997-03-05 00:20:32 +00:00
Guido van Rossum 7433b12a5c Added new global flag variable Py_InteractiveFlag and new function
Py_FdIsInteractive().  The flag is supposed to be set by the -i
command line option.  The function is supposed to be called instead of
isatty().  This is used for Lee Busby's wish #1, to have an option
that pretends stdin is interactive even when it really isn't.
1997-02-14 19:45:36 +00:00
Guido van Rossum 80bb9655f0 Keep gcc -Wall happy. 1996-12-05 23:27:02 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum 9b38a145e2 Rationalized MS ifdefs 1996-09-11 23:12:24 +00:00
Guido van Rossum ded690fc35 rename printrefs, getobjects to _Py_ prefix 1996-05-24 20:48:31 +00:00
Guido van Rossum aae0d32f66 Use new names for debug macros. Don't include pythonrun.h. 1996-05-22 16:35:33 +00:00
Guido van Rossum 4f1c59b818 Add'l change for NT (Mark H.). 1996-04-09 02:37:03 +00:00
Jack Jansen 66a8977b0e Moved mac-specific exit handling to macmain.c 1995-10-27 13:22:14 +00:00
Guido van Rossum 1c45ca310b keep exitfunc alive while calling it 1995-10-07 19:14:01 +00:00