Commit Graph

885 Commits

Author SHA1 Message Date
Guido van Rossum d341500d8f Add 'N' format character to Py_BuildValue -- like 'O' but doesn't INCREF.
Patch and suggestion by Greg Couch.
1998-12-23 05:01:38 +00:00
Guido van Rossum 6058eb49ee Improve comment for PyImport_Import() as suggested by Bill Tutt. 1998-12-21 19:51:00 +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 18bc7c2276 Make current_tstate a global, _PyThreadState_Current. This is to
support a macro in pystate.h.
1998-12-21 18:27:28 +00:00
Guido van Rossum 1924a0677d Chris H. writes:
If we're going to put the PyOS_strtol() proto in intobject.h we should
include it here or the symbol isn't exported on PowerPC.
1998-12-18 22:02:37 +00:00
Guido van Rossum 0e1d0e95ea Patch by Chris Herborth:
have to use a const-correct prototype on BeOS or the compiler gets uppity.
1998-12-17 18:03:10 +00:00
Guido van Rossum 2edcf0d71c Move the prototype for dump_counts() to before where it is used.
(This only applies when COUNT_ALLOCS is defined.)
1998-12-15 16:12:00 +00:00
Guido van Rossum 46e9705eca Remove prototypes for PyOS_strto[u]l -- Chris Herborth. 1998-12-10 16:57:44 +00:00
Guido van Rossum ca90605678 Add more SET_LINENO instructions in long argument lists 1998-12-10 16:56:22 +00:00
Guido van Rossum 926f7b6615 Adding thread support for BeOS by Chris Herborth. 1998-12-07 21:56:59 +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 f261526423 Need to add default decl of DL_IMPORT, for mymalloc.h 1998-12-04 18:50:20 +00:00
Barry Warsaw 344864fcfb Added new builtin standard exception: NotImplementedError (its C
counterpart is PyExc_NotImplementedError).
1998-12-01 18:52:06 +00:00
Guido van Rossum df12a59305 Fix cosmetic bug in delattr docstring discovered by JvR. 1998-11-23 22:13:04 +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 66468568df Jim Fulton writes:
"""
I had originally not realized that PyEval_GetGlobals did not
INCREF it's return value.  The fix is to add the INCREF,
as shown below.
"""
1998-10-22 15:46:50 +00:00
Guido van Rossum e0e59829e0 When errno is zero, avoid calling strerror() and use "Error" for the
message.
1998-10-14 20:38:13 +00:00
Guido van Rossum 2f3667a7b9 Replace fprintf(stderr, ...) with PySys_WriteStderr(...). 1998-10-12 18:23:55 +00:00
Guido van Rossum 8442af35fe Patches for mywrite() by Marc Lemburg: save/restore the error state
reliably; check return value of vsprintf().
1998-10-12 18:22:10 +00:00
Guido van Rossum b317f8aa0d Implement new format character 't#'. This is like s#, accepting an
object that implements the buffer interface, but requires a buffer
that contains 8-bit character data.  Greg Stein.
1998-10-08 02:21:21 +00:00
Guido van Rossum 5bd893b1ea The previous checkin contained an experiment of Greg Stein's that wasn't
meant for checkin, and which broke marshal.loads().
1998-10-08 01:45:47 +00:00
Guido van Rossum 0f8b30f8ce On Win32, use
LoadLibraryEx(pathname, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)
to search dependent DLLs in the directory of the pathname.
1998-10-08 01:44:41 +00:00
Guido van Rossum 2a570049ac Changes to deal with the sigcheck+intrcheck vs. signalmodule controversy. 1998-10-07 22:51:56 +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 9e46e56264 BSDI specific patches, inspired by Nigel Head and otto@mail.olympus.net.
Also (non-BSDI specific):

- Change the CHECK_STATUS() macro so it tests for nonzero error codes
instead of negative error codes only (this was needed for BSDI, but
appears to be correct according to the PTHREADS spec).

