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
Guido van Rossum
c6a04c2629
Patch #1637 : fix urlparse for URLs like ' http://x.com?arg=/foo '.
...
Fix by John Nagle.
2008-01-05 22:19:06 +00:00
Georg Brandl
f725b9587c
Doc patch #1730 from Robin Stocker; minor corrections mostly to os.rst.
2008-01-05 19:44:22 +00:00
Andrew M. Kuchling
0589914e60
Fix comment typo
2008-01-05 15:13:49 +00:00
Jeffrey Yasskin
9871d8fe22
Continue rolling back pep-3141 changes that changed behavior from 2.5. This
...
round included:
* Revert round to its 2.6 behavior (half away from 0).
* Because round, floor, and ceil always return float again, it's no
longer necessary to have them delegate to __xxx___, so I've ripped
that out of their implementations and the Real ABC. This also helps
in implementing types that work in both 2.6 and 3.0: you return int
from the __xxx__ methods, and let it get enabled by the version
upgrade.
* Make pow(-1, .5) raise a ValueError again.
2008-01-05 08:47:13 +00:00
Fred Drake
f7476c4d46
clean up a comment
2008-01-05 04:38:38 +00:00
Raymond Hettinger
1b50fd7cb3
Add error-checking to namedtuple's _replace() method.
2008-01-05 02:17:24 +00:00
Raymond Hettinger
02740f73ff
Improve namedtuple's _cast() method with a docstring, new name, and error-checking.
2008-01-05 01:35:43 +00:00
Guido van Rossum
ced4eb06e4
Patch #1698 by Senthil: allow '@' in username when parsed by urlparse.py.
2008-01-05 01:21:57 +00:00
Guido van Rossum
3b83549ea0
Patch #1725 by Mark Dickinson, fixes incorrect conversion of -1e1000
...
and adds errors for -0x.
2008-01-05 00:59:59 +00:00
Christian Heimes
a47b75b0a0
socket.ioctl is only available on Windows
2008-01-04 15:48:06 +00:00
Christian Heimes
04ae916fa2
Added interface to Windows' WSAIoctl and a simple example for a network sniffer.
2008-01-04 15:23:30 +00:00
Lars Gustäbel
2ee1c760cc
Issue #1735 : TarFile.extractall() now correctly sets
...
directory permissions and times.
(will backport to 2.5)
2008-01-04 14:00:33 +00:00
Christian Heimes
0687561c94
Bug #1713 : posixpath.ismount() claims symlink to a mountpoint is a mountpoint.
2008-01-04 13:21:07 +00:00
Jeffrey Yasskin
737c73f96f
Make math.{floor,ceil}({int,long}) return float again for backwards
...
compatibility after r59671 made them return integral types.
2008-01-04 08:01:23 +00:00
Raymond Hettinger
e0734e7dc0
Minor fix-ups to named tuples:
...
* Make the _replace() method respect subclassing.
* Using property() to make _fields read-only wasn't a good idea.
It caused len(Point._fields) to fail.
* Add note to _cast() about length checking and alternative with the star-operator.
2008-01-04 03:22:53 +00:00
Christian Heimes
76d19f68e4
Added _struct._clearcache() for regression tests
2008-01-04 02:54:42 +00:00
Christian Heimes
f2f41ebef4
Fixed refleak tests for _struct changes
2008-01-04 02:46:19 +00:00
Christian Heimes
8267d1dfe5
Bug #1481296 : Fixed long(float('nan'))!=0L.
2008-01-04 00:37:34 +00:00
Christian Heimes
0613188bc3
Fixed #1687 : plistlib.py restricts <integer> to Python int when writing
2008-01-04 00:04:52 +00:00
Raymond Hettinger
2f6621cce7
Finish-up the struct module optimizations started at the Iceland NFS sprint.
2008-01-04 00:01:15 +00:00
Christian Heimes
eebb79cc69
Added copysign(x, y) function to the math module
2008-01-03 22:32:26 +00:00
Christian Heimes
e2ca4245c9
Added math.isinf() and math.isnan()
2008-01-03 20:23:15 +00:00
Guido van Rossum
ae04c3356e
Issue #1700 , reported by Nguyen Quan Son, fix by Fredruk Lundh:
...
Regular Expression inline flags not handled correctly for some unicode
characters. (Forward port from 2.5.2.)
2008-01-03 19:12:44 +00:00
Jeffrey Yasskin
2f3c16be73
Backport PEP 3141 from the py3k branch to the trunk. This includes r50877 (just
...
the complex_pow part), r56649, r56652, r56715, r57296, r57302, r57359, r57361,
r57372, r57738, r57739, r58017, r58039, r58040, and r59390, and new
documentation. The only significant difference is that round(x) returns a float
to preserve backward-compatibility. See http://bugs.python.org/issue1689 .
2008-01-03 02:21:52 +00:00
Guido van Rossum
27edd829d7
Patch #1696 . Don't attempt to close None in dry-run mode.
2008-01-02 19:00:46 +00:00
Kurt B. Kaiser
0a11232978
Change docstrings to comments so test output will display normally.
2008-01-02 05:23:38 +00:00
Kurt B. Kaiser
0f7c25d20f
Issue1177
...
r58207 and r58247 patch logic is reversed. I noticed this when I
tried to use urllib to retrieve a file which required auth.
Fix that and add a test for 401 error to verify.
2008-01-02 04:11:28 +00:00
Martin v. Löwis
f5d902fc47
Always convert Text.index result to string.
...
This improves compatibility with Tcl 8.5, which would
otherwise return textindex objects.
2008-01-01 21:08:18 +00:00
Christian Heimes
9a1d8cec11
Added support for new Windows build dirs in PC/ to distutils.sysconfig
2008-01-01 14:37:32 +00:00
Guido van Rossum
96b3249670
Fix an odd error which would only occur close to new year's eve, due
...
to use of datetime.datetime.now() instead of utcnow() for comparison.
(I think the test can still fail if it's executed pretty much *at*
new year's eve, but that's not worth fixing.)
2008-01-01 04:15:29 +00:00
Christian Heimes
cdaa2cbfd5
Added wininst-9.0.exe executable for VS 2008
...
Integrated bdist_wininst into PCBuild9 directory
2007-12-31 14:47:07 +00:00
Kurt B. Kaiser
28c7bcf38e
Configure Dialog: improved layout for keybinding. Patch 1457 Tal Einat.
2007-12-28 04:18:01 +00:00
Brett Cannon
a6e515b90d
Remove a straggling debugging print line.
2007-12-25 06:44:59 +00:00
Brett Cannon
4e438bcc56
Actually execute the tests for the getter/setter/deleter tests on properties.
...
Also fix the test by having the test classes inherit from object.
Are the getter/setter/deleter attributes supposed to be able to chain? As of
right now they can't as the property tries to call what the property returns,
which is another property when they are chained.
2007-12-25 00:14:34 +00:00
Guido van Rossum
e9a0e885db
Patch #1672 by Joseph Armbruster. Use tempdir() to get a temporary directory.
2007-12-20 17:28:10 +00:00
Brett Cannon
905c31c73d
Add tests for the warnings module; specifically formatwarning and showwarning.
...
Still need tests for warn_explicit and simplefilter.
2007-12-20 10:09:52 +00:00
Guido van Rossum
0b7b6fdff3
Patch #1549 by Thomas Herve.
...
This changes the rules for when __hash__ is inherited slightly,
by allowing it to be inherited when one or more of __lt__, __le__,
__gt__, __ge__ are overridden, as long as __eq__ and __ne__ aren't.
2007-12-19 22:51:13 +00:00
Guido van Rossum
02de8979cc
Patch #1583 by Adam Olsen.
...
This adds signal.set_wakeup_fd(fd) which sets a file descriptor to
which a zero byte will be written whenever a C exception handler runs.
I added a simple C API as well, PySignal_SetWakeupFd(fd).
2007-12-19 19:41:06 +00:00
Raymond Hettinger
80016c9555
Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes.
2007-12-19 18:13:31 +00:00
Facundo Batista
0f5e7bf304
Some minor cleanups. Thanks Mark Dickinson.
2007-12-19 12:53:01 +00:00
Raymond Hettinger
3b63556d4a
Beef-up tests for dict literals
2007-12-19 00:21:06 +00:00
Raymond Hettinger
85dfcf3530
Users demand iterable input for named tuples. The author capitulates.
2007-12-18 23:51:15 +00:00
Christian Heimes
0a8143f646
Applied patch #1635 : Float patch for inf and nan on Windows (and other platforms).
...
The patch unifies float("inf") and repr(float("inf")) on all platforms.
2007-12-18 23:22:54 +00:00
Raymond Hettinger
8777bcae27
Simplify and speedup _asdict() for named tuples.
2007-12-18 22:21:27 +00:00
Christian Heimes
0423698bc3
Fixed #1649 : IDLE error: dictionary changed size during iteration
2007-12-18 21:56:09 +00:00
Raymond Hettinger
fd7ed407d7
Give meaning to the oparg for BUILD_MAP: estimated size of the dictionary.
...
Allows dictionaries to be pre-sized (upto 255 elements) saving time lost
to re-sizes with their attendant mallocs and re-insertions.
Has zero effect on small dictionaries (5 elements or fewer), a slight
benefit for dicts upto 22 elements (because they had to resize once
anyway), and more benefit for dicts upto 255 elements (saving multiple
resizes during the build-up and reducing the number of collisions on
the first insertions). Beyond 255 elements, there is no addional benefit.
2007-12-18 21:24:09 +00:00
Thomas Heller
153038efa4
Issue #1642 : Fix segfault in ctypes when trying to delete attributes.
2007-12-18 19:00:34 +00:00
Raymond Hettinger
effde12f5f
Speed-up dictionary constructor by about 10%.
...
New opcode, STORE_MAP saves the compiler from awkward stack manipulations
and specializes for dicts using PyDict_SetItem instead of PyObject_SetItem.
Old disassembly:
0 BUILD_MAP 0
3 DUP_TOP
4 LOAD_CONST 1 (1)
7 ROT_TWO
8 LOAD_CONST 2 ('x')
11 STORE_SUBSCR
12 DUP_TOP
13 LOAD_CONST 3 (2)
16 ROT_TWO
17 LOAD_CONST 4 ('y')
20 STORE_SUBSCR
New disassembly:
0 BUILD_MAP 0
3 LOAD_CONST 1 (1)
6 LOAD_CONST 2 ('x')
9 STORE_MAP
10 LOAD_CONST 3 (2)
13 LOAD_CONST 4 ('y')
16 STORE_MAP
2007-12-18 18:26:18 +00:00
Christian Heimes
bb89992211
Make it a bit easier to test Tcl/Tk and idle from a build dir.
2007-12-18 09:00:13 +00:00
Raymond Hettinger
88880b2dd6
Add more namedtuple() test cases. Neaten the code and comments.
2007-12-18 00:13:45 +00:00
Facundo Batista
e64acfad3d
Removed the private _rounding_decision: it was not needed, and the code
...
is now simpler. Thanks Mark Dickinson.
2007-12-17 14:18:42 +00:00
Georg Brandl
9c8497eb6e
Revert dummy commit now that the build slave is building.
2007-12-16 11:21:48 +00:00
Georg Brandl
6f6f6adea2
Dummy commit to investigate #1617 .
2007-12-16 11:06:09 +00:00