Commit Graph

23879 Commits

Author SHA1 Message Date
Martin v. Löwis 8a8da798a5 Patch #505705: Remove eval in pickle and cPickle. 2002-08-14 07:46:28 +00:00
Skip Montanaro cffac66393 tightening up a few except: clauses
see bug 411881
2002-08-14 02:58:16 +00:00
Neal Norwitz 72cf6a8c07 Fix memory leaks reported by valgrind 2002-08-14 02:03:50 +00:00
Skip Montanaro 23b5918f68 add some example docstrings using PyDoc_STR 2002-08-14 01:45:37 +00:00
Skip Montanaro d9e7d24557 add PyDoc_STR and PyDoc_STRVAR calls as examples for module authors 2002-08-14 01:44:33 +00:00
Tim Peters 632a4fbd4d runtest(): I don't know why we don't just use TESTFN, but if we have to
do bizarre things to get a temp file, I changed it to use mkstemp instead
of NamedTemporaryFile.  This tried to leave the file open while passing
its name to execfile().  On Win2K (but not Win9X), though, a file created
with O_TEMPORARY cannot be opened again, so the test failed with a
permission error when execfile tried to open it.  Closer to the truth:
a file created with O_TEMPORARY can be opened again, but only if the
file is also created with SHARE_DELETE access via the Win32 CreateFile()
function.  There's no way to get at that from MS's version of libc, though
(we'd have to ditch the "std" C file functions in favor of Win32 API
calls).
2002-08-14 01:05:57 +00:00
Tim Peters d41bf34825 mkstemp(): Repaired error in docstring (the sense of the 'binary' flag
was reversed).
2002-08-14 00:49:50 +00:00
Tim Peters f69b3e9edc mkstemp(): The optional "binary" argument is clearly intended to be a
Boolean, so changed its default value from 1 to True.
2002-08-13 23:38:30 +00:00
Tim Peters c21ea74971 NamedTemporaryFile(), TemporaryFile(): removed needless local vrbl 'bin'. 2002-08-13 23:36:01 +00:00
Tim Peters bd7b4c7e46 template: removed special-casing for NT; there isn't an 8-character limit. 2002-08-13 23:33:56 +00:00
Tim Peters 1749b252c9 _once(): Removed obfuscating aliasing of _once_lock. 2002-08-13 23:31:02 +00:00
Tim Peters fd0f0c9f02 _once(): Simplified dict manipulation. 2002-08-13 23:29:21 +00:00
Neal Norwitz 200788ce45 Allow more docstrings to be removed during compilation in some modules 2002-08-13 22:20:41 +00:00
Neal Norwitz 5dc2a37f0f Allow more docstrings to be removed during compilation 2002-08-13 22:19:13 +00:00
Tim Peters 7f270ba860 Added a test specifically to tickle Karatsuba; it costs no appreciable
runtime.
2002-08-13 21:06:55 +00:00
Jeremy Hylton 22dae28c1a Add a missing call to _strclass(). 2002-08-13 20:43:46 +00:00
Tim Peters cba6e96929 Fixed error in new comment. 2002-08-13 20:42:00 +00:00
Tim Peters d6974a54ab k_mul(): The fix for (ah+al)*(bh+bl) spilling 1 bit beyond the allocated
space is no longer needed, so removed the code.  It was only possible when
a degenerate (ah->ob_size == 0) split happened, but after that fix went
in I added k_lopsided_mul(), which saves the body of k_mul() from seeing
a degenerate split.  So this removes code, and adds a honking long comment
block explaining why spilling out of bounds isn't possible anymore.  Note:
ff we end up spilling out of bounds anyway <wink>, an assert in v_iadd()
is certain to trigger.
2002-08-13 20:37:51 +00:00
Barry Warsaw 259b1e18b4 Regress Guido's change of 2002/08/06 to check for the zlib version
1.1.4.  Redhat hasn't upgraded but does provide a patched 1.1.3
package, so checking for 1.1.4 just makes life difficult.
2002-08-13 20:09:26 +00:00
Neal Norwitz d47714a727 Allow docstrings to be removed during compilation for *SLOT macro and friends 2002-08-13 19:01:38 +00:00
Guido van Rossum 8b056da6c8 Add tests for including __dict__ and/or __weakref__ in __slots__.
Add some more rigor to slotmultipleinheritance().
2002-08-13 18:26:26 +00:00
Neal Norwitz b0df6a1afa SF bug #574235, convert_path fails with empty pathname 2002-08-13 17:42:57 +00:00
Neal Norwitz 858e34f649 Allow docstrings to be removed during compilation 2002-08-13 17:18:45 +00:00
Neal Norwitz f9dd0f1924 Add test for SF bug # 575229, multiple inheritance w/ slots dumps core
Fix already checked in by Guido
2002-08-13 17:16:49 +00:00
Fred Drake a87a521b83 Remove ugly irregular spaces from in front of some comments. 2002-08-13 13:59:55 +00:00
Jason Tishler 83499db4f0 Bug #556025: list(xrange(1e9)) --> seg fault
Close the bug report again -- this time for Cygwin due to a newlib bug.
See the following for the details:

	http://sources.redhat.com/ml/newlib/2002/msg00369.html

