Commit Graph

20018 Commits

Author SHA1 Message Date
Jeremy Hylton c785f4841c Supply code objects a new-style tp_members slot and tp_getattr impl.
The chief effects are to make dir() do something useful and supply
them with an __class__.
2001-09-14 20:08:07 +00:00
Guido van Rossum a8c60f478c tp_new_wrapper(): A subtle change in the check for safe use.
Allow staticbase != type, as long as their tp_new slots are the same.
2001-09-14 19:43:36 +00:00
Guido van Rossum f21c6be7bd Add call_maybe(): a variant of call_method() that returns
NotImplemented when the lookup fails, and use this for binary
operators.  Also lookup_maybe() which doesn't raise an exception when
the lookup fails (still returning NULL).
2001-09-14 17:51:50 +00:00
Fred Drake f2a5f3f721 Markup adjustments for consistency. 2001-09-14 17:48:41 +00:00
Guido van Rossum 717ce00c7c call_method():
- Don't turn a non-tuple argument into a one-tuple.  Rather, the
  caller must pass a format that causes Py_VaBuildValue() to return a
  tuple.

- Speed things up by calling PyObject_Call (which is fairly low-level
  and straightforward) rather than PyObject_CallObject (which calls
  PyEval_CallObjectWithKeywords which calls PyObject_Call, and nothing
  is really done in the mean time except some tests for NULL args and
  valid types, which are already guaranteed).

- Cosmetics.

Other places:

- Make sure that the format argument to call_method() is surrounded by
  parentheses, so it will cause a tuple to be created.

- Replace a few calls to PyEval_CallObject() with a surefire tuple for
  args to calls to PyObject_Call().  (A few calls to
  PyEval_CallObject() remain that have NULL for args.)
2001-09-14 16:58:08 +00:00
Guido van Rossum 5560b7492c PyObject_CallObject(): this may as well call PyEval_CallObject()
directly, as the only thing done here (replace NULL args with an empty
tuple) is also done there.

XXX Maybe we should take one step further and equate the two at the
macro level?  That's harder though because PyEval_Call* is declared in
a header that's not included standard.  But it is silly that
PyObject_CallObject calls PyEval_CallObject which calls back to
PyObject_Call.  Maybe PyEval_CallObject should be moved into this file
instead?  All I know is that there are too many call APIs!  The
differences between PyObject_Call and PyEval_CallObjectWithKeywords is
that the latter allows args to be NULL, and does explicit type checks
for args and kwds.
2001-09-14 16:47:50 +00:00
Guido van Rossum d8185ca43e Mention SMTP additions and hmac module. 2001-09-14 16:35:16 +00:00
Andrew M. Kuchling 1efd7ad88e Add support for SMTP TLS 2001-09-14 16:19:27 +00:00
Guido van Rossum f7fcf5eea6 SF patch #461413 (Gerhard Häring): Add STARTTLS feature to smtplib
This patch adds the features from RFC 2487 (Secure SMTP
   over TLS) to the smtplib module:

   - A starttls() function
   - Wrapper classes that simulate enough of sockets and
     files for smtplib, but really wrap a SSLObject
   - reset the list of known SMTP extensions at each call
     of ehlo(). This should have been the case anyway.
