Commit Graph

20445 Commits

Author SHA1 Message Date
Guido van Rossum 7ad2d1eb8e Add __del__ callbacks. They are too useful to leave out.
XXX Remaining problems:

- The GC module doesn't know about these; I think it has its reasons
  to disallow calling __del__, but for now, __del__ on new-style
  objects is called when the GC module discards an object, for better
  or for worse.

- The code to call a __del__ handler is really ridiculously
  complicated, due to all the different debug #ifdefs.  I've copied
  this from the similar code in classobject.c, so I'm pretty sure I
  did it right, but it's not pretty. :-(

- No tests yet.
2001-10-29 22:11:00 +00:00
Tim Peters c57a285cb4 SF bug #476138: tempfile behavior across platforms
Ensure that a tempfile can be closed any number of times without error.
This wasn't true on Windows.
2001-10-29 21:46:08 +00:00
Fred Drake e59feb5edc Revise the PDF support in the LaTeX style sheet. This still isn't quite
right, but the tests for whether we are generating PDF are a bit more
readable, and some unnecessary indirection has been removed.
2001-10-29 21:02:28 +00:00
Fred Drake 8e26b52a5c Update to reflect changes to the low-level logreader: share the info
dictionary instead of building a new one, and provide an overridable method
to allow subclasses to catch ADD_INFO records that are not part of the
initial block of ADD_INFO records created by the profiler itself.
2001-10-29 20:57:23 +00:00
Fred Drake f3c54d6fc7 Add a test for the insertion of user-provided ADD_INFO records. 2001-10-29 20:54:01 +00:00
Fred Drake 165b2cc2bd Allow user code to call the addinfo() method on the profiler object. 2001-10-29 20:48:09 +00:00
Fred Drake 4c2e1af890 Make the low-level log-reader object export a dictionary mapping keys
to lists of values, giving the contents of all the ADD_INFO records
seen so far.  This is initialized agressively when the log file is
opened, so that whoever is looking at the log reader can always see
the initial data loaded into the data stream.  ADD_INFO events later
in the log file continue to be reported to the application layer as
before.

Add a new method, addinfo(), to the profiler.  This can be used to
insert additional ADD_INFO records into the profiler log.

Fix the tp_flags and tp_name slots on the type objects.
2001-10-29 20:45:57 +00:00
Andrew M. Kuchling 1117d930fa dictionary -> dict 2001-10-29 20:37:47 +00:00
Andrew M. Kuchling 4f9e220e7f Fix two typos noted by Jens Quade
Bump version number
2001-10-29 18:09:42 +00:00
Fred Drake 589abb7212 Add additional information on exceptions from time.mktime() and related to
improper time tuples passed to various functions.  Based on comments from
Andreas Jung.
2001-10-29 18:01:24 +00:00
Fred Drake 1b58bff8a0 More refcount information. 2001-10-29 17:43:14 +00:00
Fred Drake b0109ffb3b Ignore all *.tex files in the typesetting output directories since there are
a bunch of them now.
2001-10-29 17:42:17 +00:00
Fred Drake 520b0093db Make sure we generate versions of each file in the Python/C API manual with
reference-count annotations; this is needed for the typeset forms of the
manuals.
2001-10-29 17:40:40 +00:00
Jeremy Hylton e16e54f7f1 Use connect_ex() instead of connect().
Removes old XXX comment and possible source of long-delays.
2001-10-29 16:44:37 +00:00
Jeremy Hylton fbd5797eb7 Fix for SF bug 453099 -- select not defensive
And SF patch 473223 -- infinite getattr loop

Wrap select() and poll() calls with try/except for EINTR.  If EINTR is
raised, treat as a response where no fd is ready.

