summaryrefslogtreecommitdiffstats
path: root/Parser/pgenmain.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35808: Retire pgen and use pgen2 to generate the parser (GH-11814)Pablo Galindo2019-03-011-188/+0
| | | | | Pgen is the oldest piece of technology in the CPython repository, building it requires various #if[n]def PGEN hacks in other parts of the code and it also depends more and more on CPython internals. This commit removes the old pgen C code and replaces it for a new version implemented in pure Python. This is a modified and adapted version of lib2to3/pgen2 that can generate grammar files compatibles with the current parser. This commit also eliminates all the #ifdef and code branches related to pgen, simplifying the code and making it more maintainable. The regen-grammar step now uses $(PYTHON_FOR_REGEN) that can be any version of the interpreter, so the new pgen code maintains compatibility with older versions of the interpreter (this also allows regenerating the grammar with the current CI solution that uses Python3.5). The new pgen Python module also makes use of the Grammar/Tokens file that holds the token specification, so is always kept in sync and avoids having to maintain duplicate token definitions.
* bpo-35081: Rename internal headers (GH-10275)Victor Stinner2018-11-121-2/+2
| | | | | | | | | | | | | | Rename Include/internal/ headers: * pycore_hash.h -> pycore_pyhash.h * pycore_lifecycle.h -> pycore_pylifecycle.h * pycore_mem.h -> pycore_pymem.h * pycore_state.h -> pycore_pystate.h Add missing headers to Makefile.pre.in and PCbuild: * pycore_condvar.h. * pycore_hamt.h * pycore_pyhash.h
* bpo-35081: Add pycore_ prefix to internal header files (GH-10263)Victor Stinner2018-10-311-2/+2
| | | | | | | | | | | | | | | | | | | | * Rename Include/internal/ header files: * pyatomic.h -> pycore_atomic.h * ceval.h -> pycore_ceval.h * condvar.h -> pycore_condvar.h * context.h -> pycore_context.h * pygetopt.h -> pycore_getopt.h * gil.h -> pycore_gil.h * hamt.h -> pycore_hamt.h * hash.h -> pycore_hash.h * mem.h -> pycore_mem.h * pystate.h -> pycore_state.h * warnings.h -> pycore_warnings.h * PCbuild project, Makefile.pre.in, Modules/Setup: add the Include/internal/ directory to the search paths of header files. * Update includes. For example, replace #include "internal/mem.h" with #include "pycore_mem.h".
* bpo-34170: Add _PyCoreConfig.bytes_warning (GH-8447)Victor Stinner2018-07-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add more fields to _PyCoreConfig: * _check_hash_pycs_mode * bytes_warning * debug * inspect * interactive * legacy_windows_fs_encoding * legacy_windows_stdio * optimization_level * quiet * unbuffered_stdio * user_site_directory * verbose * write_bytecode Changes: * Remove pymain_get_global_config() and pymain_set_global_config() which became useless. These functions have been replaced by _PyCoreConfig_GetGlobalConfig() and _PyCoreConfig_SetGlobalConfig(). * sys.flags.dont_write_bytecode value is now restricted to 1 even if -B option is specified multiple times on the command line. * PyThreadState_Clear() now uses the config from the current interpreter rather than using global Py_VerboseFlag
* bpo-32096: Remove obj and mem from _PyRuntime (#4532)Victor Stinner2017-11-241-2/+0
| | | | | | | | | | | | | | | | | bpo-32096, bpo-30860: Partially revert the commit 2ebc5ce42a8a9e047e790aefbf9a94811569b2b6: * Move structures back from Include/internal/mem.h to Objects/obmalloc.c * Remove _PyObject_Initialize() and _PyMem_Initialize() * Remove Include/internal/pymalloc.h * Add test_capi.test_pre_initialization_api(): Make sure that it's possible to call Py_DecodeLocale(), and then call Py_SetProgramName() with the decoded string, before Py_Initialize(). PyMem_RawMalloc() and Py_DecodeLocale() can be called again before _PyRuntimeState_Init(). Co-Authored-By: Eric Snow <ericsnowcurrently@gmail.com>
* bpo-32030: Split Py_Main() into subfunctions (#4399)Victor Stinner2017-11-151-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Don't use "Python runtime" anymore to parse command line options or to get environment variables: pymain_init() is now a strict separation. * Use an error message rather than "crashing" directly with Py_FatalError(). Limit the number of calls to Py_FatalError(). It prepares the code to handle errors more nicely later. * Warnings options (-W, PYTHONWARNINGS) and "XOptions" (-X) are now only added to the sys module once Python core is properly initialized. * _PyMain is now the well identified owner of some important strings like: warnings options, XOptions, and the "program name". The program name string is now properly freed at exit. pymain_free() is now responsible to free the "command" string. * Rename most methods in Modules/main.c to use a "pymain_" prefix to avoid conflits and ease debug. * Replace _Py_CommandLineDetails_INIT with memset(0) * Reorder a lot of code to fix the initialization ordering. For example, initializing standard streams now comes before parsing PYTHONWARNINGS. * Py_Main() now handles errors when adding warnings options and XOptions. * Add _PyMem_GetDefaultRawAllocator() private function. * Cleanup _PyMem_Initialize(): remove useless global constants: move them into _PyMem_Initialize(). * Call _PyRuntime_Initialize() as soon as possible: _PyRuntime_Initialize() now returns an error message on failure. * Add _PyInitError structure and following macros: * _Py_INIT_OK() * _Py_INIT_ERR(msg) * _Py_INIT_USER_ERR(msg): "user" error, don't abort() in that case * _Py_INIT_FAILED(err)
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-081-0/+5
| | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-2/+0
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* Revert "bpo-30860: Consolidate stateful runtime globals." (#3379)Eric Snow2017-09-061-4/+0
| | | Windows buildbots started failing due to include-related errors.
* bpo-30860: Consolidate stateful runtime globals. (#2594)Eric Snow2017-09-061-0/+4
| | | | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* properly free memory in pgenBenjamin Peterson2016-09-191-0/+1
|
* Issue #27336: Fix compilation failures --without-threadsBerker Peksag2016-06-171-2/+3
|
* On memory error, dump the memory block tracebackVictor Stinner2016-03-151-4/+4
| | | | | | Issue #26564: _PyObject_DebugDumpAddress() now dumps the traceback where a memory block was allocated on memory block. Use the tracemalloc module to get the traceback.
* Add more checks on the GILVictor Stinner2016-03-141-0/+8
| | | | | | | | | | | | Issue #10915, #15751, #26558: * PyGILState_Check() now returns 1 (success) before the creation of the GIL and after the destruction of the GIL. It allows to use the function early in Python initialization and late in Python finalization. * Add a flag to disable PyGILState_Check(). Disable PyGILState_Check() when Py_NewInterpreter() is called * Add assert(PyGILState_Check()) to: _Py_dup(), _Py_fstat(), _Py_read() and _Py_write()
* Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka2015-12-251-2/+2
| | | | private functions.
* Silenced some warnings about comparison between signed and unsigned integerSerhiy Storchaka2014-09-051-3/+4
| | | | expressions.
* Issue #1772673: The type of `char*` arguments now changed to `const char*`.Serhiy Storchaka2013-10-191-1/+1
|
* Fix resource leak in parser, free node ptrChristian Heimes2013-06-291-0/+1
| | | | | CID 1028068 (#1 of 1): Resource leak (RESOURCE_LEAK) leaked_storage: Variable n going out of scope leaks the storage it points to.
* Issue #8914: fix various warnings from the Clang static analyzer v254.Brett Cannon2011-02-221-0/+2
|
* Compile pgenmain.c and printgrammar.c with PGEN definedVictor Stinner2010-12-281-0/+2
|
* Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou2010-05-091-97/+97
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
* Merge p3yk branch with the trunk up to revision 45595. This breaks a fairThomas Wouters2006-04-211-3/+3
| | | | | | | | | | | | | | | | | | | | number of tests, all because of the codecs/_multibytecodecs issue described here (it's not a Py3K issue, just something Py3K discovers): http://mail.python.org/pipermail/python-dev/2006-April/064051.html Hye-Shik Chang promised to look for a fix, so no need to fix it here. The tests that are expected to break are: test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecs test_multibytecodec This merge fixes an actual test failure (test_weakref) in this branch, though, so I believe merging is the right thing to do anyway.
* - Fix segfault with invalid coding.Neal Norwitz2005-10-021-0/+7
| | | | | | | - SF Bug #772896, unknown encoding results in MemoryError, which is not helpful I will only backport the segfault fix. I'll let Anthony decide if he wants the other changes backported. I will do the backport if asked.
* Remove support for --without-universal-newlines (see PEP 11).Skip Montanaro2004-02-071-2/+0
|
* Talk about old code: removed a reference to THINK_C.Jack Jansen2003-11-201-30/+0
|
* Getting rid of all the code inside #ifdef macintosh too.Jack Jansen2003-11-201-9/+0
|
* Change PyOS_Readline declaration to match the recent change to myreadline.cSkip Montanaro2002-10-271-2/+2
| | | | | | (see Patch 512981). I changed stdin to sys_stdin in the body of the function, but did not change stderr to sys_stdout, though I suspect that may be the correct course. I don't know the code involved well enough to judge.
* The Py_REF_DEBUG/COUNT_ALLOCS/Py_TRACE_REFS macro minefield: addedTim Peters2002-07-091-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.
* Add definition of Py_IgnoreEnvironmentFlag (needed at least in debugGuido van Rossum2002-05-311-0/+1
| | | | mode).
* Mass checkin of universal newline support.Jack Jansen2002-04-141-0/+11
| | | | | | | | Highlights: import and friends will understand any of \r, \n and \r\n as end of line. Python file input will do the same if you use mode 'U'. Everything can be disabled by configuring with --without-universal-newlines. See PEP278 for details.
* Silence parser generator output.Guido van Rossum2001-09-111-2/+4
|
* Take output filenames as arguments instead of hard-coding them.Neil Schemenauer2001-02-161-9/+14
|
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-9/+0
| | | | This should match the situation in the 1.6b1 tree.
* Mass ANSIfication.Thomas Wouters2000-07-221-29/+7
| | | | | | Work around intrcheck.c's desire to pass 'PyErr_CheckSignals' to 'Py_AddPendingCall' by providing a (static) wrapper function that has the right number of arguments.
* Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.Tim Peters2000-07-091-3/+3
|
* Change copyright notice - 2nd try.Guido van Rossum2000-06-301-6/+0
|
* Change copyright notice.Guido van Rossum2000-06-301-22/+7
|
* Trent Mick: familiar simple Win64 patchesGuido van Rossum2000-06-281-2/+2
|
* Vladimir Marangozov's long-awaited malloc restructuring.Guido van Rossum2000-05-031-3/+3
| | | | | | | | | | 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.)
* Add a version of PySys_WriteStderr() that writes to stderr, so we canGuido van Rossum1998-08-251-0/+27
| | | | use it in tokenizer.c.
* Add dummy Py_VerboseFlag now that it's referenced in parsetok.c.Guido van Rossum1998-04-101-0/+1
|
* Another directory quickly renamed.Guido van Rossum1997-04-291-18/+18
|
* Make gcc -Wall happyGuido van Rossum1996-12-021-0/+1
|
* New permission notice, includes CNRI.Guido van Rossum1996-10-251-13/+20
|
* Added 1995 to copyright message.Guido van Rossum1995-01-041-2/+2
|
* Parser/tokenizer.c (tok_nextc): zap tok->buf after freeing;Guido van Rossum1994-12-301-1/+0
| | | | rest: abort() -> fatal(); small things
* Merge back to main trunkGuido van Rossum1994-08-301-10/+50
|
* * Makefile: added all: and default: targets.Guido van Rossum1993-07-051-10/+17
| | | | | | | | | | | | * 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.
* * Changed all copyright messages to include 1993.Guido van Rossum1993-03-291-2/+2
| | | | | | | | | | | | | | | | | * 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
* Copyright for 1992 addedGuido van Rossum1992-04-051-1/+1
|