Commit Graph

290 Commits

Author SHA1 Message Date
Tim Peters 6d6c1a35e0 Merge of descr-branch back into trunk. 2001-08-02 04:15:00 +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 a1b3a47406 PyRun_StringFlags(): forgot to pass the flags on to
PyParser_SimpleParseString().  Now calls
PyParser_SimpleParseStringFlags() with the correct flag.
2001-07-16 16:51:33 +00:00
Tim Peters fe2127d3cb Ugly. A pile of new xxxFlags() functions, to communicate to the parser
that 'yield' is a keyword.  This doesn't help test_generators at all!  I
don't know why not.  These things do work now (and didn't before this
patch):

1. "from __future__ import generators" now works in a native shell.

2. Similarly "python -i xxx.py" now has generators enabled in the
   shell if xxx.py had them enabled.

3. This program (which was my doctest proxy) works fine:

from __future__ import generators

source = """\
def f():
    yield 1
"""

exec compile(source, "", "single") in globals()
print type(f())
2001-07-16 05:37:24 +00:00
Tim Peters 51d76f1f75 future.c: insert a cosmetic space.
pythonrun.c, run_pyc_file():  repair semantic error wrt CO_GENERATOR vs
CO_GENERATOR_ALLOWED.
2001-07-16 03:11:48 +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 464fe3aa7b Temporarily disable the message to stderr. Jeremy will know what to do
about this...
2001-06-13 17:18:06 +00:00
Jeremy Hylton 673a4fda51 Bug fix: compile() called from a nested-scopes-enable Python was not
using nested scopes to compile its argument.  Pass compiler flags
through to underlying compile call.
2001-03-26 19:53:38 +00:00
Guido van Rossum 66e8e86cf8 Finishing touch to Ping's changes. This is a patch that Ping sent me
but apparently he had to go to school, so I am checking it in for him.

This makes PyRun_HandleSystemExit() a static instead, called
handle_system_exit(), and let it use the current exception rather than
passing in an exception.  This slightly simplifies the code.
2001-03-23 17:54:43 +00:00
Fred Drake 6a12d8d3b4 call_sys_exitfunc(): Remove unused variable f. 2001-03-23 17:34:02 +00:00
Ka-Ping Yee 26fabb0016 Allow sys.excepthook and sys.exitfunc to quietly exit with a sys.exit().
sys.exitfunc gets the last word on the exit status of the program.
2001-03-23 15:36:41 +00:00
Guido van Rossum 4131830c23 Fix memory leak with SyntaxError. (The DECREF was originally hidden
inside a piece of code that was deemed reduntant; the DECREF was
unfortunately *not* redundant!)
2001-03-23 04:01:07 +00:00
Ka-Ping Yee b5c5132d1a Add sys.excepthook.
Update docstring and library reference section on 'sys' module.
New API PyErr_Display, just for displaying errors, called by excepthook.
Uncaught exceptions now call sys.excepthook; if that fails, we fall back
    to calling PyErr_Display directly.
Also comes with sys.__excepthook__ and sys.__displayhook__.
2001-03-23 02:46:52 +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
Jeremy Hylton 9f324e964e Useful future statement support for the interactive interpreter
(Also remove warning about module-level global decl, because we can't
distinguish from code passed to exec.)

Define PyCompilerFlags type contains a single element,
cf_nested_scopes, that is true if a nested scopes future statement has
been entered at the interactive prompt.

New API functions:
    PyNode_CompileFlags()
    PyRun_InteractiveOneFlags()
    -- same as their non Flags counterparts except that the take an
       optional PyCompilerFlags pointer

compile.c: In jcompile() use PyCompilerFlags argument.  If
    cf_nested_scopes is true, compile code with nested scopes.  If it
    is false, but the code has a valid future nested scopes statement,
    set it to true.

pythonrun.c: Create a new PyCompilerFlags object in
    PyRun_InteractiveLoop() and thread it through to
    PyRun_InteractiveOneFlags().
2001-03-01 22:59:14 +00:00
Fred Drake b797f1f6d2 Now that Jeremy is asking about this code, it looks really bogus to me,
so let's rip it out.  The constructor for SyntaxError does the right
thing, so we do not need to do it again.
2001-02-28 20:58:04 +00:00
Jeremy Hylton 9f1b9932b8 Print the offending line of code in the traceback for SyntaxErrors
raised by the compiler.

