Commit Graph

1273 Commits

Author SHA1 Message Date
Jeremy Hylton 4db62b1e14 Improved __future__ parser; still more to do
Makefile.pre.in: add target future.o

Include/compile.h: define PyFutureFeaters and PyNode_Future()
                   add c_future slot to struct compiling

Include/symtable.h: add st_future slot to struct symtable

Python/future.c: implementation of PyNode_Future()

Python/compile.c: use PyNode_Future() for nested_scopes support

Python/symtable.c: include compile.h to pick up PyFutureFeatures decl
2001-02-27 19:07:02 +00:00
Jeremy Hylton be77cf7d57 Add warnings about undefined "global"
SF bug #233532

XXX Can't figure out how to write test cases that work with warnings
2001-02-27 05:15:57 +00:00
Jeremy Hylton 29906eef3a Preliminary support for future nested scopes
compile.h: #define NESTED_SCOPES_DEFAULT 0 for Python 2.1
           __future__ feature name: "nested_scopes"

symtable.h: Add st_nested_scopes slot.  Define flags to track exec and
    import star.

Lib/test/test_scope.py: requires nested scopes

compile.c: Fiddle with error messages.

    Reverse the sense of ste_optimized flag on
    PySymtableEntryObjects.  If it is true, there is an optimization
    conflict.

    Modify get_ref_type to respect st_nested_scopes flags.

    Refactor symtable_load_symbols() into several smaller functions,
    which use struct symbol_info to share variables.  In new function
    symtable_update_flags(), raise an error or warning for import * or
    bare exec that conflicts with nested scopes.  Also, modify handle
    for free variables to respect st_nested_scopes flag.

    In symtable_init() assign st_nested_scopes flag to
    NESTED_SCOPES_DEFAULT (defined in compile.h).

    Add preliminary and often incorrect implementation of
    symtable_check_future().

    Add symtable_lookup() helper for future use.
2001-02-27 04:23:34 +00:00
Tim Peters 1e542110f9 Shuffle premature decref; nuke unreachable code block.
Fixes the "debug-build -O test_builtin.py and no test_b2.pyo" crash just
discussed on Python-Dev.
2001-02-23 22:23:53 +00:00
Barry Warsaw 0372af754e symtable_update_free_vars(), symtable_undo_free(),
symtable_enter_scope(): Removed some unnecessary backslashes at the
end of lines.  C != Python. :)
2001-02-23 18:22:59 +00:00
Jeremy Hylton 74b3bc47df Fix for bug 133489: compiler leaks memory
Two different but related problems:

1. PySymtable_Free() must explicitly DECREF(st->st_cur), which should
always point to the global symtable entry.  This entry is setup by the
first enter_scope() call, but there is never a corresponding
exit_scope() call.

Since each entry has a reference to scopes defined within it, the
missing DECREF caused all symtable entries to be leaked.

2. The leak here masked a separate problem with
PySymtableEntry_New().  When the requested entry was found in
st->st_symbols, the entry was returned without doing an INCREF.

And problem c) The ste_children slot was getting two copies of each
child entry, because it was populating the slot on the first and
second passes.  Now only populate on the first pass.
2001-02-23 17:55:27 +00:00
Guido van Rossum 85cd1d690c The code in PyImport_Import() tried to save itself a bit of work and
save the __builtin__ module in a static variable.  But this doesn't
work across Py_Finalise()/Py_Initialize()!  It also doesn't work when
using multiple interpreter states created with PyInterpreterState_New().

So I'm ripping out this small optimization.

This was probably broken since PyImport_Import() was introduced in
1997!  We really need a better test suite for multiple interpreter
states and repeatedly initializing.