In dispatcher constructor, make sure self.socket is always
initialized.
2001-10-29 16:32:19 +00:00
Andrew M. Kuchling 2836907bbb Fix some markup errors noted by MH
Use attribute assignment to illustrate __slots__ raising an error
2001-10-29 15:47:33 +00:00
Guido van Rossum afe7a94089 When overriding __str__ or __repr__, set the tp_print slot to NULL. 2001-10-29 14:33:44 +00:00
Steven M. Gava 7c01786188 more loading from cfg files 2001-10-29 11:19:46 +00:00
Steven M. Gava 41a8532f66 more of config dialog reading from files 2001-10-29 08:05:34 +00:00
Guido van Rossum 9bd1401bbb Use sendall() in the stream test instead of send(). 2001-10-29 07:18:02 +00:00
Guido van Rossum cb65688218 Test sendall(). 2001-10-29 07:14:10 +00:00
Guido van Rossum b2c763fed2 Add 'sendall' to list of socket methods. 2001-10-29 07:13:53 +00:00
Fredrik Lundh b7747e2a2d added finditer sanity check 2001-10-28 20:15:40 +00:00
Guido van Rossum ca6dfa55c5 Oops. In the tp_name field, the name should be "_socket.socket", not
"socket.socket" -- on Windows, "socket.socket" is the wrapper class.
Also added the module name to the SSL type (which is not a new-style
class -- I don't want to mess with it yet).
2001-10-28 12:31:33 +00:00
Fred Drake b0c079e3e5 PyObject_CallFunctionObArgs() ---> PyObject_CallFunctionObjArgs()
PyObject_CallMethodObArgs() ---> PyObject_CallMethodObjArgs()
2001-10-28 02:39:03 +00:00
Guido van Rossum 86443216b7 News about the socket type and the HP-UX port. 2001-10-27 22:28:54 +00:00
Guido van Rossum 384ca9c6dd Made SocketType and socket the same thing: a subclassable type whose
constructor acts just like socket() before.  All three arguments have
a sensible default now; socket() is equivalent to
socket(AF_INET, SOCK_STREAM).

One minor issue: the socket() function and the SocketType had
different doc strings; socket.__doc__ gave the signature,
SocketType.__doc__ gave the methods.  I've merged these for now, but
maybe the list of methods is no longer necessary since it can easily
be recovered through socket.__dict__.keys().  The problem with keeping
it is that the total doc string is a bit long (34 lines -- it scrolls
of a standard tty screen).

Another general issue with the socket module is that it's a big mess.
There's pages and pages of random platform #ifdefs, and the naming
conventions are totally wrong: it uses Py prefixes and CapWords for
static functions.  That's a cleanup for another day...  (Also I think
the big starting comment that summarizes the API can go -- it's a
repeat of the docstring.)
2001-10-27 22:20:47 +00:00
Guido van Rossum bd67d6f32c SF patch #475657 (Dietmar Schwertberger)
RISCOS/Makefile:
include structseq and weakrefobject;
changes to keep command line length below 2048

RISCOS/Modules/riscosmodule.c:
typos from the stat structseq patch

Include/pyport.h:
don't re-#define __attribute__(__x) on RISC OS as it is already defined in c library
2001-10-27 21:16:16 +00:00
Tim Peters 3abca127fe SF bug #475327: type() produces incorrect error msg
object.h:  Added PyType_CheckExact macro.

typeobject.c, type_new():

+ Use the new macro.
+ Assert that the arguments have the right types rather than do incomplete
  runtime checks "sometimes".
+ If this isn't the 1-argument flavor() of type, and there aren't 3 args
  total, produce a "types() takes 1 or 3 args" msg before
  PyArg_ParseTupleAndKeywords produces a "takes exactly 3" msg.
2001-10-27 19:37:48 +00:00
Tim Peters 4d85953fe6 dictionary() constructor:
+ Change keyword arg name from "x" to "items".  People passing a mapping
  object can stretch their imaginations <wink>.
+ Simplify the docstring text.
2001-10-27 18:27:48 +00:00
Tim Peters c2f011201a vgetargskeywords()
+ Squash another potential buffer overrun.
+ Simplify the keyword-arg loop by decrementing the count of keywords
  remaining instead of incrementing Yet Another Variable; also break
  out early if the number of keyword args remaining hits 0.

Since I hit the function's closing curly brace with this patch, that's
enough of this for now <wink>.
2001-10-27 07:25:06 +00:00
Tim Peters b639d49798 vgetargskeywords: Now that it's clear that nkwlist must equal max, and
we're ensuring that's true during the format parse, get rid of nkwlist.
2001-10-27 07:00:56 +00:00
Tim Peters dc5eff9170 vgetargskeywords: Prevent another potential sprintf buffer overrun. 2001-10-27 06:53:00 +00:00
Tim Peters 62d48e1735 vgetargskeywords: Verify kwlist has the required length while parsing
the format, instead of waiting until after we can overindex it by
mistake.
2001-10-27 06:42:16 +00:00
Fred Drake b92cf067c6 PyObject_CallFunction(), PyObject_CallMethod(): Make sure we do not touch
the va_list until we are sure we have a format string and need to use it;
this avoid premature initialization and having to finalize it several
different places because of error returns.
2001-10-27 06:16:31 +00:00
Tim Peters 0af4916ad4 vgetargskeywords: Removed all PyErr_Clear() calls. It's possible that
this routine will report an error now when it didn't before, but, if so,
it's a legitimate error that should never have been suppressed.
2001-10-27 06:14:32 +00:00
Tim Peters 077f574db1 vgetargskeywords: The keywords arg is a dict (if non-NULL), so use the
dict API everywhere on it instead of sometimes using the slower mapping
API.
2001-10-27 05:50:39 +00:00
Tim Peters 61dde63e3b vgetargskeywords: Removed one of the mysterious PyErr_Clear() calls.
The "need" for this was probably removed by an earlier patch that stopped
the loop right before it from passing NULL to a dict lookup routine.
I still haven't convinced myself that the next loop is correct, so am
leaving the next mysterious PyErr_Clear() call in for now.
2001-10-27 05:30:17 +00:00
Tim Peters b054be41c0 vgetargskeywords:
+ Generally test nkeywords against 0 instead of keywords against NULL
  (saves a little work if an empty keywords dict is passed, and is
  conceptually more on-target regardless).
