summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
AgeCommit message (Collapse)AuthorLines
2003-08-11Fix refcounting and cut & paste error (?) in last checkin.Michael W. Hudson-3/+1
This should go onto release23-maint, too.
2003-08-09Move initialization of sys.std{in,out}.encoding to Py_Initialize.Martin v. Löwis-15/+51
Verify that the encoding actually exists. Fixes #775985. Will backport to 2.3.
2003-07-16Correct previous patch looking for warnings module: sys.modules, notMark Hammond-1/+1
sys.__modules__.
2003-07-15Fix [ 771097 ] frozen programs fail due to implicit import of "warnings".Mark Hammond-5/+36
If the initial import of warnings fails, clear the error. When the module is actually needed, if the original import failed, see if it has managed to find its way to sys.modules yet and if so, remember it.
2003-04-22PyGILState cleanup was too early - destructors called via module cleanup may ↵Mark Hammond-5/+5
use the API.
2003-04-19handle_system_exit(): This leaked the current exception info, inTim Peters-4/+16
particular leaving the traceback object (and everything reachable from it) alive throughout shutdown. The patch is mostly from Guido. Bugfix candidate.
2003-04-19New PyGILState_ API - implements pep 311, from patch 684256.Mark Hammond-0/+15
2003-04-17_Py_PrintReferences(): Changed to print object address at start of eachTim Peters-2/+9
new line. New pvt API function _Py_PrintReferenceAddresses(): Prints only the addresses and refcnts of the live objects. This is always safe to call, because it has no dependence on Python's C API. Py_Finalize(): If envar PYTHONDUMPREFS is set, call (the new) _Py_PrintReferenceAddresses() right before dumping final pymalloc stats. We can't print the reprs of the objects here because too much of the interpreter has been shut down. You need to correlate the addresses displayed here with the object reprs printed by the earlier PYTHONDUMPREFS call to _Py_PrintReferences().
2003-04-17- New C API PyGC_Collect(), same as calling gc.collect().Guido van Rossum-0/+8
- Call this in Py_Finalize(). - Expand the Misc/NEWS text on PY_LONG_LONG.
2003-04-17A missing piece of the PEP 269 patch: add PyParser_SetError(), aGuido van Rossum-0/+9
wrapper around err_input().
2003-04-17Trimmed trailing whitespace.Tim Peters-10/+10
2003-04-17Py_Finalize(): Reverted recent changes that tried to move theTim Peters-8/+11
PYTHONDUMPREFS output after most teardown. Attempts to use PYTHONDUMPREFS with the Zope3 test suite died with Py_FatalError(), since _Py_PrintReferences() can end up executing arbitrary Python code (for objects that override __repr__), and that requires an intact interpreter.
2003-04-15- pythunrun.c, Py_Finalize(): move the call to _Py_PrintReferences()Guido van Rossum-8/+8
even farther down, to just before the call to _PyObject_DebugMallocStats(). This required the following changes: - pystate.c, PyThreadState_GetDict(): changed not to raise an exception or issue a fatal error when no current thread state is available, but simply return NULL without raising an exception (ever). - object.c, Py_ReprEnter(): when PyThreadState_GetDict() returns NULL, don't raise an exception but return 0. This means that when printing a container that's recursive, printing will go on and on and on. But that shouldn't happen in the case we care about (see first bullet). - Updated Misc/NEWS and Doc/api/init.tex to reflect changes to PyThreadState_GetDict() definition.
2003-04-15Move the call to _Py_PrintReferences() a bit further down. ThisGuido van Rossum-7/+12
prevents it from showing stuff (like codec state) that is cleared when the interpreter state is cleared.
2003-04-10Move declaration of enc to scope where it is usedNeal Norwitz-2/+1
2003-03-19Fixed SF bug #663074. The codec system was using global staticGustavo Niemeyer-8/+0
variables to store internal data. As a result, any atempts to use the unicode system with multiple active interpreters, or successive interpreter executions, would fail. Now that information is stored into members of the PyInterpreterState structure.
2003-03-05Declare all variables at the start of their scope.Fred Drake-1/+1
2003-03-05Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,Martin v. Löwis-0/+28
and not as a side effect of setlocale. Expose it as sys.getfilesystemencoding. Adjust test case.
2003-02-25Addendum to #683658:Just van Rossum-2/+2
import warnings.py _after_ site.py has run. This ensures that site.py is again the first .py to be imported, giving it back full control over sys.path.
2003-02-19Fix bug 683658 - PyErr_Warn may cause import deadlock.Mark Hammond-0/+11
2003-02-13- Finally fixed the bug in compile() and exec where a string endingGuido van Rossum-6/+2
with an indented code block but no newline would raise SyntaxError. This would have been a four-line change in parsetok.c... Except codeop.py depends on this behavior, so a compilation flag had to be invented that causes the tokenizer to revert to the old behavior; this required extra changes to 2 .h files, 2 .c files, and 2 .py files. (Fixes SF bug #501622.)
2003-01-24MacPython-OS9 has had an abort() function for quite a while now, so there's ↵Jack Jansen-3/+0
no reason to stall in an endless loop, just call abort() on a fatal error.
2003-01-22Patch #671459: Invoke import hooks in Py_NewInterpreter.Martin v. Löwis-0/+1
2002-12-31Since the *_Init() are private, prefix with _, suggested by SkipNeal Norwitz-2/+2
2002-12-30SF #561244, Micro optimizationsNeal Norwitz-0/+6
Initialize the small integers and __builtins__ in startup. This removes some if conditions. Change XDECREF to DECREF for values which shouldn't be NULL.
2002-12-30PEP 302 + zipimport:Just van Rossum-0/+2
- new import hooks in import.c, exposed in the sys module - new module called 'zipimport' - various changes to allow bootstrapping from zip files I hope I didn't break the Windows build (or anything else for that matter), but then again, it's been sitting on sf long enough... Regarding the latest discussions on python-dev: zipimport sets pkg.__path__ as specified in PEP 273, and likewise, sys.path item such as /path/to/Archive.zip/subdir/ are supported again.
2002-12-13Added missing casts.Jack Jansen-2/+2
2002-12-11Constify filenames and scripts. Fixes #651362.Martin v. Löwis-41/+41
2002-11-17Remove _Py_ResetReferences. Fixes bug #529750 "Circular reference makesNeil Schemenauer-4/+0
Py_Init crash". refchain cannot be cleared because objects can live across Py_Finalize() and Py_Initialize() if they are kept alive by circular references.
2002-10-17If we have a filename and __main__.__file__ hasn't already been set,Fred Drake-1/+11
set it. Closes SF issue #624729.
2002-10-05s/_alloca/alloca/g; Windows doesn't need the former, at least not unlessTim Peters-2/+2
__STDC__ is defined (or something like that ...).
2002-08-15provide less mysterious error messages when seeing end-of-line inSkip Montanaro-0/+6
single-quoted strings or end-of-file in triple-quoted strings. closes patch 586561.
2002-08-04Patch #534304: Implement phase 1 of PEP 263.Martin v. Löwis-0/+13
2002-07-09_Py_AskYesNo(): Removed this function. It was defined only in aTim Peters-20/+0
Py_TRACE_REFS build, but wasn't referenced.
2002-07-09Fix SF Bug 564931: compile() traceback must include filename.Thomas Heller-2/+27
2002-07-09The Py_REF_DEBUG/COUNT_ALLOCS/Py_TRACE_REFS macro minefield: addedTim Peters-1/+1
more trivial lexical helper macros so that uses of these guys expand to nothing at all when they're not enabled. This should help sub- standard compilers that can't do a good job of optimizing away the previous "(void)0" expressions. Py_DECREF: There's only one definition of this now. Yay! That was that last one in the family defined multiple times in an #ifdef maze. Py_FatalError(): Changed the char* signature to const char*. _Py_NegativeRefcount(): New helper function for the Py_REF_DEBUG expansion of Py_DECREF. Calling an external function cuts down on the volume of generated code. The previous inline expansion of abort() didn't work as intended on Windows (the program often kept going, and the error msg scrolled off the screen unseen). _Py_NegativeRefcount calls Py_FatalError instead, which captures our best knowledge of how to abort effectively across platforms.
2002-06-30Patch #569753: Remove support for WIN16.Martin v. Löwis-3/+3
Rename all occurrences of MS_WIN32 to MS_WINDOWS.
2002-04-23Ignore SIGXFSZ.Jeremy Hylton-0/+3
The SIGXFSZ signal is sent when the maximum file size limit is exceeded (RLIMIT_FSIZE). Apparently, it is also sent when the 2GB file limit is reached on platforms without large file support. The default action for SIGXFSZ is to terminate the process and dump core. When it is ignored, the system call that caused the limit to be exceeded returns an error and sets errno to EFBIG. Python always checks errno on I/O syscalls, so there is nothing to do with the signal.
2002-04-13_PyObject_DebugDumpStats: renamed to _PyObject_DebugMallocStats.Tim Peters-0/+5
Added code to call this when PYMALLOC_DEBUG is enabled, and envar PYTHONMALLOCSTATS is set, whenever a new arena is obtained and once late in the Python shutdown process.
2002-04-08Move Unicode finalization further down in the chain.Marc-André Lemburg-5/+5
Fixes bug #525620.
2002-04-01Get rid of another use of PyArg_Parse()Neal Norwitz-2/+2
2002-03-22Disable the parser hacks that enabled the "yield" keyword using a futureNeil Schemenauer-11/+13
statement.
2002-03-03Patch #50002: Display line information for bad \x escapes:Martin v. Löwis-1/+1
- recognize "SyntaxError"s by the print_file_and_line attribute. - add the syntaxerror attributes to all exceptions in compile.c. Fixes #221791
2002-01-12Include <unistd.h> in Python.h. Fixes #500924.Martin v. Löwis-4/+0
2001-12-07Missing DECREFs when exception is raised in sys.excepthook.Jeremy Hylton-0/+3
Bug fix candidate for 2.1 branch. (I imagine the other recent leak patches are bug fix candidates, too, but I forgot to mark mine as such.)
2001-12-06SF bug #488514: -Qnew needs workTim Peters-0/+4
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-11-28Use PyOS_snprintf instead of sprintf.Jeremy Hylton-1/+1
2001-11-13PyOS_getsig(), PyOS_setsig(): The minimal amount of work to avoid theBarry Warsaw-0/+12
uninitialized memory reads reported in bug #478001. Note that this doesn't address the following larger issues: - Error conditions are not documented for PyOS_*sig() in the C API. - Nothing that actually calls PyOS_*sig() in the core interpreter and extension modules actually /checks/ the return value of the call. Fixing those is left as an exercise for a later day.
2001-10-12SF patch #467455 : Enhanced environment variables, by Toby Dickenson.Guido van Rossum-3/+14
This patch changes to logic to: if env.var. set and non-empty: if env.var. is an integer: set flag to that integer if flag is zero: # [actually, <= 0 --GvR] set flag to 1 Under this patch, anyone currently using PYTHONVERBOSE=yes will get the same output as before. PYTHONVERBNOSE=2 will generate more verbosity than before. The only unusual case that the following three are still all equivalent: PYTHONVERBOSE=yespleas PYTHONVERBOSE=1 PYTHONVERBOSE=0
2001-08-31Add warning mode for classic division, almost exactly as specified inGuido van Rossum-1/+7
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.