Commit Graph

114 Commits

Author SHA1 Message Date
Guido van Rossum d6af46d4ae Need a cast when comparing type object in isinstance() 1997-12-10 05:51:47 +00:00
Guido van Rossum f5dd914196 Support type objects in isinstance().
E.g. isinstance('',types.StringType) will return true now instead of
raising a TypeError exception.  This is for JPython compatibility.
1997-12-02 19:11:45 +00:00
Guido van Rossum ee81af8977 Release interpreter lock around readline call in [raw_]input(). 1997-09-26 21:47:43 +00:00
Barry Warsaw b01a7fa5f8 initerrors(): Eliminate circular reference which was causing a small
but annoying memory leak.  This was introduced when PyExc_Exception
was added; the loop above populating the PyExc_StandardError exception
tuple started at index 1 in bltin_exc, but PyExc_Exception was added
at index 0, so PyExc_StandardError was getting inserted in itself!
How else can a tuple include itself?!

Change the loop to start at index 2.

This was a *fun* one! :-)
1997-09-18 03:44:38 +00:00
Barry Warsaw 412cdc2284 [Py_Exc]NumberError => [Py_Exc]ArithmeticError 1997-09-16 21:51:14 +00:00
Guido van Rossum 0474832d9c Introduce PyExc_Exception as the conceptual root class for all exceptions. 1997-09-16 18:43:15 +00:00
Guido van Rossum aee0bad0a5 First part of package support.
This doesn't yet support "import a.b.c" or "from a.b.c import x", but
it does recognize directories.  When importing a directory, it
initializes __path__ to a list containing the directory name, and
loads the __init__ module if found.

The (internal) find_module() and load_module() functions are
restructured so that they both also handle built-in and frozen modules
and Mac resources (and directories of course).  The imp module's
find_module() and (new) load_module() also have this functionality.
Moreover, imp unconditionally defines constants for all module types,
and has two more new functions: find_module_in_package() and
find_module_in_directory().

There's also a new API function, PyImport_ImportModuleEx(), which
takes all four __import__ arguments (name, globals, locals, fromlist).
The last three may be NULL.  This is currently the same as
PyImport_ImportModule() but in the future it will be able to do
relative dotted-path imports.

Other changes:

- bltinmodule.c: in __import__, call PyImport_ImportModuleEx().

- ceval.c: always pass the fromlist to __import__, even if it is a C
function, so PyImport_ImportModuleEx() is useful.

- getmtime.c: the function has a second argument, the FILE*, on which
it applies fstat().  According to Sjoerd this is much faster.  The
first (pathname) argument is ignored, but remains for backward
compatibility (so the Mac version still works without changes).

By cleverly combining the new imp functionality, the full support for
dotted names in Python (mini.py, not checked in) is now about 7K,
lavishly commented (vs. 14K for ni plus 11K for ihooks, also lavishly
commented).

Good night!
1997-09-05 07:33:22 +00:00
Barry Warsaw 757af0e7bb Removed obsolete exception PyExc_AccessError.
Added PyErr_MemoryErrorInst to hold the pre-instantiated instance when
using class based exceptions.

Simplified the creation of all built-in exceptions, both class based
and string based.  Actually, for class based exceptions, the string
ones are still created just in case there's a problem creating the
class based ones (so you still get *some* exception handling!).  Now
the init and fini functions run through a list of structure elements,
creating the strings (and optionally classes) for every entry.

initerrors(): the new base class exceptions StandardError,
LookupError, and NumberError are initialized when using string
exceptions, to tuples containing the list of derived string
exceptions.  This GvR trick enables forward compatibility!  One bit of
nastiness is that the C code has to know the inheritance tree embodied
in exceptions.py.

Added the two phase init and fini functions.
1997-08-29 22:13:51 +00:00
Barry Warsaw cde8b1ba0c Two new built-in functions: issubclass() and isinstance(). Both take
classes as their second arguments.  The former takes a class as the
first argument and returns true iff first is second, or is a subclass
of second.

The latter takes any object as the first argument and returns true iff
first is an instance of the second, or any subclass of second.

Also, change all occurances of pointer compares against
PyExc_IndexError with PyErr_ExceptionMatches() calls.
1997-08-22 21:14:38 +00:00
Guido van Rossum 25ce566661 The last of the mass checkins for separate (sub)interpreters.
Everything should now work again.

See the comments for the .h files mass checkin (e.g. pystate.h) for
more detail.
1997-08-02 03:10:38 +00:00
Guido van Rossum c8b6df9004 PyObject_Compare can raise an exception now. 1997-05-23 00:06:51 +00:00
Guido van Rossum b6a7f77c9f Oops -- missed FloatingPointError in renaming. 1997-05-09 03:03:23 +00:00
Guido van Rossum b05a5c7698 Instead of importing graminit.h whenever one of the three grammar 'root'
symbols is needed, define these in Python.h with a Py_ prefix.
1997-05-07 17:46:13 +00:00
Guido van Rossum 666b17a280 New dir() function --
- uses abstract interface where possible
- uses __members__ and __methods__
- returns [] when an object has no info available
1997-05-06 16:36:57 +00:00
Guido van Rossum 15e33a4c42 Avoid sprintf buffer overflow if more than 9999 arguments. 1997-04-30 19:00:27 +00:00
Guido van Rossum 79f25d9a7b Quickly renamed the remaining files -- this directory is done. 1997-04-29 20:08:16 +00:00
Guido van Rossum 6bf62dad9e Keep gcc -Wall and Microsoft VC happy. 1997-04-11 20:37:35 +00:00
Guido van Rossum c6472e9ee1 1. Add string conversions to int(), long(), float(). (Not to complex()!)
2. Fix two bugs in complex():

   - Memory leak when using complex(classinstance) -- r was never
   DECREF'ed.

   - Conversion of the second argument, if not complex, was done using
   the type vector of the 1st.