This fixes the problems Barry reported in Demo/embed/loop.c.
2001-02-20 21:43:24 +00:00
Jeremy Hylton 2b3f0ca2ac Fix for implicit tuple + default arguments, courtesy of Michael Hudson.
SF patch #103749
2001-02-19 23:52:49 +00:00
Jeremy Hylton 384639f80e When running python -O, do not include blocks defined in asserts in
the symbol table pass.  These blocks were already ignored by the code
gen pass.  Both passes must visit the same set of blocks in the same
order.

Fixes SF buf 132820
2001-02-19 15:50:51 +00:00
Jeremy Hylton 17820c4f1b Tolerate ill-formed trees in symtable_assign(). Fixes SF bug 132510. 2001-02-19 15:33:10 +00:00
Tim Peters 4e30378e80 Bug #132313 error message confusing for assignment in lambda.
They're actually complaining about something more specific, an assignment
in a lambda as an actual argument, so that Python parses the
lambda as if it were a keyword argument.  Like f(lambda x: x[0]=42).
The "lambda x: x[0]" part gets parsed as if it were a keyword, being
bound to 42, and the resulting error msg didn't make much sense.
2001-02-18 04:45:10 +00:00
Tim Peters 6f5a4efc0a Bug #132850 unix line terminator on windows.
Miserable hack to replace the previous miserable hack in maybe_pyc_file.
2001-02-17 22:02:34 +00:00
Tim Peters 3081421d9e Change temp names created by listcomps from [%d] to _[%d], so the one-liner
[k for k in dir() if k[0] != "_"]
can be used to get the non-private names (used to contain "[1]").
2001-02-17 05:30:26 +00:00
Thomas Wouters fc93b0a81a Remove trailing comma from 'why_code' enum, which was introduced by the
continue-inside-try patch. Partly fixes SF bug #132597.
2001-02-16 11:52:31 +00:00
Tim Peters 5c4d5bfaf5 Related to SF bug 132008 (PyList_Reverse blows up).
_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
2001-02-12 22:13:26 +00:00
Jeremy Hylton d7f393edae In symtable_update_free_vars() do not modify the dictionary while
iterating over it using PyDict_Next().

This bug fix brought to you by the letters b, c, d, g, h, ... and the
reporter Ping.
2001-02-12 16:01:03 +00:00
Tim Peters 3e876565a3 Ugly fix for SF bug 131239 (-x flag busted).
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-11 04:35:39 +00:00
Jeremy Hylton 8af6b83e61 When calling a PyCFunction that has METH_KEYWORDS defined, don't
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.
2001-02-09 23:23:20 +00:00
Jeremy Hylton 6492bf71da SF patch 103589: Fix handling of cell vars that are either * or ** parameters.
(Nick Mathewson)