- use memset() to zero out the allocated lock structure.  Again, this
was needed for BSDI, but can't hurt elsewhere either.
1998-10-07 16:39:47 +00:00
Guido van Rossum 562f5b1480 Support PYTHONOPTIMIZE variable; by Marc Lemburg. 1998-10-07 14:50:42 +00:00
Guido van Rossum dfede31c7f Eh, better error message for the previous change. It now says
"non-default argument follows default argument".
1998-10-02 14:06:56 +00:00
Guido van Rossum 29d38cd088 Treat def f(a, b=1, c): ... as an error (missing default for c)
instead of silently supplying a default of None fore c.
1998-10-02 13:41:54 +00:00
Guido van Rossum e364b7d46a Renamed thread.h to pythread.h.
(Also removed whitespace after # in some BEOS related cpp directives.)
1998-10-01 20:43:23 +00:00
Guido van Rossum 49b560698b Renamed thread.h to pythread.h. 1998-10-01 20:42:43 +00:00
Guido van Rossum 2dcfc9618d On second though, NEXITFUNCS should be defined here and not in
pystate.h; pystate.h doesn't use it (I thought I wanted to move the
array there but that won't work).
1998-10-01 16:01:57 +00:00
Barry Warsaw 968f8cbace builtin_apply(): Second argument type check is relaxed to allow any sequence. 1998-10-01 15:33:12 +00:00
Guido van Rossum 566373e974 While scalling sys.modules, skip entries that don't have string keys,
to protect us from jokers who put items with non-string keys in
sys.modules.  Reported by Greg Stein.
1998-10-01 15:24:50 +00:00
Guido van Rossum 65f15d435e In FreeBSD when using ELF, an underscore is needed in front of the
function name.  (Vladimir Kushnir by way of Thomas Gellekum.)
1998-09-30 14:34:52 +00:00
Guido van Rossum 93d27547d0 Remove redundant definition of NEXITFUNCS.
(Reported by Jeff Rush.)
1998-09-28 22:15:37 +00:00
Barry Warsaw 98b6246c0c Several changes that Python carry on in the face of errors in the
initialization of class exceptions.  Specifically:

init_class_exc(): This function now returns an integer status of the
class exception initialization.  No fatal errors in this method now.
Also, use PySys_WriteStderr() when writing error messages.  When an
error occurs in this function, 0 is returned, but the partial creation
of the exception classes is not undone (this happens elsewhere).

Things that could trigger the fallback:

    - exceptions.py fails to be imported (due to syntax error, etc.)

    - one of the exception classes is missing (e.g. due to library
      version mismatch)

    - exception class can't be inserted into __builtin__'s dictionary

    - MemoryError instance can't be pre-allocated

    - some other PyErr_Occurred

newstdexception(): Changed the error message.  This is still a fatal
error because if the string based exceptions can't be created, we
really can't continue.

initerrors(): Be sure to xdecref the .exc field, which might be
non-NULL if class exceptions init was aborted.

_PyBuiltin_Init_2(): If class exception init fails, print a warning
message and reinstate the string based exceptions.
1998-09-14 18:51:11 +00:00
Guido van Rossum a0f0a33d05 Mac-specific mod to enable aliases on import paths.
(Jack Jansen and/or Just van Rossum)
1998-09-14 13:40:53 +00:00
Guido van Rossum d21744a1dd Apparently on AIX when using gcc you need to call pthread_init()
(which is not a POSIX threads call!).  Reported and confirmed by Brad
Howes.
1998-09-10 03:04:40 +00:00
Guido van Rossum a74d0e4c55 Correct typo in #ifdef: PY_THREAD_D4, should be PY_PTHREAD_D4.
Reported by Jonathan Giddy.
1998-09-04 13:38:32 +00:00
Guido van Rossum 746340d989 Should no longer surround PyOS_Readline() call with
Py_{BEGIN,END}_ALLOW_THREADS macros.  Also get rid of the declaration
for it (it's now in pythonrun.h).
1998-09-03 22:25:05 +00:00
Guido van Rossum 44ee479427 Add a 'volatile' to the declaration of threadid in get_thread_ident().
According to Vladimir Marangozov, this is necessary for AIX, where
high optimization levels inline this function and then get it wrong :-(
1998-08-27 19:21:53 +00:00
Guido van Rossum 53195c1a83 Don't release the interpreter lock around PyParser_ParseFile().
It is needed so that tokenizer.c can use PySys_WriteStderr().
1998-08-27 19:14:49 +00:00
Guido van Rossum afd3daedde __file__ used to be always set to the .pyc (or .pyo) file, even if
that file in fact did not exist or at least was not used.  Change this
so that __file__ is *only* set to the .pyc/.pyo file when it actually
read the code object from it; otherwise __file__ is set to the .py
file.
1998-08-25 18:44:34 +00:00
Guido van Rossum 90f827c67e Comment out the print statement about underflow. (This only seems to
happen when you use a non-keyword argument after a keyword argument,
and in this case you also get a syntax error.  I fully suspect that
the underflow is caused by the code that stops generating code when it
detects the syntax error, but I can't find the culprit right now.  I
know, I know.)
1998-08-25 18:22:17 +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 d0dc5b06a2 Restructure the file so that it is never empty. No longer needs
Metrowerks specific #ifdef.
1998-08-25 17:48:25 +00:00
Guido van Rossum 3293b07df5 Patch by Mark Hammond to support 64-bit ints on MS platforms.
The MS compiler doesn't call it 'long long', it uses __int64,
so a new #define, LONG_LONG, has been added and all occurrences
of 'long long' are replaced with it.
1998-08-25 16:07:15 +00:00
Guido van Rossum ab076fdb6f Ted Horst writes in psa-members@python.org:
This is a patch that Bill Bummgarner did for 1.4 that hasn't made its
way into the distribution yet.  This is important if you want to use
the ObjC module.
1998-08-24 14:15:44 +00:00
Guido van Rossum 0ba353608f Add DebugBreak() call to Py_FatalError() for Mark Hammond (only on
Win32 in Debug mode).
1998-08-13 13:33:16 +00:00
Guido van Rossum 0506a431d5 Patch by Just van Rossum that changes how we search for submodules of
frozen packages.  (I *think* this means that we can now have a
built-in module bar that's a submodule of a frozen package foo, by
registering the built-in module with a name "foo.bar" in the table of
builtin modules.)
1998-08-11 15:07:39 +00:00
Guido van Rossum c4099e6b3c # Fix strange type (methonname instead of methodname). 1998-08-08 20:51:26 +00:00
Guido van Rossum 9c241ba014 Added declarations for Mac code resource modules (Jack Jansen). 1998-08-06 13:36:43 +00:00
Guido van Rossum 0f84a349bb Added handling for Mac code resource modules (Jack Jansen). 1998-08-06 13:36:01 +00:00
Guido van Rossum 40552d0857 Gack. The module doc string is too long for VC++ 5.0.
However two string literals concatenated are fine!
Hope this doesn't break other platforms.
1998-08-06 03:34:39 +00:00
Fred Drake d807879b31 Make getversion.o dependent on ../Include/patchlevel.h as well. 1998-08-05 21:33:54 +00:00
Guido van Rossum 1a8791e0b8 Changes for BeOS, QNX and long long, by Chris Herborth. 1998-08-04 22:46:29 +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
Barry Warsaw 97d951533e PyErr_SetFromErrnoWithFilename(): New function which supports setting
an exception from errno, with a supplied filename (primarily used by
IOError and OSError).  If class exceptions are used then the exception
is instantiated with a 3-tuple: (errno, strerror, filename).  For
backwards compatibility reasons, if string exceptions are used,
filename is ignored.

PyErr_SetFromErrno(): Implement in terms of
PyErr_SetFromErrnoWithFilename().
1998-07-23 16:05:56 +00:00
Barry Warsaw d086a1a864 Added support for two new standard errors: EnvironmentError and
OSError.  The EnvironmentError serves primarily as the (common
implementation) base class for IOError and OSError.  OSError is used
by posixmodule.c

Also added tuple definition of EnvironmentError when using string
based exceptions.
1998-07-23 15:59:57 +00:00
Guido van Rossum fa4ac71dd6 Small changes to map() and filter():
(1) If a sequence S is shorter than len(S) indicated, don't fail --
just use the shorter size.  (I.e, len(S) is just a hint.)

(2) Implement the special case map(None, S) as list(S) -- it's faster.
1998-07-10 17:37:30 +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 bb71ab68f9 Reindented some OS/2 and hpux code that looked ugly or at least
inconsistent.
1998-07-08 13:47:12 +00:00
Guido van Rossum 233f4b54d3 Two error messages still used the old name of the functio mkvalue() --
which is now Py_BuildValue().
1998-07-07 22:32:19 +00:00
Guido van Rossum e32d1537f0 Sigh. The hack to enable special treatment for errno on SGI machines
must be enabled here, otherwise the errno we set on overflows is not
the errno that's being read by compile.c.  Wonder how many other files
that do their own "#include config.h" need this too :-(

(Because of the structure of autoconf, it's not so simple to get this
into config.h...)
1998-07-07 21:32:53 +00:00
Guido van Rossum b68cd421e1 Fix two smal memory leaks discovered by Vadim Chugunov. 1998-07-01 17:36:26 +00:00
Guido van Rossum 8ea9f4d10a Fix a stupid little bug: len() of an unsized returns -1 and leaves an
exception waiting to happen next...
1998-06-29 22:26:50 +00:00
Guido van Rossum 950ff2923a Experimental feature: add default argument to getattr(). 1998-06-29 13:38:57 +00:00
Guido van Rossum a5e1b008a9 Windows-specific hack to make sure that when LoadLibrary() is called,
the filename contains at least a rudimentary pathname.
(The bad part is that we need to call getcwd() because only a prefix
of ".\\" is not enough -- we prefix the drive letter.)
1998-06-27 21:53:17 +00:00
Guido van Rossum c3bc31e249 Added doc strings. Maybe the doc string for the module itself is a bit
long, but it sure helps!
1998-06-27 19:43:25 +00:00
Guido van Rossum f9d9c6c5d2 Added doc strings. 1998-06-26 21:23:49 +00:00
Guido van Rossum d9b5208e90 In raw_input(prompt), make sure that str(prompt) really a string
object before using it.
1998-06-26 18:25:38 +00:00
Guido van Rossum 323bf5e1f7 Ignore Windows case check for ALL CAPS 8.3 files 1998-06-24 03:54:06 +00:00
Guido van Rossum a45cb45965 When unmarshalling, add test for negative lengths on strings, tuples
and lists; if the size is negative, raise an exception.  Also raise an
exception when an undefined type is found -- all this to increase the
chance that garbage input causes an exception instead of a core dump.
1998-06-08 20:27:29 +00:00
Guido van Rossum 9396673a58 Remove a few unused locals (I love VC++ for this!). 1998-05-29 02:59:00 +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 09df08a105 A bunch of functions are now properly implemented in abstract.c, and
the code here becomes much simpler.  In particular: abs(), divmod(),
pow(), int(), long(), float(), len(), tuple(), list().

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.

A few other cosmetic things, such as properly reindenting slice().
1998-05-22 00:51:39 +00:00
Guido van Rossum adf0e437cb Trivial little change: when setting a member to an object, hold the
old value in a temporary and XDECREF it only after then new value has
been set.  This prevents the (unlikely) case where the destructor of
the member uses the containing object -- it would find it in an
undefined state.
1998-05-20 22:25:32 +00:00
Guido van Rossum 9c0afe5dc7 Fix a curious bug: statements like "import sys.time" would succeed,
because the path through the code would notice that sys.__path__ did
not exist and it would fall back to the default path (builtins +
sys.path) instead of failing).  No longer.
1998-05-19 15:09:05 +00:00
Guido van Rossum 6b077878a5 Remove use of RTLD_GLOBAL. 1998-05-18 13:42:45 +00:00
Guido van Rossum fccfe89753 Another veeeeeery old patch...
Date:    Thu, 14 Sep 1995 12:18:20 -0400
From:    Alan Morse <alan@dvcorp.com>
To:      python-list@cwi.nl
Subject: getargs bug in 1.2 and 1.3 BETA

We have found a bug in the part of the getargs code that we added
and submitted, and which was incorporated into 1.1.

The parsing of "O?" format specifiers is not handled correctly;
there is no "else" for the "if" and therefore it can never fail.
What's worse, the advancing of the varargs pointer is not
handled properly, so from then on it is out of sync, wreaking
all sorts of havoc. (If it had failed properly, then the out-of-sync
varargs would not have been an issue.)

Below is the context diff for the change.

Note that I have made a few stylistic changes beyond adding the
else case, namely:

1) Making the "O" case follow the convention established by the other
format specifiers of getting all their vararg arguments before
performing the test, rather than getting some before and some after
the test passes.

2) Making the logic of the tests parallel, so the "if" part indicates
that the format is accepted and the "else" part indicates that the
format has failed. They were inconsistent with each other and with the
the other format specifiers.

-Alan Morse (amorse@dvcorp.com)
1998-05-15 22:04:07 +00:00
Guido van Rossum 859b16c847 In debug mode on MS Windows, DLLs are called foo_d.pyd or foo_d.dll. 1998-05-15 20:22:08 +00:00
Guido van Rossum 532246ef55 Improved version of patch for HPUX from David Arnold. 1998-05-14 21:01:27 +00:00
Guido van Rossum 09cae1f8cd New APIs for embedding applications that want to add their own entries
to the table of built-in modules.  This should normally be called
*before* Py_Initialize().  When the malloc() or realloc() call fails,
-1 is returned and the existing table is unchanged.

After a similar function by Just van Rossum.

int PyImport_ExtendInittab(struct _inittab *newtab);
int PyImport_AppendInittab(char *name, void (*initfunc)());
1998-05-14 02:32:54 +00:00
Guido van Rossum ba7cc0cfba Remove unnecessary PyErr_Clear(). 1998-05-14 02:31:26 +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 a890e68807 New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Adapted from code submitted by Just van Rossum.

   PySys_WriteStdout(format, ...)
   PySys_WriteStderr(format, ...)

      The first function writes to sys.stdout; the second to sys.stderr.  When
      there is a problem, they write to the real (C level) stdout or stderr;
      no exceptions are raised (but a pending exception may be cleared when a
      new exception is caught).

      Both take a printf-style format string as their first argument followed
      by a variable length argument list determined by the format string.

      *** WARNING ***

      The format should limit the total size of the formatted output string to
      1000 bytes.  In particular, this means that no unrestricted "%s" formats
      should occur; these should be limited using "%.<N>s where <N> is a
      decimal number calculated so that <N> plus the maximum size of other
      formatted text does not exceed 1000 bytes.  Also watch out for "%f",
      which can print hundreds of digits for very large numbers.
1998-05-12 14:59:24 +00:00
Guido van Rossum 1e162d3753 Implement round() slightly different, so that for negative ndigits no
additional errors happen in the last step.  The trick is to avoid
division by 0.1**n -- multiply by 10.0**n instead.
1998-05-09 14:42:25 +00:00
Guido van Rossum 89df70bfbb Support HPUX 10.20 DCE threads. 1998-05-07 13:28:23 +00:00
Guido van Rossum a937d14898 Fred's right -- we need PyList_SET_ITEM(). 1998-04-24 18:22:02 +00:00
Guido van Rossum 507338e5ca In-line the code in range() to set the list items; there's really no
need to call PyList_SetItem(v,i,w) when PyList_GET_ITEM(v,i)=w {sic}
will do.
1998-04-23 21:46:19 +00:00
Guido van Rossum 1f74016735 Support for OpenBSD :-( 1998-04-13 15:27:21 +00:00
Guido van Rossum 111c20b992 Reject empty module names -- otherwise __import__("") does something
weird!
1998-04-11 17:38:22 +00:00
Guido van Rossum cecadc469b Move #include <sys/param.h> to before osdefs.h (Donn Cave). 1998-04-10 23:45:14 +00:00
Guido van Rossum 8766a7797e Comment out a label on an #endif. 1998-04-10 23:44:32 +00:00
Guido van Rossum 730806d3d9 Make new gcc -Wall happy 1998-04-10 22:27:42 +00:00
Guido van Rossum 39b0f8976c Address warnings issued by the MSVC++ compiler 1998-04-10 21:52:06 +00:00