1997-03-31 17:15:43 +00:00
Guido van Rossum 1c6a459921 Define __debug__ as 0 if -O is given, 1 otherwise. Also test for
errors in initializing the dictionary.
1997-03-11 18:43:26 +00:00
Guido van Rossum 0ae748d3c4 Changes for Lee Busby's SIGFPE patch set.
New file pyfpe.c and exception FloatingPointError.
Surround some f.p. operations with PyFPE macro brackets.
1997-02-14 22:58:07 +00:00
Guido van Rossum e8811f85ed Added intern() function. 1997-02-14 15:48:05 +00:00
Guido van Rossum 8d75161671 Intern the string "__complex__". 1997-01-18 08:04:16 +00:00
Guido van Rossum 1a2c5cbcc4 Add unistd.h to make gcc -Wall happy. 1996-12-10 15:37:36 +00:00
Guido van Rossum ed0af8fe70 Support __complex__ method on instances, for complex() conversion.
Keep gcc -Wall happy.
1996-12-05 23:18:18 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum b75fba04c7 Forget about Ellipses b/w compatibility. 1996-10-16 04:18:36 +00:00
Guido van Rossum e449af7da9 Ellipses -> Ellipsis rename (the dictionary really says that it should
be Ellipsis!).
Bumped the API version because a linker-visible symbol is affected.
Old C code will still compile -- there's a b/w compat macro.
Similarly, old Python code will still run, builtin exports both
Ellipses and Ellipsis.
1996-10-11 16:25:41 +00:00
Guido van Rossum b072150d7f Stupid bug: complex(x,y) would yield x+xj 1996-09-07 15:55:27 +00:00
Guido van Rossum 79d96d6bff Don't die in resizestring() on filter(<func>, ""). 1996-08-16 20:44:34 +00:00
Guido van Rossum fe4b6ee775 Include mymath.h instead of declaring prototypes for math functions.
Fix leak and unchecked error in complex().
1996-08-08 18:49:41 +00:00
Guido van Rossum 6ffd553899 Add 'Ellipses' object. 1996-07-30 18:37:55 +00:00
Guido van Rossum 8861b74445 Changes for slice and ellipses 1996-07-30 16:49:37 +00:00
Guido van Rossum 530956d247 Py_complex; and WITHOUT_COMPLEX added to getargs.c 1996-07-21 02:27:43 +00:00
Guido van Rossum 795ba583f2 Removed some redundant header includes.
dir(object) now returns object.__dict__.keys() even if __dict__ is not
a dictionary.
1996-05-23 22:49:07 +00:00
Guido van Rossum d17057745c Add list() method, analogous to tuple(). 1996-04-09 02:41:06 +00:00
Guido van Rossum c96ef6ab9e properly initialize optional arguments to apply() 1996-01-26 20:44:30 +00:00
Guido van Rossum 8a5c5d277e changes for complex numbers 1996-01-12 01:09:56 +00:00
Guido van Rossum b7b45627e8 avoid resize of 0-length tuple 1995-08-04 04:07:45 +00:00
Guido van Rossum 53bb7fff11 be more suspicious of getlocals() 1995-07-26 16:26:31 +00:00
Guido van Rossum 681d79aaf3 keyword arguments and faster calls 1995-07-18 14:51:37 +00:00
Guido van Rossum 32120311ed rename arglist to alist (conflict with new grammar symbol) 1995-07-10 13:52:21 +00:00
Guido van Rossum 872537cc86 added locals() and globals(); [raw_]input() uses readline() 1995-07-07 22:43:42 +00:00
Guido van Rossum 8a1e8eb62f fix bogus test for negative float 1995-02-18 14:51:32 +00:00
Guido van Rossum 24c137432c call __import__() with 4 args instead of 1 1995-02-14 09:42:43 +00:00
Guido van Rossum 2165158ab3 test for float to the float power here 1995-02-10 16:57:16 +00:00
Guido van Rossum a6f6050229 moved callable() to object.c 1995-01-26 00:39:50 +00:00
Guido van Rossum 7f9fa97ca2 fix import related leaks 1995-01-20 16:53:12 +00:00
Guido van Rossum 0865dd9ce9 fix Alpha bug in (x)range; different __builtins__ initialization 1995-01-17 16:30:22 +00:00
Guido van Rossum 58b6873f6b fix subtle refcount big in filter() -- Tim MacKenzie 1995-01-10 17:40:55 +00:00
Guido van Rossum 5524a59b09 move coerce() from bltinmodule.c to object.c and implement builtin_coerce() differently 1995-01-10 15:26:20 +00:00