Remove to XXX comments
2001-02-09 22:55:26 +00:00
Jeremy Hylton cb17ae8b19 Relax the rules for using 'from ... import *' and exec in the presence
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.
2001-02-09 22:22:18 +00:00
Marc-André Lemburg 3c61c3525f This modified version of a patch by Thomas Heller allows __import__
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.
2001-02-09 19:40:15 +00:00
Guido van Rossum cd90c20b62 Reindent a function that was somehow indented by 7 spaces. Also did a
spaces->tab conversion for fields added to struct compiling.
2001-02-09 15:06:42 +00:00
Jeremy Hylton 2524d699f5 SF patch 103596 by Nick Mathewson: rause UnboundLocalError for
uninitialized free variables
2001-02-05 17:23:16 +00:00
Neil Schemenauer 693291ba23 Superseded by $(srcdir)/Makefile.pre.in. 2001-02-03 17:18:21 +00:00
Jeremy Hylton b1cbc1e36b bump the magic number; the compiler has changed since 2.1a1 2001-02-02 20:13:24 +00:00
Jeremy Hylton 5acc0c0cfc Fix symbol table pass to generation SyntaxError exceptions that
include the filename and line number.
2001-02-02 20:01:10 +00:00
Barry Warsaw 914a0b1db6 Steve Majewski's patch #103495, MatchFilename() and find_module()
patch for case-preserving HFS+ suport.  Untested except to verify that
it builds and doesn't break anything on Linux RH6.1.
2001-02-02 19:12:16 +00:00
Jeremy Hylton 4b38da664c Move a bunch of definitions that were internal to compile.c to
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-02-02 18:19:15 +00:00
Jeremy Hylton bbf10b59d1 add missing DECREF (thanks, Barry) 2001-02-02 02:58:48 +00:00
Jeremy Hylton 3faa52ecc4 Allow 'continue' inside 'try' clause
SF patch 102989 by Thomas Wouters
2001-02-01 22:48:12 +00:00
Jeremy Hylton 483638c9a8 Undo recent change that banned using import to bind a global, as per
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
2001-02-01 20:20:45 +00:00
Tim Peters 1ff31f9534 SF bug #130532: newest CVS won't build on AIX.
Removed illegal redefinition of REPR macro; kept the one with the
argument name that isn't too easy to confuse with zero <wink>.
2001-01-31 01:16:47 +00:00
Jeremy Hylton eab156f8eb Enforce two illegal import statements that were outlawed in the
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.
2001-01-30 01:24:43 +00:00
Jeremy Hylton 2b724da8d9 Remove f_closure slot of frameobject and use f_localsplus instead.
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.
2001-01-29 22:51:52 +00:00
Jeremy Hylton 2fdfadf6dd plug leak detected by Barry 2001-01-29 22:42:28 +00:00
Tim Peters d9b9ac855c It's unclear whether PyMarshal_XXX() are part of the public or private API.
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-28 00:27:39 +00:00
Tim Peters 547397c45b 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.
2001-01-27 06:20:08 +00:00
Jeremy Hylton a0ac40c530 Better error message when non-dictionary received for **kwarg 2001-01-25 20:13:10 +00:00
Jeremy Hylton 64949cb753 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.
2001-01-25 20:06:59 +00:00
Jeremy Hylton a6ebc4841d 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.
2001-01-25 17:01:49 +00:00
Barry Warsaw 9667ed23c5 Leak pluggin', bug fixin' and better documentin'. Specifically,
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.
2001-01-23 16:08:34 +00:00
Guido van Rossum 2975786dec Add a new API, PyThreadState_DeleteCurrent() that combines
PyThreadState_Delete() and PyEval_ReleaseLock().  It is only defined
if WITH_THREAD is defined.
2001-01-23 01:46:06 +00:00
Jeremy Hylton 5f827f4e9b Visit the initial test element of the listmaker for a list
comprehension.  Fixes bug reported by Tim Peters.
2001-01-23 01:26:20 +00:00
Jeremy Hylton 1113cfc767 prevent symtable_params() from dereferencing off the end of the
varagslist node. based on fix from Thomas Wouters.
2001-01-23 00:50:52 +00:00
Barry Warsaw 174e8018c4 com_init(): My entry into the smallest patch possible category.
(cosmetic whitespace change).
2001-01-22 04:35:57 +00:00
Tim Peters 384fd106e8 Bug #128475: mimetools.encode (sometimes) fails when called from a thread.
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-21 03:40:37 +00:00
Tim Peters 7f3e4adf60 SF patch #103336: Missing cast. 2001-01-20 05:15:26 +00:00
Jack Jansen c7050d9bb9 Use #if TARGET_API_MAC_CARBON to determine carbon/classic macos, not #ifdef. 2001-01-19 23:34:06 +00:00
Marc-André Lemburg 6f77667a64 Backed out the unistr() builtin. 2001-01-19 21:36:19 +00:00
Jeremy Hylton c862cf400f clearer error messages for apply() and "no locals" 2001-01-19 03:25:05 +00:00
Jeremy Hylton e36f77814e This patch introduces an extra pass to the compiler that generates a
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.
2001-01-19 03:21:30 +00:00
Guido van Rossum 8dabbf149e Fix for the bug in complex() just reported by Ping. 2001-01-19 02:11:59 +00:00
Guido van Rossum fc5ce61abd SF Patch #103250, by pj99: Optimize a strspn() out of startup.
Minor startup speedup: avoid a call to strspn().
2001-01-19 00:24:06 +00:00
Guido van Rossum d94ade1fcc Add my name to the copyright notice. 2001-01-18 14:50:11 +00:00
Tim Peters 691e0e95de Variant of SF patch 103252: Startup optimize: read *.pyc as string, not with getc(). 2001-01-18 04:39:16 +00:00
Tim Peters 60f42b50d8 Move distributed and duplicated config for stat() and fstat() into pyport.h. 2001-01-18 03:03:16 +00:00
Guido van Rossum 44a6ff6cf4 Get rid of the initialization of _PyCompareState_Key. 2001-01-17 21:27:36 +00:00
Marc-André Lemburg ad7c98e264 This patch adds a new builtin unistr() which behaves like str()
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.
2001-01-17 17:09:53 +00:00
Guido van Rossum 53451b3fd1 Use rich comparisons in min and max. 2001-01-17 15:47:24 +00:00
Guido van Rossum ac7be6888b Rich comparisons fall-out:
- 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.
2001-01-17 15:42:30 +00:00
Ka-Ping Yee 2057970601 This patch makes sure that the function name always appears in the error
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.
2001-01-15 22:14:16 +00:00
Jack Jansen 8eb4b56828 Added a separate extension (.carbon.slb) for Carbon dynamic modules. 2001-01-15 16:00:40 +00:00
Guido van Rossum 03df3b3bc1 Neil discovered a bad DECREF on warnoptions, that caused repeated
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.)
2001-01-13 22:06:05 +00:00
Fred Drake f1fbc62a8c Update the docstring for apply() so that "args" is marked as optional
(since it is).
2001-01-12 17:05:05 +00:00
Guido van Rossum 18d4d8f71d Two changes to from...import:
1) "from M import X" now works even if M is not a real module; it's
   basically a getattr() operation with AttributeError exceptions
   changed into ImportError.

