Martin v. Löwis [Sat, 27 Jan 2001 08:38:34 +0000 (08:38 +0000)]
Merge changes of PyXML 1.13:
Use nodeName, not tagName in attributes.
Provide get method for dictionary-like objects.
Use DOM exceptions instead of standard exceptions.
Tim Peters [Sat, 27 Jan 2001 06:20:08 +0000 (06:20 +0000)]
SF bug http://sourceforge.net/bugs/?func=detailbug&bug_id=130242&group_id=5470
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.
Remaining single-line change from patch #102409: to install shared modules,
run setup.py with the --install-platlib flag so you can override
'prefix' when running make (e.g. make prefix=/tmp/python/usr/local install)
Instead of using mkdir to create directories, use install -d (mkdir -p
apparently isn't portable)
Emacs make-mode reported line 371 as suspicious; removed the whitespace from
that line.
Be extra careful with linking against libtermcap. This is now only done
if we can find the libtermcap in the usual places. Some platforms don't
have libtermcap, e.g. MacOSX.
Neil Schemenauer [Fri, 26 Jan 2001 16:18:16 +0000 (16:18 +0000)]
- LIBRARY is now a SUBST variable.
- Add CFLAGSFORSHARED variable. configure sets this to CCSHARED if LDLIBRARY
is a shared library.
- Remove -fPIC from OPT, it has no business there.
- Change CCSHARED option for Linux to -fPIC. It should probably be
-fPIC on a few other platforms as well.
- Don't create silly boot Makefile, create Setup files and run makesetup
instead.
Neil Schemenauer [Fri, 26 Jan 2001 16:14:41 +0000 (16:14 +0000)]
- Add CFLAGSFORSHARED variable. configure sets this to CCSHARED if LDLIBRARY
is a shared library.
- Add PY_CFLAGS variable (flags used to compile the interpreter)
- clobber now just removes object files, libraries and binaries
Jeremy Hylton [Thu, 25 Jan 2001 20:10:32 +0000 (20:10 +0000)]
In subst_vars(), change the name of the argument from str to s to
prevent binding for str from masking use of builtin str in nested
function.
(This is the only case I found in the standard library where a local
shadows a global or builtin. There may be others, but the regression
test doesn't catch them.)
Jeremy Hylton [Thu, 25 Jan 2001 20:06:59 +0000 (20:06 +0000)]
PEP 227 implementation
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.
Jeremy Hylton [Thu, 25 Jan 2001 17:01:49 +0000 (17:01 +0000)]
Fix bug reported by Ka-Ping Yee: The compiler botched parsing function
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.
Skip Montanaro [Thu, 25 Jan 2001 13:47:00 +0000 (13:47 +0000)]
fail more completely by deleting dbhash from sys.modules if bsddb can't be
loaded - prevents second import later from succeeding spuriously - mostly of
use in regression tests where the module might get imported more than once
Tim Peters [Thu, 25 Jan 2001 06:23:18 +0000 (06:23 +0000)]
Fix bugs introduced by rewrite (in particular, time-based initialization
got broken). Also added new method .jumpahead(N). This finally gives us
a semi-decent answer to how Python's RNGs can be used safely and efficiently
in multithreaded programs (although it requires the user to use the new
machinery!).
Tim Peters [Thu, 25 Jan 2001 03:36:26 +0000 (03:36 +0000)]
Reworked random.py so that it no longer depends on, and offers all the
functionality of, whrandom.py. Also closes all the "XXX" todos in
random.py. New frequently-requested functions/methods getstate() and
setstate(). All exported functions are now bound methods of a hidden
instance. Killed all unintended exports. Updated the docs.
FRED: The more I fiddle the docs, the less I understand the exact
intended use of the \var, \code, \method tags. Please review critically.
GUIDO: See email. I updated NEWS as if whrandom were deprecated; I
think it should be.
Tim Peters [Wed, 24 Jan 2001 23:06:53 +0000 (23:06 +0000)]
Supply long-missing docs for random.seed(). Extensive rewrite of module
intro docs.
*************** Fred: check my LaTeX! Also, the docs for whrandom should
*************** be moved into Obsolete Modules.
Guido van Rossum [Wed, 24 Jan 2001 22:14:43 +0000 (22:14 +0000)]
Check the Py_TPFLAGS_HAVE_RICHCOMPARE flag before using the
tp_richcompare field! (Hopefully this will make Python 2.1 binary
compatible with certain Zope extensions. :-)
Guido van Rossum [Wed, 24 Jan 2001 21:44:21 +0000 (21:44 +0000)]
The array type was missing the Py_TPFLAGS_DEFAULT initializer for the
tp_flags. This will become important when I introduce
Py_TPFLAGS_HAVE_RICHCOMPARE (as I should have!).
New asynchat.py from Sam Rushing: this foregoes using the regex module
to find the prefix of strings, thus removing a warning, and simply
uses straightforward string slicing.
Neil Schemenauer [Wed, 24 Jan 2001 17:24:33 +0000 (17:24 +0000)]
- build now happens in toplevel directory, add subdir paths to filenames
- change EXE to EXTEXT, there is an autoconf macro for it
- use PROG_INSTALL macro rather than always using install-sh
- add option to disable signal module (simplifies the makefile)
- create subdirs for object files (when building out of src dir)
- don't generate subdir makefiles
- generate "boot" makefile
Neil Schemenauer [Wed, 24 Jan 2001 17:16:22 +0000 (17:16 +0000)]
Changes for flat makefile. Building of modules happens from toplevel
directory. Modify meaning of -s option to specify the Modules directory.
Add -l option to specify library source directory when building extension
modules. Perhaps these names should be switched to avoid breaking old
code. Add -c compiler option to when emitting rules to build object files.
Part of patch #102409: special cases for Cygwin:
Lib/distutils/command/build_ext.py(build_ext.finalize_options): Add
Cygwin specific code to append Python's library directory to the
extension's list of library directories.
(build_ext.get_libraries): Add Cygwin specific code to append Python's
(import) library to the extension's list of libraries.
Tim Peters [Wed, 24 Jan 2001 10:13:46 +0000 (10:13 +0000)]
test___all__ was failing on WIndows because locale.py doesn't really
know which names it exports. Didn't fix its ignorance, but patched
over the consequence.