XXX For now, text entered into the interactive intepreter is not
printed in the traceback.

Inspired by a patch from Roman Sulzhyk

compile.c:

Add helper fetch_program_text() that opens a file and reads until it
finds the specified line number.  The code is a near duplicate of
similar code in traceback.c.

Modify com_error() to pass two arguments to SyntaxError constructor,
where the second argument contains the offending text when possible.

Modify set_error_location(), now used only by the symtable pass, to
set the text attribute on existing exceptions.

pythonrun.c:

Change parse_syntax_error() to continue of the offset attribute of a
SyntaxError is None.  In this case, it sets offset to -1.

Move code from PyErr_PrintEx() into helper function
print_error_text().  In the helper, only print the caret for a
SyntaxError if offset > 0.
2001-02-28 07:07:43 +00:00
Tim Peters 6f5a4efc0a Bug #132850 unix line terminator on windows.
Miserable hack to replace the previous miserable hack in maybe_pyc_file.
2001-02-17 22:02:34 +00:00
Tim Peters 3e876565a3 Ugly fix for SF bug 131239 (-x flag busted).
Bug was introduced by tricks played to make .pyc files executable
via cmdline arg.  Then again, -x worked via a trick to begin with.
If anyone can think of a portable way to test -x, be my guest!
2001-02-11 04:35:39 +00:00
Jeremy Hylton 4b38da664c Move a bunch of definitions that were internal to compile.c to
symtable.h, so that they can be used by external module.

Improve error handling in symtable_enter_scope(), which return an
error code that went unchecked by most callers. XXX The error handling
in symtable code is sloppy in general.

Modify symtable to record the line number that begins each scope.
This can help to identify which code block is being referred to when
multiple blocks are bound to the same name.

Add st_scopes dict that is used to preserve scope info when
PyNode_CompileSymtable() is called.  Otherwise, this information is
tossed as soon as it is no longer needed.

Add Py_SymtableString() to pythonrun; analogous to Py_CompileString().
2001-02-02 18:19:15 +00:00
Tim Peters d9b9ac855c It's unclear whether PyMarshal_XXX() are part of the public or private API.
They're named as if public, so I did a Bad Thing by changing
PyMarshal_ReadObjectFromFile() to suck up the remainder of the file in one
gulp:  anyone who counted on that leaving the file pointer merely at the
end of the next object would be screwed.  So restored
PyMarshal_ReadObjectFromFile() to its earlier state, renamed the new greedy
code to PyMarshal_ReadLastObjectFromFile(), and changed Python internals to
call the latter instead.
2001-01-28 00:27:39 +00:00
Tim Peters 384fd106e8 Bug #128475: mimetools.encode (sometimes) fails when called from a thread.
pythonrun.c:  In Py_Finalize, don't reset the initialized flag until after
the exit funcs have run.
atexit.py:  in _run_exitfuncs, mutate the list of pending calls in a
threadsafe way.  This wasn't a contributor to bug 128475, it just burned
my eyeballs when looking at that bug.
2001-01-21 03:40:37 +00:00
Guido van Rossum 44a6ff6cf4 Get rid of the initialization of _PyCompareState_Key. 2001-01-17 21:27:36 +00:00
Tim Peters b8584e0894 Fix signed/unsigned wng. Unfortunately, (unsigned char) << int
has type int in C.
2001-01-05 00:54:29 +00:00
Martin v. Löwis be4c0f56a2 Recognize pyc files even if they don't end in pyc.
Patch #103067 with modifications as discussed in email.
2001-01-04 20:30:56 +00:00
Guido van Rossum 6f25618be5 Add PyOS_getsig() and PyOS_setsig() -- wrappers around signal() or
sigaction() (if HAVE_SIGACTION is defined).
2000-09-16 16:32:19 +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
Fred Drake 399739f79f PyOS_CheckStack(): Better ANSI'fy this while we're at it. 2000-08-31 05:52:44 +00:00
Fred Drake e8de31cbd0 Add a comment explaining the return value of PyOS_CheckStack(). 2000-08-31 05:38:39 +00:00
Tim Peters e868211e10 Hard to believe Guido compiled this! Function lacked a return stmt. 2000-08-27 20:18:17 +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 2f15b25da2 implements PyOS_CheckStack for Windows and MSVC. this fixes a
couple of potential stack overflows, including bug #110615.