2) "from M import *" now looks for M.__all__ to decide which names to
   import; if M.__all__ doesn't exist, it uses M.__dict__.keys() but
   filters out names starting with '_' as before.  Whether or not
   __all__ exists, there's no restriction on the type of M.
2001-01-12 16:24:03 +00:00
Guido van Rossum ad991775ab (Modified) patch by Ping - SF Patch #102681.
- Make error messages from issubclass() and isinstance() a bit more
  descriptive (Ping, modified by Guido)

- Couple of tiny fixes to other docstrings (Ping)

- Get rid of trailing whitespace (Guido)
2001-01-12 16:03:05 +00:00
Moshe Zadka f5df3834eb Fixed bugs noted by Greg Stein
* x wasn't initialized to NULL
* Did not DECREF result from displayhook function
2001-01-11 11:55:37 +00:00
Greg Stein ceb9b7c700 stdout is sometimes a macro; use "outf" instead.
Submitted by: Mark Favas <m.favas@per.dem.csiro.au>
2001-01-11 09:27:34 +00:00
Moshe Zadka f68f2fec7d Implementation of PEP-0217.
This closes the PEP, and patch 103170
2001-01-11 05:41:27 +00:00
Charles G. Waldman eec72a7fd9 Add missing Py_DECREF in fast_cfunction. Partial fix for SF bug
#127699.
2001-01-10 22:11:59 +00:00
Guido van Rossum fef124346e Oops, one more part of the cygwin patch (SF patch #102409 by jlt63:
Cygwin Python DLL and Shared Extension Patch).  Add module.dll as a
valid extension.

