Ka-Ping Yee [Mon, 15 Jan 2001 22:14:16 +0000 (22:14 +0000)]
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.
Barry Warsaw [Mon, 15 Jan 2001 20:40:19 +0000 (20:40 +0000)]
Committing PEP 232, function attribute feature, approved by Guido.
Closes SF patch #103123.
funcobject.h:
PyFunctionObject: add the func_dict slot.
funcobject.c:
PyFunction_New(): Initialize the func_dict slot to NULL.
func_getattr(): Rename to func_getattro() and change the
signature. It's more efficient to use attro methods and dig the C
string out than it is to re-convert a C string to a PyString.
Also, add support for getting the __dict__ (a.k.a. func_dict)
attribute, and for getting an arbitrary function attribute.
func_setattr(): Rename to func_setattro() and change the signature
for the same reason. Also add support for setting __dict__
(a.k.a. func_dict) and any arbitrary function attribute.
func_dealloc(): Be sure to DECREF the func_dict slot.
func_traverse(): Be sure to traverse func_dict too.
PyFunction_Type: make the necessary func_?etattro() changes.
classobject.c:
instancemethod_memberlist: Add __dict__
instancemethod_setattro(): New method to set arbitrary attributes
on methods (really the underlying im_func). Raise TypeError when
the instance is bound or when you're trying to set one of the
reserved im_* attributes.
instancemethod_getattr(): Renamed to instancemethod_getattro()
since that's what it really is. Also, added support fo getting
arbitrary attributes through the im_func.
Barry Warsaw [Mon, 15 Jan 2001 20:28:50 +0000 (20:28 +0000)]
Document function attributes for both the function type and the method
type. The method documentation also includes a new brief discussion
of `bound' vs. `unbound' and why setting an attr on a bound method is
a TypeError. Includes Skip's suggested text.
Guido van Rossum [Mon, 15 Jan 2001 18:58:56 +0000 (18:58 +0000)]
SF patch #103158 by Greg Ball: Don't do unsafe arithmetic in xrange
object.
This fixes potential overflows in xrange()'s internal calculations on
64-bit platforms. The fix is complicated because the sq_length slot
function can only return an int; we want to support
xrange(sys.maxint), which is a 64-bit quantity on most 64-bit
platforms (except Win64). The solution is hacky but the best
possible: when the range is that long, we can use it in a for loop but
we can't ask for its length (nor can we actually iterate beyond
2**31-1, because the sq_item slot function has the same restrictions
on its arguments. Fixing those restrictions is a project for another
day...
Barry Warsaw [Mon, 15 Jan 2001 17:07:21 +0000 (17:07 +0000)]
Committing patch #103216, autodetect of dbmmodule support and building
of dbmmodule dynamically by default (otherwise it can pull in
dependencies with libdb that croak pybsddb3). This change moves the
Setup line for dbmmodule to Setup.config.in.
Guido van Rossum [Mon, 15 Jan 2001 16:53:58 +0000 (16:53 +0000)]
Geoffrey Gerrietts discovered that a KeyError was caught that probably
should have been a NameError. I'm checking in a change that catches
both, just to be sure -- I can't be bothered trying to understand this
code any more. :-)
Guido van Rossum [Mon, 15 Jan 2001 16:32:49 +0000 (16:32 +0000)]
Default to passive mode. See SF bug #126851.
This is slightly controversial, but after reading the argumentation in
the bug tracker for and against, I believe this is the right solution.
Let me know if it breaks for you, and how.
Fix from Jack Jansen for the Mac and the Metrowerks compiler, posted
to the Distutils-SIG and archived at
http://mail.python.org/pipermail/distutils-sig/2000-November/001755.html
Tim Peters [Mon, 15 Jan 2001 10:36:56 +0000 (10:36 +0000)]
Speed getline_via_fgets(), by supplying two "fast paths", although one is
faster than the other. Should be faster for Mark Favas's 254-character
mail log lines, and *is* 3-4% quicker for my test case with much shorter
lines (but they're typical of *my* text files, and I'm tired of optimizing
for everyone else at my expense <wink> -- in fact, the only one who loses
here is Guido ...).
Guido van Rossum [Sun, 14 Jan 2001 23:21:25 +0000 (23:21 +0000)]
- Use mimetypes.types_map to initialize extensions_map.
- Change the default file type to application/octet-stream.
- Add support to recognize .py, .c, .h files as text/plain (this is
what I use most :-).
Guido van Rossum [Sun, 14 Jan 2001 21:03:01 +0000 (21:03 +0000)]
SF Patch #103232 by dougfort: Preserve Nonstandard Port Number in Host
Header
Dougfort's comments: httplib does not include ':port ' in the HTTP 1.1
'Host:' header. This causes problems if the server is not listening
on Port 80. The test case I use is the login to /manage under Zope,
with Zope listening on port 8080. Zope returns a <frameset> with the
<frame> source URLs lacking the :8080.
Fredrik Lundh [Sun, 14 Jan 2001 15:06:11 +0000 (15:06 +0000)]
SRE fixes for 2.1 alpha:
-- added some more docstrings
-- fixed typo in scanner class (#125531)
-- the multiline flag (?m) should't affect the \Z operator (#127259)
-- fixed non-greedy backtracking bug (#123769, #127259)
-- added sre.DEBUG flag (currently dumps the parsed pattern structure)
-- fixed a couple of glitches in groupdict (the #126587 memory leak
had already been fixed by AMK)
Guido van Rossum [Sun, 14 Jan 2001 14:08:40 +0000 (14:08 +0000)]
- Added keyword argument 'append' to filterwarnings(); if true, this
appends to list of filters instead of inserting at the front. This
is useful to add a filter with a lower priority than -W options.
- Cosmetic improvements to a docstring and an error message.
Guido van Rossum [Sat, 13 Jan 2001 22:06:05 +0000 (22:06 +0000)]
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.)
Guido van Rossum [Sat, 13 Jan 2001 16:55:33 +0000 (16:55 +0000)]
SF Patch #103225 by Ping: httplib: smallest Python patch ever
The ASCII-art diagram at the top of httplib contains a backslash at
the end of a line, which causes Python to remove the newline. This
one-character patch adds a space after the backslash so it will
appear at the end of the line in the docstring as intended.
Tim Peters [Sat, 13 Jan 2001 03:04:02 +0000 (03:04 +0000)]
Guido found a brand new race in tempfile on Linux, due to Linux changing
pid across threads (but in that case, it's still the same process, and so
still sharing the "template" cache in tempfile.py). Repaired that, and
added a new std test.
On Linux, someone please run that standalone with more files and/or more
threads; e.g.,
Jack Jansen [Fri, 12 Jan 2001 23:39:00 +0000 (23:39 +0000)]
SetpopupData and GetPopupData are gone under Carbon, use {Get,Set}PopupMenu{Handle,ID} in stead.
The UserPane routines appear to be fixed in the current Universal Headers, so they're re-enabled.
Guido van Rossum [Fri, 12 Jan 2001 16:24:03 +0000 (16:24 +0000)]
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.
Tim Peters [Fri, 12 Jan 2001 10:02:46 +0000 (10:02 +0000)]
A variant of SF patch 103028 (Make tempfile.mktemp threadsafe).
Tested on Windows. Should be tested on Linux. Should also be
tested on some platform without threads (I simulated that by
making the "import thread" fail, but that's not the same as
actually doing it!).
Thomas Wouters [Thu, 11 Jan 2001 14:46:40 +0000 (14:46 +0000)]
Move the _socket module closer to the SSL-_socket line (mmap and
xreadlines inserted themselves inbetween the two) and clarify that the
normal socket module should be commented out. (Someone also suggested the
latter on c.l.py some time ago, I forget who, sorry.)
Guido van Rossum [Wed, 10 Jan 2001 21:17:27 +0000 (21:17 +0000)]
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?