closes patch #101238
2000-08-27 19:15:31 +00:00
Marc-André Lemburg dc3d606bd9 Fix to [ Bug #111165 ] doc-string removal masked by PYTHONOPTIMIZE 2000-08-25 21:00:46 +00:00
Fred Drake a811a5b13a Remove the osdefs.h #include; it was not needed in the final version of
my last set of changes.
2000-08-15 16:13:37 +00:00
Fred Drake 83cb797380 When raising a SyntaxError, make a best-effort attempt to set the
filename and lineno attributes, but do not mask the SyntaxError if we
fail.

This is part of what is needed to close SoruceForge bug #110628
(Jitterbug PR#278).
2000-08-15 15:49:03 +00:00
Thomas Wouters f70ef4f860 Mass ANSIfication of function definitions. Doesn't cover all 'extern'
declarations yet, those come later.
2000-07-22 18:47:25 +00:00
Thomas Wouters 7e47402264 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
comments, docstrings or error messages. I fixed two minor things in
test_winreg.py ("didn't" -> "Didn't" and "Didnt" -> "Didn't").

There is a minor style issue involved: Guido seems to have preferred English
grammar (behaviour, honour) in a couple places. This patch changes that to
American, which is the more prominent style in the source. I prefer English
myself, so if English is preferred, I'd be happy to supply a patch myself ;)
2000-07-16 12:04:32 +00:00
Jack Jansen cbf630f0a9 Include macglue.h for some function prototypes, and renamed a few
mac-specific functions to have a PyMac_ name.
2000-07-11 21:59:16 +00:00
Fred Drake 85f363990c Create two new exceptions: IndentationError and TabError. These are
used for indentation related errors.  This patch includes Ping's
improvements for indentation-related error messages.

Closes SourceForge patches #100734 and #100856.
2000-07-11 17:53:00 +00:00
Tim Peters dbd9ba6a6c Nuke all remaining occurrences of Py_PROTO and Py_FPROTO. 2000-07-09 03:09:57 +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
Jeremy Hylton 94988067b9 Add new parser error code, E_OVERFLOW. This error is returned when
the number of children of a node exceeds the max possible value for
the short that is used to count them.  The Python runtime converts
this parser error into the SyntaxError "expression too long."
2000-06-20 19:10:44 +00:00
Barry Warsaw f242aa0d1e Py_Initialize(): Now that standard exceptions are builtin, we don't
need two phase init or fini of the builtin module.  Change the call of
_PyBuiltin_Init_1() to _PyBuiltin_Init().  Add a call to
init_exceptions().

Py_Finalize(): Don't call _PyBuiltin_Fini_1().  Instead call
fini_exceptions() but move this to before the thread state is
cleared.
2000-05-25 23:09:49 +00:00
Guido van Rossum b18618dab7 Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives.
For documentation read the comments in mymalloc.h and objimpl.h.

(This is not exactly what Vladimir posted to the patches list; I've
made a few changes, and Vladimir sent me a fix in private email for a
problem that only occurs in debug mode.  I'm also holding back on his
change to main.c, which seems unnecessary to me.)
2000-05-03 23:44:39 +00:00
Barry Warsaw 3ce096459e Py_UseClassExceptionsFlag is deprecated. We keep the C variable for C
API consistency, but nothing sets it or checks it now.
2000-05-02 19:18:59 +00:00
Guido van Rossum b16d197d66 Marc-Andre Lemburg:
Added Py_UnicodeFlag for use by the -U command line option.
2000-05-01 17:55:15 +00:00
Guido van Rossum eca4784781 Mark Hammond: For Windows debug builds, we now only offer to dump
remaining object references if the environment variable PYTHONDUMPREFS
exists.  The default behaviour caused problems for background or
otherwise invisible processes that use the debug build of Python.
2000-04-27 23:44:15 +00:00
Jeremy Hylton 4a3dd2dcc2 Fix PR#7 comparisons of recursive objects
Note that comparisons of deeply nested objects can still dump core in
extreme cases.
2000-04-14 19:13:24 +00:00
Guido van Rossum c94044c11d Marc-Andre Lemburg: add calls to initialize and finalize Unicode and
Codec registry.
2000-03-10 23:03:54 +00:00
Guido van Rossum bffd683f73 The rest of the changes by Trent Mick and Dale Nagata for warning-free
compilation on NT Alpha.  Mostly added casts etc.
2000-01-20 22:32:56 +00:00
Guido van Rossum 7c85ab829d Marc-Andre Lemburg discovered that the switch from .pyc to .pyo files,
done by _PyImport_Init(), comes to late to affect the import of
exceptions.py by _PyBuiltin_Init_2().  Move  _PyImport_Init() up few lines.
1999-07-08 17:26:56 +00:00
Guido van Rossum b6987b13fe Alas, get rid of the Win specific hack to ask the user to press Return
before exiting when an error happened.  This didn't work right when
Python is invoked from a daemon.
1999-04-07 18:32:51 +00:00
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
Guido van Rossum befa14f1b9 #undef argument, for the Mac 1995-09-18 21:42:42 +00:00
Jack Jansen 21eb0b56a8 mac CW-only fix for messy windows upon exit 1995-07-29 13:55:06 +00:00
Guido van Rossum 681d79aaf3 keyword arguments and faster calls 1995-07-18 14:51:37 +00:00
Guido van Rossum 527c2643d1 flush stdout before writing to stderr in print_error() 1995-03-30 11:01:44 +00:00
Guido van Rossum 6f9e433ab3 fix dusty debugging macros 1995-03-29 16:57:48 +00:00
Guido van Rossum a44823b776 In NT, write fatal() msg to debugging device 1995-03-14 15:01:17 +00:00
Jack Jansen bd06e96217 mac changes:
- Assume files of types 'PYC ' and 'APPL' are compiled python code
- For mwerks, show status line when program has terminated while
  keeping window open.
1995-02-13 11:44:56 +00:00
Guido van Rossum 262e124107 print class name for exceptions that are classes 1995-02-07 15:30:45 +00:00
Jack Jansen 08e767bdc5 Under CodeWarrior, make the window go away on exit(0) 1995-02-02 14:30:20 +00:00
Guido van Rossum 42a5124101 Think C mod to suppress pausing at normal exit 1995-01-30 12:52:46 +00:00
Guido van Rossum 8ae87c0489 make call_pyc_file static 1995-01-26 00:40:38 +00:00
Guido van Rossum 94390ec2a6 use getbuiltins() everywhere, it defaults to getbuiltidict() 1995-01-12 11:37:57 +00:00
Guido van Rossum 6135a87f2b __builtins__ mods (and sys_checkinterval for ceval.c) 1995-01-09 17:53:26 +00:00
Guido van Rossum 6d023c98b0 Added 1995 to copyright message.
bltinmodule.c: fixed coerce() nightmare in ternary pow().
modsupport.c (initmodule2): pass METH_FREENAME flag to newmethodobject().
pythonrun.c: move flushline() into and around print_error().
1995-01-04 19:12:13 +00:00
Guido van Rossum 1ae940a587 Lots of changes, most minor (fatal() instead of abort(), use of
err_fetch/err_restore and so on).  But...
NOTE: import.c has been rewritten and all the DL stuff is now in the
new file importdl.c.
1995-01-02 19:04:15 +00:00
Jack Jansen e00637bdcf Removed extraneous fclose() in case of .pyc file argument 1994-12-14 12:58:37 +00:00
Guido van Rossum 83dd6c319e * Python/pythonrun.c: add string "Python" to fatal error message 1994-09-29 09:38:33 +00:00
Guido van Rossum 798199d8a6 * Python/pythonrun.c (print_error): print only last line of
multi-line source line
1994-09-19 08:08:50 +00:00
Guido van Rossum fdef271550 * Import/pythonrun.h, Python/{import,pythonrun}.c,
mac/macsetfiletype.c: changes by Jack to execute .pyc file passed
	as command line argument.  On the Mac .pyc files are given a
	special type so they can be double-clicked
1994-09-14 13:31:04 +00:00
Guido van Rossum 1662dd5a3d added Py_AtExit() -- register cleanup functions for C modules 1994-09-07 14:38:28 +00:00
Guido van Rossum a110aa658b * Python/pythonrun.c (print_error): added INCREF/DECREF pair --
the exception returned by a syntax error (when reported) would
        contain an object with refcnt zero!
MPW changes
1994-08-29 12:50:44 +00:00
Guido van Rossum b376a4ad18 * timemodule.c: Add hack for Solaris 2.
* posixmodule.c: don't prototype getcwd() -- it's not portable...
* mappingobject.c: double-check validity of last_name_char in
  dict{lookup,insert,remove}.
* arraymodule.c: need memmove only for non-STDC Suns.
* Makefile: comment out HTML_LIBS and XT_USE by default
* pythonmain.c: don't prototype getopt() -- it's not standardized
* socketmodule.c: cast flags arg to {get,set}sockopt() and addrbuf arg to
  recvfrom() to (ANY*).
* pythonrun.c (initsigs): fix prototype, make it static
* intobject.c (LONG_BIT): only #define it if not already defined
* classobject.[ch]: remove all references to unused instance_convert()
* mappingobject.c (getmappingsize): Don't return NULL in int function.
1993-11-23 17:53:17 +00:00
Guido van Rossum b73cc04e62 * ceval.c, longobject.c, methodobject.c, listnode.c, arraymodule.c,
pythonrun.c: added static forward declarations
* pythonrun.h, ceval.h, longobject.h, node.h: removed declarations of
  static routines
1993-11-01 16:28:59 +00:00
Sjoerd Mullender a9c3c22c33 * Extended X interface: pixmap objects, colormap objects visual objects,
image objects, and lots of new methods.
* Added counting of allocations and deallocations of builtin types if
  COUNT_ALLOCS is defined.  Had to move calls to NEWREF down in some
  files.
* Bug fix in sorting lists.
1993-10-11 12:54:31 +00:00
Guido van Rossum f1dc566328 * Makefile: added all: and default: targets.
* many files: made some functions static; removed "extern int errno;".
* frozenmain.c: fixed bugs introduced on 24 June...
* flmodule.c: remove 1.5 bw compat hacks, add new functions in 2.2a
  (and some old functions that were omitted).
* timemodule.c: added MSDOS floatsleep version .
* pgenmain.c: changed exit() to goaway() and added defn of goaway().
* intrcheck.c: add hack (to UNIX only) so interrupting 3 times
  will exit from a hanging program.  The second interrupt prints
  a message explaining this to the user.
1993-07-05 10:31:29 +00:00
Guido van Rossum 81daa32c15 Access checks now work, at least for instance data (not for methods
yet).  The class is now passed to eval_code and stored in the current
frame.  It is also stored in instance method objects.  An "unbound"
instance method is now returned when a function is retrieved through
"classname.funcname", which when called passes the class to eval_code.
1993-05-20 14:24:46 +00:00
Guido van Rossum 6ac258d381 * pythonrun.c: Print exception type+arg *after* stack trace instead of
before it.
* ceval.c, object.c: moved testbool() to object.c (now extern visible)
* stringobject.c: fix bugs in and rationalize string resize in formatstring()
* tokenizer.[ch]: fix non-working code for lines longer than BUFSIZ
1993-05-12 08:24:20 +00:00
Guido van Rossum 5b7221849e * Fixed some subtleties with fastlocals. You can no longer access
f_fastlocals in a traceback object (this is a core dump hazard
  if there are <nil> entries), but instead eval_code() merges the fast
  locals back into the locals dictionary if it looks like the local
  variables will be retained.  Also, the merge routines save
  exceptions since this is sometimes needed (alas!).

* Added id() to bltinmodule.c, which returns an object's address
  (identity).  Useful to walk arbitrary data structures containing
  cycles.

* Added compile() to bltinmodule.c and compile_string() to
  pythonrun.[ch]: support to exec/eval arbitrary code objects.  The
  code that defaults globals and locals is moved from run_node in
  pythonrun.c (which is now identical to eval_node) to eval_code in
  ceval.c.  [XXX For elegance a clean-up session is necessary.]
1993-03-30 17:46:03 +00:00
Guido van Rossum 8b17d6bd89 Changes to speed up local variables enormously, by avoiding dictionary
lookup (opcode.h, ceval.[ch], compile.c, frameobject.[ch],
pythonrun.c, import.c).  The .pyc MAGIC number is changed again.
Added get_menu_text to flmodule.
1993-03-30 13:18:41 +00:00
Guido van Rossum 9bfef44d97 * Changed all copyright messages to include 1993.
* Stubs for faster implementation of local variables (not yet finished)
* Added function name to code object.  Print it for code and function
  objects.  THIS MAKES THE .PYC FILE FORMAT INCOMPATIBLE (the version
  number has changed accordingly)
* Print address of self for built-in methods
* New internal functions getattro and setattro (getattr/setattr with
  string object arg)
* Replaced "dictobject" with more powerful "mappingobject"
* New per-type functio tp_hash to implement arbitrary object hashing,
  and hashobject() to interface to it
* Added built-in functions hash(v) and hasattr(v, 'name')
* classobject: made some functions static that accidentally weren't;
  added __hash__ special instance method to implement hash()
* Added proper comparison for built-in methods and functions
1993-03-29 10:43:31 +00:00
Guido van Rossum a9e7dc1081 * bltinmodule.c: added built-in function cmp(a, b)
* flmodule.c: added {do,check}_only_forms to fl's list of functions;
  and don't print a message when an unknown object is returned.

* pythonrun.c: catch SIGHUP and SIGTERM to do essential cleanup.

* Made jpegmodule.c smaller by using getargs() and mkvalue() consistently.

* Increased parser stack size to 500 in parser.h.

* Implemented custom allocation of stack frames to frameobject.c and
  added dynamic stack overflow checks (value stack only) to ceval.c.
  (There seems to be a bug left: sometimes stack traces don't make sense.)
1992-10-18 18:53:57 +00:00
Guido van Rossum 3165fe6a56 Modified most (but not yet all) I/O to always go through sys.stdout or
sys.stderr or sys.stdin, and to work with any object as long as it has
a write() (respectively readline()) methods.  Some functions that took
a FILE* argument now take an object* argument.
1992-09-25 21:59:05 +00:00
Guido van Rossum 59bff399a0 Add sys.exitfunc feature. Make askync non-static. 1992-09-03 20:28:00 +00:00
Guido van Rossum f9f2e82fca New thread.c from Sjoerd, supports _exit_prog(). Use this in goaway()
to avoid hanging in cleanup().
1992-08-17 08:59:08 +00:00
Guido van Rossum df72a655b9 To ignore a call, cast it to (void), not to (void *)... 1992-08-12 15:27:32 +00:00
Guido van Rossum ff4949eeee * Makefile: cosmetics
* socketmodule.c: get rid of makepair(); fix makesocketaddr to fix
  broken recvfrom()
* socketmodule: get rid of getStrarg()
* ceval.h: move eval_code() to new file eval.h, so compile.h is no
  longer needed.
* ceval.c: move thread comments to ceval.h; always make save/restore
  thread functions available (for dynloaded modules)
* cdmodule.c, listobject.c: don't include compile.h
* flmodule.c: include ceval.h
* import.c: include eval.h instead of ceval.h
* cgen.py: add forground(); noport(); winopen(""); to initgl().
* bltinmodule.c, socketmodule.c, fileobject.c, posixmodule.c,
  selectmodule.c:
  adapt to threads (add BGN/END SAVE macros)
* stdwinmodule.c: adapt to threads and use a special stdwin lock.
* pythonmain.c: don't include getpythonpath().
* pythonrun.c: use BGN/END SAVE instead of direct calls; also more
  BGN/END SAVE calls etc.
* thread.c: bigger stack size for sun; change exit() to _exit()
* threadmodule.c: use BGN/END SAVE macros where possible
* timemodule.c: adapt better to threads; use BGN/END SAVE; add
  longsleep internal function if BSD_TIME; cosmetics
1992-08-05 19:58:53 +00:00
Guido van Rossum 1984f1e1c6 * Makefile adapted to changes below.
* split pythonmain.c in two: most stuff goes to pythonrun.c, in the library.
* new optional built-in threadmodule.c, build upon Sjoerd's thread.{c,h}.
* new module from Sjoerd: mmmodule.c (dynamically loaded).
* new module from Sjoerd: sv (svgen.py, svmodule.c.proto).
* new files thread.{c,h} (from Sjoerd).
* new xxmodule.c (example only).
* myselect.h: bzero -> memset
* select.c: bzero -> memset; removed global variable
1992-08-04 12:41:02 +00:00