Commit Graph

12450 Commits

Author SHA1 Message Date
Thomas Heller 0f75f9847a Use 'g' instead of 'D' as the ctypes typecode for c_longdouble, for
compliance with PEP 3118.
2008-01-16 20:34:37 +00:00
Thomas Heller 415c1e36a9 Raise a TypeError instead of a ValueError when too many initializers
are used in a Structure or Union constructor.
2008-01-16 19:45:51 +00:00
Thomas Heller 02ec289f3e Raise a TypeError if conflicting positional and named arguments are
passed to a Structure or Union constructor.
2008-01-16 19:37:33 +00:00
Thomas Heller 902d30752f Convert the internal ctypes array type cache to a WeakValueDict so
that array types do not live longer than needed.
2008-01-16 19:16:27 +00:00
Andrew M. Kuchling c8acc882a9 Docstring typos 2008-01-16 00:32:03 +00:00
Amaury Forgeot d'Arc ff0f2670ff test_doctest fails since r59984.
Not sure if these are the correct values, but save_stdout has to be set before its usage...
2008-01-15 21:25:11 +00:00
Raymond Hettinger f59e962b49 Refactor if/elif chain for clarity and speed. Remove dependency on subclasses having to implement _empty and _full. 2008-01-15 20:52:42 +00:00
Guido van Rossum cad3724352 Issue #1786 (by myself): pdb should use its own stdin/stdout around an
exec call and when creating a recursive instance.
2008-01-15 17:59:29 +00:00
Jeffrey Yasskin d7b00334f3 Add rational.Rational as an implementation of numbers.Rational with infinite
precision. This has been discussed at http://bugs.python.org/issue1682. It's
useful primarily for teaching, but it also demonstrates how to implement a
member of the numeric tower, including fallbacks for mixed-mode arithmetic.

I expect to write a couple more patches in this area:
 * Rational.from_decimal()
 * Rational.trim/approximate() (maybe with different names)
 * Maybe remove the parentheses from Rational.__str__()
 * Maybe rename one of the Rational classes
 * Maybe make Rational('3/2') work.
2008-01-15 07:46:24 +00:00
Raymond Hettinger cbf8f6cffb Temporarily revert 59967 until GC can be added. 2008-01-15 05:39:59 +00:00
Raymond Hettinger c216df9288 Issue 1820: structseq objects did not work with the % formatting operator or isinstance(t, tuple).
Orignal patch (without tests) by Leif Walsh.
2008-01-15 03:02:37 +00:00
Andrew M. Kuchling 7ce9b18460 Typo fixes 2008-01-15 01:29:16 +00:00
Raymond Hettinger 351e1a3e88 Fix 1698398: Zipfile.printdir() crashed because the format string expected a tuple object of length six instead of a time.struct_time object. 2008-01-14 22:58:05 +00:00
Christian Heimes c94e2b5c12 Now that I've learnt about structseq objects I felt like converting sys.float_info to a structseq. It's
readonly and help(sys.float_info) explains the attributes nicely.
2008-01-14 04:13:37 +00:00
Christian Heimes f31b69f9db Applied patch #1816: sys.flags patch 2008-01-14 03:42:48 +00:00
Christian Heimes 9c2019632b Added new an better structseq representation. E.g. repr(time.gmtime(0)) now returns 'time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)' instead of '(1970, 1, 1, 0, 0, 0, 3, 1, 0)'. The feature is part of #1816: sys.flags 2008-01-14 03:33:52 +00:00
Ka-Ping Yee 9e0f116fac Check in the patch proposed by Ben Hayden (benjhayden) for issue
#1550: help('modules') broken by several 3rd party libraries.

Tested with Python build: trunk:54235:59936M -- the reported error
occurs with Django installed (or with any __init__.py present on
the path that raises an exception), and such errors indeed go away
when this change is applied.
2008-01-13 11:25:13 +00:00
Mark Dickinson 59bc20bb27 Issue 1780: Allow leading and trailing whitespace in Decimal constructor,
when constructing from a string. Disallow trailing newlines in
Context.create_decimal.
2008-01-12 01:56:00 +00:00
Thomas Heller c682614df0 Raise an error instead of crashing with a segfault when a NULL
function pointer is called.