+ When a call erroneously specifies a keyword argument both by position
  and by keyword name:
    - It was easy to provoke this routine into an internal buffer overrun
      by using a long argument name.  Now uses PyErr_format instead (which
      computes a safe buffer size).
    - Improved the error msg.
2001-10-27 05:07:41 +00:00
Tim Peters b0872fc8a6 vgetargskeywords:
+ Got rid of now-redundant dict typecheck.
+ Renamed nkwds to nkwlist.  Now all the "counting" vrbls have names
  related to the things they're counting in an obvious way.
2001-10-27 04:45:34 +00:00
Tim Peters 6fb2635f25 vgetargskeywords:
+ Renamed argslen to nargs.
+ Renamed kwlen to nkeywords.  This one was especially confusing because
  kwlen wasn't the length of the kwlist argument, but of the keywords
  argument.
2001-10-27 04:38:11 +00:00
Tim Peters 28bf7a9770 vgetargskeywords:
+ Removed now-redundant tuple typecheck.
+ Renamed "tplen" local to "argslen" (it's the length of the "args"
  argument; I suppose "tp" was for "Tim Peters should rename me
  someday <wink>).
2001-10-27 04:33:41 +00:00
Tim Peters f8cd3e8621 PyArg_ParseTupleAndKeywords: return false on internal error, not -1 (I
introduced this bug just a little while ago, when *adding* internal error
checks).

vgetargskeywords:  Rewrote the section that crawls over the format string.
+ Added block comment so it won't take the next person 15 minutes to
  reverse-engineer what it's doing.
+ Lined up the "else" clauses.
+ Rearranged the ifs in decreasing order of likelihood (for speed).
2001-10-27 04:26:57 +00:00
Tim Peters 45772cde7e PyArg_ParseTupleAndKeywords: do basic sanity checks on the arguments,
and raise an error if they're insane.
vgetargskeywords:  the same, except that since this is an internal routine,
just assert that the arguments are sane.
2001-10-27 03:58:40 +00:00
Tim Peters a9f4739a1b tuple(3,4,5,x=2) dumped core on my box. vgetargskeywords() overindexed
the kwlist vector whenever there was a mix of positional and keyword
arguments, and the number of positional arguments exceeded the length
of the kwlist vector.  If there was just one more positional arg than
keyword, the kwlist-terminating NULL got passed to PyMapping_HasKeyString,
which set an internal error that vgetargskeywords() then squashed (but
it's impossible to say whether it knew it was masking an error).  If
more than one more positional argument, it went on to pass random trash
to PyMapping_HasKeyString, which is why the example at the start
happened to kill the process.

Pure bugfix candidate.
2001-10-27 00:46:09 +00:00
Tim Peters f4331c1c38 vgetargskeywords(): remove test that can't succeed. Not a bugfix, just
removing useless obfuscation.
2001-10-27 00:17:34 +00:00
Tim Peters 9fda73cdd1 dict_constructor(): The last test was passing for the wrong reason (it
was intended to verify that sub-sequences of lengths 1 and 3 raise
ValueError, but was actually testing string lengths).
2001-10-26 20:57:38 +00:00
Andrew M. Kuchling cf31d5d5d0 Fill in remaining XXX spots
- Describe UnpackTuple()
        - Credit __unicode__ to MAL
Use \pep macro everywhere in body text.
   (Listening to "The Great Gate of Kiev" -- appropriately triumphal
    music for this check-in...)
2001-10-26 20:37:55 +00:00
Fred Drake e21e2bb121 Fix up a number of small problems with the DOM documentation.
There's still a lot to do, but it's better now.
2001-10-26 20:09:49 +00:00
Andrew M. Kuchling b83769cb82 Finish off the type/class section; I don't think there's much else
to be covered in an overview article like this.
2001-10-26 20:07:03 +00:00