summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-01-16 03:54:08 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-01-16 03:54:08 (GMT)
commit058e31ef2aec3ea079cdf297fc0d4f40d3d9975a (patch)
tree0c8a2abae4490b207ed2a32d20680b3b2c9a48f7 /Lib
parent1456778a6a2b4a3381a9eb6749dc62921253c402 (diff)
downloadcpython-058e31ef2aec3ea079cdf297fc0d4f40d3d9975a.zip
cpython-058e31ef2aec3ea079cdf297fc0d4f40d3d9975a.tar.gz
cpython-058e31ef2aec3ea079cdf297fc0d4f40d3d9975a.tar.bz2
Merged revisions 68450,68480-68481,68493,68495,68501,68512,68514-68515,68534-68536,68552,68563,68570-68572,68575,68582,68596,68623-68624,68628 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r68450 | jeffrey.yasskin | 2009-01-09 10:47:07 -0600 (Fri, 09 Jan 2009) | 3 lines Fix issue 4884, preventing a crash in the socket code when python is compiled with llvm-gcc and run with a glibc <2.10. ........ r68480 | vinay.sajip | 2009-01-10 07:38:04 -0600 (Sat, 10 Jan 2009) | 1 line Minor documentation changes cross-referencing NullHandler to the documentation on configuring logging in a library. ........ r68481 | vinay.sajip | 2009-01-10 07:42:04 -0600 (Sat, 10 Jan 2009) | 1 line Corrected an incorrect self-reference. ........ r68493 | benjamin.peterson | 2009-01-10 11:18:55 -0600 (Sat, 10 Jan 2009) | 1 line rewrite verbose conditionals ........ r68495 | benjamin.peterson | 2009-01-10 11:36:44 -0600 (Sat, 10 Jan 2009) | 1 line tp_iter only exists with Py_TPFLAGS_HAVE_ITER #4901 ........ r68501 | vinay.sajip | 2009-01-10 13:22:57 -0600 (Sat, 10 Jan 2009) | 1 line Corrected minor typo and added .currentmodule directives to fix missing cross-references. ........ r68512 | benjamin.peterson | 2009-01-10 16:42:10 -0600 (Sat, 10 Jan 2009) | 1 line make tests fail if they can't be imported ........ r68514 | benjamin.peterson | 2009-01-10 17:41:59 -0600 (Sat, 10 Jan 2009) | 1 line move seealso to a more appropiate place ........ r68515 | benjamin.peterson | 2009-01-10 17:49:08 -0600 (Sat, 10 Jan 2009) | 1 line macos 9 isn't supported ........ r68534 | gregory.p.smith | 2009-01-11 11:53:33 -0600 (Sun, 11 Jan 2009) | 2 lines correct email address ........ r68535 | gregory.p.smith | 2009-01-11 11:57:54 -0600 (Sun, 11 Jan 2009) | 9 lines Update the documentation for binascii and zlib crc32/adler32 functions to better describe the signed vs unsigned return value behavior on different platforms and versions of python. Mention the workaround to make them all return the same thing by using & 0xffffffff. Fixes issue4903. Also needs to be merged into release26-maint, release30-maint, & py3k. ........ r68536 | benjamin.peterson | 2009-01-11 13:48:15 -0600 (Sun, 11 Jan 2009) | 1 line add email addresses ........ r68552 | vinay.sajip | 2009-01-12 14:36:18 -0600 (Mon, 12 Jan 2009) | 1 line Minor changes/corrections in markup. ........ r68563 | benjamin.peterson | 2009-01-12 19:49:10 -0600 (Mon, 12 Jan 2009) | 1 line small logic correction ........ r68570 | raymond.hettinger | 2009-01-13 03:08:32 -0600 (Tue, 13 Jan 2009) | 5 lines Issue 4922: Incorrect comments for MutableSet.add() and MutableSet.discard(). Needs to be backported to 2.6 and forward ported to 3.0 and 3.1. ........ r68571 | armin.ronacher | 2009-01-13 05:52:23 -0600 (Tue, 13 Jan 2009) | 3 lines ast.literal_eval can properly evaluate complex numbers now. This fixes issue4907. ........ r68572 | andrew.kuchling | 2009-01-13 07:40:54 -0600 (Tue, 13 Jan 2009) | 1 line Note that first coord. is left alone ........ r68575 | thomas.heller | 2009-01-13 11:32:28 -0600 (Tue, 13 Jan 2009) | 1 line Fix refcount leak in error cases. Bug found by coverity. ........ r68582 | georg.brandl | 2009-01-13 16:14:01 -0600 (Tue, 13 Jan 2009) | 2 lines Use assertRaises. ........ r68596 | amaury.forgeotdarc | 2009-01-13 17:39:22 -0600 (Tue, 13 Jan 2009) | 3 lines #1162154: inspect.getmembers() now skips attributes that raise AttributeError, e.g. a __slots__ attribute which has not been set. ........ r68623 | vinay.sajip | 2009-01-15 16:48:13 -0600 (Thu, 15 Jan 2009) | 1 line Made minor changes/corrections in markup. Added a couple of section headings. ........ r68624 | vinay.sajip | 2009-01-15 17:04:47 -0600 (Thu, 15 Jan 2009) | 1 line Minor changes/corrections in markup. ........ r68628 | benjamin.peterson | 2009-01-15 20:55:24 -0600 (Thu, 15 Jan 2009) | 1 line compare with == not is #4946 ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/_abcoll.py4
-rw-r--r--Lib/ast.py12
-rw-r--r--Lib/ctypes/test/__init__.py3
-rw-r--r--Lib/inspect.py5
-rw-r--r--Lib/test/test_ast.py6
-rw-r--r--Lib/test/test_inspect.py11
6 files changed, 35 insertions, 6 deletions
diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py
index 72f1397..ca82c41 100644
--- a/Lib/_abcoll.py
+++ b/Lib/_abcoll.py
@@ -283,12 +283,12 @@ class MutableSet(Set):
@abstractmethod
def add(self, value):
- """Return True if it was added, False if already there."""
+ """Add an element."""
raise NotImplementedError
@abstractmethod
def discard(self, value):
- """Return True if it was deleted, False if not there."""
+ """Remove an element. Do not raise an exception if absent."""
raise NotImplementedError
def remove(self, value):
diff --git a/Lib/ast.py b/Lib/ast.py
index 53130cf..0b8baf7 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -64,6 +64,18 @@ def literal_eval(node_or_string):
elif isinstance(node, Name):
if node.id in _safe_names:
return _safe_names[node.id]
+ elif isinstance(node, BinOp) and \
+ isinstance(node.op, (Add, Sub)) and \
+ isinstance(node.right, Num) and \
+ isinstance(node.right.n, complex) and \
+ isinstance(node.left, Num) and \
+ isinstance(node.left.n, (int, float)):
+ left = node.left.n
+ right = node.right.n
+ if isinstance(node.op, Add):
+ return left + right
+ else:
+ return left - right
raise ValueError('malformed string')
return _convert(node_or_string)
diff --git a/Lib/ctypes/test/__init__.py b/Lib/ctypes/test/__init__.py
index bdcf62b..1e0460a 100644
--- a/Lib/ctypes/test/__init__.py
+++ b/Lib/ctypes/test/__init__.py
@@ -67,9 +67,6 @@ def get_tests(package, mask, verbosity, exclude=()):
if verbosity > 1:
print("Skipped %s: %s" % (modname, detail), file=sys.stderr)
continue
- except Exception as detail:
- print("Warning: could not import %s: %s" % (modname, detail), file=sys.stderr)
- continue
for name in dir(mod):
if name.startswith("_"):
continue
diff --git a/Lib/inspect.py b/Lib/inspect.py
index da55ac6..b84aec0 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -249,7 +249,10 @@ def getmembers(object, predicate=None):
Optionally, only return members that satisfy a given predicate."""
results = []
for key in dir(object):
- value = getattr(object, key)
+ try:
+ value = getattr(object, key)
+ except AttributeError:
+ continue
if not predicate or predicate(value):
results.append((key, value))
results.sort()
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 2aa3b8f..54a3b35 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -265,6 +265,12 @@ class ASTHelpers_Test(unittest.TestCase):
self.assertEqual(ast.literal_eval('(True, False, None)'), (True, False, None))
self.assertRaises(ValueError, ast.literal_eval, 'foo()')
+ def test_literal_eval_issue4907(self):
+ self.assertEqual(ast.literal_eval('2j'), 2j)
+ self.assertEqual(ast.literal_eval('10 + 2j'), 10 + 2j)
+ self.assertEqual(ast.literal_eval('1.5 - 2j'), 1.5 - 2j)
+ self.assertRaises(ValueError, ast.literal_eval, '2 + (3 + 4j)')
+
def test_main():
support.run_unittest(AST_Tests, ASTHelpers_Test)
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index bde6d6c..ac9fcd7 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -99,6 +99,17 @@ class TestPredicates(IsTestBase):
self.assert_(inspect.isroutine(mod.spam))
self.assert_(inspect.isroutine([].count))
+ def test_get_slot_members(self):
+ class C(object):
+ __slots__ = ("a", "b")
+
+ x = C()
+ x.a = 42
+ members = dict(inspect.getmembers(x))
+ self.assert_('a' in members)
+ self.assert_('b' not in members)
+
+
class TestInterpreterStack(IsTestBase):
def __init__(self, *args, **kwargs):
unittest.TestCase.__init__(self, *args, **kwargs)