2001-09-14 16:08:44 +00:00
Guido van Rossum 5f5512d246 _PyObject_Dump(): print the type of the object. This is by far the
most frequently interesting information IMO.  Also tidy up the output.
2001-09-14 15:50:08 +00:00
Tim Peters 4441001b56 The end of [#460467] file objects should be subclassable.
A surprising number of changes to split tp_new into tp_new and tp_init.
Turned out the older PyFile_FromFile() didn't initialize the memory it
allocated in all (error) cases, which caused new sanity asserts
elsewhere to fail left & right (and could have, e.g., caused file_dealloc
to try decrefing random addresses).
2001-09-14 03:26:08 +00:00
Tim Peters 0ab085c4cb Changed the dict implementation to take "string shortcuts" only when
keys are true strings -- no subclasses need apply.  This may be debatable.

The problem is that a str subclass may very well want to override __eq__
and/or __hash__ (see the new example of case-insensitive strings in
test_descr), but go-fast shortcuts for strings are ubiquitous in our dicts
(and subclass overrides aren't even looked for then).  Another go-fast
reason for the change is that PyCheck_StringExact() is a quicker test
than PyCheck_String(), and we make such a test on virtually every access
to every dict.

OTOH, a str subclass may also be perfectly happy using the base str eq
and hash, and this change slows them a lot.  But those cases are still
hypothetical, while Python's own reliance on true-string dicts is not.
2001-09-14 00:25:33 +00:00
Tim Peters 742dfd6f17 Get rid of builtin_open() entirely (the C code and docstring, not the
builtin function); Guido pointed out that it could be just another
name in the __builtin__ dict for the file constructor now.
2001-09-13 21:49:44 +00:00
Tim Peters 4b7625ee83 _PyBuiltin_Init(): For clarity, macroize this purely repetitive code. 2001-09-13 21:37:17 +00:00
Tim Peters 8fa45677c1 Now that file objects are subclassable, you can get at the file constructor
just by doing type(f) where f is any file object.  This left a hole in
restricted execution mode that rexec.py can't plug by itself (although it
can plug part of it; the rest is plugged in fileobject.c now).
2001-09-13 21:01:29 +00:00
Tim Peters 561f899d19 Use the keyword form of file() instead of open() to create TESTFN. 2001-09-13 19:36:36 +00:00
Tim Peters 808b94eb45 Added simple tests of keyword arguments in the basic type constructors. 2001-09-13 19:33:07 +00:00
Tim Peters 3f996e7266 type_call(): Change in policy. The keyword args (if any) are now passed
on to the tp_new slot (if non-NULL), as well as to the tp_init slot (if
any).  A sane type implementing both tp_new and tp_init should probably
pay attention to the arguments in only one of them.
2001-09-13 19:18:27 +00:00
Skip Montanaro bafedecc06 based upon a suggestion in c.l.py, this slight expansion of the
OverflowError message seems reasonable.
2001-09-13 19:05:30 +00:00
Fred Drake b9a96282f1 Admit that we'll never add the args for a "call" event to the profile
and trace functions; this now declares that None will be passed for the
"call" event.
This closes SF bug/suggestion #460315.
2001-09-13 16:56:43 +00:00
Greg Ward 02fac83ba1 Comment tweak: point to Robin Dunn's pybsddb project on SourceForge. 2001-09-13 15:05:08 +00:00
Tim Peters 59c9a645e2 SF bug [#460467] file objects should be subclassable.
Preliminary support.  What's here works, but needs fine-tuning.
2001-09-13 05:38:56 +00:00
Guido van Rossum 93a696f491 SF bug #461073: mailbox __iter__ bug, by Andrew Dalke.
Andrew quite correctly notices that the next() method isn't quite what
we need, since it returns None upon end instead of raising
StopIteration.  His fix is easy enough, using iter(self.next, None)
instead.
2001-09-13 01:29:13 +00:00
Tim Peters 1f47d11ff2 Added items about significant subclass bugfixes. 2001-09-12 23:40:29 +00:00
Tim Peters 4f467e8057 Added subclass equality tests. Almost all of these are commented out now,
because they don't work yet.
2001-09-12 19:53:15 +00:00
Guido van Rossum 7851eea5f2 build_class(): one more (hopefully the last) step on the way to
backwards compatibility.  When using the class of the first base as
the metaclass, use its __class__ attribute in preference over its
ob_type slot.  This ensures that we can still use classic classes as
metaclasse, as shown in the original "Metaclasses" essay.  This also
makes all the examples in Demo/metaclasses/ work again (maybe these
should be turned into a test suite?).
2001-09-12 19:19:18 +00:00
Tim Peters 2400fa4ad1 Again perhaps the end of [#460020] bug or feature: unicode() and subclasses.
Inhibited complex unary plus optimization when applied to a complex subtype.
Added PyComplex_CheckExact macro.  Some comments and minor code fiddling.
2001-09-12 19:12:49 +00:00
Guido van Rossum 1140cb2b9e When MAKEFLAGS contains '-s', invoke setup.py with '-q', to silence
its normally chatty nature.

(This completes a side project to make "make -s" truly silent unless
errors occur.)
2001-09-12 18:59:25 +00:00
Tim Peters 111f60964e If interning an instance of a string subclass, intern a real string object
with the same value instead.  This ensures that a string (or string
subclass) object's ob_sinterned pointer is always a str (or NULL), and
that the dict of interned strings only has strs as keys.
2001-09-12 07:54:51 +00:00
Tim Peters af90b3e610 str_subtype_new, unicode_subtype_new:
+ These were leaving the hash fields at 0, which all string and unicode
  routines believe is a legitimate hash code.  As a result, hash() applied
  to str and unicode subclass instances always returned 0, which in turn
  confused dict operations, etc.
+ Changed local names "new"; no point to antagonizing C++ compilers.
2001-09-12 05:18:58 +00:00
Tim Peters 7a29bd5861 More on bug 460020: disable many optimizations of unicode subclasses. 2001-09-12 03:03:31 +00:00
Tim Peters 8fa5dd0601 More bug 460020: lots of string optimizations inhibited for string
subclasses, all "the usual" ones (slicing etc), plus replace, translate,
ljust, rjust, center and strip.  I don't know how to be sure they've all
been caught.

Question:  Should we complain if someone tries to intern an instance of
a string subclass?  I hate to slow any code on those paths.
2001-09-12 02:18:30 +00:00
Fred Drake ee0fe0b743 Add missing "}". 2001-09-12 00:43:13 +00:00
Tim Peters 40c397dd56 long_invert(): tiny speed and space optimization. 2001-09-11 23:24:22 +00:00
Tim Peters 9a9471ca1c Add info about Windows filesystem limits. 2001-09-11 23:18:51 +00:00
Tim Peters 69c2de3ad6 More bug 460020. Disable a number of long optimizations for long subclasses. 2001-09-11 22:31:33 +00:00
Tim Peters 0280cf79a7 More bug 460020: when F is a subclass of float, disable the unary plus
optimization (+F(whatever)).
2001-09-11 21:53:35 +00:00
Tim Peters 73a1dfe367 More bug 460020. When I is a subclass of int, disable the +I(whatever),
I(0) << whatever, I(0) >> whatever, I(whatever) << 0 and I(whatever) >> 0
optimizations.
2001-09-11 21:44:14 +00:00
Jack Jansen 95fefc7a7a These modules now live under the Carbon package.
Added a few new toolbox modules.
Noted machine dependencies for some modules.
Moved waste to undoc.tex.
2001-09-11 21:25:10 +00:00
Jack Jansen 945bf5f627 Added applesingle, macresource, Nav and videoreader.
Moved icopen to its alphabetical place.
Moved waste here (from toolbox).
2001-09-11 21:24:07 +00:00
Jack Jansen 827713a660 Added a note that these are not available under Carbon (or
OSX MachO Python).
2001-09-11 20:18:04 +00:00
Fred Drake 85ddfbc4cb Another documentation contributor. 2001-09-11 19:58:51 +00:00
Fred Drake 098d7fae39 Document clearly that the only way to retrieve the return code from the
child processes is to use the Popen3 and Popen4 classes.
This fixes SF bug #460512.
2001-09-11 19:56:51 +00:00
Tim Peters 7b07a41e9f The endless 460020 bug.
Disable t[:], t*0, t*1 optimizations when t is of a tuple subclass type.
2001-09-11 19:48:03 +00:00
Jack Jansen f0b0f680fe Added Donovan Preston. 2001-09-11 19:12:02 +00:00
Fred Drake 1c66f8965a Added entry for the hmac module. 2001-09-11 16:59:42 +00:00
Fred Drake aae8da18fd Documentation for the new login() method of the smtplib.SMTP class,
contributed by Gerhard Häring.
This is part of SF patch #460112.
2001-09-11 16:58:00 +00:00
Fred Drake 42706803cd Documentation for the new hmac module, contributed by Gerhard Häring.
This is part of SF patch #460112.
2001-09-11 16:56:09 +00:00
Guido van Rossum 25dfe2c095 Silence parser generator output. 2001-09-11 16:43:16 +00:00
Fred Drake 2732cb4269 Added documentation on the getfirst() and getlist() methods of the
cgi.FieldStorage class.
This closes SF patch #453691.
2001-09-11 16:27:03 +00:00