summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* Related to SF bug 132008 (PyList_Reverse blows up).Tim Peters2001-02-121-0/+2
| | | | | | | | _testcapimodule.c make sure PyList_Reverse doesn't blow up again getargs.c assert args isn't NULL at the top of vgetargs1 instead of waiting for a NULL-pointer dereference at the end
* In symtable_update_free_vars() do not modify the dictionary whileJeremy Hylton2001-02-121-7/+27
| | | | | | | iterating over it using PyDict_Next(). This bug fix brought to you by the letters b, c, d, g, h, ... and the reporter Ping.
* Ugly fix for SF bug 131239 (-x flag busted).Tim Peters2001-02-111-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!
* When calling a PyCFunction that has METH_KEYWORDS defined, don'tJeremy Hylton2001-02-091-10/+0
| | | | | | | | create an empty dictionary if it is called without keyword args. Just pass NULL. XXX I had believed that this caused weird errors, but the test suite runs cleanly.
* SF patch 103589: Fix handling of cell vars that are either * or ** parameters.Jeremy Hylton2001-02-091-8/+15
| | | | | | (Nick Mathewson) Remove to XXX comments
* Relax the rules for using 'from ... import *' and exec in the presenceJeremy Hylton2001-02-092-297/+259
| | | | | | | | | | | | | | | | | | | of nested functions. Either is allowed in a function if it contains no defs or lambdas or the defs and lambdas it contains have no free variables. If a function is itself nested and has free variables, either is illegal. Revise the symtable to use a PySymtableEntryObject, which holds all the revelent information for a scope, rather than using a bunch of st_cur_XXX pointers in the symtable struct. The changes simplify the internal management of the current symtable scope and of the stack. Added new C source file: Python/symtable.c. (Does the Windows build process need to be updated?) As part of these changes, the initial _symtable module interface introduced in 2.1a2 is replaced. A dictionary of PySymtableEntryObjects are returned.
* This modified version of a patch by Thomas Heller allows __import__Marc-André Lemburg2001-02-091-8/+9
| | | | | | | | | | hooks to take over the Python import machinery at a very early stage in the Python startup phase. If there are still places in the Python interpreter which need to bypass the __import__ hook, these places must now use PyImport_ImportModuleEx() instead. So far no other places than in the import mechanism itself have been identified.
* Reindent a function that was somehow indented by 7 spaces. Also did aGuido van Rossum2001-02-091-15/+15
| | | | spaces->tab conversion for fields added to struct compiling.
* SF patch 103596 by Nick Mathewson: rause UnboundLocalError forJeremy Hylton2001-02-051-0/+16
| | | | uninitialized free variables
* Superseded by $(srcdir)/Makefile.pre.in.Neil Schemenauer2001-02-031-140/+0
|
* bump the magic number; the compiler has changed since 2.1a1Jeremy Hylton2001-02-021-1/+1
|
* Fix symbol table pass to generation SyntaxError exceptions thatJeremy Hylton2001-02-021-32/+46
| | | | include the filename and line number.
* Steve Majewski's patch #103495, MatchFilename() and find_module()Barry Warsaw2001-02-021-0/+53
| | | | | patch for case-preserving HFS+ suport. Untested except to verify that it builds and doesn't break anything on Linux RH6.1.
* Move a bunch of definitions that were internal to compile.c toJeremy Hylton2001-02-022-116/+110
| | | | | | | | | | | | | | | | | | 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().
* add missing DECREF (thanks, Barry)Jeremy Hylton2001-02-021-0/+1
|
* Allow 'continue' inside 'try' clauseJeremy Hylton2001-02-012-12/+37
| | | | SF patch 102989 by Thomas Wouters
* Undo recent change that banned using import to bind a global, as perJeremy Hylton2001-02-012-27/+28
| | | | | | | | | | | discussion on python-dev. 'from mod import *' is still banned except at the module level. Fix value for special NOOPT entry in symtable. Initialze to 0 instead of None, so that later uses of PyInt_AS_LONG() are valid. (Bug reported by Donn Cave.) replace local REPR macros with PyObject_REPR in object.h
* SF bug #130532: newest CVS won't build on AIX.Tim Peters2001-01-311-2/+0
| | | | | Removed illegal redefinition of REPR macro; kept the one with the argument name that isn't too easy to confuse with zero <wink>.
* Enforce two illegal import statements that were outlawed in theJeremy Hylton2001-01-301-44/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | reference manual but not checked: Names bound by import statemants may not occur in global statements in the same scope. The from ... import * form may only occur in a module scope. I guess these changes could break code, but the reference manual warned about them. Several other small changes If a variable is declared global in the nearest enclosing scope of a free variable, then treat it is a global in the nested scope too. Get rid of com_mangle and symtable_mangle functions and call mangle directly. If errors occur during symtable table creation, return -1 from symtable_build(). Do not increment st_errors in assignment to lambda, because exception is not set. Add extra argument to symtable_assign(); the argument, flag, is ORed with DEF_LOCAL for each symtable_add_def() call.
* Remove f_closure slot of frameobject and use f_localsplus instead.Jeremy Hylton2001-01-291-4/+16
| | | | | | | | | | | | This change eliminates an extra malloc/free when a frame with free variables is created. Any cell vars or free vars are stored in f_localsplus after the locals and before the stack. eval_code2() fills in the appropriate values after handling initialization of locals. To track the size the frame has an f_size member that tracks the total size of f_localsplus. It used to be implicitly f_nlocals + f_stacksize.
* plug leak detected by BarryJeremy Hylton2001-01-291-0/+1
|
* It's unclear whether PyMarshal_XXX() are part of the public or private API.Tim Peters2001-01-283-35/+51
| | | | | | | | | | 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.
* SF bug http://sourceforge.net/bugs/?func=detailbug&bug_id=130242&group_id=5470Tim Peters2001-01-271-0/+1
| | | | | | | | SF patch http://sourceforge.net/patch/?func=detailpatch&patch_id=103453&group_id=5470 PyMember_Set of T_CHAR always raises exception. Unfortunately, this is a use of a C API function that Python itself never makes, so there's no .py test I can check in to verify this stays fixed. But the fault in the code is obvious, and Dave Cole's patch just as obviously fixes it.
* Better error message when non-dictionary received for **kwargJeremy Hylton2001-01-251-2/+7
|
* PEP 227 implementationJeremy Hylton2001-01-254-328/+858
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The majority of the changes are in the compiler. The mainloop changes primarily to implement the new opcodes and to pass a function's closure to eval_code2(). Frames and functions got new slots to hold the closure. Include/compile.h Add co_freevars and co_cellvars slots to code objects. Update PyCode_New() to take freevars and cellvars as arguments Include/funcobject.h Add func_closure slot to function objects. Add GetClosure()/SetClosure() functions (and corresponding macros) for getting at the closure. Include/frameobject.h PyFrame_New() now takes a closure. Include/opcode.h Add four new opcodes: MAKE_CLOSURE, LOAD_CLOSURE, LOAD_DEREF, STORE_DEREF. Remove comment about old requirement for opcodes to fit in 7 bits. compile.c Implement changes to code objects for co_freevars and co_cellvars. Modify symbol table to use st_cur_name (string object for the name of the current scope) and st_cur_children (list of nested blocks). Also define st_nested, which might more properly be called st_cur_nested. Add several DEF_XXX flags to track def-use information for free variables. New or modified functions of note: com_make_closure(struct compiling *, PyCodeObject *) Emit LOAD_CLOSURE opcodes as needed to pass cells for free variables into nested scope. com_addop_varname(struct compiling *, int, char *) Emits opcodes for LOAD_DEREF and STORE_DEREF. get_ref_type(struct compiling *, char *name) Return NAME_CLOSURE if ref type is FREE or CELL symtable_load_symbols(struct compiling *) Decides what variables are cell or free based on def-use info. Can now raise SyntaxError if nested scopes are mixed with exec or from blah import *. make_scope_info(PyObject *, PyObject *, int, int) Helper functions for symtable scope stack. symtable_update_free_vars(struct symtable *) After a code block has been analyzed, it must check each of its children for free variables that are not defined in the block. If a variable is free in a child and not defined in the parent, then it is defined by block the enclosing the current one or it is a global. This does the right logic. symtable_add_use() is now a macro for symtable_add_def() symtable_assign(struct symtable *, node *) Use goto instead of for (;;) Fixed bug in symtable where name of keyword argument in function call was treated as assignment in the scope of the call site. Ex: def f(): g(a=2) # a was considered a local of f ceval.c eval_code2() now take one more argument, a closure. Implement LOAD_CLOSURE, LOAD_DEREF, STORE_DEREF, MAKE_CLOSURE> Also: When name error occurs for global variable, report that the name was global in the error mesage. Objects/frameobject.c Initialize f_closure to be a tuple containing space for cellvars and freevars. f_closure is NULL if neither are present. Objects/funcobject.c Add support for func_closure. Python/import.c Change the magic number. Python/marshal.c Track changes to code objects.
* Fix bug reported by Ka-Ping Yee: The compiler botched parsing functionJeremy Hylton2001-01-251-12/+15
| | | | | | | | | parameters that contained both anonymous tuples and *arg or **arg. Ex: def f(a, (b, c), *d): pass Fix the symtable_params() to generate names in the right order for co_varnames slot of code object. Consider *arg and **arg before the "complex" names introduced by anonymous tuples.
* Leak pluggin', bug fixin' and better documentin'. Specifically,Barry Warsaw2001-01-231-56/+72
| | | | | | | | | | | | | module__doc__: Document the Warning subclass heirarchy. make_class(): Added a "goto finally" so that if populate_methods() fails, the return status will be -1 (failure) instead of 0 (success). fini_exceptions(): When decref'ing the static pointers to the exception classes, clear out their dictionaries too. This breaks a cycle from class->dict->method->class and allows the classes with unbound methods to be reclaimed. This plugs a large memory leak in a common Py_Initialize()/dosomething/Py_Finalize() loop.
* Add a new API, PyThreadState_DeleteCurrent() that combinesGuido van Rossum2001-01-231-4/+27
| | | | | PyThreadState_Delete() and PyEval_ReleaseLock(). It is only defined if WITH_THREAD is defined.
* Visit the initial test element of the listmaker for a listJeremy Hylton2001-01-231-1/+2
| | | | comprehension. Fixes bug reported by Tim Peters.
* prevent symtable_params() from dereferencing off the end of theJeremy Hylton2001-01-231-0/+2
| | | | varagslist node. based on fix from Thomas Wouters.
* com_init(): My entry into the smallest patch possible category.Barry Warsaw2001-01-221-1/+1
| | | | (cosmetic whitespace change).
* Bug #128475: mimetools.encode (sometimes) fails when called from a thread.Tim Peters2001-01-211-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.
* SF patch #103336: Missing cast.Tim Peters2001-01-201-1/+1
|
* Use #if TARGET_API_MAC_CARBON to determine carbon/classic macos, not #ifdef.Jack Jansen2001-01-191-1/+1
|
* Backed out the unistr() builtin.Marc-André Lemburg2001-01-191-18/+0
|
* clearer error messages for apply() and "no locals"Jeremy Hylton2001-01-192-11/+18
|
* This patch introduces an extra pass to the compiler that generates aJeremy Hylton2001-01-191-284/+1036
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | symbol table for each top-level compilation unit. The information in the symbol table allows the elimination of the later optimize() pass; the bytecode generation emits the correct opcodes. The current version passes the complete regression test, but may still contain some bugs. It's a fairly substantial revision. The current code adds an assert() and a test that may lead to a Py_FatalError(). I expect to remove these before 2.1 beta 1. The symbol table (struct symtable) is described in comments in the code. The changes affects the several com_XXX() functions that were used to emit LOAD_NAME and its ilk. The primary interface for this bytecode is now com_addop_varname() which takes a kind and a name, where kind is one of VAR_LOAD, VAR_STORE, or VAR_DELETE. There are many other smaller changes: - The name mangling code is no longer contained in ifdefs. There are two functions that expose the mangling logical: com_mangle() and symtable_mangle(). - The com_error() function can accept NULL for its first argument; this is useful with is_constant_false() is called during symbol table generation. - The loop index names used by list comprehensions have been changed from __1__ to [1], so that they can not be accessed by Python code. - in com_funcdef(), com_argdefs() is now called before the body of the function is compiled. This provides consistency with com_lambdef() and symtable_funcdef(). - Helpers do_pad(), dump(), and DUMP() are added to aid in debugging the compiler.
* Fix for the bug in complex() just reported by Ping.Guido van Rossum2001-01-191-1/+7
|
* SF Patch #103250, by pj99: Optimize a strspn() out of startup.Guido van Rossum2001-01-191-4/+21
| | | | Minor startup speedup: avoid a call to strspn().
* Add my name to the copyright notice.Guido van Rossum2001-01-181-1/+5
|
* Variant of SF patch 103252: Startup optimize: read *.pyc as string, not with ↵Tim Peters2001-01-181-0/+47
| | | | getc().
* Move distributed and duplicated config for stat() and fstat() into pyport.h.Tim Peters2001-01-182-29/+0
|
* Get rid of the initialization of _PyCompareState_Key.Guido van Rossum2001-01-171-2/+0
|
* This patch adds a new builtin unistr() which behaves like str()Marc-André Lemburg2001-01-171-0/+18
| | | | | | | | | | except that it always returns Unicode objects. A new C API PyObject_Unicode() is also provided. This closes patch #101664. Written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
* Use rich comparisons in min and max.Guido van Rossum2001-01-171-9/+9
|
* Rich comparisons fall-out:Guido van Rossum2001-01-171-148/+147
| | | | | | | | | | | | - Use PyObject_RichCompare*() where possible: when comparing keyword arguments, in _PyEval_SliceIndex(), and of course in cmp_outcome(). Unrelated stuff: - Removed all trailing whitespace. - Folded some long lines.
* This patch makes sure that the function name always appears in the errorKa-Ping Yee2001-01-152-55/+89
| | | | | | | message, and tries to make the messages more consistent and helpful when the wrong number of arguments or duplicate keyword arguments are supplied. Comes with more tests for test_extcall.py and and an update to an error message in test/output/test_pyexpat.
* Added a separate extension (.carbon.slb) for Carbon dynamic modules.Jack Jansen2001-01-151-0/+4
|
* Neil discovered a bad DECREF on warnoptions, that caused repeatedGuido van Rossum2001-01-131-2/+1
| | | | | | re-initializing Python (Py_Finalize() followed by Py_Initialize()) to blow up quickly. With the DECREF removed I can't get it to fail any more. (Except it still leaks, but that's probably a separate issue.)
* Update the docstring for apply() so that "args" is marked as optionalFred Drake2001-01-121-1/+1
| | | | (since it is).