jlt63 writes: Note that his change essentially backs out the fix for
bug #115973. Should ".pyd" be retained instead for posterity?
2001-01-10 21:17:27 +00:00
Guido van Rossum 4c3f57cf05 SF Patch #103154 by jlt63: Cygwin Check Import Case Patch.
Note: I've reordered acconfig.h and config.h.in to obtain alphabetical
order (modulo case and leading _).
2001-01-10 20:40:46 +00:00
Tim Peters b8584e0894 Fix signed/unsigned wng. Unfortunately, (unsigned char) << int
has type int in C.
2001-01-05 00:54:29 +00:00
Fred Drake 1a7aab70d1 When a PyCFunction that takes only positional parameters is called with
an empty keywords dictionary (via apply() or the extended call syntax),
the keywords dict should be ignored.  If the keywords dict is not empty,
TypeError should be raised.  (Between the restructuring of the call
machinery and this patch, an empty dict in this situation would trigger
a SystemError via PyErr_BadInternalCall().)

Added regression tests to detect errors for this.
2001-01-04 22:33:02 +00:00
Martin v. Löwis be4c0f56a2 Recognize pyc files even if they don't end in pyc.
Patch #103067 with modifications as discussed in email.
2001-01-04 20:30:56 +00:00
Neil Schemenauer 23ab199bfd Add NotImplemented to the builtin module. 2001-01-04 01:48:42 +00:00
Jeremy Hylton 5282044be7 Revised implementation of CALL_FUNCTION and friends.
More revision still needed.

Much of the code that was in the mainloop was moved to a series of
helper functions.  PyEval_CallObjectWithKeywords was split into two
parts.  The first part now only does argument handling.  The second
part is now named call_object and delegates the call to a
call_(function,method,etc.) helper.

XXX The call_XXX helper functions should be replaced with tp_call
functions for the respective types.

The CALL_FUNCTION implementation contains three kinds of optimization:
1. fast_cfunction and fast_function are called when the arguments on
   the stack can be passed directly to eval_code2() without copying
   them into a tuple.
2. PyCFunction objects are dispatched immediately, because they are
   presumed to occur more often than anything else.
3. Bound methods are dispatched inline.  The method object contains a
   pointer to the function object that will be called.  The function
   is called from within the mainloop, which may allow optimization #1
   to be used, too.

The extened call implementation -- f(*args) and f(**kw) -- are
implemented as a separate case in the mainloop.  This allows the
common case of normal function calls to execute without wasting time
on checks for extended calls, although it does introduce a small
amount of code duplication.

Also, the unused final argument of eval_code2() was removed.  This is
probably the last trace of the access statement :-).
2001-01-03 23:52:36 +00:00
Andrew M. Kuchling f07aad171a CHange error messages for ord(), using "string" instead of "string or Unicode" 2000-12-23 14:11:28 +00:00
Andrew M. Kuchling 9bcc68c183 Whoops! Two stray characters crept in to my last check-in 2000-12-20 15:07:34 +00:00
Andrew M. Kuchling 34c20cf705 Patch #102955, fixing one of the warnings in bug #121479:
Simplifies ord()'s logic at the cost of some code duplication, removing a
    " `ord' might be used uninitialized in this function" warning