Note that this commit is only a documentation (i.e., comment) change.
2002-08-13 11:42:41 +00:00
Guido van Rossum 4571e9d42a Add an improvement wrinkle to Neil Schemenauer's change to int_mul
(rev. 2.86).  The other type is only disqualified from sq_repeat when
it has the CHECKTYPES flag.  This means that for extension types that
only support "old-style" numeric ops, such as Zope 2's ExtensionClass,
sq_repeat still trumps nb_multiply.
2002-08-13 10:05:56 +00:00
Tim Peters d0876b859d test_division(): Added one larger digits value, to ensure that the
"lopsided Karatsuba" driver also gets some exercise.
2002-08-13 02:24:25 +00:00
Tim Peters 28b0e2a7f8 Machines-- and Python --are a lot faster in relevant ways since this
test was written.  So boosted the number of "digits" this generates, and
also beefed up the "* / divmod" test to tickle numbers big enough to
trigger the Karatsuba algorithm.  It takes about 2 seconds now on my box.
2002-08-13 02:17:11 +00:00
Guido van Rossum d8c8048f5e Fix comment for PyLong_AsUnsignedLong() to say that the return value
is an *unsigned* long.
2002-08-13 00:24:58 +00:00
Guido van Rossum 820819c7ca Fix wanrings about unsigned hex constants. 2002-08-12 22:11:28 +00:00
Tim Peters 1203403743 k_lopsided_mul(): This allocated more space for bslice than necessary. 2002-08-12 22:10:00 +00:00
Fred Drake 918af2aef7 The auto-reply text for the python-docs address. This is not automatically
updated when checkins are made, but I can get that updated when needed.
2002-08-12 22:01:42 +00:00
Tim Peters 6000464d08 Added new function k_lopsided_mul(), which is much more efficient than
k_mul() when inputs have vastly different sizes, and a little more
efficient when they're close to a factor of 2 out of whack.

