Commit Graph

1182 Commits

Author SHA1 Message Date
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