Commit Graph

38575 Commits

Author SHA1 Message Date
Georg Brandl 27cca3cca7 Fix function name. 2008-02-17 15:14:10 +00:00
Georg Brandl 5e203f56db #2131: note that codecs.open() always opens files in binary mode. 2008-02-17 11:33:38 +00:00
Brett Cannon f9db8a3a20 Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
2008-02-17 01:59:18 +00:00
Amaury Forgeot d'Arc 632fad3933 Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
2008-02-16 20:55:24 +00:00
Amaury Forgeot d'Arc 588ff93f13 Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.

In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.

I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?

Example:

class SpecialStr(str):
    def __del__(self):
        s.close()

import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
2008-02-16 14:34:57 +00:00
Georg Brandl 943321d586 #2120: broken links in advocacy document. 2008-02-16 09:37:32 +00:00
Raymond Hettinger 71fa93af22 Add __all__ to logging module. 2008-02-16 01:22:54 +00:00
Amaury Forgeot d'Arc 64d6843788 mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
2008-02-16 00:16:50 +00:00
Amaury Forgeot d'Arc d8bcbf2b2e Re-enable tests, they were failing since gc.collect() clears the various freelists.
They still remain fragile.

For example, a call to assertEqual currently does not make any allocation
(which surprised me at first).
But this can change when gc.collect also deletes the numerous "zombie frames"
attached to each function.
2008-02-15 22:44:20 +00:00
Kurt B. Kaiser f05fa33a6c Configured selection highlighting colors were ignored; updating highlighting
in the config dialog would cause non-Python files to be colored as if they
were Python source; improve use of ColorDelagator.  Patch 1334. Tal Einat.
2008-02-15 22:25:09 +00:00
Kurt B. Kaiser e312cfddd3 ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat. 2008-02-15 21:56:36 +00:00
Amaury Forgeot d'Arc f67abccf64 Temporarily let these tests pass 2008-02-15 21:27:44 +00:00
Amaury Forgeot d'Arc 60d6c7f0cc Issue #2115: __slot__ attributes setting was 10x slower.
Also correct a possible crash using ABCs.

This change is exactly the same as an optimisation
done 5 years ago, but on slot *access*:
http://svn.python.org/view?view=rev&rev=28297
2008-02-15 21:22:45 +00:00
Raymond Hettinger e9b9b35931 Update example to match the current syntax. 2008-02-15 21:21:25 +00:00
Skip Montanaro 04735179f0 Two new functions:
* place_summary_first copies the regrtest summary to the front of the file
    making it easier to scan quickly for problems.

  * count_failures gets the actual count of the number of failing tests, not
    just a 1 (some failures) or 0 (no failures).
2008-02-15 19:03:59 +00:00
Eric Smith 3f91437e5f In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long. 2008-02-15 12:14:32 +00:00
Christian Heimes 7adfad850a Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ
Thanks to Thomas Herve for the fix.
2008-02-15 08:20:11 +00:00
Christian Heimes 2f0da53d28 Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them. 2008-02-15 06:57:08 +00:00
Christian Heimes e247f0037f Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115 2008-02-14 22:40:11 +00:00
Thomas Heller e7fb0c5114 Try to correct a markup error that does hide the following paragraph. 2008-02-14 21:00:28 +00:00
Raymond Hettinger 36316e37d5 No need to register subclass of ABCs. 2008-02-14 19:30:30 +00:00
Raymond Hettinger 5111c522e7 Fix markup 2008-02-14 19:02:39 +00:00
Raymond Hettinger 0cd717007d Simplify moneyfmt() recipe. 2008-02-14 12:49:37 +00:00
Christian Heimes 3b718a79af Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation. 2008-02-14 12:47:33 +00:00
Raymond Hettinger 50361d4d9b Fix markup. 2008-02-14 12:05:42 +00:00
Raymond Hettinger d68bf02810 Show how to remove exponents. 2008-02-14 11:57:25 +00:00
Raymond Hettinger 27a90d989d Improve rst markup 2008-02-14 11:01:10 +00:00
Raymond Hettinger 4631481dfd Add fixed-point examples to the decimal FAQ 2008-02-14 10:46:57 +00:00
Raymond Hettinger 1b5632445b Add diagnostic message to help figure-out why SocketServer tests occasionally crash
when trying to remove a pid that in not in the activechildren list.
2008-02-14 09:32:45 +00:00
Jeffrey Yasskin 339f5e3ffc Change simple instances (in Fraction) of self.numerator and self.denominator to
self._numerator and self._denominator. This speeds abs() up from 12.2us to
10.8us and trunc() from 2.07us to 1.11us. This doesn't change _add and friends
because they're more complicated.
2008-02-14 07:49:25 +00:00
Jeffrey Yasskin 1c214d6c94 Performance optimizations on Fraction's constructor.
./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3)`
31.7 usec/loop -> 9.2 usec/loop

  ./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3, 2)'`
