Commit Graph

196 Commits

Author SHA1 Message Date
Barry Warsaw 23c9ec87cf PEP 214, Extended print Statement, has been accepted by the BDFL.
eval_code2(): Implement new bytecodes PRINT_ITEM_TO and
PRINT_NEWLINE_TO, as per accepted SF patch #100970.

Also update graminit.c based on related Grammar/Grammar changes.
2000-08-21 15:44:01 +00:00
Thomas Wouters 0400515ff0 Fix the bug Sjoerd Mullender discovered, where find_from_args() wasn't
trying hard enough to find out what the arguments to an import were. There
is no test-case for this bug, yet, but this is what it looked like:

from encodings import cp1006, cp1026
ImportError: cannot import name cp1026

'__import__' was called with only the first name in the 'arguments' list.
2000-08-20 14:01:53 +00:00
Fred Drake 04e654a63c Remove a couple of warnings turned up by "gcc -Wall". 2000-08-18 19:53:25 +00:00
Thomas Wouters 5215225ea1 Apply SF patch #101135, adding 'import module as m' and 'from module import
name as n'. By doing some twists and turns, "as" is not a reserved word.

There is a slight change in semantics for 'from module import name' (it will
now honour the 'global' keyword) but only in cases that are explicitly
undocumented.
2000-08-17 22:55:00 +00:00
Thomas Wouters 0be5aab04d Merge UNPACK_LIST and UNPACK_TUPLE into a single UNPACK_SEQUENCE, since they
did the same anyway.

I'm not sure what to do with Tools/compiler/compiler/* -- that isn't part of
distutils, is it ? Should it try to be compatible with old bytecode version ?
2000-08-11 22:15:52 +00:00
Moshe Zadka aa39a7edf7 Initialized opcode and oparg to silence a gcc -Wall warning. 2000-08-07 06:34:45 +00:00
Thomas Wouters 334fb8985b Use 'void' directly instead of the ANY #define, now that all code is ANSI C.
Leave the actual #define in for API compatibility.
2000-07-25 12:56:38 +00:00
Thomas Wouters f70ef4f860 Mass ANSIfication of function definitions. Doesn't cover all 'extern'
declarations yet, those come later.
2000-07-22 18:47:25 +00:00
Thomas Wouters 7e47402264 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
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-16 12:04:32 +00:00
Jack Jansen cbf630f0a9 Include macglue.h for some function prototypes, and renamed a few
mac-specific functions to have a PyMac_ name.
2000-07-11 21:59:16 +00:00
Tim Peters dbd9ba6a6c Nuke all remaining occurrences of Py_PROTO and Py_FPROTO. 2000-07-09 03:09:57 +00:00
Guido van Rossum ffcc3813d8 Change copyright notice - 2nd try. 2000-06-30 23:58:06 +00:00
Guido van Rossum fd71b9e9d4 Change copyright notice. 2000-06-30 23:50:40 +00:00
Guido van Rossum 582acece2e Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
tests.
2000-06-28 22:07:35 +00:00
Guido van Rossum 20c6add7ff Trent Mick:
Change static slice_index() to extern _PyEval_SliceIndex() (with
different return value interpretation: 0 for failure, 1 for success).
2000-05-08 14:06:50 +00:00
Guido van Rossum cc229ea76f Add useless 'return 1' to prtrace() to shut up VC++. 2000-05-04 00:55:17 +00:00
Guido van Rossum b18618dab7 Vladimir Marangozov's long-awaited malloc restructuring.
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.)
2000-05-03 23:44:39 +00:00
Guido van Rossum 25826c93c4 Charles Waldman writes:
"""
Running "test_extcall" repeatedly results in memory leaks.

One of these can't be fixed (at least not easily!), it happens since
this code:

def saboteur(**kw):
    kw['x'] = locals()
d = {}
saboteur(a=1, **d)

creates a circular reference - d['x']['d']==d

The others are due to some missing decrefs in ceval.c, fixed by the
patch attached below.

Note:  I originally wrote this without the "goto", just adding the
missing decref's where needed.  But I think the goto is justified in
keeping the executable code size of ceval as small as possible.
"""