Will backport to release25-maint.
2008-01-11 19:34:06 +00:00
Raymond Hettinger 0f6a656ec1 Speed-up and simplify code urlparse's result objects. 2008-01-11 18:04:55 +00:00
Raymond Hettinger 0ff4dafee0 Improve usability of the SequenceMatcher by returning named tuples describing match ranges. 2008-01-11 03:20:54 +00:00
Raymond Hettinger e896acc98c Let most inspect functions return named tuples 2008-01-11 03:04:50 +00:00
Raymond Hettinger 097a190303 Have Decimal.as_tuple return a named tuple. 2008-01-11 02:24:13 +00:00
Raymond Hettinger fff4e6e171 Doctest results return a named tuple for readability 2008-01-11 01:25:54 +00:00
Raymond Hettinger d1ef85420f Run doctests on the collections module 2008-01-11 00:23:13 +00:00
Raymond Hettinger 15b5e55b48 Neaten-up the named tuple docs 2008-01-10 23:00:01 +00:00
Amaury Forgeot d'Arc d08a8ebf2a Closing issue1761.
Surprising behaviour of the "$" regexp: it matches the
end of the string, AND just before the newline at the end
of the string::

    re.sub('$', '#', 'foo\n') == 'foo#\n#'

Python is consistent with Perl and the pcre library, so
we just document it.
Guido prefers "\Z" to match only the end of the string.
2008-01-10 21:59:42 +00:00
Raymond Hettinger e850c466c7 Clarify how to add a field to a named tuple. 2008-01-10 20:37:12 +00:00
Raymond Hettinger e1655088ca Examples for named tuple subclassing should include __slots__ 2008-01-10 19:15:10 +00:00
Christian Heimes 3403f1589d Fixed #1776. __import__() no longer imports modules by file name 2008-01-09 19:56:33 +00:00
Christian Heimes b39a756afd Added __enter__ and __exit__ functions to HKEY object
Added ExpandEnvironmentStrings to the _winreg module.
2008-01-08 15:46:10 +00:00
Andrew M. Kuchling e0a49b6e05 Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects 2008-01-08 14:30:55 +00:00
Facundo Batista 52b25795c0 Issue #1757: The hash of a Decimal instance is no longer affected
by the current context.  Thanks Mark Dickinson.
2008-01-08 12:25:20 +00:00
Christian Heimes f66f95d419 It's verbose, not debug 2008-01-08 03:40:04 +00:00
Raymond Hettinger 581671419f Expand comment. 2008-01-08 02:02:05 +00:00
Raymond Hettinger f5e8af1bb7 Use get() instead of pop() for the optimized version of _replace(). 2008-01-07 20:56:05 +00:00
Raymond Hettinger 9a359210aa Cleanup named tuple subclassing example. 2008-01-07 20:07:38 +00:00
Christian Heimes 4d7e6702e9 Fixed indention problem that caused the second TIPC test to run on systems without TIPC 2008-01-07 19:58:41 +00:00
Georg Brandl 62416bcf5a #467924, patch by Alan McIntyre: Add ZipFile.extract and ZipFile.extractall. 2008-01-07 18:47:44 +00:00
Christian Heimes fb2d25a154 Issue #1646: Make socket support TIPC. The socket module now has support
for TIPC under Linux, see http://tipc.sf.net/ for more information.
Thanks to Alberto Bertogli for the patch
2008-01-07 16:12:44 +00:00
Raymond Hettinger dc55f35f38 Add another named tuple subclassing example. 2008-01-07 09:03:49 +00:00
Jeffrey Yasskin fd1c24518b Fix issue 1747: allow classic classes to be checked for being subclasses of
ABCs.
2008-01-07 06:09:40 +00:00
Raymond Hettinger 1db6f80cd5 Cleanup subclassing example to more clearly show fixed-width print format. 2008-01-07 05:50:35 +00:00
Raymond Hettinger b8e0072fec Add subclassing example to docs for named tuples. 2008-01-07 04:24:49 +00:00
Raymond Hettinger 844f71b7e4 Speed-up named tuple's _make() constructor. 2008-01-06 22:11:54 +00:00
Georg Brandl e260ba2d33 #1325: Add docs and tests for zipimporter.archive and zipimporter.prefix. 2008-01-06 16:49:50 +00:00
Georg Brandl c45346f57a #1591: Clarify docstring of Popen3. 2008-01-06 14:33:52 +00:00
Georg Brandl 183a084da3 #1742: don't raise exception on os.path.relpath("a", "a"), but return os.curdir.
Reported by Jesse Towner.
2008-01-06 14:27:15 +00:00
Georg Brandl e2a902c669 #1696393: don't check for '.' and '..' in ntpath.walk since
they aren't returned from os.listdir anymore.
Reported by Michael Haggerty.
2008-01-06 14:17:36 +00:00
Raymond Hettinger 1166872006 Small code simplification. Forgot that classmethods can be called from intances. 2008-01-06 09:02:24 +00:00