summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
AgeCommit message (Collapse)AuthorLines
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.
2001-08-17Patch #445762: Support --disable-unicodeMartin v. Löwis-0/+4
- Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled - check for Py_USING_UNICODE in all places that use Unicode functions - disables unicode literals, and the builtin functions - add the types.StringTypes list - remove Unicode literals from most tests.
2001-08-16Oops. Two fixes for SF bug #422004 are not needed. :-)Guido van Rossum-1/+0
2001-08-16Bunchathings:Guido van Rossum-5/+6
- initsigs(): Ignore SIGXFZ so writing files beyond the file system size limit won't kill us. - Py_Initialize(): call _Py_ReadyTypes() instead of readying types here. - Py_Initialize(): call _PyImport_FixupExtension() for module "extensions". (SF bug #422004.)
2001-08-13Py_Initialize(): Apply patch by Jürgen Hermann to callBarry Warsaw-0/+1
_PyImport_FixupExtension() on the exceptions module. Now reload(exceptions) acts just like reload(sys) instead of raising an ImportError. This closes SF bug #422004.
2001-08-10Refactor future feature handlingJeremy Hylton-17/+7
Replace uses of PyCF_xxx with CO_xxx. Replace individual feature slots in PyFutureFeatures with single bitmask ff_features. When flags must be transfered among the three parts of the interpreter that care about them -- the pythonrun layer, the compiler, and the future feature parser -- can simply or (|) the definitions.
2001-08-09Apply SF patch #424554: check for PYTHONDUMPREFS to be set instead ofGuido van Rossum-5/+1
asking to print the references.
2001-08-07- Rename PyType_InitDict() to PyType_Ready().Guido van Rossum-1/+4
- Add an explicit call to PyType_Ready(&PyList_Type) to pythonrun.c (just for the heck of it, really -- we should either explicitly ready all types, or none).
2001-08-02Merge of descr-branch back into trunk.Tim Peters-3/+6
2001-07-23Add -E command line switch (ignore environment variables like PYTHONHOMENeil Schemenauer-6/+7
and PYTHONPATH).
2001-07-16PyRun_StringFlags(): forgot to pass the flags on toGuido van Rossum-1/+4
PyParser_SimpleParseString(). Now calls PyParser_SimpleParseStringFlags() with the correct flag.
2001-07-16Ugly. A pile of new xxxFlags() functions, to communicate to the parserTim Peters-9/+30
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-16future.c: insert a cosmetic space.Tim Peters-1/+1
pythonrun.c, run_pyc_file(): repair semantic error wrt CO_GENERATOR vs CO_GENERATOR_ALLOWED.
2001-07-16Part way to allowing "from __future__ import generators" to communicateTim Peters-3/+7
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-06-13Temporarily disable the message to stderr. Jeremy will know what to doMarc-André Lemburg-1/+3
about this...
2001-03-26Bug fix: compile() called from a nested-scopes-enable Python was notJeremy Hylton-1/+1
using nested scopes to compile its argument. Pass compiler flags through to underlying compile call.
2001-03-23Finishing touch to Ping's changes. This is a patch that Ping sent meGuido van Rossum-11/+11
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-23call_sys_exitfunc(): Remove unused variable f.Fred Drake-1/+1
2001-03-23Allow sys.excepthook and sys.exitfunc to quietly exit with a sys.exit().Ka-Ping Yee-32/+37
sys.exitfunc gets the last word on the exit status of the program.
2001-03-23Fix memory leak with SyntaxError. (The DECREF was originally hiddenGuido van Rossum-0/+1
inside a piece of code that was deemed reduntant; the DECREF was unfortunately *not* redundant!)
2001-03-23Add sys.excepthook.Ka-Ping Yee-9/+36
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__.