[I think the circular reference is more like kw['x']['kw'] == kw. --GvR]
2000-04-21 21:17:39 +00:00
Guido van Rossum 5db862dd0c Skip Montanaro: add string precisions to calls to PyErr_Format
to prevent possible buffer overruns.
2000-04-10 12:46:51 +00:00
Guido van Rossum 7a5b796322 Thomas Heller fixes a typo in an error message. 2000-03-31 13:52:29 +00:00
Jeremy Hylton 387b1011a1 rename args variable in CALL_FUNCTION to callargs (avoids name
override)

add missing DECREFs in error handling code of CALL_FUNCTION
2000-03-31 01:22:54 +00:00
Jeremy Hylton 074c3e62d1 Two fixes for extended call syntax:
If a non-tuple sequence is passed as the *arg, convert it to a tuple
before checking its length.
If named keyword arguments are used in combination with **kwargs, make
a copy of kwargs before inserting the new keys.
2000-03-30 23:55:31 +00:00
Barry Warsaw b2ba9d8963 eval_code2(): Oops, in the last checkin, we shouldn't check for
PyErr_Occurred(), just set x=NULL and break.  Oh, and make Jeremy stop
nagging me about the "special" indentation for this block.
2000-03-29 18:36:49 +00:00
Barry Warsaw 4961ef7086 eval_code2(): In the extended calling syntax opcodes, you must check
the return value of PySequence_Length().  If an exception occurred,
the returned length will be -1.  Make sure this doesn't get obscurred,
and that the bogus length isn't used.
2000-03-29 18:30:03 +00:00
Jeremy Hylton 7690151c7e slightly modified version of Greg Ewing's extended call syntax patch
executive summary:
Instead of typing 'apply(f, args, kwargs)' you can type 'f(*arg, **kwargs)'.
Some file-by-file details follow.

Grammar/Grammar:
    simplify varargslist, replacing '*' '*' with '**'
    add * & ** options to arglist

Include/opcode.h & Lib/dis.py:
    define three new opcodes
        CALL_FUNCTION_VAR
        CALL_FUNCTION_KW
        CALL_FUNCTION_VAR_KW

Python/ceval.c:
    extend TypeError "keyword parameter redefined" message to include
        the name of the offending keyword
    reindent CALL_FUNCTION using four spaces
    add handling of sequences and dictionaries using extend calls
    fix function import_from to use PyErr_Format
2000-03-28 23:49:17 +00:00
Andrew M. Kuchling 2194b165db Allow using long integers as slice indexes 2000-02-23 22:18:48 +00:00
Fred Drake 145c26e3d3 Remove comment that Guido agree's doesn't make sense:
PyEval_EvalCode() is *not* a "backward compatible interface", it's the
one to use!
2000-02-21 17:59:48 +00:00
Guido van Rossum a400d8a96d Fix a bug in exec_statement() noted incidentally by Tim Peters in
PR#175 -- when exec is passed a code object, it didn't sync the locals
from the dictionary back into their fast representation.

