summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
AgeCommit message (Collapse)AuthorLines
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__.
2001-03-22Extend support for from __future__ import nested_scopesJeremy Hylton-12/+82
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-01Useful future statement support for the interactive interpreterJeremy Hylton-15/+25
(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-02-28Now that Jeremy is asking about this code, it looks really bogus to me,Fred Drake-18/+0
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-28Print the offending line of code in the traceback for SyntaxErrorsJeremy Hylton-36/+48
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-17Bug #132850 unix line terminator on windows.Tim Peters-10/+14
Miserable hack to replace the previous miserable hack in maybe_pyc_file.
2001-02-11Ugly fix for SF bug 131239 (-x flag busted).Tim Peters-4/+15
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-02Move a bunch of definitions that were internal to compile.c toJeremy Hylton-0/+14
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-01-28It's unclear whether PyMarshal_XXX() are part of the public or private API.Tim Peters-1/+1
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-21Bug #128475: mimetools.encode (sometimes) fails when called from a thread.Tim Peters-1/+10
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-17Get rid of the initialization of _PyCompareState_Key.Guido van Rossum-2/+0
2001-01-05Fix signed/unsigned wng. Unfortunately, (unsigned char) << intTim Peters-2/+2
has type int in C.
2001-01-04Recognize pyc files even if they don't end in pyc.Martin v. Löwis-7/+33
Patch #103067 with modifications as discussed in email.
2000-09-16Add PyOS_getsig() and PyOS_setsig() -- wrappers around signal() orGuido van Rossum-0/+34
sigaction() (if HAVE_SIGACTION is defined).
2000-09-01REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum-9/+0
This should match the situation in the 1.6b1 tree.
2000-08-31PyOS_CheckStack(): Better ANSI'fy this while we're at it.Fred Drake-1/+1
2000-08-31Add a comment explaining the return value of PyOS_CheckStack().Fred Drake-1/+4
2000-08-27Hard to believe Guido compiled this! Function lacked a return stmt.Tim Peters-1/+1
2000-08-27Add three new APIs: PyRun_AnyFileEx(), PyRun_SimpleFileEx(),Guido van Rossum-7/+33
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-27implements PyOS_CheckStack for Windows and MSVC. this fixes aFredrik Lundh-0/+29
couple of potential stack overflows, including bug #110615. closes patch #101238
2000-08-25Fix to [ Bug #111165 ] doc-string removal masked by PYTHONOPTIMIZEMarc-André Lemburg-3/+3
2000-08-15Remove the osdefs.h #include; it was not needed in the final version ofFred Drake-1/+0
my last set of changes.
2000-08-15When raising a SyntaxError, make a best-effort attempt to set theFred Drake-1/+19
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-07-22Mass ANSIfication of function definitions. Doesn't cover all 'extern'Thomas Wouters-94/+45
declarations yet, those come later.
2000-07-16Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in eitherThomas Wouters-1/+1
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-11Include macglue.h for some function prototypes, and renamed a fewJack Jansen-2/+5
mac-specific functions to have a PyMac_ name.
2000-07-11Create two new exceptions: IndentationError and TabError. These areFred Drake-4/+25
used for indentation related errors. This patch includes Ping's improvements for indentation-related error messages. Closes SourceForge patches #100734 and #100856.
2000-07-09Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.Tim Peters-14/+14
2000-06-30Change copyright notice - 2nd try.Guido van Rossum-6/+0
2000-06-30Change copyright notice.Guido van Rossum-21/+6
2000-06-20Add new parser error code, E_OVERFLOW. This error is returned whenJeremy Hylton-0/+3
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."