2000-12-20 14:36:56 +00:00
Guido van Rossum 23fff911a2 Add definitions for PySys_ResetWarnOptions() and
PySys_AddWarnOption().
2000-12-15 22:02:05 +00:00
Guido van Rossum cfd42b556b Add PyErr_Warn(). 2000-12-15 21:58:52 +00:00
Guido van Rossum d0977cd670 Add definitions for standard warning category classes (PyExc_Warning
etc.).
2000-12-15 21:58:29 +00:00
Jack Jansen fd0226b327 Use c2pstr() in stead of Pstring() to convert C-strings to
Pascal-strings. Safer, because Pstring converts in-place and the
pathname may be reused later for error messages.
2000-12-12 22:36:57 +00:00
Barry Warsaw 0705028076 vgetargskeywords(): Patch for memory leak identified in bug #119862. 2000-12-11 20:01:55 +00:00
Barry Warsaw b6a54d2a2c _getframe(): New sys module function for getting at the stack frame.
Implements and closes SF patch #102106, with Guido's suggested
documentation changes.
2000-12-06 21:47:46 +00:00
Neil Schemenauer cc343caf41 Make isinstance() more permissive in what types of arguments it
accepts. Clarify exception messages for isinstance() and
issubclass().  Closes bug #124106.
2000-12-04 15:42:11 +00:00
Guido van Rossum 60a1e7fc99 Clarified some of the error messages, esp. "read-only character
buffer" replaced by "string or read-only character buffer".
2000-12-01 12:59:05 +00:00
Guido van Rossum 83fb073a03 Plug a memory leak in com_import_stmt(): the tuple created to hold the
"..." in "from M import ..." was never DECREFed.  Leak reported by
James Slaughter and nailed by Barry, who also provided an earlier
version of this patch.
2000-11-27 22:22:36 +00:00
Tim Peters 102e457a01 SF bug 119622: compile errors due to redundant atof decls. I don't understand
the bug report (for details, look at it), but agree there's no need for Python
to declare atof itself:  we #include stdlib.h, and ANSI C sez atof is declared
there already.
2000-11-14 20:44:53 +00:00
Guido van Rossum 128bcf4520 Fix syntax error. Submitted by Bill Bumgarner. Apparently this is
still in use, for Apple Mac OSX.
2000-11-13 19:45:45 +00:00
Guido van Rossum 215c340aa3 Rip out DOS-8x3 support. 2000-11-13 17:26:32 +00:00
Thomas Wouters 2cffc7d420 Move our own getopt() implementation to _PyOS_GetOpt(), and use it
regardless of whether the system getopt() does what we want. This avoids the
hassle with prototypes and externs, and the check to see if the system
getopt() does what we want. Prefix optind, optarg and opterr with _PyOS_ to
avoid name clashes. Add new include file to define the right symbols. Fix
Demo/pyserv/pyserv.c to include getopt.h itself, instead of relying on
Python to provide it.
2000-11-03 08:18:37 +00:00
Jeremy Hylton 6b4ec5135b Fix for SF bug #117241
When a method is called with no regular arguments and * args, defer
the first arg is subclass check until after the * args have been
expanded.

N.B. The CALL_FUNCTION implementation is getting really hairy; should
review it to see if it can be simplified.
2000-10-30 17:15:20 +00:00
Guido van Rossum c8fcdcba36 Patch 102114, Bug 11725. On OpenBSD (but apparently not on the other
BSDs) you need a leading underscore in the dlsym() lookup name.
2000-10-25 22:07:45 +00:00
Fred Drake 661ea26b3d Ka-Ping Yee <ping@lfw.org>:
Changes to error messages to increase consistency & clarity.

This (mostly) closes SourceForge patch #101839.
2000-10-24 19:57:45 +00:00
Fred Drake 237b5f44c7 Andy Dustman <adustman@users.sourceforge.net>:
Eliminate unused variables to appease compiler.
2000-10-12 20:58:32 +00:00
Thomas Wouters 0be483fd4d Do a better job at staying on-screen :P (Sorry, it's late here.) I'm
assuming here that the ANSI-C adjacent-string-concatenation technique is
allowable, now that Python requires an ANSI C compiler.
2000-10-11 23:26:11 +00:00
Thomas Wouters 8fb62a2e9a Adjust debugging code in the implementation of the DUP_TOPX bytecode, use
Py_FatalError() instead, and clarify the message somewhat. As discussed on
python-dev.
2000-10-11 23:20:09 +00:00
Fred Drake 48fba733b9 Remove the last gcc -Wall warning about possible use of an uninitialized
variable.  w should be initialized before entering the bytecode
interpretation loop since we only need one initialization to satisfy the
compiler.
2000-10-11 13:54:07 +00:00