Also took the time to remove some repetitive code there and to do the
syncing even when an exception is raised (since a partial effect
should still be synced).
2000-01-12 22:45:54 +00:00
Guido van Rossum ba98a42a0f Change the last PyErr_Format %s format to %.400s. 1999-11-15 19:29:33 +00:00
Guido van Rossum 25da5bebd8 Fix PR117. The error message is "keywords must be strings". Perhaps
not as descriptive as what Barry suggests, but this also catches the
(in my opinion important) case where some other C code besides apply()
constructs a kwdict that doesn't have the right format.  All the other
possibilities of getting it wrong (non-dict, wrong keywords etc) are
already caught so this makes sense to check here.
1999-10-26 00:12:20 +00:00
Barry Warsaw f6202635f9 call_trace(): A fix for PR#73, if an exception occurred in the
tracefunc (or profilefunc -- we're not sure which), zap the global
trace and profile funcs so that we can't get into recursive loop when
instantiating the resulting class based exception.
1999-09-08 16:26:33 +00:00
Guido van Rossum 8746082175 Patch by Tim Peters:
Introduce a new builtin exception, UnboundLocalError, raised when ceval.c
tries to retrieve or delete a local name that isn't bound to a value.
Currently raises NameError, which makes this behavior a FAQ since the same
error is raised for "missing" global names too:  when the user has a global
of the same name as the unbound local, NameError makes no sense to them.
Even in the absence of shadowing, knowing whether a bogus name is local or
global is a real aid to quick understanding.

Example:

D:\src\PCbuild>type local.py
x = 42

def f():
    print x
    x = 13
    return x

f()

D:\src\PCbuild>python local.py
Traceback (innermost last):
  File "local.py", line 8, in ?
    f()
  File "local.py", line 4, in f
    print x
UnboundLocalError: x

D:\src\PCbuild>

Note that UnboundLocalError is a subclass of NameError, for compatibility
with existing class-exception code that may be trying to catch this as a
NameError.  Unfortunately, I see no way to make this wholly compatible
with -X (see comments in bltinmodule.c):  under -X, [UnboundLocalError
is an alias for NameError --GvR].

[The ceval.c patch differs slightly from the second version that Tim
submitted; I decided not to raise UnboundLocalError for DELETE_NAME,
only for DELETE_LOCAL.  DELETE_NAME is only generated at the module
level, and since at that level a NameError is raised for referencing
an undefined name, it should also be raised for deleting one.]
1999-06-22 14:47:32 +00:00
Guido van Rossum 2571cc8bf5 Changes by Mark Hammond for Windows CE. Mostly of the form
#ifdef DONT_HAVE_header_H ... #endif around #include <header.h>.
1999-04-07 16:07:23 +00:00
Guido van Rossum eb894ebd0a Always test for an error return (usually NULL or -1) without setting
an exception.
1999-03-09 16:16:45 +00:00
Guido van Rossum 65d5b5763c Thanks to Chris Herborth, the thread primitives now have proper Py*
names in the source code (they already had those for the linker,
through some smart macros; but the source still had the old, un-Py names).
1998-12-21 19:32:43 +00:00
Guido van Rossum 885553e8d3 Use PyThreadState_GET() macro. 1998-12-21 18:33:30 +00:00
Guido van Rossum cf183acf15 Use PyInt_AS_LONG macro instead of explicit inlining. 1998-12-04 18:51:36 +00:00
Guido van Rossum 014518f66c Whoops! One the "redundant" initializations removed by Vladimir in
the previous patch wasn't -- there was a path through the code that
bypassed all initializations.  Thanks to Just for reporting the bug!
1998-11-23 21:09:51 +00:00
Guido van Rossum 50cd34888b Remove some redundant initializations -- patch by Vladimir Marangozov. 1998-11-17 17:02:51 +00:00
Guido van Rossum d076c73cc8 Changes to support other object types besides strings
as the code string of code objects, as long as they support
the (readonly) buffer interface.  By Greg Stein.
1998-10-07 19:42:25 +00:00
Guido van Rossum 49b560698b Renamed thread.h to pythread.h. 1998-10-01 20:42:43 +00:00
Guido van Rossum 2d1ad39b81 Add the type of the object to the error message about calling a non-function. 1998-08-25 18:16:54 +00:00
Guido van Rossum 5053efc2c4 In BUILD_LIST, use PyList_SET_ITEM() instead of PyList_SetItem(); and
get rid of redundant error check.
1998-08-04 15:27:50 +00:00
Guido van Rossum fa00e958fd # In case BINARY_SUBSCR, use proper PyList_GET* macros instead of inlining. 1998-07-08 15:02:37 +00:00
Guido van Rossum 7859f87fdb Marc-Andre Lemburg's patch to support instance methods with other
callable objects than regular Pythonm functions as their im_func.
1998-07-08 14:58:16 +00:00
Guido van Rossum 7e33c6e896 Moved cmp_member() to abstract.c, as PySequence_Contains() [with
swapped arguments].

Also make sure that no use of a function pointer gotten from a
tp_as_sequence or tp_as_mapping structure is made without checking it
for NULL first.
1998-05-22 00:52:29 +00:00
Guido van Rossum 234e260d5e Since PyDict_GetItem() can't raise an exception any more, there's no
need to call PyErr_Clear() when it returns NULL.
1998-05-14 02:16:20 +00:00
Guido van Rossum 2e4c899e2d DELETE_FAST should issue an exception when the local variable is undefined. 1998-05-12 20:27:36 +00:00
Guido van Rossum 730806d3d9 Make new gcc -Wall happy 1998-04-10 22:27:42 +00:00
Guido van Rossum d295f120ae Make first raise argument optional 1998-04-09 21:39:57 +00:00