27.7 usec/loop -> 9.32 usec/loop

  ./python.exe -m timeit -s 'from fractions import Fraction; f = Fraction(3, 2)' 'Fraction(f)'
31.9 usec/loop -> 14.3 usec/loop
2008-02-14 06:12:24 +00:00
Raymond Hettinger abe3237187 Fix decimal repr which should have used single quotes like other reprs. 2008-02-14 02:41:22 +00:00
Raymond Hettinger ddb164a651 Update notes on Decimal. 2008-02-14 01:08:02 +00:00
Kurt B. Kaiser ac45aff2f1 Bring NEWS.txt up to date from check-in msgs. 2008-02-14 00:08:55 +00:00
Thomas Heller 4516451aec Make the test somewhat clearer (I hope). 2008-02-13 20:36:51 +00:00
Thomas Heller a06a1a88ee Add pickle support to ctypes types. 2008-02-13 20:21:53 +00:00
Brett Cannon 91a1dec492 Fix --enable-universalsdk and its comment line so that zsh's flag completion
works.

Thanks to Jeroen Ruigrok van der Werven for the fix.
2008-02-13 19:15:44 +00:00
Jeffrey Yasskin 57bd60b465 Working on issue #1762: Brought
./python.exe -m timeit -s 'from fractions import Fraction; f = Fraction(3, 2)' 'isinstance(3, Fraction); isinstance(f, Fraction)'
from 12.3 usec/loop to 3.44 usec/loop and
  ./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3, 2)'
from 48.8 usec to 23.6 usec by avoiding genexps and sets in __instancecheck__
and inlining the common case from __subclasscheck__.
2008-02-13 17:58:04 +00:00
Georg Brandl 0a40ffb1b3 #2063: correct order of utime and stime in os.times()
result on Windows.
2008-02-13 07:20:22 +00:00
Mark Dickinson 5f8bd3729e Replace R=fractions.Fraction with F=fractions.Fraction in
test_fractions.py.  This should have been part of the name
change from Rational to Fraction.
2008-02-12 21:46:54 +00:00
Mark Dickinson 0aa52a1658 Revert change in r60712: turn alternate constructors back into
classmethods instead of staticmethods.
2008-02-12 21:40:53 +00:00
Mark Dickinson e1b824793a Implementation of Fraction.limit_denominator.
Remove Fraction.to_continued_fraction and
Fraction.from_continued_fraction
2008-02-12 21:31:59 +00:00
Raymond Hettinger a37430a0ce dict.copy() rises from the ashes. Revert r60687. 2008-02-12 19:05:36 +00:00
Martin v. Löwis dad88dc159 Patch #1966: Break infinite loop in httplib when the servers
implements the chunked encoding incorrectly.
Will backport to 2.5.
2008-02-12 18:47:34 +00:00
Kurt B. Kaiser 8d365c323f what??! Correct r60225. 2008-02-12 15:45:50 +00:00
Martin v. Löwis e0d30ef0ca Patch #1736: Fix file name handling of _msi.FCICreate. 2008-02-12 13:47:26 +00:00
Raymond Hettinger 116f72fa5c Bring decimal a bit closer to the spec for Reals. 2008-02-12 01:18:03 +00:00
Raymond Hettinger 19a5c29d27 Fix typo in comments 2008-02-12 00:48:20 +00:00
Raymond Hettinger 596fdd0fd3 Restore fractions.rst to the document tree. 2008-02-12 00:15:32 +00:00
Raymond Hettinger bc4ffc17df Backport ABC docs 2008-02-11 23:38:00 +00:00