I consider this done now, although I'll set up some more correctness
tests to run overnight.
2002-08-12 22:01:34 +00:00
Guido van Rossum 558fc977c5 Don't use hex constants representing negative numbers. 2002-08-12 22:01:24 +00:00
Guido van Rossum dc15c27f50 Suppress warnings about test_grammar.py that can't be suppressed inside
that file itself (because it's the parser that reports them).
2002-08-12 21:55:51 +00:00
Guido van Rossum 715eca932e Use PyErr_WarnExplicit() to warn about hex/oct constants, so the
correct filename and line number are reported.
2002-08-12 21:54:46 +00:00
Jack Jansen 7a1703d8cb Updated for the current state of affairs. 2002-08-12 20:46:18 +00:00
Guido van Rossum b9f1e9865d New names. 2002-08-12 20:20:39 +00:00
Guido van Rossum 611546005b Make sure that *any* object whose id() is used as a memo key is kept
alive in the memo.  This fixes SF bug 592567.
2002-08-12 20:20:08 +00:00
Tim Peters 547607c4bf k_mul(): Moved an assert down. In a debug build, interrupting a
multiply via Ctrl+C could cause a NULL-pointer dereference due to
the assert.
2002-08-12 19:43:49 +00:00
Tim Peters 70b041bbe7 k_mul(): Heh -- I checked in two fixes for the last problem. Only keep
the good one <wink>.  Also checked in a test-aid by mistake.
2002-08-12 19:38:01 +00:00
Tim Peters d8b2173ef9 k_mul(): White-box testing turned up that (ah+al)*(bh+bl) can, in rare
cases, overflow the allocated result object by 1 bit.  In such cases,
it would have been brought back into range if we subtracted al*bl and
ah*bh from it first, but I don't want to do that because it hurts cache
behavior.  Instead we just ignore the excess bit when it appears -- in
effect, this is forcing unsigned mod BASE**(asize + bsize) arithmetic
in a case where that doesn't happen all by itself.
2002-08-12 19:30:26 +00:00
Guido van Rossum 3747a0f04c Fix MSVC warnings. 2002-08-12 19:25:08 +00:00
Guido van Rossum ad47da072a Refactor how __dict__ and __weakref__ interact with __slots__.
1. You can now have __dict__ and/or __weakref__ in your __slots__
   (before only __weakref__ was supported).  This is treated
   differently than before: it merely sets a flag that the object
   should support the corresponding magic.

2. Dynamic types now always have descriptors __dict__ and __weakref__
   thrust upon them.  If the type in fact does not support one or the
   other, that descriptor's __get__ method will raise AttributeError.

3. (This is the reason for all this; it fixes SF bug 575229, reported
   by Cesar Douady.)  Given this code:
      class A(object): __slots__ = []
      class B(object): pass
      class C(A, B): __slots__ = []
   the class object for C was broken; its size was less than that of
   B, and some descriptors on B could cause a segfault.  C now
   correctly inherits __weakrefs__ and __dict__ from B, even though A
   is the "primary" base (C.__base__ is A).

4. Some code cleanup, and a few comments added.
2002-08-12 19:05:44 +00:00
Tim Peters 115c888b97 x_mul(): Made life easier for C optimizers in the "grade school"
algorithm.  MSVC 6 wasn't impressed <wink>.

Something odd:  the x_mul algorithm appears to get substantially worse
than quadratic time as the inputs grow larger:

bits in each input   x_mul time   k_mul time
------------------   ----------   ----------
             15360         0.01         0.00
             30720         0.04         0.01
             61440         0.16         0.04
            122880         0.64         0.14
            245760         2.56         0.40
            491520        10.76         1.23
            983040        71.28         3.69
           1966080       459.31        11.07

That is, x_mul is perfectly quadratic-time until a little burp at
2.56->10.76, and after that goes to hell in a hurry.  Under Karatsuba,
doubling the input size "should take" 3 times longer instead of 4, and
that remains the case throughout this range.  I conclude that my "be nice
to the cache" reworkings of k_mul() are paying.
2002-08-12 18:25:43 +00:00
Tim Peters d64c1def7c k_mul() and long_mul(): I'm confident that the Karatsuba algorithm is
correct now, so added some final comments, did some cleanup, and enabled
it for all long-int multiplies.  The KARAT envar no longer matters,
although I left some #if 0'ed code in there for my own use (temporary).
k_mul() is still much slower than x_mul() if the inputs have very
differenent sizes, and that still needs to be addressed.
2002-08-12 17:36:03 +00:00
Guido van Rossum a6fa0e6f2e Portable way of producing unsigned 32-bit hex output to print the
CRCs.
2002-08-12 15:26:05 +00:00
Guido van Rossum baf29638da Shut up warnings about hex()/oct() that can't be avoided. 2002-08-12 15:16:20 +00:00
Guido van Rossum 1ae4c3d0d8 Avoid warnings about <<. external_attr is now an unsigned long. 2002-08-12 15:15:51 +00:00