From solipsis at pitrou.net Tue Dec 1 03:42:59 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 01 Dec 2015 08:42:59 +0000 Subject: [Python-checkins] Daily reference leaks (734247d5d0f9): sum=7 Message-ID: <20151201084259.22392.3682@psf.io> results for 734247d5d0f9 on branch "default" -------------------------------------------- test_asyncio leaked [0, 3, 0] memory blocks, sum=3 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/refloghSfbUK', '--timeout', '7200'] From python-checkins at python.org Tue Dec 1 09:11:14 2015 From: python-checkins at python.org (steven.daprano) Date: Tue, 01 Dec 2015 14:11:14 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Fix_for_issue_?= =?utf-8?q?=2325177_with_the_mean_of_very_small_and_very_large_numbers=2E?= Message-ID: <20151201141109.13433.42167@psf.io> https://hg.python.org/cpython/rev/4bc9405c4f7b changeset: 99406:4bc9405c4f7b branch: 3.4 parent: 99400:65a23d24fd12 user: Steven D'Aprano date: Tue Dec 01 13:48:48 2015 +1100 summary: Fix for issue #25177 with the mean of very small and very large numbers. files: Lib/statistics.py | 181 +++++++---- Lib/test/test_statistics.py | 363 ++++++++++++++++++++--- Misc/NEWS | 4 + 3 files changed, 431 insertions(+), 117 deletions(-) diff --git a/Lib/statistics.py b/Lib/statistics.py --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -104,6 +104,8 @@ from fractions import Fraction from decimal import Decimal +from itertools import groupby + # === Exceptions === @@ -115,86 +117,102 @@ # === Private utilities === def _sum(data, start=0): - """_sum(data [, start]) -> value + """_sum(data [, start]) -> (type, sum, count) - Return a high-precision sum of the given numeric data. If optional - argument ``start`` is given, it is added to the total. If ``data`` is - empty, ``start`` (defaulting to 0) is returned. + Return a high-precision sum of the given numeric data as a fraction, + together with the type to be converted to and the count of items. + + If optional argument ``start`` is given, it is added to the total. + If ``data`` is empty, ``start`` (defaulting to 0) is returned. Examples -------- >>> _sum([3, 2.25, 4.5, -0.5, 1.0], 0.75) - 11.0 + (, Fraction(11, 1), 5) Some sources of round-off error will be avoided: >>> _sum([1e50, 1, -1e50] * 1000) # Built-in sum returns zero. - 1000.0 + (, Fraction(1000, 1), 3000) Fractions and Decimals are also supported: >>> from fractions import Fraction as F >>> _sum([F(2, 3), F(7, 5), F(1, 4), F(5, 6)]) - Fraction(63, 20) + (, Fraction(63, 20), 4) >>> from decimal import Decimal as D >>> data = [D("0.1375"), D("0.2108"), D("0.3061"), D("0.0419")] >>> _sum(data) - Decimal('0.6963') + (, Fraction(6963, 10000), 4) Mixed types are currently treated as an error, except that int is allowed. """ - # We fail as soon as we reach a value that is not an int or the type of - # the first value which is not an int. E.g. _sum([int, int, float, int]) - # is okay, but sum([int, int, float, Fraction]) is not. - allowed_types = set([int, type(start)]) + count = 0 n, d = _exact_ratio(start) - partials = {d: n} # map {denominator: sum of numerators} - # Micro-optimizations. - exact_ratio = _exact_ratio + partials = {d: n} partials_get = partials.get - # Add numerators for each denominator. - for x in data: - _check_type(type(x), allowed_types) - n, d = exact_ratio(x) - partials[d] = partials_get(d, 0) + n - # Find the expected result type. If allowed_types has only one item, it - # will be int; if it has two, use the one which isn't int. - assert len(allowed_types) in (1, 2) - if len(allowed_types) == 1: - assert allowed_types.pop() is int - T = int + T = _coerce(int, type(start)) + for typ, values in groupby(data, type): + T = _coerce(T, typ) # or raise TypeError + for n,d in map(_exact_ratio, values): + count += 1 + partials[d] = partials_get(d, 0) + n + if None in partials: + # The sum will be a NAN or INF. We can ignore all the finite + # partials, and just look at this special one. + total = partials[None] + assert not _isfinite(total) else: - T = (allowed_types - set([int])).pop() - if None in partials: - assert issubclass(T, (float, Decimal)) - assert not math.isfinite(partials[None]) - return T(partials[None]) - total = Fraction() - for d, n in sorted(partials.items()): - total += Fraction(n, d) - if issubclass(T, int): - assert total.denominator == 1 - return T(total.numerator) - if issubclass(T, Decimal): - return T(total.numerator)/total.denominator - return T(total) + # Sum all the partial sums using builtin sum. + # FIXME is this faster if we sum them in order of the denominator? + total = sum(Fraction(n, d) for d, n in sorted(partials.items())) + return (T, total, count) -def _check_type(T, allowed): - if T not in allowed: - if len(allowed) == 1: - allowed.add(T) - else: - types = ', '.join([t.__name__ for t in allowed] + [T.__name__]) - raise TypeError("unsupported mixed types: %s" % types) +def _isfinite(x): + try: + return x.is_finite() # Likely a Decimal. + except AttributeError: + return math.isfinite(x) # Coerces to float first. + + +def _coerce(T, S): + """Coerce types T and S to a common type, or raise TypeError. + + Coercion rules are currently an implementation detail. See the CoerceTest + test class in test_statistics for details. + """ + # See http://bugs.python.org/issue24068. + assert T is not bool, "initial type T is bool" + # If the types are the same, no need to coerce anything. Put this + # first, so that the usual case (no coercion needed) happens as soon + # as possible. + if T is S: return T + # Mixed int & other coerce to the other type. + if S is int or S is bool: return T + if T is int: return S + # If one is a (strict) subclass of the other, coerce to the subclass. + if issubclass(S, T): return S + if issubclass(T, S): return T + # Ints coerce to the other type. + if issubclass(T, int): return S + if issubclass(S, int): return T + # Mixed fraction & float coerces to float (or float subclass). + if issubclass(T, Fraction) and issubclass(S, float): + return S + if issubclass(T, float) and issubclass(S, Fraction): + return T + # Any other combination is disallowed. + msg = "don't know how to coerce %s and %s" + raise TypeError(msg % (T.__name__, S.__name__)) def _exact_ratio(x): - """Convert Real number x exactly to (numerator, denominator) pair. + """Return Real number x to exact (numerator, denominator) pair. >>> _exact_ratio(0.25) (1, 4) @@ -202,29 +220,31 @@ x is expected to be an int, Fraction, Decimal or float. """ try: + # Optimise the common case of floats. We expect that the most often + # used numeric type will be builtin floats, so try to make this as + # fast as possible. + if type(x) is float: + return x.as_integer_ratio() try: - # int, Fraction + # x may be an int, Fraction, or Integral ABC. return (x.numerator, x.denominator) except AttributeError: - # float try: + # x may be a float subclass. return x.as_integer_ratio() except AttributeError: - # Decimal try: + # x may be a Decimal. return _decimal_to_ratio(x) except AttributeError: - msg = "can't convert type '{}' to numerator/denominator" - raise TypeError(msg.format(type(x).__name__)) from None + # Just give up? + pass except (OverflowError, ValueError): - # INF or NAN - if __debug__: - # Decimal signalling NANs cannot be converted to float :-( - if isinstance(x, Decimal): - assert not x.is_finite() - else: - assert not math.isfinite(x) + # float NAN or INF. + assert not math.isfinite(x) return (x, None) + msg = "can't convert type '{}' to numerator/denominator" + raise TypeError(msg.format(type(x).__name__)) # FIXME This is faster than Fraction.from_decimal, but still too slow. @@ -239,7 +259,7 @@ sign, digits, exp = d.as_tuple() if exp in ('F', 'n', 'N'): # INF, NAN, sNAN assert not d.is_finite() - raise ValueError + return (d, None) num = 0 for digit in digits: num = num*10 + digit @@ -253,6 +273,24 @@ return (num, den) +def _convert(value, T): + """Convert value to given numeric type T.""" + if type(value) is T: + # This covers the cases where T is Fraction, or where value is + # a NAN or INF (Decimal or float). + return value + if issubclass(T, int) and value.denominator != 1: + T = float + try: + # FIXME: what do we do if this overflows? + return T(value) + except TypeError: + if issubclass(T, Decimal): + return T(value.numerator)/T(value.denominator) + else: + raise + + def _counts(data): # Generate a table of sorted (value, frequency) pairs. table = collections.Counter(iter(data)).most_common() @@ -290,7 +328,9 @@ n = len(data) if n < 1: raise StatisticsError('mean requires at least one data point') - return _sum(data)/n + T, total, count = _sum(data) + assert count == n + return _convert(total/n, T) # FIXME: investigate ways to calculate medians without sorting? Quickselect? @@ -460,12 +500,14 @@ """ if c is None: c = mean(data) - ss = _sum((x-c)**2 for x in data) + T, total, count = _sum((x-c)**2 for x in data) # The following sum should mathematically equal zero, but due to rounding # error may not. - ss -= _sum((x-c) for x in data)**2/len(data) - assert not ss < 0, 'negative sum of square deviations: %f' % ss - return ss + U, total2, count2 = _sum((x-c) for x in data) + assert T == U and count == count2 + total -= total2**2/len(data) + assert not total < 0, 'negative sum of square deviations: %f' % total + return (T, total) def variance(data, xbar=None): @@ -511,8 +553,8 @@ n = len(data) if n < 2: raise StatisticsError('variance requires at least two data points') - ss = _ss(data, xbar) - return ss/(n-1) + T, ss = _ss(data, xbar) + return _convert(ss/(n-1), T) def pvariance(data, mu=None): @@ -560,7 +602,8 @@ if n < 1: raise StatisticsError('pvariance requires at least one data point') ss = _ss(data, mu) - return ss/n + T, ss = _ss(data, mu) + return _convert(ss/n, T) def stdev(data, xbar=None): diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -21,6 +21,37 @@ # === Helper functions and class === +def _nan_equal(a, b): + """Return True if a and b are both the same kind of NAN. + + >>> _nan_equal(Decimal('NAN'), Decimal('NAN')) + True + >>> _nan_equal(Decimal('sNAN'), Decimal('sNAN')) + True + >>> _nan_equal(Decimal('NAN'), Decimal('sNAN')) + False + >>> _nan_equal(Decimal(42), Decimal('NAN')) + False + + >>> _nan_equal(float('NAN'), float('NAN')) + True + >>> _nan_equal(float('NAN'), 0.5) + False + + >>> _nan_equal(float('NAN'), Decimal('NAN')) + False + + NAN payloads are not compared. + """ + if type(a) is not type(b): + return False + if isinstance(a, float): + return math.isnan(a) and math.isnan(b) + aexp = a.as_tuple()[2] + bexp = b.as_tuple()[2] + return (aexp == bexp) and (aexp in ('n', 'N')) # Both NAN or both sNAN. + + def _calc_errors(actual, expected): """Return the absolute and relative errors between two numbers. @@ -675,15 +706,60 @@ self.assertEqual(_exact_ratio(D("12.345")), (12345, 1000)) self.assertEqual(_exact_ratio(D("-1.98")), (-198, 100)) + def test_inf(self): + INF = float("INF") + class MyFloat(float): + pass + class MyDecimal(Decimal): + pass + for inf in (INF, -INF): + for type_ in (float, MyFloat, Decimal, MyDecimal): + x = type_(inf) + ratio = statistics._exact_ratio(x) + self.assertEqual(ratio, (x, None)) + self.assertEqual(type(ratio[0]), type_) + self.assertTrue(math.isinf(ratio[0])) + + def test_float_nan(self): + NAN = float("NAN") + class MyFloat(float): + pass + for nan in (NAN, MyFloat(NAN)): + ratio = statistics._exact_ratio(nan) + self.assertTrue(math.isnan(ratio[0])) + self.assertIs(ratio[1], None) + self.assertEqual(type(ratio[0]), type(nan)) + + def test_decimal_nan(self): + NAN = Decimal("NAN") + sNAN = Decimal("sNAN") + class MyDecimal(Decimal): + pass + for nan in (NAN, MyDecimal(NAN), sNAN, MyDecimal(sNAN)): + ratio = statistics._exact_ratio(nan) + self.assertTrue(_nan_equal(ratio[0], nan)) + self.assertIs(ratio[1], None) + self.assertEqual(type(ratio[0]), type(nan)) + class DecimalToRatioTest(unittest.TestCase): # Test _decimal_to_ratio private function. - def testSpecialsRaise(self): - # Test that NANs and INFs raise ValueError. - # Non-special values are covered by _exact_ratio above. - for d in (Decimal('NAN'), Decimal('sNAN'), Decimal('INF')): - self.assertRaises(ValueError, statistics._decimal_to_ratio, d) + def test_infinity(self): + # Test that INFs are handled correctly. + inf = Decimal('INF') + self.assertEqual(statistics._decimal_to_ratio(inf), (inf, None)) + self.assertEqual(statistics._decimal_to_ratio(-inf), (-inf, None)) + + def test_nan(self): + # Test that NANs are handled correctly. + for nan in (Decimal('NAN'), Decimal('sNAN')): + num, den = statistics._decimal_to_ratio(nan) + # Because NANs always compare non-equal, we cannot use assertEqual. + # Nor can we use an identity test, as we don't guarantee anything + # about the object identity. + self.assertTrue(_nan_equal(num, nan)) + self.assertIs(den, None) def test_sign(self): # Test sign is calculated correctly. @@ -718,25 +794,181 @@ self.assertEqual(t, (147000, 1)) -class CheckTypeTest(unittest.TestCase): - # Test _check_type private function. +class IsFiniteTest(unittest.TestCase): + # Test _isfinite private function. - def test_allowed(self): - # Test that a type which should be allowed is allowed. - allowed = set([int, float]) - statistics._check_type(int, allowed) - statistics._check_type(float, allowed) + def test_finite(self): + # Test that finite numbers are recognised as finite. + for x in (5, Fraction(1, 3), 2.5, Decimal("5.5")): + self.assertTrue(statistics._isfinite(x)) - def test_not_allowed(self): - # Test that a type which should not be allowed raises. - allowed = set([int, float]) - self.assertRaises(TypeError, statistics._check_type, Decimal, allowed) + def test_infinity(self): + # Test that INFs are not recognised as finite. + for x in (float("inf"), Decimal("inf")): + self.assertFalse(statistics._isfinite(x)) - def test_add_to_allowed(self): - # Test that a second type will be added to the allowed set. - allowed = set([int]) - statistics._check_type(float, allowed) - self.assertEqual(allowed, set([int, float])) + def test_nan(self): + # Test that NANs are not recognised as finite. + for x in (float("nan"), Decimal("NAN"), Decimal("sNAN")): + self.assertFalse(statistics._isfinite(x)) + + +class CoerceTest(unittest.TestCase): + # Test that private function _coerce correctly deals with types. + + # The coercion rules are currently an implementation detail, although at + # some point that should change. The tests and comments here define the + # correct implementation. + + # Pre-conditions of _coerce: + # + # - The first time _sum calls _coerce, the + # - coerce(T, S) will never be called with bool as the first argument; + # this is a pre-condition, guarded with an assertion. + + # + # - coerce(T, T) will always return T; we assume T is a valid numeric + # type. Violate this assumption at your own risk. + # + # - Apart from as above, bool is treated as if it were actually int. + # + # - coerce(int, X) and coerce(X, int) return X. + # - + def test_bool(self): + # bool is somewhat special, due to the pre-condition that it is + # never given as the first argument to _coerce, and that it cannot + # be subclassed. So we test it specially. + for T in (int, float, Fraction, Decimal): + self.assertIs(statistics._coerce(T, bool), T) + class MyClass(T): pass + self.assertIs(statistics._coerce(MyClass, bool), MyClass) + + def assertCoerceTo(self, A, B): + """Assert that type A coerces to B.""" + self.assertIs(statistics._coerce(A, B), B) + self.assertIs(statistics._coerce(B, A), B) + + def check_coerce_to(self, A, B): + """Checks that type A coerces to B, including subclasses.""" + # Assert that type A is coerced to B. + self.assertCoerceTo(A, B) + # Subclasses of A are also coerced to B. + class SubclassOfA(A): pass + self.assertCoerceTo(SubclassOfA, B) + # A, and subclasses of A, are coerced to subclasses of B. + class SubclassOfB(B): pass + self.assertCoerceTo(A, SubclassOfB) + self.assertCoerceTo(SubclassOfA, SubclassOfB) + + def assertCoerceRaises(self, A, B): + """Assert that coercing A to B, or vice versa, raises TypeError.""" + self.assertRaises(TypeError, statistics._coerce, (A, B)) + self.assertRaises(TypeError, statistics._coerce, (B, A)) + + def check_type_coercions(self, T): + """Check that type T coerces correctly with subclasses of itself.""" + assert T is not bool + # Coercing a type with itself returns the same type. + self.assertIs(statistics._coerce(T, T), T) + # Coercing a type with a subclass of itself returns the subclass. + class U(T): pass + class V(T): pass + class W(U): pass + for typ in (U, V, W): + self.assertCoerceTo(T, typ) + self.assertCoerceTo(U, W) + # Coercing two subclasses that aren't parent/child is an error. + self.assertCoerceRaises(U, V) + self.assertCoerceRaises(V, W) + + def test_int(self): + # Check that int coerces correctly. + self.check_type_coercions(int) + for typ in (float, Fraction, Decimal): + self.check_coerce_to(int, typ) + + def test_fraction(self): + # Check that Fraction coerces correctly. + self.check_type_coercions(Fraction) + self.check_coerce_to(Fraction, float) + + def test_decimal(self): + # Check that Decimal coerces correctly. + self.check_type_coercions(Decimal) + + def test_float(self): + # Check that float coerces correctly. + self.check_type_coercions(float) + + def test_non_numeric_types(self): + for bad_type in (str, list, type(None), tuple, dict): + for good_type in (int, float, Fraction, Decimal): + self.assertCoerceRaises(good_type, bad_type) + + def test_incompatible_types(self): + # Test that incompatible types raise. + for T in (float, Fraction): + class MySubclass(T): pass + self.assertCoerceRaises(T, Decimal) + self.assertCoerceRaises(MySubclass, Decimal) + + +class ConvertTest(unittest.TestCase): + # Test private _convert function. + + def check_exact_equal(self, x, y): + """Check that x equals y, and has the same type as well.""" + self.assertEqual(x, y) + self.assertIs(type(x), type(y)) + + def test_int(self): + # Test conversions to int. + x = statistics._convert(Fraction(71), int) + self.check_exact_equal(x, 71) + class MyInt(int): pass + x = statistics._convert(Fraction(17), MyInt) + self.check_exact_equal(x, MyInt(17)) + + def test_fraction(self): + # Test conversions to Fraction. + x = statistics._convert(Fraction(95, 99), Fraction) + self.check_exact_equal(x, Fraction(95, 99)) + class MyFraction(Fraction): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(71, 13), MyFraction) + self.check_exact_equal(x, MyFraction(71, 13)) + + def test_float(self): + # Test conversions to float. + x = statistics._convert(Fraction(-1, 2), float) + self.check_exact_equal(x, -0.5) + class MyFloat(float): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(9, 8), MyFloat) + self.check_exact_equal(x, MyFloat(1.125)) + + def test_decimal(self): + # Test conversions to Decimal. + x = statistics._convert(Fraction(1, 40), Decimal) + self.check_exact_equal(x, Decimal("0.025")) + class MyDecimal(Decimal): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(-15, 16), MyDecimal) + self.check_exact_equal(x, MyDecimal("-0.9375")) + + def test_inf(self): + for INF in (float('inf'), Decimal('inf')): + for inf in (INF, -INF): + x = statistics._convert(inf, type(inf)) + self.check_exact_equal(x, inf) + + def test_nan(self): + for nan in (float('nan'), Decimal('NAN'), Decimal('sNAN')): + x = statistics._convert(nan, type(nan)) + self.assertTrue(_nan_equal(x, nan)) # === Tests for public functions === @@ -874,52 +1106,71 @@ self.assertIs(type(result), kind) -class TestSum(NumericTestCase, UnivariateCommonMixin, UnivariateTypeMixin): +class TestSumCommon(UnivariateCommonMixin, UnivariateTypeMixin): + # Common test cases for statistics._sum() function. + + # This test suite looks only at the numeric value returned by _sum, + # after conversion to the appropriate type. + def setUp(self): + def simplified_sum(*args): + T, value, n = statistics._sum(*args) + return statistics._coerce(value, T) + self.func = simplified_sum + + +class TestSum(NumericTestCase): # Test cases for statistics._sum() function. + # These tests look at the entire three value tuple returned by _sum. + def setUp(self): self.func = statistics._sum def test_empty_data(self): # Override test for empty data. for data in ([], (), iter([])): - self.assertEqual(self.func(data), 0) - self.assertEqual(self.func(data, 23), 23) - self.assertEqual(self.func(data, 2.3), 2.3) + self.assertEqual(self.func(data), (int, Fraction(0), 0)) + self.assertEqual(self.func(data, 23), (int, Fraction(23), 0)) + self.assertEqual(self.func(data, 2.3), (float, Fraction(2.3), 0)) def test_ints(self): - self.assertEqual(self.func([1, 5, 3, -4, -8, 20, 42, 1]), 60) - self.assertEqual(self.func([4, 2, 3, -8, 7], 1000), 1008) + self.assertEqual(self.func([1, 5, 3, -4, -8, 20, 42, 1]), + (int, Fraction(60), 8)) + self.assertEqual(self.func([4, 2, 3, -8, 7], 1000), + (int, Fraction(1008), 5)) def test_floats(self): - self.assertEqual(self.func([0.25]*20), 5.0) - self.assertEqual(self.func([0.125, 0.25, 0.5, 0.75], 1.5), 3.125) + self.assertEqual(self.func([0.25]*20), + (float, Fraction(5.0), 20)) + self.assertEqual(self.func([0.125, 0.25, 0.5, 0.75], 1.5), + (float, Fraction(3.125), 4)) def test_fractions(self): - F = Fraction - self.assertEqual(self.func([Fraction(1, 1000)]*500), Fraction(1, 2)) + self.assertEqual(self.func([Fraction(1, 1000)]*500), + (Fraction, Fraction(1, 2), 500)) def test_decimals(self): D = Decimal data = [D("0.001"), D("5.246"), D("1.702"), D("-0.025"), D("3.974"), D("2.328"), D("4.617"), D("2.843"), ] - self.assertEqual(self.func(data), Decimal("20.686")) + self.assertEqual(self.func(data), + (Decimal, Decimal("20.686"), 8)) def test_compare_with_math_fsum(self): # Compare with the math.fsum function. # Ideally we ought to get the exact same result, but sometimes # we differ by a very slight amount :-( data = [random.uniform(-100, 1000) for _ in range(1000)] - self.assertApproxEqual(self.func(data), math.fsum(data), rel=2e-16) + self.assertApproxEqual(float(self.func(data)[1]), math.fsum(data), rel=2e-16) def test_start_argument(self): # Test that the optional start argument works correctly. data = [random.uniform(1, 1000) for _ in range(100)] - t = self.func(data) - self.assertEqual(t+42, self.func(data, 42)) - self.assertEqual(t-23, self.func(data, -23)) - self.assertEqual(t+1e20, self.func(data, 1e20)) + t = self.func(data)[1] + self.assertEqual(t+42, self.func(data, 42)[1]) + self.assertEqual(t-23, self.func(data, -23)[1]) + self.assertEqual(t+Fraction(1e20), self.func(data, 1e20)[1]) def test_strings_fail(self): # Sum of strings should fail. @@ -934,7 +1185,7 @@ def test_mixed_sum(self): # Mixed input types are not (currently) allowed. # Check that mixed data types fail. - self.assertRaises(TypeError, self.func, [1, 2.0, Fraction(1, 2)]) + self.assertRaises(TypeError, self.func, [1, 2.0, Decimal(1)]) # And so does mixed start argument. self.assertRaises(TypeError, self.func, [1, 2.0], Decimal(1)) @@ -942,11 +1193,14 @@ class SumTortureTest(NumericTestCase): def test_torture(self): # Tim Peters' torture test for sum, and variants of same. - self.assertEqual(statistics._sum([1, 1e100, 1, -1e100]*10000), 20000.0) - self.assertEqual(statistics._sum([1e100, 1, 1, -1e100]*10000), 20000.0) - self.assertApproxEqual( - statistics._sum([1e-100, 1, 1e-100, -1]*10000), 2.0e-96, rel=5e-16 - ) + self.assertEqual(statistics._sum([1, 1e100, 1, -1e100]*10000), + (float, Fraction(20000.0), 40000)) + self.assertEqual(statistics._sum([1e100, 1, 1, -1e100]*10000), + (float, Fraction(20000.0), 40000)) + T, num, count = statistics._sum([1e-100, 1, 1e-100, -1]*10000) + self.assertIs(T, float) + self.assertEqual(count, 40000) + self.assertApproxEqual(float(num), 2.0e-96, rel=5e-16) class SumSpecialValues(NumericTestCase): @@ -955,7 +1209,7 @@ def test_nan(self): for type_ in (float, Decimal): nan = type_('nan') - result = statistics._sum([1, nan, 2]) + result = statistics._sum([1, nan, 2])[1] self.assertIs(type(result), type_) self.assertTrue(math.isnan(result)) @@ -968,10 +1222,10 @@ def do_test_inf(self, inf): # Adding a single infinity gives infinity. - result = statistics._sum([1, 2, inf, 3]) + result = statistics._sum([1, 2, inf, 3])[1] self.check_infinity(result, inf) # Adding two infinities of the same sign also gives infinity. - result = statistics._sum([1, 2, inf, 3, inf, 4]) + result = statistics._sum([1, 2, inf, 3, inf, 4])[1] self.check_infinity(result, inf) def test_float_inf(self): @@ -987,7 +1241,7 @@ def test_float_mismatched_infs(self): # Test that adding two infinities of opposite sign gives a NAN. inf = float('inf') - result = statistics._sum([1, 2, inf, 3, -inf, 4]) + result = statistics._sum([1, 2, inf, 3, -inf, 4])[1] self.assertTrue(math.isnan(result)) def test_decimal_extendedcontext_mismatched_infs_to_nan(self): @@ -995,7 +1249,7 @@ inf = Decimal('inf') data = [1, 2, inf, 3, -inf, 4] with decimal.localcontext(decimal.ExtendedContext): - self.assertTrue(math.isnan(statistics._sum(data))) + self.assertTrue(math.isnan(statistics._sum(data)[1])) def test_decimal_basiccontext_mismatched_infs_to_nan(self): # Test adding Decimal INFs with opposite sign raises InvalidOperation. @@ -1111,6 +1365,19 @@ d = Decimal('1e4') self.assertEqual(statistics.mean([d]), d) + def test_regression_25177(self): + # Regression test for issue 25177. + # Ensure very big and very small floats don't overflow. + # See http://bugs.python.org/issue25177. + self.assertEqual(statistics.mean( + [8.988465674311579e+307, 8.98846567431158e+307]), + 8.98846567431158e+307) + big = 8.98846567431158e+307 + tiny = 5e-324 + for n in (2, 3, 5, 200): + self.assertEqual(statistics.mean([big]*n), big) + self.assertEqual(statistics.mean([tiny]*n), tiny) + class TestMedian(NumericTestCase, AverageMixin): # Common tests for median and all median.* functions. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -113,6 +113,10 @@ Library ------- +- Issue #25177: Fixed problem with the mean of very small and very large + numbers. As a side effect, statistics.mean and statistics.variance should + be significantly faster. + - Issue #25718: Fixed copying object with state with boolean value is false. - Issue #10131: Fixed deep copying of minidom documents. Based on patch -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 1 09:11:16 2015 From: python-checkins at python.org (steven.daprano) Date: Tue, 01 Dec 2015 14:11:16 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325177=3A_Fixed_pr?= =?utf-8?q?oblem_with_the_mean_of_very_small_and_very_large_numbers=2E?= Message-ID: <20151201141110.81854.94143@psf.io> https://hg.python.org/cpython/rev/0eeb39fc8ff5 changeset: 99408:0eeb39fc8ff5 parent: 99405:734247d5d0f9 user: Steven D'Aprano date: Tue Dec 01 19:59:53 2015 +1100 summary: Issue #25177: Fixed problem with the mean of very small and very large numbers. files: Lib/statistics.py | 181 +++++++---- Lib/test/test_statistics.py | 363 ++++++++++++++++++++--- Misc/NEWS | 4 + 3 files changed, 431 insertions(+), 117 deletions(-) diff --git a/Lib/statistics.py b/Lib/statistics.py --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -104,6 +104,8 @@ from fractions import Fraction from decimal import Decimal +from itertools import groupby + # === Exceptions === @@ -115,86 +117,102 @@ # === Private utilities === def _sum(data, start=0): - """_sum(data [, start]) -> value + """_sum(data [, start]) -> (type, sum, count) - Return a high-precision sum of the given numeric data. If optional - argument ``start`` is given, it is added to the total. If ``data`` is - empty, ``start`` (defaulting to 0) is returned. + Return a high-precision sum of the given numeric data as a fraction, + together with the type to be converted to and the count of items. + + If optional argument ``start`` is given, it is added to the total. + If ``data`` is empty, ``start`` (defaulting to 0) is returned. Examples -------- >>> _sum([3, 2.25, 4.5, -0.5, 1.0], 0.75) - 11.0 + (, Fraction(11, 1), 5) Some sources of round-off error will be avoided: >>> _sum([1e50, 1, -1e50] * 1000) # Built-in sum returns zero. - 1000.0 + (, Fraction(1000, 1), 3000) Fractions and Decimals are also supported: >>> from fractions import Fraction as F >>> _sum([F(2, 3), F(7, 5), F(1, 4), F(5, 6)]) - Fraction(63, 20) + (, Fraction(63, 20), 4) >>> from decimal import Decimal as D >>> data = [D("0.1375"), D("0.2108"), D("0.3061"), D("0.0419")] >>> _sum(data) - Decimal('0.6963') + (, Fraction(6963, 10000), 4) Mixed types are currently treated as an error, except that int is allowed. """ - # We fail as soon as we reach a value that is not an int or the type of - # the first value which is not an int. E.g. _sum([int, int, float, int]) - # is okay, but sum([int, int, float, Fraction]) is not. - allowed_types = {int, type(start)} + count = 0 n, d = _exact_ratio(start) - partials = {d: n} # map {denominator: sum of numerators} - # Micro-optimizations. - exact_ratio = _exact_ratio + partials = {d: n} partials_get = partials.get - # Add numerators for each denominator. - for x in data: - _check_type(type(x), allowed_types) - n, d = exact_ratio(x) - partials[d] = partials_get(d, 0) + n - # Find the expected result type. If allowed_types has only one item, it - # will be int; if it has two, use the one which isn't int. - assert len(allowed_types) in (1, 2) - if len(allowed_types) == 1: - assert allowed_types.pop() is int - T = int + T = _coerce(int, type(start)) + for typ, values in groupby(data, type): + T = _coerce(T, typ) # or raise TypeError + for n,d in map(_exact_ratio, values): + count += 1 + partials[d] = partials_get(d, 0) + n + if None in partials: + # The sum will be a NAN or INF. We can ignore all the finite + # partials, and just look at this special one. + total = partials[None] + assert not _isfinite(total) else: - T = (allowed_types - {int}).pop() - if None in partials: - assert issubclass(T, (float, Decimal)) - assert not math.isfinite(partials[None]) - return T(partials[None]) - total = Fraction() - for d, n in sorted(partials.items()): - total += Fraction(n, d) - if issubclass(T, int): - assert total.denominator == 1 - return T(total.numerator) - if issubclass(T, Decimal): - return T(total.numerator)/total.denominator - return T(total) + # Sum all the partial sums using builtin sum. + # FIXME is this faster if we sum them in order of the denominator? + total = sum(Fraction(n, d) for d, n in sorted(partials.items())) + return (T, total, count) -def _check_type(T, allowed): - if T not in allowed: - if len(allowed) == 1: - allowed.add(T) - else: - types = ', '.join([t.__name__ for t in allowed] + [T.__name__]) - raise TypeError("unsupported mixed types: %s" % types) +def _isfinite(x): + try: + return x.is_finite() # Likely a Decimal. + except AttributeError: + return math.isfinite(x) # Coerces to float first. + + +def _coerce(T, S): + """Coerce types T and S to a common type, or raise TypeError. + + Coercion rules are currently an implementation detail. See the CoerceTest + test class in test_statistics for details. + """ + # See http://bugs.python.org/issue24068. + assert T is not bool, "initial type T is bool" + # If the types are the same, no need to coerce anything. Put this + # first, so that the usual case (no coercion needed) happens as soon + # as possible. + if T is S: return T + # Mixed int & other coerce to the other type. + if S is int or S is bool: return T + if T is int: return S + # If one is a (strict) subclass of the other, coerce to the subclass. + if issubclass(S, T): return S + if issubclass(T, S): return T + # Ints coerce to the other type. + if issubclass(T, int): return S + if issubclass(S, int): return T + # Mixed fraction & float coerces to float (or float subclass). + if issubclass(T, Fraction) and issubclass(S, float): + return S + if issubclass(T, float) and issubclass(S, Fraction): + return T + # Any other combination is disallowed. + msg = "don't know how to coerce %s and %s" + raise TypeError(msg % (T.__name__, S.__name__)) def _exact_ratio(x): - """Convert Real number x exactly to (numerator, denominator) pair. + """Return Real number x to exact (numerator, denominator) pair. >>> _exact_ratio(0.25) (1, 4) @@ -202,29 +220,31 @@ x is expected to be an int, Fraction, Decimal or float. """ try: + # Optimise the common case of floats. We expect that the most often + # used numeric type will be builtin floats, so try to make this as + # fast as possible. + if type(x) is float: + return x.as_integer_ratio() try: - # int, Fraction + # x may be an int, Fraction, or Integral ABC. return (x.numerator, x.denominator) except AttributeError: - # float try: + # x may be a float subclass. return x.as_integer_ratio() except AttributeError: - # Decimal try: + # x may be a Decimal. return _decimal_to_ratio(x) except AttributeError: - msg = "can't convert type '{}' to numerator/denominator" - raise TypeError(msg.format(type(x).__name__)) from None + # Just give up? + pass except (OverflowError, ValueError): - # INF or NAN - if __debug__: - # Decimal signalling NANs cannot be converted to float :-( - if isinstance(x, Decimal): - assert not x.is_finite() - else: - assert not math.isfinite(x) + # float NAN or INF. + assert not math.isfinite(x) return (x, None) + msg = "can't convert type '{}' to numerator/denominator" + raise TypeError(msg.format(type(x).__name__)) # FIXME This is faster than Fraction.from_decimal, but still too slow. @@ -239,7 +259,7 @@ sign, digits, exp = d.as_tuple() if exp in ('F', 'n', 'N'): # INF, NAN, sNAN assert not d.is_finite() - raise ValueError + return (d, None) num = 0 for digit in digits: num = num*10 + digit @@ -253,6 +273,24 @@ return (num, den) +def _convert(value, T): + """Convert value to given numeric type T.""" + if type(value) is T: + # This covers the cases where T is Fraction, or where value is + # a NAN or INF (Decimal or float). + return value + if issubclass(T, int) and value.denominator != 1: + T = float + try: + # FIXME: what do we do if this overflows? + return T(value) + except TypeError: + if issubclass(T, Decimal): + return T(value.numerator)/T(value.denominator) + else: + raise + + def _counts(data): # Generate a table of sorted (value, frequency) pairs. table = collections.Counter(iter(data)).most_common() @@ -290,7 +328,9 @@ n = len(data) if n < 1: raise StatisticsError('mean requires at least one data point') - return _sum(data)/n + T, total, count = _sum(data) + assert count == n + return _convert(total/n, T) # FIXME: investigate ways to calculate medians without sorting? Quickselect? @@ -460,12 +500,14 @@ """ if c is None: c = mean(data) - ss = _sum((x-c)**2 for x in data) + T, total, count = _sum((x-c)**2 for x in data) # The following sum should mathematically equal zero, but due to rounding # error may not. - ss -= _sum((x-c) for x in data)**2/len(data) - assert not ss < 0, 'negative sum of square deviations: %f' % ss - return ss + U, total2, count2 = _sum((x-c) for x in data) + assert T == U and count == count2 + total -= total2**2/len(data) + assert not total < 0, 'negative sum of square deviations: %f' % total + return (T, total) def variance(data, xbar=None): @@ -511,8 +553,8 @@ n = len(data) if n < 2: raise StatisticsError('variance requires at least two data points') - ss = _ss(data, xbar) - return ss/(n-1) + T, ss = _ss(data, xbar) + return _convert(ss/(n-1), T) def pvariance(data, mu=None): @@ -560,7 +602,8 @@ if n < 1: raise StatisticsError('pvariance requires at least one data point') ss = _ss(data, mu) - return ss/n + T, ss = _ss(data, mu) + return _convert(ss/n, T) def stdev(data, xbar=None): diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -21,6 +21,37 @@ # === Helper functions and class === +def _nan_equal(a, b): + """Return True if a and b are both the same kind of NAN. + + >>> _nan_equal(Decimal('NAN'), Decimal('NAN')) + True + >>> _nan_equal(Decimal('sNAN'), Decimal('sNAN')) + True + >>> _nan_equal(Decimal('NAN'), Decimal('sNAN')) + False + >>> _nan_equal(Decimal(42), Decimal('NAN')) + False + + >>> _nan_equal(float('NAN'), float('NAN')) + True + >>> _nan_equal(float('NAN'), 0.5) + False + + >>> _nan_equal(float('NAN'), Decimal('NAN')) + False + + NAN payloads are not compared. + """ + if type(a) is not type(b): + return False + if isinstance(a, float): + return math.isnan(a) and math.isnan(b) + aexp = a.as_tuple()[2] + bexp = b.as_tuple()[2] + return (aexp == bexp) and (aexp in ('n', 'N')) # Both NAN or both sNAN. + + def _calc_errors(actual, expected): """Return the absolute and relative errors between two numbers. @@ -675,15 +706,60 @@ self.assertEqual(_exact_ratio(D("12.345")), (12345, 1000)) self.assertEqual(_exact_ratio(D("-1.98")), (-198, 100)) + def test_inf(self): + INF = float("INF") + class MyFloat(float): + pass + class MyDecimal(Decimal): + pass + for inf in (INF, -INF): + for type_ in (float, MyFloat, Decimal, MyDecimal): + x = type_(inf) + ratio = statistics._exact_ratio(x) + self.assertEqual(ratio, (x, None)) + self.assertEqual(type(ratio[0]), type_) + self.assertTrue(math.isinf(ratio[0])) + + def test_float_nan(self): + NAN = float("NAN") + class MyFloat(float): + pass + for nan in (NAN, MyFloat(NAN)): + ratio = statistics._exact_ratio(nan) + self.assertTrue(math.isnan(ratio[0])) + self.assertIs(ratio[1], None) + self.assertEqual(type(ratio[0]), type(nan)) + + def test_decimal_nan(self): + NAN = Decimal("NAN") + sNAN = Decimal("sNAN") + class MyDecimal(Decimal): + pass + for nan in (NAN, MyDecimal(NAN), sNAN, MyDecimal(sNAN)): + ratio = statistics._exact_ratio(nan) + self.assertTrue(_nan_equal(ratio[0], nan)) + self.assertIs(ratio[1], None) + self.assertEqual(type(ratio[0]), type(nan)) + class DecimalToRatioTest(unittest.TestCase): # Test _decimal_to_ratio private function. - def testSpecialsRaise(self): - # Test that NANs and INFs raise ValueError. - # Non-special values are covered by _exact_ratio above. - for d in (Decimal('NAN'), Decimal('sNAN'), Decimal('INF')): - self.assertRaises(ValueError, statistics._decimal_to_ratio, d) + def test_infinity(self): + # Test that INFs are handled correctly. + inf = Decimal('INF') + self.assertEqual(statistics._decimal_to_ratio(inf), (inf, None)) + self.assertEqual(statistics._decimal_to_ratio(-inf), (-inf, None)) + + def test_nan(self): + # Test that NANs are handled correctly. + for nan in (Decimal('NAN'), Decimal('sNAN')): + num, den = statistics._decimal_to_ratio(nan) + # Because NANs always compare non-equal, we cannot use assertEqual. + # Nor can we use an identity test, as we don't guarantee anything + # about the object identity. + self.assertTrue(_nan_equal(num, nan)) + self.assertIs(den, None) def test_sign(self): # Test sign is calculated correctly. @@ -718,25 +794,181 @@ self.assertEqual(t, (147000, 1)) -class CheckTypeTest(unittest.TestCase): - # Test _check_type private function. +class IsFiniteTest(unittest.TestCase): + # Test _isfinite private function. - def test_allowed(self): - # Test that a type which should be allowed is allowed. - allowed = set([int, float]) - statistics._check_type(int, allowed) - statistics._check_type(float, allowed) + def test_finite(self): + # Test that finite numbers are recognised as finite. + for x in (5, Fraction(1, 3), 2.5, Decimal("5.5")): + self.assertTrue(statistics._isfinite(x)) - def test_not_allowed(self): - # Test that a type which should not be allowed raises. - allowed = set([int, float]) - self.assertRaises(TypeError, statistics._check_type, Decimal, allowed) + def test_infinity(self): + # Test that INFs are not recognised as finite. + for x in (float("inf"), Decimal("inf")): + self.assertFalse(statistics._isfinite(x)) - def test_add_to_allowed(self): - # Test that a second type will be added to the allowed set. - allowed = set([int]) - statistics._check_type(float, allowed) - self.assertEqual(allowed, set([int, float])) + def test_nan(self): + # Test that NANs are not recognised as finite. + for x in (float("nan"), Decimal("NAN"), Decimal("sNAN")): + self.assertFalse(statistics._isfinite(x)) + + +class CoerceTest(unittest.TestCase): + # Test that private function _coerce correctly deals with types. + + # The coercion rules are currently an implementation detail, although at + # some point that should change. The tests and comments here define the + # correct implementation. + + # Pre-conditions of _coerce: + # + # - The first time _sum calls _coerce, the + # - coerce(T, S) will never be called with bool as the first argument; + # this is a pre-condition, guarded with an assertion. + + # + # - coerce(T, T) will always return T; we assume T is a valid numeric + # type. Violate this assumption at your own risk. + # + # - Apart from as above, bool is treated as if it were actually int. + # + # - coerce(int, X) and coerce(X, int) return X. + # - + def test_bool(self): + # bool is somewhat special, due to the pre-condition that it is + # never given as the first argument to _coerce, and that it cannot + # be subclassed. So we test it specially. + for T in (int, float, Fraction, Decimal): + self.assertIs(statistics._coerce(T, bool), T) + class MyClass(T): pass + self.assertIs(statistics._coerce(MyClass, bool), MyClass) + + def assertCoerceTo(self, A, B): + """Assert that type A coerces to B.""" + self.assertIs(statistics._coerce(A, B), B) + self.assertIs(statistics._coerce(B, A), B) + + def check_coerce_to(self, A, B): + """Checks that type A coerces to B, including subclasses.""" + # Assert that type A is coerced to B. + self.assertCoerceTo(A, B) + # Subclasses of A are also coerced to B. + class SubclassOfA(A): pass + self.assertCoerceTo(SubclassOfA, B) + # A, and subclasses of A, are coerced to subclasses of B. + class SubclassOfB(B): pass + self.assertCoerceTo(A, SubclassOfB) + self.assertCoerceTo(SubclassOfA, SubclassOfB) + + def assertCoerceRaises(self, A, B): + """Assert that coercing A to B, or vice versa, raises TypeError.""" + self.assertRaises(TypeError, statistics._coerce, (A, B)) + self.assertRaises(TypeError, statistics._coerce, (B, A)) + + def check_type_coercions(self, T): + """Check that type T coerces correctly with subclasses of itself.""" + assert T is not bool + # Coercing a type with itself returns the same type. + self.assertIs(statistics._coerce(T, T), T) + # Coercing a type with a subclass of itself returns the subclass. + class U(T): pass + class V(T): pass + class W(U): pass + for typ in (U, V, W): + self.assertCoerceTo(T, typ) + self.assertCoerceTo(U, W) + # Coercing two subclasses that aren't parent/child is an error. + self.assertCoerceRaises(U, V) + self.assertCoerceRaises(V, W) + + def test_int(self): + # Check that int coerces correctly. + self.check_type_coercions(int) + for typ in (float, Fraction, Decimal): + self.check_coerce_to(int, typ) + + def test_fraction(self): + # Check that Fraction coerces correctly. + self.check_type_coercions(Fraction) + self.check_coerce_to(Fraction, float) + + def test_decimal(self): + # Check that Decimal coerces correctly. + self.check_type_coercions(Decimal) + + def test_float(self): + # Check that float coerces correctly. + self.check_type_coercions(float) + + def test_non_numeric_types(self): + for bad_type in (str, list, type(None), tuple, dict): + for good_type in (int, float, Fraction, Decimal): + self.assertCoerceRaises(good_type, bad_type) + + def test_incompatible_types(self): + # Test that incompatible types raise. + for T in (float, Fraction): + class MySubclass(T): pass + self.assertCoerceRaises(T, Decimal) + self.assertCoerceRaises(MySubclass, Decimal) + + +class ConvertTest(unittest.TestCase): + # Test private _convert function. + + def check_exact_equal(self, x, y): + """Check that x equals y, and has the same type as well.""" + self.assertEqual(x, y) + self.assertIs(type(x), type(y)) + + def test_int(self): + # Test conversions to int. + x = statistics._convert(Fraction(71), int) + self.check_exact_equal(x, 71) + class MyInt(int): pass + x = statistics._convert(Fraction(17), MyInt) + self.check_exact_equal(x, MyInt(17)) + + def test_fraction(self): + # Test conversions to Fraction. + x = statistics._convert(Fraction(95, 99), Fraction) + self.check_exact_equal(x, Fraction(95, 99)) + class MyFraction(Fraction): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(71, 13), MyFraction) + self.check_exact_equal(x, MyFraction(71, 13)) + + def test_float(self): + # Test conversions to float. + x = statistics._convert(Fraction(-1, 2), float) + self.check_exact_equal(x, -0.5) + class MyFloat(float): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(9, 8), MyFloat) + self.check_exact_equal(x, MyFloat(1.125)) + + def test_decimal(self): + # Test conversions to Decimal. + x = statistics._convert(Fraction(1, 40), Decimal) + self.check_exact_equal(x, Decimal("0.025")) + class MyDecimal(Decimal): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(-15, 16), MyDecimal) + self.check_exact_equal(x, MyDecimal("-0.9375")) + + def test_inf(self): + for INF in (float('inf'), Decimal('inf')): + for inf in (INF, -INF): + x = statistics._convert(inf, type(inf)) + self.check_exact_equal(x, inf) + + def test_nan(self): + for nan in (float('nan'), Decimal('NAN'), Decimal('sNAN')): + x = statistics._convert(nan, type(nan)) + self.assertTrue(_nan_equal(x, nan)) # === Tests for public functions === @@ -874,52 +1106,71 @@ self.assertIs(type(result), kind) -class TestSum(NumericTestCase, UnivariateCommonMixin, UnivariateTypeMixin): +class TestSumCommon(UnivariateCommonMixin, UnivariateTypeMixin): + # Common test cases for statistics._sum() function. + + # This test suite looks only at the numeric value returned by _sum, + # after conversion to the appropriate type. + def setUp(self): + def simplified_sum(*args): + T, value, n = statistics._sum(*args) + return statistics._coerce(value, T) + self.func = simplified_sum + + +class TestSum(NumericTestCase): # Test cases for statistics._sum() function. + # These tests look at the entire three value tuple returned by _sum. + def setUp(self): self.func = statistics._sum def test_empty_data(self): # Override test for empty data. for data in ([], (), iter([])): - self.assertEqual(self.func(data), 0) - self.assertEqual(self.func(data, 23), 23) - self.assertEqual(self.func(data, 2.3), 2.3) + self.assertEqual(self.func(data), (int, Fraction(0), 0)) + self.assertEqual(self.func(data, 23), (int, Fraction(23), 0)) + self.assertEqual(self.func(data, 2.3), (float, Fraction(2.3), 0)) def test_ints(self): - self.assertEqual(self.func([1, 5, 3, -4, -8, 20, 42, 1]), 60) - self.assertEqual(self.func([4, 2, 3, -8, 7], 1000), 1008) + self.assertEqual(self.func([1, 5, 3, -4, -8, 20, 42, 1]), + (int, Fraction(60), 8)) + self.assertEqual(self.func([4, 2, 3, -8, 7], 1000), + (int, Fraction(1008), 5)) def test_floats(self): - self.assertEqual(self.func([0.25]*20), 5.0) - self.assertEqual(self.func([0.125, 0.25, 0.5, 0.75], 1.5), 3.125) + self.assertEqual(self.func([0.25]*20), + (float, Fraction(5.0), 20)) + self.assertEqual(self.func([0.125, 0.25, 0.5, 0.75], 1.5), + (float, Fraction(3.125), 4)) def test_fractions(self): - F = Fraction - self.assertEqual(self.func([Fraction(1, 1000)]*500), Fraction(1, 2)) + self.assertEqual(self.func([Fraction(1, 1000)]*500), + (Fraction, Fraction(1, 2), 500)) def test_decimals(self): D = Decimal data = [D("0.001"), D("5.246"), D("1.702"), D("-0.025"), D("3.974"), D("2.328"), D("4.617"), D("2.843"), ] - self.assertEqual(self.func(data), Decimal("20.686")) + self.assertEqual(self.func(data), + (Decimal, Decimal("20.686"), 8)) def test_compare_with_math_fsum(self): # Compare with the math.fsum function. # Ideally we ought to get the exact same result, but sometimes # we differ by a very slight amount :-( data = [random.uniform(-100, 1000) for _ in range(1000)] - self.assertApproxEqual(self.func(data), math.fsum(data), rel=2e-16) + self.assertApproxEqual(float(self.func(data)[1]), math.fsum(data), rel=2e-16) def test_start_argument(self): # Test that the optional start argument works correctly. data = [random.uniform(1, 1000) for _ in range(100)] - t = self.func(data) - self.assertEqual(t+42, self.func(data, 42)) - self.assertEqual(t-23, self.func(data, -23)) - self.assertEqual(t+1e20, self.func(data, 1e20)) + t = self.func(data)[1] + self.assertEqual(t+42, self.func(data, 42)[1]) + self.assertEqual(t-23, self.func(data, -23)[1]) + self.assertEqual(t+Fraction(1e20), self.func(data, 1e20)[1]) def test_strings_fail(self): # Sum of strings should fail. @@ -934,7 +1185,7 @@ def test_mixed_sum(self): # Mixed input types are not (currently) allowed. # Check that mixed data types fail. - self.assertRaises(TypeError, self.func, [1, 2.0, Fraction(1, 2)]) + self.assertRaises(TypeError, self.func, [1, 2.0, Decimal(1)]) # And so does mixed start argument. self.assertRaises(TypeError, self.func, [1, 2.0], Decimal(1)) @@ -942,11 +1193,14 @@ class SumTortureTest(NumericTestCase): def test_torture(self): # Tim Peters' torture test for sum, and variants of same. - self.assertEqual(statistics._sum([1, 1e100, 1, -1e100]*10000), 20000.0) - self.assertEqual(statistics._sum([1e100, 1, 1, -1e100]*10000), 20000.0) - self.assertApproxEqual( - statistics._sum([1e-100, 1, 1e-100, -1]*10000), 2.0e-96, rel=5e-16 - ) + self.assertEqual(statistics._sum([1, 1e100, 1, -1e100]*10000), + (float, Fraction(20000.0), 40000)) + self.assertEqual(statistics._sum([1e100, 1, 1, -1e100]*10000), + (float, Fraction(20000.0), 40000)) + T, num, count = statistics._sum([1e-100, 1, 1e-100, -1]*10000) + self.assertIs(T, float) + self.assertEqual(count, 40000) + self.assertApproxEqual(float(num), 2.0e-96, rel=5e-16) class SumSpecialValues(NumericTestCase): @@ -955,7 +1209,7 @@ def test_nan(self): for type_ in (float, Decimal): nan = type_('nan') - result = statistics._sum([1, nan, 2]) + result = statistics._sum([1, nan, 2])[1] self.assertIs(type(result), type_) self.assertTrue(math.isnan(result)) @@ -968,10 +1222,10 @@ def do_test_inf(self, inf): # Adding a single infinity gives infinity. - result = statistics._sum([1, 2, inf, 3]) + result = statistics._sum([1, 2, inf, 3])[1] self.check_infinity(result, inf) # Adding two infinities of the same sign also gives infinity. - result = statistics._sum([1, 2, inf, 3, inf, 4]) + result = statistics._sum([1, 2, inf, 3, inf, 4])[1] self.check_infinity(result, inf) def test_float_inf(self): @@ -987,7 +1241,7 @@ def test_float_mismatched_infs(self): # Test that adding two infinities of opposite sign gives a NAN. inf = float('inf') - result = statistics._sum([1, 2, inf, 3, -inf, 4]) + result = statistics._sum([1, 2, inf, 3, -inf, 4])[1] self.assertTrue(math.isnan(result)) def test_decimal_extendedcontext_mismatched_infs_to_nan(self): @@ -995,7 +1249,7 @@ inf = Decimal('inf') data = [1, 2, inf, 3, -inf, 4] with decimal.localcontext(decimal.ExtendedContext): - self.assertTrue(math.isnan(statistics._sum(data))) + self.assertTrue(math.isnan(statistics._sum(data)[1])) def test_decimal_basiccontext_mismatched_infs_to_nan(self): # Test adding Decimal INFs with opposite sign raises InvalidOperation. @@ -1111,6 +1365,19 @@ d = Decimal('1e4') self.assertEqual(statistics.mean([d]), d) + def test_regression_25177(self): + # Regression test for issue 25177. + # Ensure very big and very small floats don't overflow. + # See http://bugs.python.org/issue25177. + self.assertEqual(statistics.mean( + [8.988465674311579e+307, 8.98846567431158e+307]), + 8.98846567431158e+307) + big = 8.98846567431158e+307 + tiny = 5e-324 + for n in (2, 3, 5, 200): + self.assertEqual(statistics.mean([big]*n), big) + self.assertEqual(statistics.mean([tiny]*n), tiny) + class TestMedian(NumericTestCase, AverageMixin): # Common tests for median and all median.* functions. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -107,6 +107,10 @@ Library ------- +- Issue #25177: Fixed problem with the mean of very small and very large + numbers. As a side effect, statistics.mean and statistics.variance should + be significantly faster. + - Issue #25718: Fixed copying object with state with boolean value is false. - Issue #10131: Fixed deep copying of minidom documents. Based on patch -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 1 09:12:02 2015 From: python-checkins at python.org (steven.daprano) Date: Tue, 01 Dec 2015 14:12:02 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNCk6?= =?utf-8?q?_Merge_heads=2E?= Message-ID: <20151201141110.28224.16490@psf.io> https://hg.python.org/cpython/rev/7b5057b89a56 changeset: 99409:7b5057b89a56 branch: 3.4 parent: 99403:f475379bf22c parent: 99406:4bc9405c4f7b user: Steven D'Aprano date: Wed Dec 02 01:10:09 2015 +1100 summary: Merge heads. files: Lib/statistics.py | 181 +++++++---- Lib/test/test_statistics.py | 363 ++++++++++++++++++++--- Misc/NEWS | 4 + 3 files changed, 431 insertions(+), 117 deletions(-) diff --git a/Lib/statistics.py b/Lib/statistics.py --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -104,6 +104,8 @@ from fractions import Fraction from decimal import Decimal +from itertools import groupby + # === Exceptions === @@ -115,86 +117,102 @@ # === Private utilities === def _sum(data, start=0): - """_sum(data [, start]) -> value + """_sum(data [, start]) -> (type, sum, count) - Return a high-precision sum of the given numeric data. If optional - argument ``start`` is given, it is added to the total. If ``data`` is - empty, ``start`` (defaulting to 0) is returned. + Return a high-precision sum of the given numeric data as a fraction, + together with the type to be converted to and the count of items. + + If optional argument ``start`` is given, it is added to the total. + If ``data`` is empty, ``start`` (defaulting to 0) is returned. Examples -------- >>> _sum([3, 2.25, 4.5, -0.5, 1.0], 0.75) - 11.0 + (, Fraction(11, 1), 5) Some sources of round-off error will be avoided: >>> _sum([1e50, 1, -1e50] * 1000) # Built-in sum returns zero. - 1000.0 + (, Fraction(1000, 1), 3000) Fractions and Decimals are also supported: >>> from fractions import Fraction as F >>> _sum([F(2, 3), F(7, 5), F(1, 4), F(5, 6)]) - Fraction(63, 20) + (, Fraction(63, 20), 4) >>> from decimal import Decimal as D >>> data = [D("0.1375"), D("0.2108"), D("0.3061"), D("0.0419")] >>> _sum(data) - Decimal('0.6963') + (, Fraction(6963, 10000), 4) Mixed types are currently treated as an error, except that int is allowed. """ - # We fail as soon as we reach a value that is not an int or the type of - # the first value which is not an int. E.g. _sum([int, int, float, int]) - # is okay, but sum([int, int, float, Fraction]) is not. - allowed_types = set([int, type(start)]) + count = 0 n, d = _exact_ratio(start) - partials = {d: n} # map {denominator: sum of numerators} - # Micro-optimizations. - exact_ratio = _exact_ratio + partials = {d: n} partials_get = partials.get - # Add numerators for each denominator. - for x in data: - _check_type(type(x), allowed_types) - n, d = exact_ratio(x) - partials[d] = partials_get(d, 0) + n - # Find the expected result type. If allowed_types has only one item, it - # will be int; if it has two, use the one which isn't int. - assert len(allowed_types) in (1, 2) - if len(allowed_types) == 1: - assert allowed_types.pop() is int - T = int + T = _coerce(int, type(start)) + for typ, values in groupby(data, type): + T = _coerce(T, typ) # or raise TypeError + for n,d in map(_exact_ratio, values): + count += 1 + partials[d] = partials_get(d, 0) + n + if None in partials: + # The sum will be a NAN or INF. We can ignore all the finite + # partials, and just look at this special one. + total = partials[None] + assert not _isfinite(total) else: - T = (allowed_types - set([int])).pop() - if None in partials: - assert issubclass(T, (float, Decimal)) - assert not math.isfinite(partials[None]) - return T(partials[None]) - total = Fraction() - for d, n in sorted(partials.items()): - total += Fraction(n, d) - if issubclass(T, int): - assert total.denominator == 1 - return T(total.numerator) - if issubclass(T, Decimal): - return T(total.numerator)/total.denominator - return T(total) + # Sum all the partial sums using builtin sum. + # FIXME is this faster if we sum them in order of the denominator? + total = sum(Fraction(n, d) for d, n in sorted(partials.items())) + return (T, total, count) -def _check_type(T, allowed): - if T not in allowed: - if len(allowed) == 1: - allowed.add(T) - else: - types = ', '.join([t.__name__ for t in allowed] + [T.__name__]) - raise TypeError("unsupported mixed types: %s" % types) +def _isfinite(x): + try: + return x.is_finite() # Likely a Decimal. + except AttributeError: + return math.isfinite(x) # Coerces to float first. + + +def _coerce(T, S): + """Coerce types T and S to a common type, or raise TypeError. + + Coercion rules are currently an implementation detail. See the CoerceTest + test class in test_statistics for details. + """ + # See http://bugs.python.org/issue24068. + assert T is not bool, "initial type T is bool" + # If the types are the same, no need to coerce anything. Put this + # first, so that the usual case (no coercion needed) happens as soon + # as possible. + if T is S: return T + # Mixed int & other coerce to the other type. + if S is int or S is bool: return T + if T is int: return S + # If one is a (strict) subclass of the other, coerce to the subclass. + if issubclass(S, T): return S + if issubclass(T, S): return T + # Ints coerce to the other type. + if issubclass(T, int): return S + if issubclass(S, int): return T + # Mixed fraction & float coerces to float (or float subclass). + if issubclass(T, Fraction) and issubclass(S, float): + return S + if issubclass(T, float) and issubclass(S, Fraction): + return T + # Any other combination is disallowed. + msg = "don't know how to coerce %s and %s" + raise TypeError(msg % (T.__name__, S.__name__)) def _exact_ratio(x): - """Convert Real number x exactly to (numerator, denominator) pair. + """Return Real number x to exact (numerator, denominator) pair. >>> _exact_ratio(0.25) (1, 4) @@ -202,29 +220,31 @@ x is expected to be an int, Fraction, Decimal or float. """ try: + # Optimise the common case of floats. We expect that the most often + # used numeric type will be builtin floats, so try to make this as + # fast as possible. + if type(x) is float: + return x.as_integer_ratio() try: - # int, Fraction + # x may be an int, Fraction, or Integral ABC. return (x.numerator, x.denominator) except AttributeError: - # float try: + # x may be a float subclass. return x.as_integer_ratio() except AttributeError: - # Decimal try: + # x may be a Decimal. return _decimal_to_ratio(x) except AttributeError: - msg = "can't convert type '{}' to numerator/denominator" - raise TypeError(msg.format(type(x).__name__)) from None + # Just give up? + pass except (OverflowError, ValueError): - # INF or NAN - if __debug__: - # Decimal signalling NANs cannot be converted to float :-( - if isinstance(x, Decimal): - assert not x.is_finite() - else: - assert not math.isfinite(x) + # float NAN or INF. + assert not math.isfinite(x) return (x, None) + msg = "can't convert type '{}' to numerator/denominator" + raise TypeError(msg.format(type(x).__name__)) # FIXME This is faster than Fraction.from_decimal, but still too slow. @@ -239,7 +259,7 @@ sign, digits, exp = d.as_tuple() if exp in ('F', 'n', 'N'): # INF, NAN, sNAN assert not d.is_finite() - raise ValueError + return (d, None) num = 0 for digit in digits: num = num*10 + digit @@ -253,6 +273,24 @@ return (num, den) +def _convert(value, T): + """Convert value to given numeric type T.""" + if type(value) is T: + # This covers the cases where T is Fraction, or where value is + # a NAN or INF (Decimal or float). + return value + if issubclass(T, int) and value.denominator != 1: + T = float + try: + # FIXME: what do we do if this overflows? + return T(value) + except TypeError: + if issubclass(T, Decimal): + return T(value.numerator)/T(value.denominator) + else: + raise + + def _counts(data): # Generate a table of sorted (value, frequency) pairs. table = collections.Counter(iter(data)).most_common() @@ -290,7 +328,9 @@ n = len(data) if n < 1: raise StatisticsError('mean requires at least one data point') - return _sum(data)/n + T, total, count = _sum(data) + assert count == n + return _convert(total/n, T) # FIXME: investigate ways to calculate medians without sorting? Quickselect? @@ -460,12 +500,14 @@ """ if c is None: c = mean(data) - ss = _sum((x-c)**2 for x in data) + T, total, count = _sum((x-c)**2 for x in data) # The following sum should mathematically equal zero, but due to rounding # error may not. - ss -= _sum((x-c) for x in data)**2/len(data) - assert not ss < 0, 'negative sum of square deviations: %f' % ss - return ss + U, total2, count2 = _sum((x-c) for x in data) + assert T == U and count == count2 + total -= total2**2/len(data) + assert not total < 0, 'negative sum of square deviations: %f' % total + return (T, total) def variance(data, xbar=None): @@ -511,8 +553,8 @@ n = len(data) if n < 2: raise StatisticsError('variance requires at least two data points') - ss = _ss(data, xbar) - return ss/(n-1) + T, ss = _ss(data, xbar) + return _convert(ss/(n-1), T) def pvariance(data, mu=None): @@ -560,7 +602,8 @@ if n < 1: raise StatisticsError('pvariance requires at least one data point') ss = _ss(data, mu) - return ss/n + T, ss = _ss(data, mu) + return _convert(ss/n, T) def stdev(data, xbar=None): diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -21,6 +21,37 @@ # === Helper functions and class === +def _nan_equal(a, b): + """Return True if a and b are both the same kind of NAN. + + >>> _nan_equal(Decimal('NAN'), Decimal('NAN')) + True + >>> _nan_equal(Decimal('sNAN'), Decimal('sNAN')) + True + >>> _nan_equal(Decimal('NAN'), Decimal('sNAN')) + False + >>> _nan_equal(Decimal(42), Decimal('NAN')) + False + + >>> _nan_equal(float('NAN'), float('NAN')) + True + >>> _nan_equal(float('NAN'), 0.5) + False + + >>> _nan_equal(float('NAN'), Decimal('NAN')) + False + + NAN payloads are not compared. + """ + if type(a) is not type(b): + return False + if isinstance(a, float): + return math.isnan(a) and math.isnan(b) + aexp = a.as_tuple()[2] + bexp = b.as_tuple()[2] + return (aexp == bexp) and (aexp in ('n', 'N')) # Both NAN or both sNAN. + + def _calc_errors(actual, expected): """Return the absolute and relative errors between two numbers. @@ -675,15 +706,60 @@ self.assertEqual(_exact_ratio(D("12.345")), (12345, 1000)) self.assertEqual(_exact_ratio(D("-1.98")), (-198, 100)) + def test_inf(self): + INF = float("INF") + class MyFloat(float): + pass + class MyDecimal(Decimal): + pass + for inf in (INF, -INF): + for type_ in (float, MyFloat, Decimal, MyDecimal): + x = type_(inf) + ratio = statistics._exact_ratio(x) + self.assertEqual(ratio, (x, None)) + self.assertEqual(type(ratio[0]), type_) + self.assertTrue(math.isinf(ratio[0])) + + def test_float_nan(self): + NAN = float("NAN") + class MyFloat(float): + pass + for nan in (NAN, MyFloat(NAN)): + ratio = statistics._exact_ratio(nan) + self.assertTrue(math.isnan(ratio[0])) + self.assertIs(ratio[1], None) + self.assertEqual(type(ratio[0]), type(nan)) + + def test_decimal_nan(self): + NAN = Decimal("NAN") + sNAN = Decimal("sNAN") + class MyDecimal(Decimal): + pass + for nan in (NAN, MyDecimal(NAN), sNAN, MyDecimal(sNAN)): + ratio = statistics._exact_ratio(nan) + self.assertTrue(_nan_equal(ratio[0], nan)) + self.assertIs(ratio[1], None) + self.assertEqual(type(ratio[0]), type(nan)) + class DecimalToRatioTest(unittest.TestCase): # Test _decimal_to_ratio private function. - def testSpecialsRaise(self): - # Test that NANs and INFs raise ValueError. - # Non-special values are covered by _exact_ratio above. - for d in (Decimal('NAN'), Decimal('sNAN'), Decimal('INF')): - self.assertRaises(ValueError, statistics._decimal_to_ratio, d) + def test_infinity(self): + # Test that INFs are handled correctly. + inf = Decimal('INF') + self.assertEqual(statistics._decimal_to_ratio(inf), (inf, None)) + self.assertEqual(statistics._decimal_to_ratio(-inf), (-inf, None)) + + def test_nan(self): + # Test that NANs are handled correctly. + for nan in (Decimal('NAN'), Decimal('sNAN')): + num, den = statistics._decimal_to_ratio(nan) + # Because NANs always compare non-equal, we cannot use assertEqual. + # Nor can we use an identity test, as we don't guarantee anything + # about the object identity. + self.assertTrue(_nan_equal(num, nan)) + self.assertIs(den, None) def test_sign(self): # Test sign is calculated correctly. @@ -718,25 +794,181 @@ self.assertEqual(t, (147000, 1)) -class CheckTypeTest(unittest.TestCase): - # Test _check_type private function. +class IsFiniteTest(unittest.TestCase): + # Test _isfinite private function. - def test_allowed(self): - # Test that a type which should be allowed is allowed. - allowed = set([int, float]) - statistics._check_type(int, allowed) - statistics._check_type(float, allowed) + def test_finite(self): + # Test that finite numbers are recognised as finite. + for x in (5, Fraction(1, 3), 2.5, Decimal("5.5")): + self.assertTrue(statistics._isfinite(x)) - def test_not_allowed(self): - # Test that a type which should not be allowed raises. - allowed = set([int, float]) - self.assertRaises(TypeError, statistics._check_type, Decimal, allowed) + def test_infinity(self): + # Test that INFs are not recognised as finite. + for x in (float("inf"), Decimal("inf")): + self.assertFalse(statistics._isfinite(x)) - def test_add_to_allowed(self): - # Test that a second type will be added to the allowed set. - allowed = set([int]) - statistics._check_type(float, allowed) - self.assertEqual(allowed, set([int, float])) + def test_nan(self): + # Test that NANs are not recognised as finite. + for x in (float("nan"), Decimal("NAN"), Decimal("sNAN")): + self.assertFalse(statistics._isfinite(x)) + + +class CoerceTest(unittest.TestCase): + # Test that private function _coerce correctly deals with types. + + # The coercion rules are currently an implementation detail, although at + # some point that should change. The tests and comments here define the + # correct implementation. + + # Pre-conditions of _coerce: + # + # - The first time _sum calls _coerce, the + # - coerce(T, S) will never be called with bool as the first argument; + # this is a pre-condition, guarded with an assertion. + + # + # - coerce(T, T) will always return T; we assume T is a valid numeric + # type. Violate this assumption at your own risk. + # + # - Apart from as above, bool is treated as if it were actually int. + # + # - coerce(int, X) and coerce(X, int) return X. + # - + def test_bool(self): + # bool is somewhat special, due to the pre-condition that it is + # never given as the first argument to _coerce, and that it cannot + # be subclassed. So we test it specially. + for T in (int, float, Fraction, Decimal): + self.assertIs(statistics._coerce(T, bool), T) + class MyClass(T): pass + self.assertIs(statistics._coerce(MyClass, bool), MyClass) + + def assertCoerceTo(self, A, B): + """Assert that type A coerces to B.""" + self.assertIs(statistics._coerce(A, B), B) + self.assertIs(statistics._coerce(B, A), B) + + def check_coerce_to(self, A, B): + """Checks that type A coerces to B, including subclasses.""" + # Assert that type A is coerced to B. + self.assertCoerceTo(A, B) + # Subclasses of A are also coerced to B. + class SubclassOfA(A): pass + self.assertCoerceTo(SubclassOfA, B) + # A, and subclasses of A, are coerced to subclasses of B. + class SubclassOfB(B): pass + self.assertCoerceTo(A, SubclassOfB) + self.assertCoerceTo(SubclassOfA, SubclassOfB) + + def assertCoerceRaises(self, A, B): + """Assert that coercing A to B, or vice versa, raises TypeError.""" + self.assertRaises(TypeError, statistics._coerce, (A, B)) + self.assertRaises(TypeError, statistics._coerce, (B, A)) + + def check_type_coercions(self, T): + """Check that type T coerces correctly with subclasses of itself.""" + assert T is not bool + # Coercing a type with itself returns the same type. + self.assertIs(statistics._coerce(T, T), T) + # Coercing a type with a subclass of itself returns the subclass. + class U(T): pass + class V(T): pass + class W(U): pass + for typ in (U, V, W): + self.assertCoerceTo(T, typ) + self.assertCoerceTo(U, W) + # Coercing two subclasses that aren't parent/child is an error. + self.assertCoerceRaises(U, V) + self.assertCoerceRaises(V, W) + + def test_int(self): + # Check that int coerces correctly. + self.check_type_coercions(int) + for typ in (float, Fraction, Decimal): + self.check_coerce_to(int, typ) + + def test_fraction(self): + # Check that Fraction coerces correctly. + self.check_type_coercions(Fraction) + self.check_coerce_to(Fraction, float) + + def test_decimal(self): + # Check that Decimal coerces correctly. + self.check_type_coercions(Decimal) + + def test_float(self): + # Check that float coerces correctly. + self.check_type_coercions(float) + + def test_non_numeric_types(self): + for bad_type in (str, list, type(None), tuple, dict): + for good_type in (int, float, Fraction, Decimal): + self.assertCoerceRaises(good_type, bad_type) + + def test_incompatible_types(self): + # Test that incompatible types raise. + for T in (float, Fraction): + class MySubclass(T): pass + self.assertCoerceRaises(T, Decimal) + self.assertCoerceRaises(MySubclass, Decimal) + + +class ConvertTest(unittest.TestCase): + # Test private _convert function. + + def check_exact_equal(self, x, y): + """Check that x equals y, and has the same type as well.""" + self.assertEqual(x, y) + self.assertIs(type(x), type(y)) + + def test_int(self): + # Test conversions to int. + x = statistics._convert(Fraction(71), int) + self.check_exact_equal(x, 71) + class MyInt(int): pass + x = statistics._convert(Fraction(17), MyInt) + self.check_exact_equal(x, MyInt(17)) + + def test_fraction(self): + # Test conversions to Fraction. + x = statistics._convert(Fraction(95, 99), Fraction) + self.check_exact_equal(x, Fraction(95, 99)) + class MyFraction(Fraction): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(71, 13), MyFraction) + self.check_exact_equal(x, MyFraction(71, 13)) + + def test_float(self): + # Test conversions to float. + x = statistics._convert(Fraction(-1, 2), float) + self.check_exact_equal(x, -0.5) + class MyFloat(float): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(9, 8), MyFloat) + self.check_exact_equal(x, MyFloat(1.125)) + + def test_decimal(self): + # Test conversions to Decimal. + x = statistics._convert(Fraction(1, 40), Decimal) + self.check_exact_equal(x, Decimal("0.025")) + class MyDecimal(Decimal): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(-15, 16), MyDecimal) + self.check_exact_equal(x, MyDecimal("-0.9375")) + + def test_inf(self): + for INF in (float('inf'), Decimal('inf')): + for inf in (INF, -INF): + x = statistics._convert(inf, type(inf)) + self.check_exact_equal(x, inf) + + def test_nan(self): + for nan in (float('nan'), Decimal('NAN'), Decimal('sNAN')): + x = statistics._convert(nan, type(nan)) + self.assertTrue(_nan_equal(x, nan)) # === Tests for public functions === @@ -874,52 +1106,71 @@ self.assertIs(type(result), kind) -class TestSum(NumericTestCase, UnivariateCommonMixin, UnivariateTypeMixin): +class TestSumCommon(UnivariateCommonMixin, UnivariateTypeMixin): + # Common test cases for statistics._sum() function. + + # This test suite looks only at the numeric value returned by _sum, + # after conversion to the appropriate type. + def setUp(self): + def simplified_sum(*args): + T, value, n = statistics._sum(*args) + return statistics._coerce(value, T) + self.func = simplified_sum + + +class TestSum(NumericTestCase): # Test cases for statistics._sum() function. + # These tests look at the entire three value tuple returned by _sum. + def setUp(self): self.func = statistics._sum def test_empty_data(self): # Override test for empty data. for data in ([], (), iter([])): - self.assertEqual(self.func(data), 0) - self.assertEqual(self.func(data, 23), 23) - self.assertEqual(self.func(data, 2.3), 2.3) + self.assertEqual(self.func(data), (int, Fraction(0), 0)) + self.assertEqual(self.func(data, 23), (int, Fraction(23), 0)) + self.assertEqual(self.func(data, 2.3), (float, Fraction(2.3), 0)) def test_ints(self): - self.assertEqual(self.func([1, 5, 3, -4, -8, 20, 42, 1]), 60) - self.assertEqual(self.func([4, 2, 3, -8, 7], 1000), 1008) + self.assertEqual(self.func([1, 5, 3, -4, -8, 20, 42, 1]), + (int, Fraction(60), 8)) + self.assertEqual(self.func([4, 2, 3, -8, 7], 1000), + (int, Fraction(1008), 5)) def test_floats(self): - self.assertEqual(self.func([0.25]*20), 5.0) - self.assertEqual(self.func([0.125, 0.25, 0.5, 0.75], 1.5), 3.125) + self.assertEqual(self.func([0.25]*20), + (float, Fraction(5.0), 20)) + self.assertEqual(self.func([0.125, 0.25, 0.5, 0.75], 1.5), + (float, Fraction(3.125), 4)) def test_fractions(self): - F = Fraction - self.assertEqual(self.func([Fraction(1, 1000)]*500), Fraction(1, 2)) + self.assertEqual(self.func([Fraction(1, 1000)]*500), + (Fraction, Fraction(1, 2), 500)) def test_decimals(self): D = Decimal data = [D("0.001"), D("5.246"), D("1.702"), D("-0.025"), D("3.974"), D("2.328"), D("4.617"), D("2.843"), ] - self.assertEqual(self.func(data), Decimal("20.686")) + self.assertEqual(self.func(data), + (Decimal, Decimal("20.686"), 8)) def test_compare_with_math_fsum(self): # Compare with the math.fsum function. # Ideally we ought to get the exact same result, but sometimes # we differ by a very slight amount :-( data = [random.uniform(-100, 1000) for _ in range(1000)] - self.assertApproxEqual(self.func(data), math.fsum(data), rel=2e-16) + self.assertApproxEqual(float(self.func(data)[1]), math.fsum(data), rel=2e-16) def test_start_argument(self): # Test that the optional start argument works correctly. data = [random.uniform(1, 1000) for _ in range(100)] - t = self.func(data) - self.assertEqual(t+42, self.func(data, 42)) - self.assertEqual(t-23, self.func(data, -23)) - self.assertEqual(t+1e20, self.func(data, 1e20)) + t = self.func(data)[1] + self.assertEqual(t+42, self.func(data, 42)[1]) + self.assertEqual(t-23, self.func(data, -23)[1]) + self.assertEqual(t+Fraction(1e20), self.func(data, 1e20)[1]) def test_strings_fail(self): # Sum of strings should fail. @@ -934,7 +1185,7 @@ def test_mixed_sum(self): # Mixed input types are not (currently) allowed. # Check that mixed data types fail. - self.assertRaises(TypeError, self.func, [1, 2.0, Fraction(1, 2)]) + self.assertRaises(TypeError, self.func, [1, 2.0, Decimal(1)]) # And so does mixed start argument. self.assertRaises(TypeError, self.func, [1, 2.0], Decimal(1)) @@ -942,11 +1193,14 @@ class SumTortureTest(NumericTestCase): def test_torture(self): # Tim Peters' torture test for sum, and variants of same. - self.assertEqual(statistics._sum([1, 1e100, 1, -1e100]*10000), 20000.0) - self.assertEqual(statistics._sum([1e100, 1, 1, -1e100]*10000), 20000.0) - self.assertApproxEqual( - statistics._sum([1e-100, 1, 1e-100, -1]*10000), 2.0e-96, rel=5e-16 - ) + self.assertEqual(statistics._sum([1, 1e100, 1, -1e100]*10000), + (float, Fraction(20000.0), 40000)) + self.assertEqual(statistics._sum([1e100, 1, 1, -1e100]*10000), + (float, Fraction(20000.0), 40000)) + T, num, count = statistics._sum([1e-100, 1, 1e-100, -1]*10000) + self.assertIs(T, float) + self.assertEqual(count, 40000) + self.assertApproxEqual(float(num), 2.0e-96, rel=5e-16) class SumSpecialValues(NumericTestCase): @@ -955,7 +1209,7 @@ def test_nan(self): for type_ in (float, Decimal): nan = type_('nan') - result = statistics._sum([1, nan, 2]) + result = statistics._sum([1, nan, 2])[1] self.assertIs(type(result), type_) self.assertTrue(math.isnan(result)) @@ -968,10 +1222,10 @@ def do_test_inf(self, inf): # Adding a single infinity gives infinity. - result = statistics._sum([1, 2, inf, 3]) + result = statistics._sum([1, 2, inf, 3])[1] self.check_infinity(result, inf) # Adding two infinities of the same sign also gives infinity. - result = statistics._sum([1, 2, inf, 3, inf, 4]) + result = statistics._sum([1, 2, inf, 3, inf, 4])[1] self.check_infinity(result, inf) def test_float_inf(self): @@ -987,7 +1241,7 @@ def test_float_mismatched_infs(self): # Test that adding two infinities of opposite sign gives a NAN. inf = float('inf') - result = statistics._sum([1, 2, inf, 3, -inf, 4]) + result = statistics._sum([1, 2, inf, 3, -inf, 4])[1] self.assertTrue(math.isnan(result)) def test_decimal_extendedcontext_mismatched_infs_to_nan(self): @@ -995,7 +1249,7 @@ inf = Decimal('inf') data = [1, 2, inf, 3, -inf, 4] with decimal.localcontext(decimal.ExtendedContext): - self.assertTrue(math.isnan(statistics._sum(data))) + self.assertTrue(math.isnan(statistics._sum(data)[1])) def test_decimal_basiccontext_mismatched_infs_to_nan(self): # Test adding Decimal INFs with opposite sign raises InvalidOperation. @@ -1111,6 +1365,19 @@ d = Decimal('1e4') self.assertEqual(statistics.mean([d]), d) + def test_regression_25177(self): + # Regression test for issue 25177. + # Ensure very big and very small floats don't overflow. + # See http://bugs.python.org/issue25177. + self.assertEqual(statistics.mean( + [8.988465674311579e+307, 8.98846567431158e+307]), + 8.98846567431158e+307) + big = 8.98846567431158e+307 + tiny = 5e-324 + for n in (2, 3, 5, 200): + self.assertEqual(statistics.mean([big]*n), big) + self.assertEqual(statistics.mean([tiny]*n), tiny) + class TestMedian(NumericTestCase, AverageMixin): # Common tests for median and all median.* functions. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -113,6 +113,10 @@ Library ------- +- Issue #25177: Fixed problem with the mean of very small and very large + numbers. As a side effect, statistics.mean and statistics.variance should + be significantly faster. + - Issue #25718: Fixed copying object with state with boolean value is false. - Issue #10131: Fixed deep copying of minidom documents. Based on patch -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 1 09:12:02 2015 From: python-checkins at python.org (steven.daprano) Date: Tue, 01 Dec 2015 14:12:02 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fixed_issue_?= =?utf-8?q?=2325177=2C_problems_with_the_mean_of_very_small_and_very_large?= =?utf-8?q?_numbers=2E?= Message-ID: <20151201141109.654.6754@psf.io> https://hg.python.org/cpython/rev/ed45a09e5a69 changeset: 99407:ed45a09e5a69 branch: 3.5 parent: 99404:fee19d2d7713 user: Steven D'Aprano date: Tue Dec 01 17:04:32 2015 +1100 summary: Fixed issue #25177, problems with the mean of very small and very large numbers. files: Lib/statistics.py | 181 +++++++---- Lib/test/test_statistics.py | 363 ++++++++++++++++++++--- Misc/NEWS | 4 + 3 files changed, 431 insertions(+), 117 deletions(-) diff --git a/Lib/statistics.py b/Lib/statistics.py --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -104,6 +104,8 @@ from fractions import Fraction from decimal import Decimal +from itertools import groupby + # === Exceptions === @@ -115,86 +117,102 @@ # === Private utilities === def _sum(data, start=0): - """_sum(data [, start]) -> value + """_sum(data [, start]) -> (type, sum, count) - Return a high-precision sum of the given numeric data. If optional - argument ``start`` is given, it is added to the total. If ``data`` is - empty, ``start`` (defaulting to 0) is returned. + Return a high-precision sum of the given numeric data as a fraction, + together with the type to be converted to and the count of items. + + If optional argument ``start`` is given, it is added to the total. + If ``data`` is empty, ``start`` (defaulting to 0) is returned. Examples -------- >>> _sum([3, 2.25, 4.5, -0.5, 1.0], 0.75) - 11.0 + (, Fraction(11, 1), 5) Some sources of round-off error will be avoided: >>> _sum([1e50, 1, -1e50] * 1000) # Built-in sum returns zero. - 1000.0 + (, Fraction(1000, 1), 3000) Fractions and Decimals are also supported: >>> from fractions import Fraction as F >>> _sum([F(2, 3), F(7, 5), F(1, 4), F(5, 6)]) - Fraction(63, 20) + (, Fraction(63, 20), 4) >>> from decimal import Decimal as D >>> data = [D("0.1375"), D("0.2108"), D("0.3061"), D("0.0419")] >>> _sum(data) - Decimal('0.6963') + (, Fraction(6963, 10000), 4) Mixed types are currently treated as an error, except that int is allowed. """ - # We fail as soon as we reach a value that is not an int or the type of - # the first value which is not an int. E.g. _sum([int, int, float, int]) - # is okay, but sum([int, int, float, Fraction]) is not. - allowed_types = {int, type(start)} + count = 0 n, d = _exact_ratio(start) - partials = {d: n} # map {denominator: sum of numerators} - # Micro-optimizations. - exact_ratio = _exact_ratio + partials = {d: n} partials_get = partials.get - # Add numerators for each denominator. - for x in data: - _check_type(type(x), allowed_types) - n, d = exact_ratio(x) - partials[d] = partials_get(d, 0) + n - # Find the expected result type. If allowed_types has only one item, it - # will be int; if it has two, use the one which isn't int. - assert len(allowed_types) in (1, 2) - if len(allowed_types) == 1: - assert allowed_types.pop() is int - T = int + T = _coerce(int, type(start)) + for typ, values in groupby(data, type): + T = _coerce(T, typ) # or raise TypeError + for n,d in map(_exact_ratio, values): + count += 1 + partials[d] = partials_get(d, 0) + n + if None in partials: + # The sum will be a NAN or INF. We can ignore all the finite + # partials, and just look at this special one. + total = partials[None] + assert not _isfinite(total) else: - T = (allowed_types - {int}).pop() - if None in partials: - assert issubclass(T, (float, Decimal)) - assert not math.isfinite(partials[None]) - return T(partials[None]) - total = Fraction() - for d, n in sorted(partials.items()): - total += Fraction(n, d) - if issubclass(T, int): - assert total.denominator == 1 - return T(total.numerator) - if issubclass(T, Decimal): - return T(total.numerator)/total.denominator - return T(total) + # Sum all the partial sums using builtin sum. + # FIXME is this faster if we sum them in order of the denominator? + total = sum(Fraction(n, d) for d, n in sorted(partials.items())) + return (T, total, count) -def _check_type(T, allowed): - if T not in allowed: - if len(allowed) == 1: - allowed.add(T) - else: - types = ', '.join([t.__name__ for t in allowed] + [T.__name__]) - raise TypeError("unsupported mixed types: %s" % types) +def _isfinite(x): + try: + return x.is_finite() # Likely a Decimal. + except AttributeError: + return math.isfinite(x) # Coerces to float first. + + +def _coerce(T, S): + """Coerce types T and S to a common type, or raise TypeError. + + Coercion rules are currently an implementation detail. See the CoerceTest + test class in test_statistics for details. + """ + # See http://bugs.python.org/issue24068. + assert T is not bool, "initial type T is bool" + # If the types are the same, no need to coerce anything. Put this + # first, so that the usual case (no coercion needed) happens as soon + # as possible. + if T is S: return T + # Mixed int & other coerce to the other type. + if S is int or S is bool: return T + if T is int: return S + # If one is a (strict) subclass of the other, coerce to the subclass. + if issubclass(S, T): return S + if issubclass(T, S): return T + # Ints coerce to the other type. + if issubclass(T, int): return S + if issubclass(S, int): return T + # Mixed fraction & float coerces to float (or float subclass). + if issubclass(T, Fraction) and issubclass(S, float): + return S + if issubclass(T, float) and issubclass(S, Fraction): + return T + # Any other combination is disallowed. + msg = "don't know how to coerce %s and %s" + raise TypeError(msg % (T.__name__, S.__name__)) def _exact_ratio(x): - """Convert Real number x exactly to (numerator, denominator) pair. + """Return Real number x to exact (numerator, denominator) pair. >>> _exact_ratio(0.25) (1, 4) @@ -202,29 +220,31 @@ x is expected to be an int, Fraction, Decimal or float. """ try: + # Optimise the common case of floats. We expect that the most often + # used numeric type will be builtin floats, so try to make this as + # fast as possible. + if type(x) is float: + return x.as_integer_ratio() try: - # int, Fraction + # x may be an int, Fraction, or Integral ABC. return (x.numerator, x.denominator) except AttributeError: - # float try: + # x may be a float subclass. return x.as_integer_ratio() except AttributeError: - # Decimal try: + # x may be a Decimal. return _decimal_to_ratio(x) except AttributeError: - msg = "can't convert type '{}' to numerator/denominator" - raise TypeError(msg.format(type(x).__name__)) from None + # Just give up? + pass except (OverflowError, ValueError): - # INF or NAN - if __debug__: - # Decimal signalling NANs cannot be converted to float :-( - if isinstance(x, Decimal): - assert not x.is_finite() - else: - assert not math.isfinite(x) + # float NAN or INF. + assert not math.isfinite(x) return (x, None) + msg = "can't convert type '{}' to numerator/denominator" + raise TypeError(msg.format(type(x).__name__)) # FIXME This is faster than Fraction.from_decimal, but still too slow. @@ -239,7 +259,7 @@ sign, digits, exp = d.as_tuple() if exp in ('F', 'n', 'N'): # INF, NAN, sNAN assert not d.is_finite() - raise ValueError + return (d, None) num = 0 for digit in digits: num = num*10 + digit @@ -253,6 +273,24 @@ return (num, den) +def _convert(value, T): + """Convert value to given numeric type T.""" + if type(value) is T: + # This covers the cases where T is Fraction, or where value is + # a NAN or INF (Decimal or float). + return value + if issubclass(T, int) and value.denominator != 1: + T = float + try: + # FIXME: what do we do if this overflows? + return T(value) + except TypeError: + if issubclass(T, Decimal): + return T(value.numerator)/T(value.denominator) + else: + raise + + def _counts(data): # Generate a table of sorted (value, frequency) pairs. table = collections.Counter(iter(data)).most_common() @@ -290,7 +328,9 @@ n = len(data) if n < 1: raise StatisticsError('mean requires at least one data point') - return _sum(data)/n + T, total, count = _sum(data) + assert count == n + return _convert(total/n, T) # FIXME: investigate ways to calculate medians without sorting? Quickselect? @@ -460,12 +500,14 @@ """ if c is None: c = mean(data) - ss = _sum((x-c)**2 for x in data) + T, total, count = _sum((x-c)**2 for x in data) # The following sum should mathematically equal zero, but due to rounding # error may not. - ss -= _sum((x-c) for x in data)**2/len(data) - assert not ss < 0, 'negative sum of square deviations: %f' % ss - return ss + U, total2, count2 = _sum((x-c) for x in data) + assert T == U and count == count2 + total -= total2**2/len(data) + assert not total < 0, 'negative sum of square deviations: %f' % total + return (T, total) def variance(data, xbar=None): @@ -511,8 +553,8 @@ n = len(data) if n < 2: raise StatisticsError('variance requires at least two data points') - ss = _ss(data, xbar) - return ss/(n-1) + T, ss = _ss(data, xbar) + return _convert(ss/(n-1), T) def pvariance(data, mu=None): @@ -560,7 +602,8 @@ if n < 1: raise StatisticsError('pvariance requires at least one data point') ss = _ss(data, mu) - return ss/n + T, ss = _ss(data, mu) + return _convert(ss/n, T) def stdev(data, xbar=None): diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -21,6 +21,37 @@ # === Helper functions and class === +def _nan_equal(a, b): + """Return True if a and b are both the same kind of NAN. + + >>> _nan_equal(Decimal('NAN'), Decimal('NAN')) + True + >>> _nan_equal(Decimal('sNAN'), Decimal('sNAN')) + True + >>> _nan_equal(Decimal('NAN'), Decimal('sNAN')) + False + >>> _nan_equal(Decimal(42), Decimal('NAN')) + False + + >>> _nan_equal(float('NAN'), float('NAN')) + True + >>> _nan_equal(float('NAN'), 0.5) + False + + >>> _nan_equal(float('NAN'), Decimal('NAN')) + False + + NAN payloads are not compared. + """ + if type(a) is not type(b): + return False + if isinstance(a, float): + return math.isnan(a) and math.isnan(b) + aexp = a.as_tuple()[2] + bexp = b.as_tuple()[2] + return (aexp == bexp) and (aexp in ('n', 'N')) # Both NAN or both sNAN. + + def _calc_errors(actual, expected): """Return the absolute and relative errors between two numbers. @@ -675,15 +706,60 @@ self.assertEqual(_exact_ratio(D("12.345")), (12345, 1000)) self.assertEqual(_exact_ratio(D("-1.98")), (-198, 100)) + def test_inf(self): + INF = float("INF") + class MyFloat(float): + pass + class MyDecimal(Decimal): + pass + for inf in (INF, -INF): + for type_ in (float, MyFloat, Decimal, MyDecimal): + x = type_(inf) + ratio = statistics._exact_ratio(x) + self.assertEqual(ratio, (x, None)) + self.assertEqual(type(ratio[0]), type_) + self.assertTrue(math.isinf(ratio[0])) + + def test_float_nan(self): + NAN = float("NAN") + class MyFloat(float): + pass + for nan in (NAN, MyFloat(NAN)): + ratio = statistics._exact_ratio(nan) + self.assertTrue(math.isnan(ratio[0])) + self.assertIs(ratio[1], None) + self.assertEqual(type(ratio[0]), type(nan)) + + def test_decimal_nan(self): + NAN = Decimal("NAN") + sNAN = Decimal("sNAN") + class MyDecimal(Decimal): + pass + for nan in (NAN, MyDecimal(NAN), sNAN, MyDecimal(sNAN)): + ratio = statistics._exact_ratio(nan) + self.assertTrue(_nan_equal(ratio[0], nan)) + self.assertIs(ratio[1], None) + self.assertEqual(type(ratio[0]), type(nan)) + class DecimalToRatioTest(unittest.TestCase): # Test _decimal_to_ratio private function. - def testSpecialsRaise(self): - # Test that NANs and INFs raise ValueError. - # Non-special values are covered by _exact_ratio above. - for d in (Decimal('NAN'), Decimal('sNAN'), Decimal('INF')): - self.assertRaises(ValueError, statistics._decimal_to_ratio, d) + def test_infinity(self): + # Test that INFs are handled correctly. + inf = Decimal('INF') + self.assertEqual(statistics._decimal_to_ratio(inf), (inf, None)) + self.assertEqual(statistics._decimal_to_ratio(-inf), (-inf, None)) + + def test_nan(self): + # Test that NANs are handled correctly. + for nan in (Decimal('NAN'), Decimal('sNAN')): + num, den = statistics._decimal_to_ratio(nan) + # Because NANs always compare non-equal, we cannot use assertEqual. + # Nor can we use an identity test, as we don't guarantee anything + # about the object identity. + self.assertTrue(_nan_equal(num, nan)) + self.assertIs(den, None) def test_sign(self): # Test sign is calculated correctly. @@ -718,25 +794,181 @@ self.assertEqual(t, (147000, 1)) -class CheckTypeTest(unittest.TestCase): - # Test _check_type private function. +class IsFiniteTest(unittest.TestCase): + # Test _isfinite private function. - def test_allowed(self): - # Test that a type which should be allowed is allowed. - allowed = set([int, float]) - statistics._check_type(int, allowed) - statistics._check_type(float, allowed) + def test_finite(self): + # Test that finite numbers are recognised as finite. + for x in (5, Fraction(1, 3), 2.5, Decimal("5.5")): + self.assertTrue(statistics._isfinite(x)) - def test_not_allowed(self): - # Test that a type which should not be allowed raises. - allowed = set([int, float]) - self.assertRaises(TypeError, statistics._check_type, Decimal, allowed) + def test_infinity(self): + # Test that INFs are not recognised as finite. + for x in (float("inf"), Decimal("inf")): + self.assertFalse(statistics._isfinite(x)) - def test_add_to_allowed(self): - # Test that a second type will be added to the allowed set. - allowed = set([int]) - statistics._check_type(float, allowed) - self.assertEqual(allowed, set([int, float])) + def test_nan(self): + # Test that NANs are not recognised as finite. + for x in (float("nan"), Decimal("NAN"), Decimal("sNAN")): + self.assertFalse(statistics._isfinite(x)) + + +class CoerceTest(unittest.TestCase): + # Test that private function _coerce correctly deals with types. + + # The coercion rules are currently an implementation detail, although at + # some point that should change. The tests and comments here define the + # correct implementation. + + # Pre-conditions of _coerce: + # + # - The first time _sum calls _coerce, the + # - coerce(T, S) will never be called with bool as the first argument; + # this is a pre-condition, guarded with an assertion. + + # + # - coerce(T, T) will always return T; we assume T is a valid numeric + # type. Violate this assumption at your own risk. + # + # - Apart from as above, bool is treated as if it were actually int. + # + # - coerce(int, X) and coerce(X, int) return X. + # - + def test_bool(self): + # bool is somewhat special, due to the pre-condition that it is + # never given as the first argument to _coerce, and that it cannot + # be subclassed. So we test it specially. + for T in (int, float, Fraction, Decimal): + self.assertIs(statistics._coerce(T, bool), T) + class MyClass(T): pass + self.assertIs(statistics._coerce(MyClass, bool), MyClass) + + def assertCoerceTo(self, A, B): + """Assert that type A coerces to B.""" + self.assertIs(statistics._coerce(A, B), B) + self.assertIs(statistics._coerce(B, A), B) + + def check_coerce_to(self, A, B): + """Checks that type A coerces to B, including subclasses.""" + # Assert that type A is coerced to B. + self.assertCoerceTo(A, B) + # Subclasses of A are also coerced to B. + class SubclassOfA(A): pass + self.assertCoerceTo(SubclassOfA, B) + # A, and subclasses of A, are coerced to subclasses of B. + class SubclassOfB(B): pass + self.assertCoerceTo(A, SubclassOfB) + self.assertCoerceTo(SubclassOfA, SubclassOfB) + + def assertCoerceRaises(self, A, B): + """Assert that coercing A to B, or vice versa, raises TypeError.""" + self.assertRaises(TypeError, statistics._coerce, (A, B)) + self.assertRaises(TypeError, statistics._coerce, (B, A)) + + def check_type_coercions(self, T): + """Check that type T coerces correctly with subclasses of itself.""" + assert T is not bool + # Coercing a type with itself returns the same type. + self.assertIs(statistics._coerce(T, T), T) + # Coercing a type with a subclass of itself returns the subclass. + class U(T): pass + class V(T): pass + class W(U): pass + for typ in (U, V, W): + self.assertCoerceTo(T, typ) + self.assertCoerceTo(U, W) + # Coercing two subclasses that aren't parent/child is an error. + self.assertCoerceRaises(U, V) + self.assertCoerceRaises(V, W) + + def test_int(self): + # Check that int coerces correctly. + self.check_type_coercions(int) + for typ in (float, Fraction, Decimal): + self.check_coerce_to(int, typ) + + def test_fraction(self): + # Check that Fraction coerces correctly. + self.check_type_coercions(Fraction) + self.check_coerce_to(Fraction, float) + + def test_decimal(self): + # Check that Decimal coerces correctly. + self.check_type_coercions(Decimal) + + def test_float(self): + # Check that float coerces correctly. + self.check_type_coercions(float) + + def test_non_numeric_types(self): + for bad_type in (str, list, type(None), tuple, dict): + for good_type in (int, float, Fraction, Decimal): + self.assertCoerceRaises(good_type, bad_type) + + def test_incompatible_types(self): + # Test that incompatible types raise. + for T in (float, Fraction): + class MySubclass(T): pass + self.assertCoerceRaises(T, Decimal) + self.assertCoerceRaises(MySubclass, Decimal) + + +class ConvertTest(unittest.TestCase): + # Test private _convert function. + + def check_exact_equal(self, x, y): + """Check that x equals y, and has the same type as well.""" + self.assertEqual(x, y) + self.assertIs(type(x), type(y)) + + def test_int(self): + # Test conversions to int. + x = statistics._convert(Fraction(71), int) + self.check_exact_equal(x, 71) + class MyInt(int): pass + x = statistics._convert(Fraction(17), MyInt) + self.check_exact_equal(x, MyInt(17)) + + def test_fraction(self): + # Test conversions to Fraction. + x = statistics._convert(Fraction(95, 99), Fraction) + self.check_exact_equal(x, Fraction(95, 99)) + class MyFraction(Fraction): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(71, 13), MyFraction) + self.check_exact_equal(x, MyFraction(71, 13)) + + def test_float(self): + # Test conversions to float. + x = statistics._convert(Fraction(-1, 2), float) + self.check_exact_equal(x, -0.5) + class MyFloat(float): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(9, 8), MyFloat) + self.check_exact_equal(x, MyFloat(1.125)) + + def test_decimal(self): + # Test conversions to Decimal. + x = statistics._convert(Fraction(1, 40), Decimal) + self.check_exact_equal(x, Decimal("0.025")) + class MyDecimal(Decimal): + def __truediv__(self, other): + return self.__class__(super().__truediv__(other)) + x = statistics._convert(Fraction(-15, 16), MyDecimal) + self.check_exact_equal(x, MyDecimal("-0.9375")) + + def test_inf(self): + for INF in (float('inf'), Decimal('inf')): + for inf in (INF, -INF): + x = statistics._convert(inf, type(inf)) + self.check_exact_equal(x, inf) + + def test_nan(self): + for nan in (float('nan'), Decimal('NAN'), Decimal('sNAN')): + x = statistics._convert(nan, type(nan)) + self.assertTrue(_nan_equal(x, nan)) # === Tests for public functions === @@ -874,52 +1106,71 @@ self.assertIs(type(result), kind) -class TestSum(NumericTestCase, UnivariateCommonMixin, UnivariateTypeMixin): +class TestSumCommon(UnivariateCommonMixin, UnivariateTypeMixin): + # Common test cases for statistics._sum() function. + + # This test suite looks only at the numeric value returned by _sum, + # after conversion to the appropriate type. + def setUp(self): + def simplified_sum(*args): + T, value, n = statistics._sum(*args) + return statistics._coerce(value, T) + self.func = simplified_sum + + +class TestSum(NumericTestCase): # Test cases for statistics._sum() function. + # These tests look at the entire three value tuple returned by _sum. + def setUp(self): self.func = statistics._sum def test_empty_data(self): # Override test for empty data. for data in ([], (), iter([])): - self.assertEqual(self.func(data), 0) - self.assertEqual(self.func(data, 23), 23) - self.assertEqual(self.func(data, 2.3), 2.3) + self.assertEqual(self.func(data), (int, Fraction(0), 0)) + self.assertEqual(self.func(data, 23), (int, Fraction(23), 0)) + self.assertEqual(self.func(data, 2.3), (float, Fraction(2.3), 0)) def test_ints(self): - self.assertEqual(self.func([1, 5, 3, -4, -8, 20, 42, 1]), 60) - self.assertEqual(self.func([4, 2, 3, -8, 7], 1000), 1008) + self.assertEqual(self.func([1, 5, 3, -4, -8, 20, 42, 1]), + (int, Fraction(60), 8)) + self.assertEqual(self.func([4, 2, 3, -8, 7], 1000), + (int, Fraction(1008), 5)) def test_floats(self): - self.assertEqual(self.func([0.25]*20), 5.0) - self.assertEqual(self.func([0.125, 0.25, 0.5, 0.75], 1.5), 3.125) + self.assertEqual(self.func([0.25]*20), + (float, Fraction(5.0), 20)) + self.assertEqual(self.func([0.125, 0.25, 0.5, 0.75], 1.5), + (float, Fraction(3.125), 4)) def test_fractions(self): - F = Fraction - self.assertEqual(self.func([Fraction(1, 1000)]*500), Fraction(1, 2)) + self.assertEqual(self.func([Fraction(1, 1000)]*500), + (Fraction, Fraction(1, 2), 500)) def test_decimals(self): D = Decimal data = [D("0.001"), D("5.246"), D("1.702"), D("-0.025"), D("3.974"), D("2.328"), D("4.617"), D("2.843"), ] - self.assertEqual(self.func(data), Decimal("20.686")) + self.assertEqual(self.func(data), + (Decimal, Decimal("20.686"), 8)) def test_compare_with_math_fsum(self): # Compare with the math.fsum function. # Ideally we ought to get the exact same result, but sometimes # we differ by a very slight amount :-( data = [random.uniform(-100, 1000) for _ in range(1000)] - self.assertApproxEqual(self.func(data), math.fsum(data), rel=2e-16) + self.assertApproxEqual(float(self.func(data)[1]), math.fsum(data), rel=2e-16) def test_start_argument(self): # Test that the optional start argument works correctly. data = [random.uniform(1, 1000) for _ in range(100)] - t = self.func(data) - self.assertEqual(t+42, self.func(data, 42)) - self.assertEqual(t-23, self.func(data, -23)) - self.assertEqual(t+1e20, self.func(data, 1e20)) + t = self.func(data)[1] + self.assertEqual(t+42, self.func(data, 42)[1]) + self.assertEqual(t-23, self.func(data, -23)[1]) + self.assertEqual(t+Fraction(1e20), self.func(data, 1e20)[1]) def test_strings_fail(self): # Sum of strings should fail. @@ -934,7 +1185,7 @@ def test_mixed_sum(self): # Mixed input types are not (currently) allowed. # Check that mixed data types fail. - self.assertRaises(TypeError, self.func, [1, 2.0, Fraction(1, 2)]) + self.assertRaises(TypeError, self.func, [1, 2.0, Decimal(1)]) # And so does mixed start argument. self.assertRaises(TypeError, self.func, [1, 2.0], Decimal(1)) @@ -942,11 +1193,14 @@ class SumTortureTest(NumericTestCase): def test_torture(self): # Tim Peters' torture test for sum, and variants of same. - self.assertEqual(statistics._sum([1, 1e100, 1, -1e100]*10000), 20000.0) - self.assertEqual(statistics._sum([1e100, 1, 1, -1e100]*10000), 20000.0) - self.assertApproxEqual( - statistics._sum([1e-100, 1, 1e-100, -1]*10000), 2.0e-96, rel=5e-16 - ) + self.assertEqual(statistics._sum([1, 1e100, 1, -1e100]*10000), + (float, Fraction(20000.0), 40000)) + self.assertEqual(statistics._sum([1e100, 1, 1, -1e100]*10000), + (float, Fraction(20000.0), 40000)) + T, num, count = statistics._sum([1e-100, 1, 1e-100, -1]*10000) + self.assertIs(T, float) + self.assertEqual(count, 40000) + self.assertApproxEqual(float(num), 2.0e-96, rel=5e-16) class SumSpecialValues(NumericTestCase): @@ -955,7 +1209,7 @@ def test_nan(self): for type_ in (float, Decimal): nan = type_('nan') - result = statistics._sum([1, nan, 2]) + result = statistics._sum([1, nan, 2])[1] self.assertIs(type(result), type_) self.assertTrue(math.isnan(result)) @@ -968,10 +1222,10 @@ def do_test_inf(self, inf): # Adding a single infinity gives infinity. - result = statistics._sum([1, 2, inf, 3]) + result = statistics._sum([1, 2, inf, 3])[1] self.check_infinity(result, inf) # Adding two infinities of the same sign also gives infinity. - result = statistics._sum([1, 2, inf, 3, inf, 4]) + result = statistics._sum([1, 2, inf, 3, inf, 4])[1] self.check_infinity(result, inf) def test_float_inf(self): @@ -987,7 +1241,7 @@ def test_float_mismatched_infs(self): # Test that adding two infinities of opposite sign gives a NAN. inf = float('inf') - result = statistics._sum([1, 2, inf, 3, -inf, 4]) + result = statistics._sum([1, 2, inf, 3, -inf, 4])[1] self.assertTrue(math.isnan(result)) def test_decimal_extendedcontext_mismatched_infs_to_nan(self): @@ -995,7 +1249,7 @@ inf = Decimal('inf') data = [1, 2, inf, 3, -inf, 4] with decimal.localcontext(decimal.ExtendedContext): - self.assertTrue(math.isnan(statistics._sum(data))) + self.assertTrue(math.isnan(statistics._sum(data)[1])) def test_decimal_basiccontext_mismatched_infs_to_nan(self): # Test adding Decimal INFs with opposite sign raises InvalidOperation. @@ -1111,6 +1365,19 @@ d = Decimal('1e4') self.assertEqual(statistics.mean([d]), d) + def test_regression_25177(self): + # Regression test for issue 25177. + # Ensure very big and very small floats don't overflow. + # See http://bugs.python.org/issue25177. + self.assertEqual(statistics.mean( + [8.988465674311579e+307, 8.98846567431158e+307]), + 8.98846567431158e+307) + big = 8.98846567431158e+307 + tiny = 5e-324 + for n in (2, 3, 5, 200): + self.assertEqual(statistics.mean([big]*n), big) + self.assertEqual(statistics.mean([tiny]*n), tiny) + class TestMedian(NumericTestCase, AverageMixin): # Common tests for median and all median.* functions. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -20,6 +20,10 @@ Library ------- +- Issue #25177: Fixed problem with the mean of very small and very large + numbers. As a side effect, statistics.mean and statistics.variance should + be significantly faster. + - Issue #25718: Fixed copying object with state with boolean value is false. - Issue #10131: Fixed deep copying of minidom documents. Based on patch -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Wed Dec 2 03:41:55 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 02 Dec 2015 08:41:55 +0000 Subject: [Python-checkins] Daily reference leaks (0eeb39fc8ff5): sum=4 Message-ID: <20151202084154.10714.96594@psf.io> results for 0eeb39fc8ff5 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflog7DOTE3', '--timeout', '7200'] From lp_benchmark_robot at intel.com Wed Dec 2 04:43:17 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 2 Dec 2015 09:43:17 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-02 Message-ID: <956d227e-6b15-46d2-8a04-d4ea998d3501@irsmsx101.ger.corp.intel.com> Results for project Python default, build date 2015-12-02 04:02:23 +0000 commit: 0eeb39fc8ff5ac1f77f33cc6d4468eceb0812e0e revision date: 2015-12-01 08:59:53 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.24% -2.89% 7.47% 17.39% :-| pybench 0.18% -0.06% -1.91% 8.69% :-( regex_v8 3.58% -1.59% -5.60% 6.55% :-| nbody 0.20% -0.05% -0.50% 10.12% :-| json_dump_v2 0.29% 0.83% -0.88% 10.35% :-| normal_startup 0.78% 0.06% 0.26% 4.82% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Wed Dec 2 04:44:02 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 2 Dec 2015 09:44:02 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-02 Message-ID: <1df6c6df-e395-4044-b85d-f7e0eadcb05e@irsmsx101.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python 2.7, build date 2015-12-02 04:49:51 +0000 commit: 6a35865eded462da46b7ac2ea35b10a45db31bbc revision date: 2015-11-30 22:32:49 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.15% 0.67% 2.19% 11.65% :-) pybench 0.24% 0.15% 6.20% 7.33% :-( regex_v8 1.43% -0.01% -3.13% 9.08% :-) nbody 0.12% -0.12% 9.53% 5.31% :-) json_dump_v2 0.30% 0.28% 2.67% 14.79% :-| normal_startup 1.77% -0.59% -1.87% 2.93% :-| ssbench 0.37% -0.29% 0.35% 1.04% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Wed Dec 2 08:36:25 2015 From: python-checkins at python.org (victor.stinner) Date: Wed, 02 Dec 2015 13:36:25 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Null_merge_3=2E5=2C_patch_was_already_applied_to_default?= =?utf-8?b?IChpc3VzZSAjMjUxNzcp?= Message-ID: <20151202133624.1811.91129@psf.io> https://hg.python.org/cpython/rev/a7d2307055e7 changeset: 99410:a7d2307055e7 parent: 99408:0eeb39fc8ff5 parent: 99407:ed45a09e5a69 user: Victor Stinner date: Wed Dec 02 14:36:15 2015 +0100 summary: Null merge 3.5, patch was already applied to default (isuse #25177) files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 08:38:13 2015 From: python-checkins at python.org (victor.stinner) Date: Wed, 02 Dec 2015 13:38:13 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogRml4IHRlc3RfZG9j?= =?utf-8?q?test_in_verbose_mode?= Message-ID: <20151202133809.32297.99367@psf.io> https://hg.python.org/cpython/rev/f3019e3f67d6 changeset: 99411:f3019e3f67d6 branch: 3.5 parent: 99407:ed45a09e5a69 user: Victor Stinner date: Wed Dec 02 14:37:17 2015 +0100 summary: Fix test_doctest in verbose mode files: Lib/test/test_doctest.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -2647,7 +2647,7 @@ >>> with open(fn, 'wb') as f: ... f.write(b'Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n') 35 - >>> doctest.testfile(fn, False) + >>> doctest.testfile(fn, module_relative=False, verbose=False) TestResults(failed=0, attempted=1) >>> os.remove(fn) @@ -2657,7 +2657,7 @@ >>> with open(fn, 'wb') as f: ... f.write(b'Test:\n\n >>> x = 1 + 1\n\nDone.\n') 30 - >>> doctest.testfile(fn, False) + >>> doctest.testfile(fn, module_relative=False, verbose=False) TestResults(failed=0, attempted=1) >>> os.remove(fn) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 08:38:41 2015 From: python-checkins at python.org (victor.stinner) Date: Wed, 02 Dec 2015 13:38:41 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_=28Merge_3=2E5=29_Fix_test=5Fdoctest_in_verbose_mode?= Message-ID: <20151202133809.124518.1269@psf.io> https://hg.python.org/cpython/rev/1ff29b57628e changeset: 99412:1ff29b57628e parent: 99410:a7d2307055e7 parent: 99411:f3019e3f67d6 user: Victor Stinner date: Wed Dec 02 14:37:35 2015 +0100 summary: (Merge 3.5) Fix test_doctest in verbose mode files: Lib/test/test_doctest.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -2647,7 +2647,7 @@ >>> with open(fn, 'wb') as f: ... f.write(b'Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n') 35 - >>> doctest.testfile(fn, False) + >>> doctest.testfile(fn, module_relative=False, verbose=False) TestResults(failed=0, attempted=1) >>> os.remove(fn) @@ -2657,7 +2657,7 @@ >>> with open(fn, 'wb') as f: ... f.write(b'Test:\n\n >>> x = 1 + 1\n\nDone.\n') 30 - >>> doctest.testfile(fn, False) + >>> doctest.testfile(fn, module_relative=False, verbose=False) TestResults(failed=0, attempted=1) >>> os.remove(fn) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 08:39:58 2015 From: python-checkins at python.org (victor.stinner) Date: Wed, 02 Dec 2015 13:39:58 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogRml4IHRlc3RfZG9j?= =?utf-8?q?test_in_verbose_mode?= Message-ID: <20151202133954.57684.64984@psf.io> https://hg.python.org/cpython/rev/ff351607a90d changeset: 99413:ff351607a90d branch: 2.7 parent: 99399:6a35865eded4 user: Victor Stinner date: Wed Dec 02 14:39:37 2015 +0100 summary: Fix test_doctest in verbose mode files: Lib/test/test_doctest.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -2582,7 +2582,7 @@ >>> fn = tempfile.mktemp() >>> with open(fn, 'wb') as f: ... f.write('Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n') - >>> doctest.testfile(fn, False) + >>> doctest.testfile(fn, module_relative=False, verbose=False) TestResults(failed=0, attempted=1) >>> os.remove(fn) @@ -2591,7 +2591,7 @@ >>> fn = tempfile.mktemp() >>> with open(fn, 'wb') as f: ... f.write('Test:\n\n >>> x = 1 + 1\n\nDone.\n') - >>> doctest.testfile(fn, False) + >>> doctest.testfile(fn, module_relative=False, verbose=False) TestResults(failed=0, attempted=1) >>> os.remove(fn) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 12:19:26 2015 From: python-checkins at python.org (steve.dower) Date: Wed, 02 Dec 2015 17:19:26 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NzE1?= =?utf-8?q?=3A_Python_3=2E5=2E1_installer_shows_wrong_upgrade_path_and_inc?= =?utf-8?q?orrect?= Message-ID: <20151202171924.14118.75306@psf.io> https://hg.python.org/cpython/rev/8537ec50c254 changeset: 99414:8537ec50c254 branch: 3.5 parent: 99411:f3019e3f67d6 user: Steve Dower date: Wed Dec 02 08:28:51 2015 -0800 summary: Issue #25715: Python 3.5.1 installer shows wrong upgrade path and incorrect logic for launcher detection. files: Misc/NEWS | 5 + Tools/msi/bundle/Default.thm | 2 +- Tools/msi/bundle/Default.wxl | 4 +- Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp | 223 +++++---- Tools/msi/bundle/bundle.wxs | 4 +- Tools/msi/bundle/packagegroups/launcher.wxs | 4 +- 6 files changed, 138 insertions(+), 104 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -62,6 +62,11 @@ Library ------- +Windows +------- + +- Issue #25715: Python 3.5.1 installer shows wrong upgrade path and incorrect + logic for launcher detection. What's New in Python 3.5.1 release candidate 1? =============================================== diff --git a/Tools/msi/bundle/Default.thm b/Tools/msi/bundle/Default.thm --- a/Tools/msi/bundle/Default.thm +++ b/Tools/msi/bundle/Default.thm @@ -66,7 +66,7 @@ #(loc.Include_launcherLabel) #(loc.InstallLauncherAllUsersLabel) - #(loc.Include_launcherHelpLabel) + diff --git a/Tools/msi/bundle/Default.wxl b/Tools/msi/bundle/Default.wxl --- a/Tools/msi/bundle/Default.wxl +++ b/Tools/msi/bundle/Default.wxl @@ -76,7 +76,9 @@ Python &test suite Installs the standard library test suite. py &launcher - Installs the global 'py' launcher to make it easier to start Python. + Installs the global 'py' launcher to make it easier to start Python. + Use Programs and Features to remove the 'py' launcher. + Upgrades the global 'py' launcher from the previous version. Associate &files with Python (requires the py launcher) Create shortcuts for installed applications diff --git a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp --- a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp +++ b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp @@ -94,6 +94,7 @@ ID_CUSTOM_ASSOCIATE_FILES_CHECKBOX, ID_CUSTOM_INSTALL_ALL_USERS_CHECKBOX, ID_CUSTOM_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, + ID_CUSTOM_INCLUDE_LAUNCHER_HELP_LABEL, ID_CUSTOM_COMPILE_ALL_CHECKBOX, ID_CUSTOM_BROWSE_BUTTON, ID_CUSTOM_BROWSE_BUTTON_LABEL, @@ -158,6 +159,7 @@ { ID_CUSTOM_ASSOCIATE_FILES_CHECKBOX, L"AssociateFiles" }, { ID_CUSTOM_INSTALL_ALL_USERS_CHECKBOX, L"InstallAllUsers" }, { ID_CUSTOM_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, L"CustomInstallLauncherAllUsers" }, + { ID_CUSTOM_INCLUDE_LAUNCHER_HELP_LABEL, L"Include_launcherHelp" }, { ID_CUSTOM_COMPILE_ALL_CHECKBOX, L"CompileAll" }, { ID_CUSTOM_BROWSE_BUTTON, L"CustomBrowseButton" }, { ID_CUSTOM_BROWSE_BUTTON_LABEL, L"CustomBrowseButtonLabel" }, @@ -454,6 +456,20 @@ ThemeSendControlMessage(_theme, ID_CUSTOM_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, BM_SETCHECK, installLauncherAllUsers ? BST_CHECKED : BST_UNCHECKED, 0); + + LOC_STRING *pLocString = nullptr; + LPCWSTR locKey = L"#(loc.Include_launcherHelp)"; + LONGLONG detectedLauncher; + + if (SUCCEEDED(BalGetNumericVariable(L"DetectedLauncher", &detectedLauncher)) && detectedLauncher) { + locKey = L"#(loc.Include_launcherRemove)"; + } else if (SUCCEEDED(BalGetNumericVariable(L"DetectedOldLauncher", &detectedLauncher)) && detectedLauncher) { + locKey = L"#(loc.Include_launcherUpgrade)"; + } + + if (SUCCEEDED(LocGetString(_wixLoc, locKey, &pLocString)) && pLocString) { + ThemeSetTextControl(_theme, ID_CUSTOM_INCLUDE_LAUNCHER_HELP_LABEL, pLocString->wzText); + } } void Custom2Page_Show() { @@ -641,6 +657,29 @@ return nResult; } + virtual STDMETHODIMP_(int) OnDetectRelatedMsiPackage( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOL fPerMachine, + __in DWORD64 /*dw64Version*/, + __in BOOTSTRAPPER_RELATED_OPERATION operation + ) { + if (BOOTSTRAPPER_RELATED_OPERATION_MAJOR_UPGRADE == operation && + (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, L"launcher_AllUsers", -1) || + CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, L"launcher_JustForMe", -1))) { + auto hr = LoadAssociateFilesStateFromKey(_engine, fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER); + if (hr == S_OK) { + _engine->SetVariableNumeric(L"AssociateFiles", 1); + } else if (FAILED(hr)) { + BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to load AssociateFiles state: error code 0x%08X", hr); + } + + _engine->SetVariableNumeric(L"Include_launcher", 1); + _engine->SetVariableNumeric(L"DetectedOldLauncher", 1); + _engine->SetVariableNumeric(L"InstallLauncherAllUsers", fPerMachine ? 1 : 0); + } + return CheckCanceled() ? IDCANCEL : IDNOACTION; + } virtual STDMETHODIMP_(int) OnDetectRelatedBundle( __in LPCWSTR wzBundleId, @@ -656,24 +695,8 @@ if (BOOTSTRAPPER_RELATED_OPERATION_DOWNGRADE == operation) { _downgradingOtherVersion = TRUE; } else if (BOOTSTRAPPER_RELATED_OPERATION_MAJOR_UPGRADE == operation) { - _upgradingOldVersion = TRUE; - - // Assume we don't want the launcher or file associations, and if - // they have already been installed then loading the state will - // reactivate these settings. - _engine->SetVariableNumeric(L"Include_launcher", 0); - _engine->SetVariableNumeric(L"AssociateFiles", 0); - auto hr = LoadLauncherStateFromKey(_engine, HKEY_CURRENT_USER); - if (hr == S_FALSE) { - hr = LoadLauncherStateFromKey(_engine, HKEY_LOCAL_MACHINE); - } - if (FAILED(hr)) { - BalLog( - BOOTSTRAPPER_LOG_LEVEL_ERROR, - "Failed to load launcher state: error code 0x%08X", - hr - ); - } + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Detected previous version - planning upgrade"); + _upgrading = TRUE; LoadOptionalFeatureStates(_engine); } else if (BOOTSTRAPPER_RELATED_OPERATION_NONE == operation) { @@ -699,9 +722,42 @@ virtual STDMETHODIMP_(void) OnDetectPackageComplete( __in LPCWSTR wzPackageId, - __in HRESULT /*hrStatus*/, + __in HRESULT hrStatus, __in BOOTSTRAPPER_PACKAGE_STATE state - ) { } + ) { + if (FAILED(hrStatus)) { + return; + } + + BOOL detectedLauncher = FALSE; + HKEY hkey = HKEY_LOCAL_MACHINE; + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, L"launcher_AllUsers", -1)) { + if (BOOTSTRAPPER_PACKAGE_STATE_PRESENT == state || BOOTSTRAPPER_PACKAGE_STATE_OBSOLETE == state) { + detectedLauncher = TRUE; + _engine->SetVariableNumeric(L"InstallLauncherAllUsers", 1); + } + } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, L"launcher_JustForMe", -1)) { + if (BOOTSTRAPPER_PACKAGE_STATE_PRESENT == state || BOOTSTRAPPER_PACKAGE_STATE_OBSOLETE == state) { + detectedLauncher = TRUE; + _engine->SetVariableNumeric(L"InstallLauncherAllUsers", 0); + } + } + + if (detectedLauncher) { + /* When we detect the current version of the launcher. */ + _engine->SetVariableNumeric(L"Include_launcher", 1); + _engine->SetVariableNumeric(L"DetectedLauncher", 1); + _engine->SetVariableString(L"Include_launcherState", L"disable"); + _engine->SetVariableString(L"InstallLauncherAllUsersState", L"disable"); + + auto hr = LoadAssociateFilesStateFromKey(_engine, hkey); + if (hr == S_OK) { + _engine->SetVariableNumeric(L"AssociateFiles", 1); + } else if (FAILED(hr)) { + BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to load AssociateFiles state: error code 0x%08X", hr); + } + } + } virtual STDMETHODIMP_(void) OnDetectComplete(__in HRESULT hrStatus) { @@ -716,32 +772,7 @@ if (SUCCEEDED(hrStatus)) { // Ensure the default path has been set - LONGLONG installAll; - LPWSTR targetDir = nullptr; - LPWSTR defaultTargetDir = nullptr; - - hrStatus = BalGetStringVariable(L"TargetDir", &targetDir); - if (FAILED(hrStatus) || !targetDir || !targetDir[0]) { - ReleaseStr(targetDir); - targetDir = nullptr; - - if (FAILED(BalGetNumericVariable(L"InstallAllUsers", &installAll))) { - installAll = 0; - } - - hrStatus = BalGetStringVariable( - installAll ? L"DefaultAllUsersTargetDir" : L"DefaultJustForMeTargetDir", - &defaultTargetDir - ); - - if (SUCCEEDED(hrStatus) && defaultTargetDir) { - if (defaultTargetDir[0] && SUCCEEDED(BalFormatString(defaultTargetDir, &targetDir))) { - hrStatus = _engine->SetVariableString(L"TargetDir", targetDir); - ReleaseStr(targetDir); - } - ReleaseStr(defaultTargetDir); - } - } + hrStatus = EnsureTargetDir(); } SetState(PYBA_STATE_DETECTED, hrStatus); @@ -1396,9 +1427,14 @@ hr = LoadBootstrapperBAFunctions(); BalExitOnFailure(hr, "Failed to load bootstrapper functions."); + hr = UpdateUIStrings(_command.action); BalExitOnFailure(hr, "Failed to load UI strings."); + if (_command.action == BOOTSTRAPPER_ACTION_MODIFY) { + LoadOptionalFeatureStates(_engine); + } + GetBundleFileVersion(); // don't fail if we couldn't get the version info; best-effort only LExit: @@ -1906,27 +1942,6 @@ for (DWORD i = 0; i < _theme->cControls; ++i) { THEME_CONTROL* pControl = _theme->rgControls + i; LPWSTR text = nullptr; - LPWSTR name = nullptr; - LOC_STRING *locText = nullptr; - - // If a command link has a note, then add it. - if ((pControl->dwStyle & BS_TYPEMASK) == BS_COMMANDLINK || - (pControl->dwStyle & BS_TYPEMASK) == BS_DEFCOMMANDLINK) { - hr = StrAllocFormatted(&name, L"#(loc.%lsNote)", pControl->sczName); - if (SUCCEEDED(hr)) { - hr = LocGetString(_wixLoc, name, &locText); - ReleaseStr(name); - if (SUCCEEDED(hr) && locText && locText->wzText && locText->wzText[0]) { - hr = BalFormatString(locText->wzText, &text); - if (SUCCEEDED(hr) && text && text[0]) { - ThemeSendControlMessage(_theme, pControl->wId, BCM_SETNOTE, 0, (LPARAM)text); - ReleaseStr(text); - text = nullptr; - } - } - } - hr = S_OK; - } if (!pControl->wPageId && pControl->sczText && *pControl->sczText) { HRESULT hrFormat; @@ -2048,6 +2063,7 @@ return; } + HRESULT UpdateUIStrings(__in BOOTSTRAPPER_ACTION action) { HRESULT hr = S_OK; LPCWSTR likeInstalling = nullptr; @@ -2270,6 +2286,30 @@ StrFree(controlState); } StrFree(controlName); + controlName = nullptr; + + + // If a command link has a note, then add it. + if ((pControl->dwStyle & BS_TYPEMASK) == BS_COMMANDLINK || + (pControl->dwStyle & BS_TYPEMASK) == BS_DEFCOMMANDLINK) { + hr = StrAllocFormatted(&controlName, L"#(loc.%lsNote)", pControl->sczName); + if (SUCCEEDED(hr)) { + LOC_STRING *locText = nullptr; + hr = LocGetString(_wixLoc, controlName, &locText); + if (SUCCEEDED(hr) && locText && locText->wzText && locText->wzText[0]) { + LPWSTR text = nullptr; + hr = BalFormatString(locText->wzText, &text); + if (SUCCEEDED(hr) && text && text[0]) { + ThemeSendControlMessage(_theme, pControl->wId, BCM_SETNOTE, 0, (LPARAM)text); + ReleaseStr(text); + text = nullptr; + } + } + ReleaseStr(controlName); + controlName = nullptr; + } + hr = S_OK; + } } ThemeControlEnable(_theme, pControl->wId, enableControl); @@ -2515,9 +2555,8 @@ if (_installPage == PAGE_LOADING) { switch (_command.action) { case BOOTSTRAPPER_ACTION_INSTALL: - if (_upgradingOldVersion) { + if (_upgrading) { _installPage = PAGE_UPGRADE; - _upgrading = TRUE; } else if (SUCCEEDED(BalGetNumericVariable(L"SimpleInstall", &simple)) && simple) { _installPage = PAGE_SIMPLE_INSTALL; } else { @@ -2560,11 +2599,9 @@ static BAL_CONDITION WILL_ELEVATE_CONDITION = { L"not WixBundleElevated and (" /*Elevate when installing for all users*/ - L"InstallAllUsers or" + L"InstallAllUsers or " /*Elevate when installing the launcher for all users and it was not detected*/ - L"(InstallLauncherAllUsers and Include_launcher and not DetectedLauncher) or" - /*Elevate when the launcher was installed for all users and it is being removed*/ - L"(DetectedLauncher and DetectedLauncherAllUsers and not Include_launcher)" + L"(Include_launcher and InstallLauncherAllUsers and not DetectedLauncher)" L")", L"" }; @@ -2867,19 +2904,16 @@ return HRESULT_FROM_WIN32(res); } - static HRESULT LoadLauncherStateFromKey( + static HRESULT LoadAssociateFilesStateFromKey( __in IBootstrapperEngine* pEngine, __in HKEY hkHive ) { const LPCWSTR subkey = L"Software\\Python\\PyLauncher"; HKEY hKey; LRESULT res; - - if (IsTargetPlatformx64(pEngine)) { - res = RegOpenKeyExW(hkHive, subkey, 0, KEY_READ | KEY_WOW64_64KEY, &hKey); - } else { - res = RegOpenKeyExW(hkHive, subkey, 0, KEY_READ | KEY_WOW64_32KEY, &hKey); - } + HRESULT hr; + + res = RegOpenKeyExW(hkHive, subkey, 0, KEY_READ | KEY_WOW64_32KEY, &hKey); if (res == ERROR_FILE_NOT_FOUND) { return S_FALSE; @@ -2888,26 +2922,17 @@ return HRESULT_FROM_WIN32(res); } - res = RegQueryValueExW(hKey, nullptr, nullptr, nullptr, nullptr, nullptr); - if (res == ERROR_FILE_NOT_FOUND) { - pEngine->SetVariableNumeric(L"Include_launcher", 0); - } else if (res == ERROR_SUCCESS) { - pEngine->SetVariableNumeric(L"Include_launcher", 1); - pEngine->SetVariableNumeric(L"DetectedLauncher", 1); - pEngine->SetVariableNumeric(L"InstallLauncherAllUsers", (hkHive == HKEY_LOCAL_MACHINE) ? 1 : 0); - pEngine->SetVariableNumeric(L"DetectedLauncherAllUsers", (hkHive == HKEY_LOCAL_MACHINE) ? 1 : 0); - pEngine->SetVariableString(L"InstallLauncherAllUsersState", L"disable"); - } - res = RegQueryValueExW(hKey, L"AssociateFiles", nullptr, nullptr, nullptr, nullptr); if (res == ERROR_FILE_NOT_FOUND) { - pEngine->SetVariableNumeric(L"AssociateFiles", 0); + hr = S_FALSE; } else if (res == ERROR_SUCCESS) { - pEngine->SetVariableNumeric(L"AssociateFiles", 1); + hr = S_OK; + } else { + hr = HRESULT_FROM_WIN32(res); } RegCloseKey(hKey); - return S_OK; + return hr; } static void LoadOptionalFeatureStates(__in IBootstrapperEngine* pEngine) { @@ -2918,7 +2943,11 @@ HKEY hkHive; // The launcher installation is separate from the Python install, so we - // check its state later. This also checks the file association option. + // check its state later. For now, assume we don't want the launcher or + // file associations, and if they have already been installed then + // loading the state will reactivate these settings. + pEngine->SetVariableNumeric(L"Include_launcher", 0); + pEngine->SetVariableNumeric(L"AssociateFiles", 0); // Get the registry key from the bundle, to save having to duplicate it // in multiple places. @@ -3089,7 +3118,6 @@ _hrFinal = hrHostInitialization; _downgradingOtherVersion = FALSE; - _upgradingOldVersion = FALSE; _restartResult = BOOTSTRAPPER_APPLY_RESTART_NONE; _restartRequired = FALSE; _allowRestart = FALSE; @@ -3113,8 +3141,6 @@ _hBAFModule = nullptr; _baFunction = nullptr; - - EnsureTargetDir(); } @@ -3174,7 +3200,6 @@ DWORD _calculatedExecuteProgress; BOOL _downgradingOtherVersion; - BOOL _upgradingOldVersion; BOOTSTRAPPER_APPLY_RESTART _restartResult; BOOL _restartRequired; BOOL _allowRestart; diff --git a/Tools/msi/bundle/bundle.wxs b/Tools/msi/bundle/bundle.wxs --- a/Tools/msi/bundle/bundle.wxs +++ b/Tools/msi/bundle/bundle.wxs @@ -51,7 +51,7 @@ --> - + @@ -72,6 +72,7 @@ + @@ -81,6 +82,7 @@ + diff --git a/Tools/msi/bundle/packagegroups/launcher.wxs b/Tools/msi/bundle/packagegroups/launcher.wxs --- a/Tools/msi/bundle/packagegroups/launcher.wxs +++ b/Tools/msi/bundle/packagegroups/launcher.wxs @@ -11,7 +11,7 @@ EnableFeatureSelection="yes" Permanent="yes" Visible="yes" - InstallCondition="(InstallAllUsers or InstallLauncherAllUsers) and Include_launcher" /> + InstallCondition="(InstallAllUsers or InstallLauncherAllUsers) and Include_launcher and not DetectedLauncher" /> + InstallCondition="not (InstallAllUsers or InstallLauncherAllUsers) and Include_launcher and not DetectedLauncher" /> \ No newline at end of file -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 12:19:26 2015 From: python-checkins at python.org (steve.dower) Date: Wed, 02 Dec 2015 17:19:26 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_from_3=2E5_=28including_all_NEWS_entries=29?= Message-ID: <20151202171924.14106.51279@psf.io> https://hg.python.org/cpython/rev/7dcc03b344b5 changeset: 99415:7dcc03b344b5 parent: 99412:1ff29b57628e parent: 99414:8537ec50c254 user: Steve Dower date: Wed Dec 02 09:19:07 2015 -0800 summary: Merge from 3.5 (including all NEWS entries) files: Misc/NEWS | 260 +++++++++- Tools/msi/bundle/Default.thm | 2 +- Tools/msi/bundle/Default.wxl | 4 +- Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp | 223 ++++--- Tools/msi/bundle/bundle.wxs | 4 +- Tools/msi/bundle/packagegroups/launcher.wxs | 4 +- 6 files changed, 389 insertions(+), 108 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -476,21 +476,84 @@ `python3 -m venv`. +What's New in Python 3.5.1 final? +================================= + +Release date: 2015-12-06 + +Core and Builtins +----------------- + +Library +------- + +Windows +------- + +- Issue #25715: Python 3.5.1 installer shows wrong upgrade path and incorrect + logic for launcher detection. + What's New in Python 3.5.1 release candidate 1? =============================================== -Release date: TBA +Release date: 2015-11-22 Core and Builtins ----------------- +- Issue #25630: Fix a possible segfault during argument parsing in functions + that accept filesystem paths. + +- Issue #23564: Fixed a partially broken sanity check in the _posixsubprocess + internals regarding how fds_to_pass were passed to the child. The bug had + no actual impact as subprocess.py already avoided it. + +- Issue #25388: Fixed tokenizer crash when processing undecodable source code + with a null byte. + +- Issue #25462: The hash of the key now is calculated only once in most + operations in C implementation of OrderedDict. + +- Issue #22995: Default implementation of __reduce__ and __reduce_ex__ now + rejects builtin types with not defined __new__. + +- Issue #25555: Fix parser and AST: fill lineno and col_offset of "arg" node + when compiling AST from Python objects. + - Issue #24802: Avoid buffer overreads when int(), float(), compile(), exec() and eval() are passed bytes-like objects. These objects are not necessarily terminated by a null byte, but the functions assumed they were. +- Issue #24726: Fixed a crash and leaking NULL in repr() of OrderedDict that + was mutated by direct calls of dict methods. + +- Issue #25449: Iterating OrderedDict with keys with unstable hash now raises + KeyError in C implementations as well as in Python implementation. + +- Issue #25395: Fixed crash when highly nested OrderedDict structures were + garbage collected. + +- Issue #25274: sys.setrecursionlimit() now raises a RecursionError if the new + recursion limit is too low depending at the current recursion depth. Modify + also the "lower-water mark" formula to make it monotonic. This mark is used + to decide when the overflowed flag of the thread state is reset. + - Issue #24402: Fix input() to prompt to the redirected stdout when sys.stdout.fileno() fails. +- Issue #24806: Prevent builtin types that are not allowed to be subclassed from + being subclassed through multiple inheritance. + +- Issue #24848: Fixed a number of bugs in UTF-7 decoding of misformed data. + +- Issue #25280: Import trace messages emitted in verbose (-v) mode are no + longer formatted twice. + +- Issue #25003: On Solaris 11.3 or newer, os.urandom() now uses the + getrandom() function instead of the getentropy() function. The getentropy() + function is blocking to generate very good quality entropy, os.urandom() + doesn't need such high-quality entropy. + - Issue #25182: The stdprinter (used as sys.stderr before the io module is imported at startup) now uses the backslashreplace error handler. @@ -514,6 +577,12 @@ - Issue #25583: Avoid incorrect errors raised by os.makedirs(exist_ok=True) when the OS gives priority to errors such as EACCES over EEXIST. +- Issue #25593: Change semantics of EventLoop.stop() in asyncio. + +- Issue #6973: When we know a subprocess.Popen process has died, do + not allow the send_signal(), terminate(), or kill() methods to do + anything as they could potentially signal a different process. + - Issue #25590: In the Readline completer, only call getattr() once per attribute. @@ -521,6 +590,71 @@ by wrapping a memoryview. This was a regression made in 3.5a1. Based on patch by Eryksun. +- Issue #25584: Added "escape" to the __all__ list in the glob module. + +- Issue #25584: Fixed recursive glob() with patterns starting with '\*\*'. + +- Issue #25446: Fix regression in smtplib's AUTH LOGIN support. + +- Issue #18010: Fix the pydoc web server's module search function to handle + exceptions from importing packages. + +- Issue #25554: Got rid of circular references in regular expression parsing. + +- Issue #25510: fileinput.FileInput.readline() now returns b'' instead of '' + at the end if the FileInput was opened with binary mode. + Patch by Ryosuke Ito. + +- Issue #25503: Fixed inspect.getdoc() for inherited docstrings of properties. + Original patch by John Mark Vandenberg. + +- Issue #25515: Always use os.urandom as a source of randomness in uuid.uuid4. + +- Issue #21827: Fixed textwrap.dedent() for the case when largest common + whitespace is a substring of smallest leading whitespace. + Based on patch by Robert Li. + +- Issue #25447: The lru_cache() wrapper objects now can be copied and pickled + (by returning the original object unchanged). + +- Issue #25390: typing: Don't crash on Union[str, Pattern]. + +- Issue #25441: asyncio: Raise error from drain() when socket is closed. + +- Issue #25410: Cleaned up and fixed minor bugs in C implementation of + OrderedDict. + +- Issue #25411: Improved Unicode support in SMTPHandler through better use of + the email package. Thanks to user simon04 for the patch. + +- Issue #25407: Remove mentions of the formatter module being removed in + Python 3.6. + +- Issue #25406: Fixed a bug in C implementation of OrderedDict.move_to_end() + that caused segmentation fault or hang in iterating after moving several + items to the start of ordered dict. + +- Issue #25364: zipfile now works in threads disabled builds. + +- Issue #25328: smtpd's SMTPChannel now correctly raises a ValueError if both + decode_data and enable_SMTPUTF8 are set to true. + +- Issue #25316: distutils raises OSError instead of DistutilsPlatformError + when MSVC is not installed. + +- Issue #25380: Fixed protocol for the STACK_GLOBAL opcode in + pickletools.opcodes. + +- Issue #23972: Updates asyncio datagram create method allowing reuseport + and reuseaddr socket options to be set prior to binding the socket. + Mirroring the existing asyncio create_server method the reuseaddr option + for datagram sockets defaults to True if the O/S is 'posix' (except if the + platform is Cygwin). Patch by Chris Laws. + +- Issue #25304: Add asyncio.run_coroutine_threadsafe(). This lets you + submit a coroutine to a loop from another thread, returning a + concurrent.futures.Future. By Vincent Michel. + - Issue #25232: Fix CGIRequestHandler to split the query from the URL at the first question mark (?) rather than the last. Patch from Xiang Zhang. @@ -548,6 +682,9 @@ - Issue #25233: Rewrite the guts of asyncio.Queue and asyncio.Semaphore to be more understandable and correct. +- Issue #25203: Failed readline.set_completer_delims() no longer left the + module in inconsistent state. + - Issue #23600: Default implementation of tzinfo.fromutc() was returning wrong results in some cases. @@ -621,6 +758,19 @@ - Issue #24881: Fixed setting binary mode in Python implementation of FileIO on Windows and Cygwin. Patch from Akira Li. +- Issue #25578: Fix (another) memory leak in SSLSocket.getpeercer(). + +- Issue #25530: Disable the vulnerable SSLv3 protocol by default when creating + ssl.SSLContext. + +- Issue #25569: Fix memory leak in SSLSocket.getpeercert(). + +- Issue #25471: Sockets returned from accept() shouldn't appear to be + nonblocking. + +- Issue #25319: When threading.Event is reinitialized, the underlying condition + should use a regular lock rather than a recursive lock. + - Issue #21112: Fix regression in unittest.expectedFailure on subclasses. Patch from Berker Peksag. @@ -642,8 +792,104 @@ - Issue #23572: Fixed functools.singledispatch on classes with falsy metaclasses. Patch by Ethan Furman. -- Issue #12006: Add ISO 8601 year, week, and day directives (%G, %V, %u) to - strptime. +- asyncio: ensure_future() now accepts awaitable objects. + +IDLE +---- + +- Issue 15348: Stop the debugger engine (normally in a user process) + before closing the debugger window (running in the IDLE process). + This prevents the RuntimeErrors that were being caught and ignored. + +- Issue #24455: Prevent IDLE from hanging when a) closing the shell while the + debugger is active (15347); b) closing the debugger with the [X] button + (15348); and c) activating the debugger when already active (24455). + The patch by Mark Roseman does this by making two changes. + 1. Suspend and resume the gui.interaction method with the tcl vwait + mechanism intended for this purpose (instead of root.mainloop & .quit). + 2. In gui.run, allow any existing interaction to terminate first. + +- Change 'The program' to 'Your program' in an IDLE 'kill program?' message + to make it clearer that the program referred to is the currently running + user program, not IDLE itself. + +- Issue #24750: Improve the appearance of the IDLE editor window status bar. + Patch by Mark Roseman. + +- Issue #25313: Change the handling of new built-in text color themes to better + address the compatibility problem introduced by the addition of IDLE Dark. + Consistently use the revised idleConf.CurrentTheme everywhere in idlelib. + +- Issue #24782: Extension configuration is now a tab in the IDLE Preferences + dialog rather than a separate dialog. The former tabs are now a sorted + list. Patch by Mark Roseman. + +- Issue #22726: Re-activate the config dialog help button with some content + about the other buttons and the new IDLE Dark theme. + +- Issue #24820: IDLE now has an 'IDLE Dark' built-in text color theme. + It is more or less IDLE Classic inverted, with a cobalt blue background. + Strings, comments, keywords, ... are still green, red, orange, ... . + To use it with IDLEs released before November 2015, hit the + 'Save as New Custom Theme' button and enter a new name, + such as 'Custom Dark'. The custom theme will work with any IDLE + release, and can be modified. + +- Issue #25224: README.txt is now an idlelib index for IDLE developers and + curious users. The previous user content is now in the IDLE doc chapter. + 'IDLE' now means 'Integrated Development and Learning Environment'. + +- Issue #24820: Users can now set breakpoint colors in + Settings -> Custom Highlighting. Original patch by Mark Roseman. + +- Issue #24972: Inactive selection background now matches active selection + background, as configured by users, on all systems. Found items are now + always highlighted on Windows. Initial patch by Mark Roseman. + +- Issue #24570: Idle: make calltip and completion boxes appear on Macs + affected by a tk regression. Initial patch by Mark Roseman. + +- Issue #24988: Idle ScrolledList context menus (used in debugger) + now work on Mac Aqua. Patch by Mark Roseman. + +- Issue #24801: Make right-click for context menu work on Mac Aqua. + Patch by Mark Roseman. + +- Issue #25173: Associate tkinter messageboxes with a specific widget. + For Mac OSX, make them a 'sheet'. Patch by Mark Roseman. + +- Issue #25198: Enhance the initial html viewer now used for Idle Help. + * Properly indent fixed-pitch text (patch by Mark Roseman). + * Give code snippet a very Sphinx-like light blueish-gray background. + * Re-use initial width and height set by users for shell and editor. + * When the Table of Contents (TOC) menu is used, put the section header + at the top of the screen. + +- Issue #25225: Condense and rewrite Idle doc section on text colors. + +- Issue #21995: Explain some differences between IDLE and console Python. + +- Issue #22820: Explain need for *print* when running file from Idle editor. + +- Issue #25224: Doc: augment Idle feature list and no-subprocess section. + +- Issue #25219: Update doc for Idle command line options. + Some were missing and notes were not correct. + +- Issue #24861: Most of idlelib is private and subject to change. + Use idleib.idle.* to start Idle. See idlelib.__init__.__doc__. + +- Issue #25199: Idle: add synchronization comments for future maintainers. + +- Issue #16893: Replace help.txt with help.html for Idle doc display. + The new idlelib/help.html is rstripped Doc/build/html/library/idle.html. + It looks better than help.txt and will better document Idle as released. + The tkinter html viewer that works for this file was written by Mark Roseman. + The now unused EditorWindow.HelpDialog class and helt.txt file are deprecated. + +- Issue #24199: Deprecate unused idlelib.idlever with possible removal in 3.6. + +- Issue #24790: Remove extraneous code (which also create 2 & 3 conflicts). Documentation ------------- @@ -670,6 +916,8 @@ Tests ----- +- Issue #25449: Added tests for OrderedDict subclasses. + - Issue #25099: Make test_compileall not fail when an entry on sys.path cannot be written to (commonly seen in administrative installs on Windows). @@ -689,7 +937,6 @@ - Issue #24986: It is now possible to build Python on Windows without errors when external libraries are not available. - Windows ------- @@ -728,6 +975,11 @@ - Issue #25022: Removed very outdated PC/example_nt/ directory. +Tools/Demos +----------- + +- Issue #25440: Fix output of python-config --extension-suffix. + What's New in Python 3.5.0 final? ================================= diff --git a/Tools/msi/bundle/Default.thm b/Tools/msi/bundle/Default.thm --- a/Tools/msi/bundle/Default.thm +++ b/Tools/msi/bundle/Default.thm @@ -66,7 +66,7 @@ #(loc.Include_launcherLabel) #(loc.InstallLauncherAllUsersLabel) - #(loc.Include_launcherHelpLabel) + diff --git a/Tools/msi/bundle/Default.wxl b/Tools/msi/bundle/Default.wxl --- a/Tools/msi/bundle/Default.wxl +++ b/Tools/msi/bundle/Default.wxl @@ -76,7 +76,9 @@ Python &test suite Installs the standard library test suite. py &launcher - Installs the global 'py' launcher to make it easier to start Python. + Installs the global 'py' launcher to make it easier to start Python. + Use Programs and Features to remove the 'py' launcher. + Upgrades the global 'py' launcher from the previous version. Associate &files with Python (requires the py launcher) Create shortcuts for installed applications diff --git a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp --- a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp +++ b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp @@ -94,6 +94,7 @@ ID_CUSTOM_ASSOCIATE_FILES_CHECKBOX, ID_CUSTOM_INSTALL_ALL_USERS_CHECKBOX, ID_CUSTOM_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, + ID_CUSTOM_INCLUDE_LAUNCHER_HELP_LABEL, ID_CUSTOM_COMPILE_ALL_CHECKBOX, ID_CUSTOM_BROWSE_BUTTON, ID_CUSTOM_BROWSE_BUTTON_LABEL, @@ -158,6 +159,7 @@ { ID_CUSTOM_ASSOCIATE_FILES_CHECKBOX, L"AssociateFiles" }, { ID_CUSTOM_INSTALL_ALL_USERS_CHECKBOX, L"InstallAllUsers" }, { ID_CUSTOM_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, L"CustomInstallLauncherAllUsers" }, + { ID_CUSTOM_INCLUDE_LAUNCHER_HELP_LABEL, L"Include_launcherHelp" }, { ID_CUSTOM_COMPILE_ALL_CHECKBOX, L"CompileAll" }, { ID_CUSTOM_BROWSE_BUTTON, L"CustomBrowseButton" }, { ID_CUSTOM_BROWSE_BUTTON_LABEL, L"CustomBrowseButtonLabel" }, @@ -454,6 +456,20 @@ ThemeSendControlMessage(_theme, ID_CUSTOM_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, BM_SETCHECK, installLauncherAllUsers ? BST_CHECKED : BST_UNCHECKED, 0); + + LOC_STRING *pLocString = nullptr; + LPCWSTR locKey = L"#(loc.Include_launcherHelp)"; + LONGLONG detectedLauncher; + + if (SUCCEEDED(BalGetNumericVariable(L"DetectedLauncher", &detectedLauncher)) && detectedLauncher) { + locKey = L"#(loc.Include_launcherRemove)"; + } else if (SUCCEEDED(BalGetNumericVariable(L"DetectedOldLauncher", &detectedLauncher)) && detectedLauncher) { + locKey = L"#(loc.Include_launcherUpgrade)"; + } + + if (SUCCEEDED(LocGetString(_wixLoc, locKey, &pLocString)) && pLocString) { + ThemeSetTextControl(_theme, ID_CUSTOM_INCLUDE_LAUNCHER_HELP_LABEL, pLocString->wzText); + } } void Custom2Page_Show() { @@ -641,6 +657,29 @@ return nResult; } + virtual STDMETHODIMP_(int) OnDetectRelatedMsiPackage( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR /*wzProductCode*/, + __in BOOL fPerMachine, + __in DWORD64 /*dw64Version*/, + __in BOOTSTRAPPER_RELATED_OPERATION operation + ) { + if (BOOTSTRAPPER_RELATED_OPERATION_MAJOR_UPGRADE == operation && + (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, L"launcher_AllUsers", -1) || + CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, L"launcher_JustForMe", -1))) { + auto hr = LoadAssociateFilesStateFromKey(_engine, fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER); + if (hr == S_OK) { + _engine->SetVariableNumeric(L"AssociateFiles", 1); + } else if (FAILED(hr)) { + BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to load AssociateFiles state: error code 0x%08X", hr); + } + + _engine->SetVariableNumeric(L"Include_launcher", 1); + _engine->SetVariableNumeric(L"DetectedOldLauncher", 1); + _engine->SetVariableNumeric(L"InstallLauncherAllUsers", fPerMachine ? 1 : 0); + } + return CheckCanceled() ? IDCANCEL : IDNOACTION; + } virtual STDMETHODIMP_(int) OnDetectRelatedBundle( __in LPCWSTR wzBundleId, @@ -656,24 +695,8 @@ if (BOOTSTRAPPER_RELATED_OPERATION_DOWNGRADE == operation) { _downgradingOtherVersion = TRUE; } else if (BOOTSTRAPPER_RELATED_OPERATION_MAJOR_UPGRADE == operation) { - _upgradingOldVersion = TRUE; - - // Assume we don't want the launcher or file associations, and if - // they have already been installed then loading the state will - // reactivate these settings. - _engine->SetVariableNumeric(L"Include_launcher", 0); - _engine->SetVariableNumeric(L"AssociateFiles", 0); - auto hr = LoadLauncherStateFromKey(_engine, HKEY_CURRENT_USER); - if (hr == S_FALSE) { - hr = LoadLauncherStateFromKey(_engine, HKEY_LOCAL_MACHINE); - } - if (FAILED(hr)) { - BalLog( - BOOTSTRAPPER_LOG_LEVEL_ERROR, - "Failed to load launcher state: error code 0x%08X", - hr - ); - } + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Detected previous version - planning upgrade"); + _upgrading = TRUE; LoadOptionalFeatureStates(_engine); } else if (BOOTSTRAPPER_RELATED_OPERATION_NONE == operation) { @@ -699,9 +722,42 @@ virtual STDMETHODIMP_(void) OnDetectPackageComplete( __in LPCWSTR wzPackageId, - __in HRESULT /*hrStatus*/, + __in HRESULT hrStatus, __in BOOTSTRAPPER_PACKAGE_STATE state - ) { } + ) { + if (FAILED(hrStatus)) { + return; + } + + BOOL detectedLauncher = FALSE; + HKEY hkey = HKEY_LOCAL_MACHINE; + if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, L"launcher_AllUsers", -1)) { + if (BOOTSTRAPPER_PACKAGE_STATE_PRESENT == state || BOOTSTRAPPER_PACKAGE_STATE_OBSOLETE == state) { + detectedLauncher = TRUE; + _engine->SetVariableNumeric(L"InstallLauncherAllUsers", 1); + } + } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, L"launcher_JustForMe", -1)) { + if (BOOTSTRAPPER_PACKAGE_STATE_PRESENT == state || BOOTSTRAPPER_PACKAGE_STATE_OBSOLETE == state) { + detectedLauncher = TRUE; + _engine->SetVariableNumeric(L"InstallLauncherAllUsers", 0); + } + } + + if (detectedLauncher) { + /* When we detect the current version of the launcher. */ + _engine->SetVariableNumeric(L"Include_launcher", 1); + _engine->SetVariableNumeric(L"DetectedLauncher", 1); + _engine->SetVariableString(L"Include_launcherState", L"disable"); + _engine->SetVariableString(L"InstallLauncherAllUsersState", L"disable"); + + auto hr = LoadAssociateFilesStateFromKey(_engine, hkey); + if (hr == S_OK) { + _engine->SetVariableNumeric(L"AssociateFiles", 1); + } else if (FAILED(hr)) { + BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to load AssociateFiles state: error code 0x%08X", hr); + } + } + } virtual STDMETHODIMP_(void) OnDetectComplete(__in HRESULT hrStatus) { @@ -716,32 +772,7 @@ if (SUCCEEDED(hrStatus)) { // Ensure the default path has been set - LONGLONG installAll; - LPWSTR targetDir = nullptr; - LPWSTR defaultTargetDir = nullptr; - - hrStatus = BalGetStringVariable(L"TargetDir", &targetDir); - if (FAILED(hrStatus) || !targetDir || !targetDir[0]) { - ReleaseStr(targetDir); - targetDir = nullptr; - - if (FAILED(BalGetNumericVariable(L"InstallAllUsers", &installAll))) { - installAll = 0; - } - - hrStatus = BalGetStringVariable( - installAll ? L"DefaultAllUsersTargetDir" : L"DefaultJustForMeTargetDir", - &defaultTargetDir - ); - - if (SUCCEEDED(hrStatus) && defaultTargetDir) { - if (defaultTargetDir[0] && SUCCEEDED(BalFormatString(defaultTargetDir, &targetDir))) { - hrStatus = _engine->SetVariableString(L"TargetDir", targetDir); - ReleaseStr(targetDir); - } - ReleaseStr(defaultTargetDir); - } - } + hrStatus = EnsureTargetDir(); } SetState(PYBA_STATE_DETECTED, hrStatus); @@ -1396,9 +1427,14 @@ hr = LoadBootstrapperBAFunctions(); BalExitOnFailure(hr, "Failed to load bootstrapper functions."); + hr = UpdateUIStrings(_command.action); BalExitOnFailure(hr, "Failed to load UI strings."); + if (_command.action == BOOTSTRAPPER_ACTION_MODIFY) { + LoadOptionalFeatureStates(_engine); + } + GetBundleFileVersion(); // don't fail if we couldn't get the version info; best-effort only LExit: @@ -1906,27 +1942,6 @@ for (DWORD i = 0; i < _theme->cControls; ++i) { THEME_CONTROL* pControl = _theme->rgControls + i; LPWSTR text = nullptr; - LPWSTR name = nullptr; - LOC_STRING *locText = nullptr; - - // If a command link has a note, then add it. - if ((pControl->dwStyle & BS_TYPEMASK) == BS_COMMANDLINK || - (pControl->dwStyle & BS_TYPEMASK) == BS_DEFCOMMANDLINK) { - hr = StrAllocFormatted(&name, L"#(loc.%lsNote)", pControl->sczName); - if (SUCCEEDED(hr)) { - hr = LocGetString(_wixLoc, name, &locText); - ReleaseStr(name); - if (SUCCEEDED(hr) && locText && locText->wzText && locText->wzText[0]) { - hr = BalFormatString(locText->wzText, &text); - if (SUCCEEDED(hr) && text && text[0]) { - ThemeSendControlMessage(_theme, pControl->wId, BCM_SETNOTE, 0, (LPARAM)text); - ReleaseStr(text); - text = nullptr; - } - } - } - hr = S_OK; - } if (!pControl->wPageId && pControl->sczText && *pControl->sczText) { HRESULT hrFormat; @@ -2048,6 +2063,7 @@ return; } + HRESULT UpdateUIStrings(__in BOOTSTRAPPER_ACTION action) { HRESULT hr = S_OK; LPCWSTR likeInstalling = nullptr; @@ -2270,6 +2286,30 @@ StrFree(controlState); } StrFree(controlName); + controlName = nullptr; + + + // If a command link has a note, then add it. + if ((pControl->dwStyle & BS_TYPEMASK) == BS_COMMANDLINK || + (pControl->dwStyle & BS_TYPEMASK) == BS_DEFCOMMANDLINK) { + hr = StrAllocFormatted(&controlName, L"#(loc.%lsNote)", pControl->sczName); + if (SUCCEEDED(hr)) { + LOC_STRING *locText = nullptr; + hr = LocGetString(_wixLoc, controlName, &locText); + if (SUCCEEDED(hr) && locText && locText->wzText && locText->wzText[0]) { + LPWSTR text = nullptr; + hr = BalFormatString(locText->wzText, &text); + if (SUCCEEDED(hr) && text && text[0]) { + ThemeSendControlMessage(_theme, pControl->wId, BCM_SETNOTE, 0, (LPARAM)text); + ReleaseStr(text); + text = nullptr; + } + } + ReleaseStr(controlName); + controlName = nullptr; + } + hr = S_OK; + } } ThemeControlEnable(_theme, pControl->wId, enableControl); @@ -2515,9 +2555,8 @@ if (_installPage == PAGE_LOADING) { switch (_command.action) { case BOOTSTRAPPER_ACTION_INSTALL: - if (_upgradingOldVersion) { + if (_upgrading) { _installPage = PAGE_UPGRADE; - _upgrading = TRUE; } else if (SUCCEEDED(BalGetNumericVariable(L"SimpleInstall", &simple)) && simple) { _installPage = PAGE_SIMPLE_INSTALL; } else { @@ -2560,11 +2599,9 @@ static BAL_CONDITION WILL_ELEVATE_CONDITION = { L"not WixBundleElevated and (" /*Elevate when installing for all users*/ - L"InstallAllUsers or" + L"InstallAllUsers or " /*Elevate when installing the launcher for all users and it was not detected*/ - L"(InstallLauncherAllUsers and Include_launcher and not DetectedLauncher) or" - /*Elevate when the launcher was installed for all users and it is being removed*/ - L"(DetectedLauncher and DetectedLauncherAllUsers and not Include_launcher)" + L"(Include_launcher and InstallLauncherAllUsers and not DetectedLauncher)" L")", L"" }; @@ -2867,19 +2904,16 @@ return HRESULT_FROM_WIN32(res); } - static HRESULT LoadLauncherStateFromKey( + static HRESULT LoadAssociateFilesStateFromKey( __in IBootstrapperEngine* pEngine, __in HKEY hkHive ) { const LPCWSTR subkey = L"Software\\Python\\PyLauncher"; HKEY hKey; LRESULT res; - - if (IsTargetPlatformx64(pEngine)) { - res = RegOpenKeyExW(hkHive, subkey, 0, KEY_READ | KEY_WOW64_64KEY, &hKey); - } else { - res = RegOpenKeyExW(hkHive, subkey, 0, KEY_READ | KEY_WOW64_32KEY, &hKey); - } + HRESULT hr; + + res = RegOpenKeyExW(hkHive, subkey, 0, KEY_READ | KEY_WOW64_32KEY, &hKey); if (res == ERROR_FILE_NOT_FOUND) { return S_FALSE; @@ -2888,26 +2922,17 @@ return HRESULT_FROM_WIN32(res); } - res = RegQueryValueExW(hKey, nullptr, nullptr, nullptr, nullptr, nullptr); - if (res == ERROR_FILE_NOT_FOUND) { - pEngine->SetVariableNumeric(L"Include_launcher", 0); - } else if (res == ERROR_SUCCESS) { - pEngine->SetVariableNumeric(L"Include_launcher", 1); - pEngine->SetVariableNumeric(L"DetectedLauncher", 1); - pEngine->SetVariableNumeric(L"InstallLauncherAllUsers", (hkHive == HKEY_LOCAL_MACHINE) ? 1 : 0); - pEngine->SetVariableNumeric(L"DetectedLauncherAllUsers", (hkHive == HKEY_LOCAL_MACHINE) ? 1 : 0); - pEngine->SetVariableString(L"InstallLauncherAllUsersState", L"disable"); - } - res = RegQueryValueExW(hKey, L"AssociateFiles", nullptr, nullptr, nullptr, nullptr); if (res == ERROR_FILE_NOT_FOUND) { - pEngine->SetVariableNumeric(L"AssociateFiles", 0); + hr = S_FALSE; } else if (res == ERROR_SUCCESS) { - pEngine->SetVariableNumeric(L"AssociateFiles", 1); + hr = S_OK; + } else { + hr = HRESULT_FROM_WIN32(res); } RegCloseKey(hKey); - return S_OK; + return hr; } static void LoadOptionalFeatureStates(__in IBootstrapperEngine* pEngine) { @@ -2918,7 +2943,11 @@ HKEY hkHive; // The launcher installation is separate from the Python install, so we - // check its state later. This also checks the file association option. + // check its state later. For now, assume we don't want the launcher or + // file associations, and if they have already been installed then + // loading the state will reactivate these settings. + pEngine->SetVariableNumeric(L"Include_launcher", 0); + pEngine->SetVariableNumeric(L"AssociateFiles", 0); // Get the registry key from the bundle, to save having to duplicate it // in multiple places. @@ -3089,7 +3118,6 @@ _hrFinal = hrHostInitialization; _downgradingOtherVersion = FALSE; - _upgradingOldVersion = FALSE; _restartResult = BOOTSTRAPPER_APPLY_RESTART_NONE; _restartRequired = FALSE; _allowRestart = FALSE; @@ -3113,8 +3141,6 @@ _hBAFModule = nullptr; _baFunction = nullptr; - - EnsureTargetDir(); } @@ -3174,7 +3200,6 @@ DWORD _calculatedExecuteProgress; BOOL _downgradingOtherVersion; - BOOL _upgradingOldVersion; BOOTSTRAPPER_APPLY_RESTART _restartResult; BOOL _restartRequired; BOOL _allowRestart; diff --git a/Tools/msi/bundle/bundle.wxs b/Tools/msi/bundle/bundle.wxs --- a/Tools/msi/bundle/bundle.wxs +++ b/Tools/msi/bundle/bundle.wxs @@ -51,7 +51,7 @@ --> - + @@ -72,6 +72,7 @@ + @@ -81,6 +82,7 @@ + diff --git a/Tools/msi/bundle/packagegroups/launcher.wxs b/Tools/msi/bundle/packagegroups/launcher.wxs --- a/Tools/msi/bundle/packagegroups/launcher.wxs +++ b/Tools/msi/bundle/packagegroups/launcher.wxs @@ -11,7 +11,7 @@ EnableFeatureSelection="yes" Permanent="yes" Visible="yes" - InstallCondition="(InstallAllUsers or InstallLauncherAllUsers) and Include_launcher" /> + InstallCondition="(InstallAllUsers or InstallLauncherAllUsers) and Include_launcher and not DetectedLauncher" /> + InstallCondition="not (InstallAllUsers or InstallLauncherAllUsers) and Include_launcher and not DetectedLauncher" /> \ No newline at end of file -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 18:06:25 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 02 Dec 2015 23:06:25 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Null_merge?= Message-ID: <20151202230625.4864.75826@psf.io> https://hg.python.org/cpython/rev/c0522985bd7c changeset: 99416:c0522985bd7c branch: 3.5 parent: 99414:8537ec50c254 parent: 99409:7b5057b89a56 user: Serhiy Storchaka date: Thu Dec 03 00:57:41 2015 +0200 summary: Null merge files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 18:06:26 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 02 Dec 2015 23:06:26 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogSXNzdWUgIzI1NzA5?= =?utf-8?q?=3A_Fixed_problem_with_in-place_string_concatenation_and_utf-8_?= =?utf-8?q?cache=2E?= Message-ID: <20151202230625.21943.24373@psf.io> https://hg.python.org/cpython/rev/67718032badb changeset: 99418:67718032badb branch: 3.4 parent: 99409:7b5057b89a56 user: Serhiy Storchaka date: Thu Dec 03 01:02:03 2015 +0200 summary: Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. files: Lib/test/test_unicode.py | 17 +++++++++++++++++ Misc/NEWS | 2 ++ Objects/unicodeobject.c | 5 +++++ 3 files changed, 24 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -2672,6 +2672,23 @@ self.assertTrue(astral >= bmp2) self.assertFalse(astral >= astral2) + @support.cpython_only + def test_pep393_utf8_caching_bug(self): + # Issue #25709: Problem with string concatenation and utf-8 cache + from _testcapi import getargs_s_hash + for k in 0x24, 0xa4, 0x20ac, 0x1f40d: + s = '' + for i in range(5): + # Due to CPython specific optimization the 's' string can be + # resized in-place. + s += chr(k) + # Parsing with the "s#" format code calls indirectly + # PyUnicode_AsUTF8AndSize() which creates the UTF-8 + # encoded string cached in the Unicode object. + self.assertEqual(getargs_s_hash(s), chr(k).encode() * (i + 1)) + # Check that the second call returns the same result + self.assertEqual(getargs_s_hash(s), chr(k).encode() * (i + 1)) + class StringModuleTest(unittest.TestCase): def test_formatter_parser(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. + - Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside __getattr__. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -724,6 +724,11 @@ } new_size = (struct_size + (length + 1) * char_size); + if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) { + PyObject_DEL(_PyUnicode_UTF8(unicode)); + _PyUnicode_UTF8(unicode) = NULL; + _PyUnicode_UTF8_LENGTH(unicode) = 0; + } _Py_DEC_REFTOTAL; _Py_ForgetReference(unicode); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 18:06:26 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 02 Dec 2015 23:06:26 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325709=3A_Fixed_problem_with_in-place_string_con?= =?utf-8?q?catenation_and_utf-8_cache=2E?= Message-ID: <20151202230626.28754.20609@psf.io> https://hg.python.org/cpython/rev/9e800b2aeeac changeset: 99420:9e800b2aeeac parent: 99417:a89f92ac7d19 parent: 99419:a0e2376768dc user: Serhiy Storchaka date: Thu Dec 03 01:05:52 2015 +0200 summary: Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. files: Lib/test/test_unicode.py | 17 +++++++++++++++++ Misc/NEWS | 2 ++ Objects/unicodeobject.c | 5 +++++ 3 files changed, 24 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -2702,6 +2702,23 @@ self.assertTrue(astral >= bmp2) self.assertFalse(astral >= astral2) + @support.cpython_only + def test_pep393_utf8_caching_bug(self): + # Issue #25709: Problem with string concatenation and utf-8 cache + from _testcapi import getargs_s_hash + for k in 0x24, 0xa4, 0x20ac, 0x1f40d: + s = '' + for i in range(5): + # Due to CPython specific optimization the 's' string can be + # resized in-place. + s += chr(k) + # Parsing with the "s#" format code calls indirectly + # PyUnicode_AsUTF8AndSize() which creates the UTF-8 + # encoded string cached in the Unicode object. + self.assertEqual(getargs_s_hash(s), chr(k).encode() * (i + 1)) + # Check that the second call returns the same result + self.assertEqual(getargs_s_hash(s), chr(k).encode() * (i + 1)) + class StringModuleTest(unittest.TestCase): def test_formatter_parser(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. + - Issue #5319: New Py_FinalizeEx() API allowing Python to set an exit status of 120 on failure to flush buffered streams. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -885,6 +885,11 @@ } new_size = (struct_size + (length + 1) * char_size); + if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) { + PyObject_DEL(_PyUnicode_UTF8(unicode)); + _PyUnicode_UTF8(unicode) = NULL; + _PyUnicode_UTF8_LENGTH(unicode) = 0; + } _Py_DEC_REFTOTAL; _Py_ForgetReference(unicode); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 18:06:29 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 02 Dec 2015 23:06:29 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Issue_=2325709=3A_Fixed_problem_with_in-place_string_concatena?= =?utf-8?q?tion_and_utf-8_cache=2E?= Message-ID: <20151202230625.57674.63601@psf.io> https://hg.python.org/cpython/rev/a0e2376768dc changeset: 99419:a0e2376768dc branch: 3.5 parent: 99416:c0522985bd7c parent: 99418:67718032badb user: Serhiy Storchaka date: Thu Dec 03 01:04:37 2015 +0200 summary: Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. files: Lib/test/test_unicode.py | 17 +++++++++++++++++ Misc/NEWS | 2 ++ Objects/unicodeobject.c | 5 +++++ 3 files changed, 24 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -2702,6 +2702,23 @@ self.assertTrue(astral >= bmp2) self.assertFalse(astral >= astral2) + @support.cpython_only + def test_pep393_utf8_caching_bug(self): + # Issue #25709: Problem with string concatenation and utf-8 cache + from _testcapi import getargs_s_hash + for k in 0x24, 0xa4, 0x20ac, 0x1f40d: + s = '' + for i in range(5): + # Due to CPython specific optimization the 's' string can be + # resized in-place. + s += chr(k) + # Parsing with the "s#" format code calls indirectly + # PyUnicode_AsUTF8AndSize() which creates the UTF-8 + # encoded string cached in the Unicode object. + self.assertEqual(getargs_s_hash(s), chr(k).encode() * (i + 1)) + # Check that the second call returns the same result + self.assertEqual(getargs_s_hash(s), chr(k).encode() * (i + 1)) + class StringModuleTest(unittest.TestCase): def test_formatter_parser(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. + - Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside __getattr__. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -722,6 +722,11 @@ } new_size = (struct_size + (length + 1) * char_size); + if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) { + PyObject_DEL(_PyUnicode_UTF8(unicode)); + _PyUnicode_UTF8(unicode) = NULL; + _PyUnicode_UTF8_LENGTH(unicode) = 0; + } _Py_DEC_REFTOTAL; _Py_ForgetReference(unicode); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 18:06:46 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 02 Dec 2015 23:06:46 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <20151202230625.57684.25615@psf.io> https://hg.python.org/cpython/rev/a89f92ac7d19 changeset: 99417:a89f92ac7d19 parent: 99415:7dcc03b344b5 parent: 99416:c0522985bd7c user: Serhiy Storchaka date: Thu Dec 03 00:58:13 2015 +0200 summary: Null merge files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 20:53:59 2015 From: python-checkins at python.org (martin.panter) Date: Thu, 03 Dec 2015 01:53:59 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzE0Mjg1?= =?utf-8?q?=3A_Do_not_catch_=5F=5Finit=5F=5F=2Epy_exceptions_in_runpy?= Message-ID: <20151203015359.13865.29868@psf.io> https://hg.python.org/cpython/rev/784a64a21fd0 changeset: 99421:784a64a21fd0 branch: 3.5 parent: 99419:a0e2376768dc user: Martin Panter date: Thu Dec 03 01:23:10 2015 +0000 summary: Issue #14285: Do not catch __init__.py exceptions in runpy Initialize package before calling find_spec() for __main__, so that we do not incorrectly handle exceptions from __init__.py. When runpy is used from the Python CLI, use an internal exception rather than ImportError, to avoid catching unexpected exceptions. Also remove exception message rewriting in _run_module_as_main(), because it seems to be redundant with the _get_main_module_details() function. files: Lib/runpy.py | 44 +++++------ Lib/test/test_cmd_line_script.py | 71 +++++++++++++++++-- Lib/test/test_runpy.py | 22 ++++++ Misc/NEWS | 5 + 4 files changed, 110 insertions(+), 32 deletions(-) diff --git a/Lib/runpy.py b/Lib/runpy.py --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -99,7 +99,7 @@ return mod_globals.copy() # Helper to get the loader, code and filename for a module -def _get_module_details(mod_name): +def _get_module_details(mod_name, error=ImportError): try: spec = importlib.util.find_spec(mod_name) except (ImportError, AttributeError, TypeError, ValueError) as ex: @@ -107,27 +107,34 @@ # importlib, where the latter raises other errors for cases where # pkgutil previously raised ImportError msg = "Error while finding spec for {!r} ({}: {})" - raise ImportError(msg.format(mod_name, type(ex), ex)) from ex + raise error(msg.format(mod_name, type(ex), ex)) from ex if spec is None: - raise ImportError("No module named %s" % mod_name) + raise error("No module named %s" % mod_name) if spec.submodule_search_locations is not None: if mod_name == "__main__" or mod_name.endswith(".__main__"): - raise ImportError("Cannot use package as __main__ module") + raise error("Cannot use package as __main__ module") + __import__(mod_name) # Do not catch exceptions initializing package try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError as e: - raise ImportError(("%s; %r is a package and cannot " + + raise error(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name)) loader = spec.loader if loader is None: - raise ImportError("%r is a namespace package and cannot be executed" + raise error("%r is a namespace package and cannot be executed" % mod_name) - code = loader.get_code(mod_name) + try: + code = loader.get_code(mod_name) + except ImportError as e: + raise error(format(e)) from e if code is None: - raise ImportError("No code object available for %s" % mod_name) + raise error("No code object available for %s" % mod_name) return mod_name, spec, code +class _Error(Exception): + """Error that _run_module_as_main() should report without a traceback""" + # XXX ncoghlan: Should this be documented and made public? # (Current thoughts: don't repeat the mistake that lead to its # creation when run_module() no longer met the needs of @@ -148,20 +155,11 @@ """ try: if alter_argv or mod_name != "__main__": # i.e. -m switch - mod_name, mod_spec, code = _get_module_details(mod_name) + mod_name, mod_spec, code = _get_module_details(mod_name, _Error) else: # i.e. directory or zipfile execution - mod_name, mod_spec, code = _get_main_module_details() - except ImportError as exc: - # Try to provide a good error message - # for directories, zip files and the -m switch - if alter_argv: - # For -m switch, just display the exception - info = str(exc) - else: - # For directories/zipfiles, let the user - # know what the code was looking for - info = "can't find '__main__' module in %r" % sys.argv[0] - msg = "%s: %s" % (sys.executable, info) + mod_name, mod_spec, code = _get_main_module_details(_Error) + except _Error as exc: + msg = "%s: %s" % (sys.executable, exc) sys.exit(msg) main_globals = sys.modules["__main__"].__dict__ if alter_argv: @@ -184,7 +182,7 @@ # Leave the sys module alone return _run_code(code, {}, init_globals, run_name, mod_spec) -def _get_main_module_details(): +def _get_main_module_details(error=ImportError): # Helper that gives a nicer error message when attempting to # execute a zipfile or directory by invoking __main__.py # Also moves the standard __main__ out of the way so that the @@ -196,7 +194,7 @@ return _get_module_details(main_name) except ImportError as exc: if main_name in str(exc): - raise ImportError("can't find %r module in %r" % + raise error("can't find %r module in %r" % (main_name, sys.path[0])) from exc raise finally: diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -397,20 +397,73 @@ script_name, script_name, '', '', importlib.machinery.SourceFileLoader) + @contextlib.contextmanager + def setup_test_pkg(self, *args): + with support.temp_dir() as script_dir, \ + support.change_cwd(path=script_dir): + pkg_dir = os.path.join(script_dir, 'test_pkg') + make_pkg(pkg_dir, *args) + yield pkg_dir + + def check_dash_m_failure(self, *args): + rc, out, err = assert_python_failure('-m', *args, __isolated=False) + if verbose > 1: + print(repr(out)) + self.assertEqual(rc, 1) + return err + def test_dash_m_error_code_is_one(self): # If a module is invoked with the -m command line flag # and results in an error that the return code to the # shell is '1' - with support.temp_dir() as script_dir: - with support.change_cwd(path=script_dir): - pkg_dir = os.path.join(script_dir, 'test_pkg') - make_pkg(pkg_dir) - script_name = _make_test_script(pkg_dir, 'other', - "if __name__ == '__main__': raise ValueError") - rc, out, err = assert_python_failure('-m', 'test_pkg.other', *example_args) - if verbose > 1: - print(repr(out)) + with self.setup_test_pkg() as pkg_dir: + script_name = _make_test_script(pkg_dir, 'other', + "if __name__ == '__main__': raise ValueError") + err = self.check_dash_m_failure('test_pkg.other', *example_args) + self.assertIn(b'ValueError', err) + + def test_dash_m_errors(self): + # Exercise error reporting for various invalid package executions + tests = ( + ('builtins', br'No code object available'), + ('builtins.x', br'Error while finding spec.*AttributeError'), + ('builtins.x.y', br'Error while finding spec.*' + br'ImportError.*No module named.*not a package'), + ('os.path', br'loader.*cannot handle'), + ('importlib', br'No module named.*' + br'is a package and cannot be directly executed'), + ('importlib.nonexistant', br'No module named'), + ) + for name, regex in tests: + with self.subTest(name): + rc, _, err = assert_python_failure('-m', name) self.assertEqual(rc, 1) + self.assertRegex(err, regex) + self.assertNotIn(b'Traceback', err) + + def test_dash_m_init_traceback(self): + # These were wrapped in an ImportError and tracebacks were + # suppressed; see Issue 14285 + exceptions = (ImportError, AttributeError, TypeError, ValueError) + for exception in exceptions: + exception = exception.__name__ + init = "raise {0}('Exception in __init__.py')".format(exception) + with self.subTest(exception), \ + self.setup_test_pkg(init) as pkg_dir: + err = self.check_dash_m_failure('test_pkg') + self.assertIn(exception.encode('ascii'), err) + self.assertIn(b'Exception in __init__.py', err) + self.assertIn(b'Traceback', err) + + def test_dash_m_main_traceback(self): + # Ensure that an ImportError's traceback is reported + with self.setup_test_pkg() as pkg_dir: + main = "raise ImportError('Exception in __main__ module')" + _make_test_script(pkg_dir, '__main__', main) + err = self.check_dash_m_failure('test_pkg') + self.assertIn(b'ImportError', err) + self.assertIn(b'Exception in __main__ module', err) + self.assertIn(b'Traceback', err) def test_pep_409_verbiage(self): # Make sure PEP 409 syntax properly suppresses diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -439,6 +439,28 @@ if verbose > 1: print("Testing package depth:", depth) self._check_package(depth) + def test_run_package_init_exceptions(self): + # These were previously wrapped in an ImportError; see Issue 14285 + result = self._make_pkg("", 1, "__main__") + pkg_dir, _, mod_name, _ = result + mod_name = mod_name.replace(".__main__", "") + self.addCleanup(self._del_pkg, pkg_dir, 1, mod_name) + init = os.path.join(pkg_dir, "__runpy_pkg__", "__init__.py") + + exceptions = (ImportError, AttributeError, TypeError, ValueError) + for exception in exceptions: + name = exception.__name__ + with self.subTest(name): + source = "raise {0}('{0} in __init__.py.')".format(name) + with open(init, "wt", encoding="ascii") as mod_file: + mod_file.write(source) + try: + run_module(mod_name) + except exception as err: + self.assertNotIn("finding spec", format(err)) + else: + self.fail("Nothing raised; expected {}".format(name)) + def test_run_package_in_namespace_package(self): for depth in range(1, 4): if verbose > 1: print("Testing package depth:", depth) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,11 @@ Library ------- +- Issue #14285: When executing a package with the "python -m package" option, + and package initialization fails, a proper traceback is now reported. The + "runpy" module now lets exceptions from package initialization pass back to + the caller, rather than raising ImportError. + - Issue #25177: Fixed problem with the mean of very small and very large numbers. As a side effect, statistics.mean and statistics.variance should be significantly faster. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 2 20:54:00 2015 From: python-checkins at python.org (martin.panter) Date: Thu, 03 Dec 2015 01:54:00 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2314285=3A_Merge_runpy_exception_fix_from_3=2E5?= Message-ID: <20151203015400.1997.3869@psf.io> https://hg.python.org/cpython/rev/01397c11ebb8 changeset: 99422:01397c11ebb8 parent: 99420:9e800b2aeeac parent: 99421:784a64a21fd0 user: Martin Panter date: Thu Dec 03 01:36:03 2015 +0000 summary: Issue #14285: Merge runpy exception fix from 3.5 files: Lib/runpy.py | 44 +++++------ Lib/test/test_cmd_line_script.py | 71 +++++++++++++++++-- Lib/test/test_runpy.py | 22 ++++++ Misc/NEWS | 5 + 4 files changed, 110 insertions(+), 32 deletions(-) diff --git a/Lib/runpy.py b/Lib/runpy.py --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -99,7 +99,7 @@ return mod_globals.copy() # Helper to get the loader, code and filename for a module -def _get_module_details(mod_name): +def _get_module_details(mod_name, error=ImportError): try: spec = importlib.util.find_spec(mod_name) except (ImportError, AttributeError, TypeError, ValueError) as ex: @@ -107,27 +107,34 @@ # importlib, where the latter raises other errors for cases where # pkgutil previously raised ImportError msg = "Error while finding spec for {!r} ({}: {})" - raise ImportError(msg.format(mod_name, type(ex), ex)) from ex + raise error(msg.format(mod_name, type(ex), ex)) from ex if spec is None: - raise ImportError("No module named %s" % mod_name) + raise error("No module named %s" % mod_name) if spec.submodule_search_locations is not None: if mod_name == "__main__" or mod_name.endswith(".__main__"): - raise ImportError("Cannot use package as __main__ module") + raise error("Cannot use package as __main__ module") + __import__(mod_name) # Do not catch exceptions initializing package try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError as e: - raise ImportError(("%s; %r is a package and cannot " + + raise error(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name)) loader = spec.loader if loader is None: - raise ImportError("%r is a namespace package and cannot be executed" + raise error("%r is a namespace package and cannot be executed" % mod_name) - code = loader.get_code(mod_name) + try: + code = loader.get_code(mod_name) + except ImportError as e: + raise error(format(e)) from e if code is None: - raise ImportError("No code object available for %s" % mod_name) + raise error("No code object available for %s" % mod_name) return mod_name, spec, code +class _Error(Exception): + """Error that _run_module_as_main() should report without a traceback""" + # XXX ncoghlan: Should this be documented and made public? # (Current thoughts: don't repeat the mistake that lead to its # creation when run_module() no longer met the needs of @@ -148,20 +155,11 @@ """ try: if alter_argv or mod_name != "__main__": # i.e. -m switch - mod_name, mod_spec, code = _get_module_details(mod_name) + mod_name, mod_spec, code = _get_module_details(mod_name, _Error) else: # i.e. directory or zipfile execution - mod_name, mod_spec, code = _get_main_module_details() - except ImportError as exc: - # Try to provide a good error message - # for directories, zip files and the -m switch - if alter_argv: - # For -m switch, just display the exception - info = str(exc) - else: - # For directories/zipfiles, let the user - # know what the code was looking for - info = "can't find '__main__' module in %r" % sys.argv[0] - msg = "%s: %s" % (sys.executable, info) + mod_name, mod_spec, code = _get_main_module_details(_Error) + except _Error as exc: + msg = "%s: %s" % (sys.executable, exc) sys.exit(msg) main_globals = sys.modules["__main__"].__dict__ if alter_argv: @@ -184,7 +182,7 @@ # Leave the sys module alone return _run_code(code, {}, init_globals, run_name, mod_spec) -def _get_main_module_details(): +def _get_main_module_details(error=ImportError): # Helper that gives a nicer error message when attempting to # execute a zipfile or directory by invoking __main__.py # Also moves the standard __main__ out of the way so that the @@ -196,7 +194,7 @@ return _get_module_details(main_name) except ImportError as exc: if main_name in str(exc): - raise ImportError("can't find %r module in %r" % + raise error("can't find %r module in %r" % (main_name, sys.path[0])) from exc raise finally: diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -397,20 +397,73 @@ script_name, script_name, '', '', importlib.machinery.SourceFileLoader) + @contextlib.contextmanager + def setup_test_pkg(self, *args): + with support.temp_dir() as script_dir, \ + support.change_cwd(path=script_dir): + pkg_dir = os.path.join(script_dir, 'test_pkg') + make_pkg(pkg_dir, *args) + yield pkg_dir + + def check_dash_m_failure(self, *args): + rc, out, err = assert_python_failure('-m', *args, __isolated=False) + if verbose > 1: + print(repr(out)) + self.assertEqual(rc, 1) + return err + def test_dash_m_error_code_is_one(self): # If a module is invoked with the -m command line flag # and results in an error that the return code to the # shell is '1' - with support.temp_dir() as script_dir: - with support.change_cwd(path=script_dir): - pkg_dir = os.path.join(script_dir, 'test_pkg') - make_pkg(pkg_dir) - script_name = _make_test_script(pkg_dir, 'other', - "if __name__ == '__main__': raise ValueError") - rc, out, err = assert_python_failure('-m', 'test_pkg.other', *example_args) - if verbose > 1: - print(repr(out)) + with self.setup_test_pkg() as pkg_dir: + script_name = _make_test_script(pkg_dir, 'other', + "if __name__ == '__main__': raise ValueError") + err = self.check_dash_m_failure('test_pkg.other', *example_args) + self.assertIn(b'ValueError', err) + + def test_dash_m_errors(self): + # Exercise error reporting for various invalid package executions + tests = ( + ('builtins', br'No code object available'), + ('builtins.x', br'Error while finding spec.*AttributeError'), + ('builtins.x.y', br'Error while finding spec.*' + br'ImportError.*No module named.*not a package'), + ('os.path', br'loader.*cannot handle'), + ('importlib', br'No module named.*' + br'is a package and cannot be directly executed'), + ('importlib.nonexistant', br'No module named'), + ) + for name, regex in tests: + with self.subTest(name): + rc, _, err = assert_python_failure('-m', name) self.assertEqual(rc, 1) + self.assertRegex(err, regex) + self.assertNotIn(b'Traceback', err) + + def test_dash_m_init_traceback(self): + # These were wrapped in an ImportError and tracebacks were + # suppressed; see Issue 14285 + exceptions = (ImportError, AttributeError, TypeError, ValueError) + for exception in exceptions: + exception = exception.__name__ + init = "raise {0}('Exception in __init__.py')".format(exception) + with self.subTest(exception), \ + self.setup_test_pkg(init) as pkg_dir: + err = self.check_dash_m_failure('test_pkg') + self.assertIn(exception.encode('ascii'), err) + self.assertIn(b'Exception in __init__.py', err) + self.assertIn(b'Traceback', err) + + def test_dash_m_main_traceback(self): + # Ensure that an ImportError's traceback is reported + with self.setup_test_pkg() as pkg_dir: + main = "raise ImportError('Exception in __main__ module')" + _make_test_script(pkg_dir, '__main__', main) + err = self.check_dash_m_failure('test_pkg') + self.assertIn(b'ImportError', err) + self.assertIn(b'Exception in __main__ module', err) + self.assertIn(b'Traceback', err) def test_pep_409_verbiage(self): # Make sure PEP 409 syntax properly suppresses diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -439,6 +439,28 @@ if verbose > 1: print("Testing package depth:", depth) self._check_package(depth) + def test_run_package_init_exceptions(self): + # These were previously wrapped in an ImportError; see Issue 14285 + result = self._make_pkg("", 1, "__main__") + pkg_dir, _, mod_name, _ = result + mod_name = mod_name.replace(".__main__", "") + self.addCleanup(self._del_pkg, pkg_dir, 1, mod_name) + init = os.path.join(pkg_dir, "__runpy_pkg__", "__init__.py") + + exceptions = (ImportError, AttributeError, TypeError, ValueError) + for exception in exceptions: + name = exception.__name__ + with self.subTest(name): + source = "raise {0}('{0} in __init__.py.')".format(name) + with open(init, "wt", encoding="ascii") as mod_file: + mod_file.write(source) + try: + run_module(mod_name) + except exception as err: + self.assertNotIn("finding spec", format(err)) + else: + self.fail("Nothing raised; expected {}".format(name)) + def test_run_package_in_namespace_package(self): for depth in range(1, 4): if verbose > 1: print("Testing package depth:", depth) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -109,6 +109,11 @@ Library ------- +- Issue #14285: When executing a package with the "python -m package" option, + and package initialization fails, a proper traceback is now reported. The + "runpy" module now lets exceptions from package initialization pass back to + the caller, rather than raising ImportError. + - Issue #25177: Fixed problem with the mean of very small and very large numbers. As a side effect, statistics.mean and statistics.variance should be significantly faster. -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Thu Dec 3 03:43:03 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 03 Dec 2015 08:43:03 +0000 Subject: [Python-checkins] Daily reference leaks (01397c11ebb8): sum=4 Message-ID: <20151203084302.29749.81209@psf.io> results for 01397c11ebb8 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflog0MKx4_', '--timeout', '7200'] From lp_benchmark_robot at intel.com Thu Dec 3 12:00:10 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 3 Dec 2015 17:00:10 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-03 Message-ID: <88843176-a722-4499-aab3-44238c688615@irsmsx151.ger.corp.intel.com> Results for project Python default, build date 2015-12-03 04:02:59 +0000 commit: 01397c11ebb809a7ccc0a1b4c873183e318dc9dc revision date: 2015-12-03 01:36:03 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.20% 2.73% 10.00% 15.45% :-( pybench 0.20% -0.14% -2.06% 9.28% :-( regex_v8 2.73% 1.82% -3.69% 4.90% :-( nbody 0.06% -2.57% -3.09% 12.18% :-| json_dump_v2 0.23% -0.21% -1.09% 11.34% :-| normal_startup 0.87% 0.09% 0.41% 4.48% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Thu Dec 3 12:00:37 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 3 Dec 2015 17:00:37 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-03 Message-ID: <6f47ad62-6d81-4f28-af36-9777a7406f82@irsmsx151.ger.corp.intel.com> Results for project Python 2.7, build date 2015-12-03 04:50:31 +0000 commit: ff351607a90d345d1335eef3518ab5f43f1ee118 revision date: 2015-12-02 13:39:37 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-| django_v2 0.18% -0.59% 1.62% 8.58% :-) pybench 0.19% -0.12% 6.09% 7.21% :-( regex_v8 1.40% -0.20% -3.33% 9.06% :-) nbody 0.13% -0.03% 9.51% 2.45% :-) json_dump_v2 0.32% 0.07% 2.74% 13.46% :-| normal_startup 1.94% 0.40% -1.47% 2.15% :-| ssbench 0.35% 0.01% 0.35% 2.39% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Thu Dec 3 13:48:12 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 03 Dec 2015 18:48:12 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE5NTQz?= =?utf-8?q?=3A_Added_Py3k_warning_for_decoding_unicode=2E?= Message-ID: <20151203184812.21502.21478@psf.io> https://hg.python.org/cpython/rev/c89a0f24d5f6 changeset: 99423:c89a0f24d5f6 branch: 2.7 parent: 99413:ff351607a90d user: Serhiy Storchaka date: Thu Dec 03 20:47:48 2015 +0200 summary: Issue #19543: Added Py3k warning for decoding unicode. files: Lib/test/test_unicode.py | 10 ++++++---- Misc/NEWS | 2 ++ Objects/unicodeobject.c | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -1037,10 +1037,12 @@ self.assertEqual(unicode('Andr\202 x','ascii','ignore'), u"Andr x") self.assertEqual(unicode('Andr\202 x','ascii','replace'), u'Andr\uFFFD x') self.assertEqual(unicode('\202 x', 'ascii', 'replace'), u'\uFFFD x') - self.assertEqual(u'abcde'.decode('ascii', 'ignore'), - u'abcde'.decode('ascii', errors='ignore')) - self.assertEqual(u'abcde'.decode('ascii', 'replace'), - u'abcde'.decode(encoding='ascii', errors='replace')) + with test_support.check_py3k_warnings(): + self.assertEqual(u'abcde'.decode('ascii', 'ignore'), + u'abcde'.decode('ascii', errors='ignore')) + with test_support.check_py3k_warnings(): + self.assertEqual(u'abcde'.decode('ascii', 'replace'), + u'abcde'.decode(encoding='ascii', errors='replace')) # Error handling (unknown character names) self.assertEqual("\\N{foo}xx".decode("unicode-escape", "ignore"), u"xx") diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #19543: Added Py3k warning for decoding unicode. + - Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside __getattr__. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1288,6 +1288,9 @@ goto onError; } + if (PyErr_WarnPy3k("decoding Unicode is not supported in 3.x", 1) < 0) + goto onError; + if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 3 15:28:11 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 03 Dec 2015 20:28:11 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogSXNzdWUgIzY0Nzg6?= =?utf-8?q?_=5Fstrptime=27s_regexp_cache_now_is_reset_after_changing_timez?= =?utf-8?q?one?= Message-ID: <20151203202811.4074.80006@psf.io> https://hg.python.org/cpython/rev/4b0a4da1aa27 changeset: 99425:4b0a4da1aa27 branch: 3.4 parent: 99418:67718032badb user: Serhiy Storchaka date: Thu Dec 03 22:21:07 2015 +0200 summary: Issue #6478: _strptime's regexp cache now is reset after changing timezone with time.tzset(). files: Lib/_strptime.py | 21 +++++++++---- Lib/test/test_strptime.py | 40 ++++++++++++++++++++++---- Misc/NEWS | 3 ++ 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/Lib/_strptime.py b/Lib/_strptime.py --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -77,6 +77,8 @@ self.__calc_date_time() if _getlang() != self.lang: raise ValueError("locale changed during initialization") + if time.tzname != self.tzname or time.daylight != self.daylight: + raise ValueError("timezone changed during initialization") def __pad(self, seq, front): # Add '' to seq to either the front (is True), else the back. @@ -161,15 +163,17 @@ def __calc_timezone(self): # Set self.timezone by using time.tzname. - # Do not worry about possibility of time.tzname[0] == timetzname[1] - # and time.daylight; handle that in strptime . + # Do not worry about possibility of time.tzname[0] == time.tzname[1] + # and time.daylight; handle that in strptime. try: time.tzset() except AttributeError: pass - no_saving = frozenset(["utc", "gmt", time.tzname[0].lower()]) - if time.daylight: - has_saving = frozenset([time.tzname[1].lower()]) + self.tzname = time.tzname + self.daylight = time.daylight + no_saving = frozenset(["utc", "gmt", self.tzname[0].lower()]) + if self.daylight: + has_saving = frozenset([self.tzname[1].lower()]) else: has_saving = frozenset() self.timezone = (no_saving, has_saving) @@ -308,12 +312,15 @@ global _TimeRE_cache, _regex_cache with _cache_lock: - if _getlang() != _TimeRE_cache.locale_time.lang: + locale_time = _TimeRE_cache.locale_time + if (_getlang() != locale_time.lang or + time.tzname != locale_time.tzname or + time.daylight != locale_time.daylight): _TimeRE_cache = TimeRE() _regex_cache.clear() + locale_time = _TimeRE_cache.locale_time if len(_regex_cache) > _CACHE_MAX_SIZE: _regex_cache.clear() - locale_time = _TimeRE_cache.locale_time format_regex = _regex_cache.get(format) if not format_regex: try: diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -4,6 +4,7 @@ import time import locale import re +import os import sys from test import support from datetime import date as datetime_date @@ -324,9 +325,10 @@ tz_name = time.tzname[0] if tz_name.upper() in ("UTC", "GMT"): self.skipTest('need non-UTC/GMT timezone') - try: - original_tzname = time.tzname - original_daylight = time.daylight + + with support.swap_attr(time, 'tzname', (tz_name, tz_name)), \ + support.swap_attr(time, 'daylight', 1), \ + support.swap_attr(time, 'tzset', lambda: None): time.tzname = (tz_name, tz_name) time.daylight = 1 tz_value = _strptime._strptime_time(tz_name, "%Z")[8] @@ -334,9 +336,6 @@ "%s lead to a timezone value of %s instead of -1 when " "time.daylight set to %s and passing in %s" % (time.tzname, tz_value, time.daylight, tz_name)) - finally: - time.tzname = original_tzname - time.daylight = original_daylight def test_date_time(self): # Test %c directive @@ -548,7 +547,7 @@ _strptime._strptime_time("10", "%d") self.assertIsNot(locale_time_id, _strptime._TimeRE_cache.locale_time) - def test_TimeRE_recreation(self): + def test_TimeRE_recreation_locale(self): # The TimeRE instance should be recreated upon changing the locale. locale_info = locale.getlocale(locale.LC_TIME) try: @@ -577,6 +576,33 @@ finally: locale.setlocale(locale.LC_TIME, locale_info) + @support.run_with_tz('STD-1DST') + def test_TimeRE_recreation_timezone(self): + # The TimeRE instance should be recreated upon changing the timezone. + oldtzname = time.tzname + tm = _strptime._strptime_time(time.tzname[0], '%Z') + self.assertEqual(tm.tm_isdst, 0) + tm = _strptime._strptime_time(time.tzname[1], '%Z') + self.assertEqual(tm.tm_isdst, 1) + # Get id of current cache object. + first_time_re = _strptime._TimeRE_cache + # Change the timezone and force a recreation of the cache. + os.environ['TZ'] = 'EST+05EDT,M3.2.0,M11.1.0' + time.tzset() + tm = _strptime._strptime_time(time.tzname[0], '%Z') + self.assertEqual(tm.tm_isdst, 0) + tm = _strptime._strptime_time(time.tzname[1], '%Z') + self.assertEqual(tm.tm_isdst, 1) + # Get the new cache object's id. + second_time_re = _strptime._TimeRE_cache + # They should not be equal. + self.assertIsNot(first_time_re, second_time_re) + # Make sure old names no longer accepted. + with self.assertRaises(ValueError): + _strptime._strptime_time(oldtzname[0], '%Z') + with self.assertRaises(ValueError): + _strptime._strptime_time(oldtzname[1], '%Z') + def test_main(): support.run_unittest( diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -115,6 +115,9 @@ Library ------- +- Issue #6478: _strptime's regexp cache now is reset after changing timezone + with time.tzset(). + - Issue #25177: Fixed problem with the mean of very small and very large numbers. As a side effect, statistics.mean and statistics.variance should be significantly faster. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 3 15:28:14 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 03 Dec 2015 20:28:14 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=236478=3A_=5Fstrptime=27s_regexp_cache_now_is_res?= =?utf-8?q?et_after_changing_timezone?= Message-ID: <20151203202811.105473.78656@psf.io> https://hg.python.org/cpython/rev/ea576db13827 changeset: 99427:ea576db13827 parent: 99422:01397c11ebb8 parent: 99426:5fa855d20624 user: Serhiy Storchaka date: Thu Dec 03 22:27:31 2015 +0200 summary: Issue #6478: _strptime's regexp cache now is reset after changing timezone with time.tzset(). files: Lib/_strptime.py | 22 +++++++++----- Lib/test/test_strptime.py | 40 ++++++++++++++++++++++---- Misc/NEWS | 3 ++ 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/Lib/_strptime.py b/Lib/_strptime.py --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -77,6 +77,8 @@ self.__calc_date_time() if _getlang() != self.lang: raise ValueError("locale changed during initialization") + if time.tzname != self.tzname or time.daylight != self.daylight: + raise ValueError("timezone changed during initialization") def __pad(self, seq, front): # Add '' to seq to either the front (is True), else the back. @@ -161,15 +163,17 @@ def __calc_timezone(self): # Set self.timezone by using time.tzname. - # Do not worry about possibility of time.tzname[0] == timetzname[1] - # and time.daylight; handle that in strptime . + # Do not worry about possibility of time.tzname[0] == time.tzname[1] + # and time.daylight; handle that in strptime. try: time.tzset() except AttributeError: pass - no_saving = frozenset({"utc", "gmt", time.tzname[0].lower()}) - if time.daylight: - has_saving = frozenset({time.tzname[1].lower()}) + self.tzname = time.tzname + self.daylight = time.daylight + no_saving = frozenset({"utc", "gmt", self.tzname[0].lower()}) + if self.daylight: + has_saving = frozenset({self.tzname[1].lower()}) else: has_saving = frozenset() self.timezone = (no_saving, has_saving) @@ -326,13 +330,15 @@ global _TimeRE_cache, _regex_cache with _cache_lock: - - if _getlang() != _TimeRE_cache.locale_time.lang: + locale_time = _TimeRE_cache.locale_time + if (_getlang() != locale_time.lang or + time.tzname != locale_time.tzname or + time.daylight != locale_time.daylight): _TimeRE_cache = TimeRE() _regex_cache.clear() + locale_time = _TimeRE_cache.locale_time if len(_regex_cache) > _CACHE_MAX_SIZE: _regex_cache.clear() - locale_time = _TimeRE_cache.locale_time format_regex = _regex_cache.get(format) if not format_regex: try: diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -4,6 +4,7 @@ import time import locale import re +import os import sys from test import support from datetime import date as datetime_date @@ -344,9 +345,10 @@ tz_name = time.tzname[0] if tz_name.upper() in ("UTC", "GMT"): self.skipTest('need non-UTC/GMT timezone') - try: - original_tzname = time.tzname - original_daylight = time.daylight + + with support.swap_attr(time, 'tzname', (tz_name, tz_name)), \ + support.swap_attr(time, 'daylight', 1), \ + support.swap_attr(time, 'tzset', lambda: None): time.tzname = (tz_name, tz_name) time.daylight = 1 tz_value = _strptime._strptime_time(tz_name, "%Z")[8] @@ -354,9 +356,6 @@ "%s lead to a timezone value of %s instead of -1 when " "time.daylight set to %s and passing in %s" % (time.tzname, tz_value, time.daylight, tz_name)) - finally: - time.tzname = original_tzname - time.daylight = original_daylight def test_date_time(self): # Test %c directive @@ -579,7 +578,7 @@ _strptime._strptime_time("10", "%d") self.assertIsNot(locale_time_id, _strptime._TimeRE_cache.locale_time) - def test_TimeRE_recreation(self): + def test_TimeRE_recreation_locale(self): # The TimeRE instance should be recreated upon changing the locale. locale_info = locale.getlocale(locale.LC_TIME) try: @@ -608,6 +607,33 @@ finally: locale.setlocale(locale.LC_TIME, locale_info) + @support.run_with_tz('STD-1DST') + def test_TimeRE_recreation_timezone(self): + # The TimeRE instance should be recreated upon changing the timezone. + oldtzname = time.tzname + tm = _strptime._strptime_time(time.tzname[0], '%Z') + self.assertEqual(tm.tm_isdst, 0) + tm = _strptime._strptime_time(time.tzname[1], '%Z') + self.assertEqual(tm.tm_isdst, 1) + # Get id of current cache object. + first_time_re = _strptime._TimeRE_cache + # Change the timezone and force a recreation of the cache. + os.environ['TZ'] = 'EST+05EDT,M3.2.0,M11.1.0' + time.tzset() + tm = _strptime._strptime_time(time.tzname[0], '%Z') + self.assertEqual(tm.tm_isdst, 0) + tm = _strptime._strptime_time(time.tzname[1], '%Z') + self.assertEqual(tm.tm_isdst, 1) + # Get the new cache object's id. + second_time_re = _strptime._TimeRE_cache + # They should not be equal. + self.assertIsNot(first_time_re, second_time_re) + # Make sure old names no longer accepted. + with self.assertRaises(ValueError): + _strptime._strptime_time(oldtzname[0], '%Z') + with self.assertRaises(ValueError): + _strptime._strptime_time(oldtzname[1], '%Z') + if __name__ == '__main__': unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -109,6 +109,9 @@ Library ------- +- Issue #6478: _strptime's regexp cache now is reset after changing timezone + with time.tzset(). + - Issue #14285: When executing a package with the "python -m package" option, and package initialization fails, a proper traceback is now reported. The "runpy" module now lets exceptions from package initialization pass back to -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 3 15:28:17 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 03 Dec 2015 20:28:17 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzY0Nzg6?= =?utf-8?q?_=5Fstrptime=27s_regexp_cache_now_is_reset_after_changing_timez?= =?utf-8?q?one?= Message-ID: <20151203202811.33671.31291@psf.io> https://hg.python.org/cpython/rev/2ae5c51c5dea changeset: 99424:2ae5c51c5dea branch: 2.7 user: Serhiy Storchaka date: Thu Dec 03 22:20:45 2015 +0200 summary: Issue #6478: _strptime's regexp cache now is reset after changing timezone with time.tzset(). files: Lib/_strptime.py | 21 ++++++++---- Lib/test/test_strptime.py | 44 +++++++++++++++++++++----- Lib/test/test_support.py | 35 ++++++++++++++++++++- Misc/NEWS | 3 + 4 files changed, 86 insertions(+), 17 deletions(-) diff --git a/Lib/_strptime.py b/Lib/_strptime.py --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -75,6 +75,8 @@ self.__calc_date_time() if _getlang() != self.lang: raise ValueError("locale changed during initialization") + if time.tzname != self.tzname or time.daylight != self.daylight: + raise ValueError("timezone changed during initialization") def __pad(self, seq, front): # Add '' to seq to either the front (is True), else the back. @@ -159,15 +161,17 @@ def __calc_timezone(self): # Set self.timezone by using time.tzname. - # Do not worry about possibility of time.tzname[0] == timetzname[1] - # and time.daylight; handle that in strptime . + # Do not worry about possibility of time.tzname[0] == time.tzname[1] + # and time.daylight; handle that in strptime. try: time.tzset() except AttributeError: pass - no_saving = frozenset(["utc", "gmt", time.tzname[0].lower()]) - if time.daylight: - has_saving = frozenset([time.tzname[1].lower()]) + self.tzname = time.tzname + self.daylight = time.daylight + no_saving = frozenset(["utc", "gmt", self.tzname[0].lower()]) + if self.daylight: + has_saving = frozenset([self.tzname[1].lower()]) else: has_saving = frozenset() self.timezone = (no_saving, has_saving) @@ -296,12 +300,15 @@ """Return a time struct based on the input string and the format string.""" global _TimeRE_cache, _regex_cache with _cache_lock: - if _getlang() != _TimeRE_cache.locale_time.lang: + locale_time = _TimeRE_cache.locale_time + if (_getlang() != locale_time.lang or + time.tzname != locale_time.tzname or + time.daylight != locale_time.daylight): _TimeRE_cache = TimeRE() _regex_cache.clear() + locale_time = _TimeRE_cache.locale_time if len(_regex_cache) > _CACHE_MAX_SIZE: _regex_cache.clear() - locale_time = _TimeRE_cache.locale_time format_regex = _regex_cache.get(format) if not format_regex: try: diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -4,8 +4,9 @@ import time import locale import re +import os import sys -from test import test_support +from test import test_support as support from datetime import date as datetime_date import _strptime @@ -314,9 +315,10 @@ tz_name = time.tzname[0] if tz_name.upper() in ("UTC", "GMT"): self.skipTest('need non-UTC/GMT timezone') - try: - original_tzname = time.tzname - original_daylight = time.daylight + + with support.swap_attr(time, 'tzname', (tz_name, tz_name)), \ + support.swap_attr(time, 'daylight', 1), \ + support.swap_attr(time, 'tzset', lambda: None): time.tzname = (tz_name, tz_name) time.daylight = 1 tz_value = _strptime._strptime_time(tz_name, "%Z")[8] @@ -324,9 +326,6 @@ "%s lead to a timezone value of %s instead of -1 when " "time.daylight set to %s and passing in %s" % (time.tzname, tz_value, time.daylight, tz_name)) - finally: - time.tzname = original_tzname - time.daylight = original_daylight def test_date_time(self): # Test %c directive @@ -538,7 +537,7 @@ _strptime._strptime_time("10", "%d") self.assertIsNot(locale_time_id, _strptime._TimeRE_cache.locale_time) - def test_TimeRE_recreation(self): + def test_TimeRE_recreation_locale(self): # The TimeRE instance should be recreated upon changing the locale. locale_info = locale.getlocale(locale.LC_TIME) try: @@ -567,9 +566,36 @@ finally: locale.setlocale(locale.LC_TIME, locale_info) + @support.run_with_tz('STD-1DST') + def test_TimeRE_recreation_timezone(self): + # The TimeRE instance should be recreated upon changing the timezone. + oldtzname = time.tzname + tm = _strptime._strptime_time(time.tzname[0], '%Z') + self.assertEqual(tm.tm_isdst, 0) + tm = _strptime._strptime_time(time.tzname[1], '%Z') + self.assertEqual(tm.tm_isdst, 1) + # Get id of current cache object. + first_time_re = _strptime._TimeRE_cache + # Change the timezone and force a recreation of the cache. + os.environ['TZ'] = 'EST+05EDT,M3.2.0,M11.1.0' + time.tzset() + tm = _strptime._strptime_time(time.tzname[0], '%Z') + self.assertEqual(tm.tm_isdst, 0) + tm = _strptime._strptime_time(time.tzname[1], '%Z') + self.assertEqual(tm.tm_isdst, 1) + # Get the new cache object's id. + second_time_re = _strptime._TimeRE_cache + # They should not be equal. + self.assertIsNot(first_time_re, second_time_re) + # Make sure old names no longer accepted. + with self.assertRaises(ValueError): + _strptime._strptime_time(oldtzname[0], '%Z') + with self.assertRaises(ValueError): + _strptime._strptime_time(oldtzname[1], '%Z') + def test_main(): - test_support.run_unittest( + support.run_unittest( getlang_Tests, LocaleTime_Tests, TimeRETests, diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -40,7 +40,7 @@ "threading_cleanup", "reap_threads", "start_threads", "cpython_only", "check_impl_detail", "get_attribute", "py3k_bytes", "import_fresh_module", "threading_cleanup", "reap_children", - "strip_python_stderr", "IPV6_ENABLED"] + "strip_python_stderr", "IPV6_ENABLED", "run_with_tz"] class Error(Exception): """Base class for regression test exceptions.""" @@ -1226,6 +1226,39 @@ return decorator #======================================================================= +# Decorator for running a function in a specific timezone, correctly +# resetting it afterwards. + +def run_with_tz(tz): + def decorator(func): + def inner(*args, **kwds): + try: + tzset = time.tzset + except AttributeError: + raise unittest.SkipTest("tzset required") + if 'TZ' in os.environ: + orig_tz = os.environ['TZ'] + else: + orig_tz = None + os.environ['TZ'] = tz + tzset() + + # now run the function, resetting the tz on exceptions + try: + return func(*args, **kwds) + finally: + if orig_tz is None: + del os.environ['TZ'] + else: + os.environ['TZ'] = orig_tz + time.tzset() + + inner.__name__ = func.__name__ + inner.__doc__ = func.__doc__ + return inner + return decorator + +#======================================================================= # Big-memory-test support. Separate from 'resources' because memory use should be configurable. # Some handy shorthands. Note that these are used for byte-limits as well diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,9 @@ Library ------- +- Issue #6478: _strptime's regexp cache now is reset after changing timezone + with time.tzset(). + - Issue #25718: Fixed copying object with state with boolean value is false. - Issue #25742: :func:`locale.setlocale` now accepts a Unicode string for -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 3 15:28:18 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 03 Dec 2015 20:28:18 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Issue_=236478=3A_=5Fstrptime=27s_regexp_cache_now_is_reset_aft?= =?utf-8?q?er_changing_timezone?= Message-ID: <20151203202811.33671.93236@psf.io> https://hg.python.org/cpython/rev/5fa855d20624 changeset: 99426:5fa855d20624 branch: 3.5 parent: 99421:784a64a21fd0 parent: 99425:4b0a4da1aa27 user: Serhiy Storchaka date: Thu Dec 03 22:26:36 2015 +0200 summary: Issue #6478: _strptime's regexp cache now is reset after changing timezone with time.tzset(). files: Lib/_strptime.py | 22 +++++++++----- Lib/test/test_strptime.py | 40 ++++++++++++++++++++++---- Misc/NEWS | 3 ++ 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/Lib/_strptime.py b/Lib/_strptime.py --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -77,6 +77,8 @@ self.__calc_date_time() if _getlang() != self.lang: raise ValueError("locale changed during initialization") + if time.tzname != self.tzname or time.daylight != self.daylight: + raise ValueError("timezone changed during initialization") def __pad(self, seq, front): # Add '' to seq to either the front (is True), else the back. @@ -161,15 +163,17 @@ def __calc_timezone(self): # Set self.timezone by using time.tzname. - # Do not worry about possibility of time.tzname[0] == timetzname[1] - # and time.daylight; handle that in strptime . + # Do not worry about possibility of time.tzname[0] == time.tzname[1] + # and time.daylight; handle that in strptime. try: time.tzset() except AttributeError: pass - no_saving = frozenset({"utc", "gmt", time.tzname[0].lower()}) - if time.daylight: - has_saving = frozenset({time.tzname[1].lower()}) + self.tzname = time.tzname + self.daylight = time.daylight + no_saving = frozenset({"utc", "gmt", self.tzname[0].lower()}) + if self.daylight: + has_saving = frozenset({self.tzname[1].lower()}) else: has_saving = frozenset() self.timezone = (no_saving, has_saving) @@ -307,13 +311,15 @@ global _TimeRE_cache, _regex_cache with _cache_lock: - - if _getlang() != _TimeRE_cache.locale_time.lang: + locale_time = _TimeRE_cache.locale_time + if (_getlang() != locale_time.lang or + time.tzname != locale_time.tzname or + time.daylight != locale_time.daylight): _TimeRE_cache = TimeRE() _regex_cache.clear() + locale_time = _TimeRE_cache.locale_time if len(_regex_cache) > _CACHE_MAX_SIZE: _regex_cache.clear() - locale_time = _TimeRE_cache.locale_time format_regex = _regex_cache.get(format) if not format_regex: try: diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -4,6 +4,7 @@ import time import locale import re +import os import sys from test import support from datetime import date as datetime_date @@ -324,9 +325,10 @@ tz_name = time.tzname[0] if tz_name.upper() in ("UTC", "GMT"): self.skipTest('need non-UTC/GMT timezone') - try: - original_tzname = time.tzname - original_daylight = time.daylight + + with support.swap_attr(time, 'tzname', (tz_name, tz_name)), \ + support.swap_attr(time, 'daylight', 1), \ + support.swap_attr(time, 'tzset', lambda: None): time.tzname = (tz_name, tz_name) time.daylight = 1 tz_value = _strptime._strptime_time(tz_name, "%Z")[8] @@ -334,9 +336,6 @@ "%s lead to a timezone value of %s instead of -1 when " "time.daylight set to %s and passing in %s" % (time.tzname, tz_value, time.daylight, tz_name)) - finally: - time.tzname = original_tzname - time.daylight = original_daylight def test_date_time(self): # Test %c directive @@ -548,7 +547,7 @@ _strptime._strptime_time("10", "%d") self.assertIsNot(locale_time_id, _strptime._TimeRE_cache.locale_time) - def test_TimeRE_recreation(self): + def test_TimeRE_recreation_locale(self): # The TimeRE instance should be recreated upon changing the locale. locale_info = locale.getlocale(locale.LC_TIME) try: @@ -577,6 +576,33 @@ finally: locale.setlocale(locale.LC_TIME, locale_info) + @support.run_with_tz('STD-1DST') + def test_TimeRE_recreation_timezone(self): + # The TimeRE instance should be recreated upon changing the timezone. + oldtzname = time.tzname + tm = _strptime._strptime_time(time.tzname[0], '%Z') + self.assertEqual(tm.tm_isdst, 0) + tm = _strptime._strptime_time(time.tzname[1], '%Z') + self.assertEqual(tm.tm_isdst, 1) + # Get id of current cache object. + first_time_re = _strptime._TimeRE_cache + # Change the timezone and force a recreation of the cache. + os.environ['TZ'] = 'EST+05EDT,M3.2.0,M11.1.0' + time.tzset() + tm = _strptime._strptime_time(time.tzname[0], '%Z') + self.assertEqual(tm.tm_isdst, 0) + tm = _strptime._strptime_time(time.tzname[1], '%Z') + self.assertEqual(tm.tm_isdst, 1) + # Get the new cache object's id. + second_time_re = _strptime._TimeRE_cache + # They should not be equal. + self.assertIsNot(first_time_re, second_time_re) + # Make sure old names no longer accepted. + with self.assertRaises(ValueError): + _strptime._strptime_time(oldtzname[0], '%Z') + with self.assertRaises(ValueError): + _strptime._strptime_time(oldtzname[1], '%Z') + if __name__ == '__main__': unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,9 @@ Library ------- +- Issue #6478: _strptime's regexp cache now is reset after changing timezone + with time.tzset(). + - Issue #14285: When executing a package with the "python -m package" option, and package initialization fails, a proper traceback is now reported. The "runpy" module now lets exceptions from package initialization pass back to -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 3 18:27:55 2015 From: python-checkins at python.org (guido.van.rossum) Date: Thu, 03 Dec 2015 23:27:55 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Add_Awaitable=2C_AsyncIterabl?= =?utf-8?q?e=2C_AsyncIterator_to_PEP_484_=28to_be_released_3=2E5=2E2=29=2E?= Message-ID: <20151203232755.29619.83269@psf.io> https://hg.python.org/peps/rev/73dde33e2a4a changeset: 6134:73dde33e2a4a user: Guido van Rossum date: Thu Dec 03 15:27:36 2015 -0800 summary: Add Awaitable, AsyncIterable, AsyncIterator to PEP 484 (to be released 3.5.2). files: pep-0484.txt | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/pep-0484.txt b/pep-0484.txt --- a/pep-0484.txt +++ b/pep-0484.txt @@ -1261,6 +1261,12 @@ Generic variants of container ABCs (and a few non-containers): +* Awaitable + +* AsyncIterable + +* AsyncIterator + * ByteString * Callable (see above, listed here for completeness) -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Dec 3 20:32:25 2015 From: python-checkins at python.org (martin.panter) Date: Fri, 04 Dec 2015 01:32:25 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE0Mjg1?= =?utf-8?q?=3A_Do_not_catch_ImportError_from_=5F=5Finit=5F=5F=2Epy_in_runp?= =?utf-8?q?y?= Message-ID: <20151204013225.60126.80921@psf.io> https://hg.python.org/cpython/rev/c4e950338e79 changeset: 99428:c4e950338e79 branch: 2.7 parent: 99424:2ae5c51c5dea user: Martin Panter date: Thu Dec 03 01:23:10 2015 +0000 summary: Issue #14285: Do not catch ImportError from __init__.py in runpy Initialize package before calling get_loader() for __main__, so that we do not incorrectly handle ImportError from __init__.py. When runpy is used from the Python CLI, use an internal exception rather than ImportError, to avoid catching an unexpected ImportError. Also simplify message formatting: str() is redundant with %s. Also fix test_dash_m_error_code_is_one() in test_cmd_line_script, which was failing because the test package was not in the current directlry, rather the desired ValueError. files: Lib/runpy.py | 42 ++++++++---- Lib/test/script_helper.py | 4 +- Lib/test/test_cmd_line_script.py | 64 ++++++++++++++++++- Lib/test/test_runpy.py | 24 +++++++ Misc/NEWS | 4 + 5 files changed, 115 insertions(+), 23 deletions(-) diff --git a/Lib/runpy.py b/Lib/runpy.py --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -97,27 +97,35 @@ return None # Helper to get the loader, code and filename for a module -def _get_module_details(mod_name): - loader = get_loader(mod_name) - if loader is None: - raise ImportError("No module named %s" % mod_name) - if loader.is_package(mod_name): +def _get_module_details(mod_name, error=ImportError): + try: + loader = get_loader(mod_name) + if loader is None: + raise error("No module named %s" % mod_name) + ispkg = loader.is_package(mod_name) + except ImportError as e: + raise error(format(e)) + if ispkg: if mod_name == "__main__" or mod_name.endswith(".__main__"): - raise ImportError("Cannot use package as __main__ module") + raise error("Cannot use package as __main__ module") + __import__(mod_name) # Do not catch exceptions initializing package try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: - raise ImportError(("%s; %r is a package and cannot " + + raise error(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name)) - code = loader.get_code(mod_name) + try: + code = loader.get_code(mod_name) + except ImportError as e: + raise error(format(e)) if code is None: - raise ImportError("No code object available for %s" % mod_name) + raise error("No code object available for %s" % mod_name) filename = _get_filename(loader, mod_name) return mod_name, loader, code, filename -def _get_main_module_details(): +def _get_main_module_details(error=ImportError): # Helper that gives a nicer error message when attempting to # execute a zipfile or directory by invoking __main__.py main_name = "__main__" @@ -125,10 +133,13 @@ return _get_module_details(main_name) except ImportError as exc: if main_name in str(exc): - raise ImportError("can't find %r module in %r" % + raise error("can't find %r module in %r" % (main_name, sys.path[0])) raise +class _Error(Exception): + """Error that _run_module_as_main() should report without a traceback""" + # This function is the actual implementation of the -m switch and direct # execution of zipfiles and directories and is deliberately kept private. # This avoids a repeat of the situation where run_module() no longer met the @@ -148,11 +159,12 @@ """ try: if alter_argv or mod_name != "__main__": # i.e. -m switch - mod_name, loader, code, fname = _get_module_details(mod_name) + mod_name, loader, code, fname = _get_module_details( + mod_name, _Error) else: # i.e. directory or zipfile execution - mod_name, loader, code, fname = _get_main_module_details() - except ImportError as exc: - msg = "%s: %s" % (sys.executable, str(exc)) + mod_name, loader, code, fname = _get_main_module_details(_Error) + except _Error as exc: + msg = "%s: %s" % (sys.executable, exc) sys.exit(msg) pkg_name = mod_name.rpartition('.')[0] main_globals = sys.modules["__main__"].__dict__ diff --git a/Lib/test/script_helper.py b/Lib/test/script_helper.py --- a/Lib/test/script_helper.py +++ b/Lib/test/script_helper.py @@ -134,9 +134,9 @@ # zip_file.close() return zip_name, os.path.join(zip_name, name_in_zip) -def make_pkg(pkg_dir): +def make_pkg(pkg_dir, init_source=''): os.mkdir(pkg_dir) - make_script(pkg_dir, '__init__', '') + make_script(pkg_dir, '__init__', init_source) def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename, source, depth=1, compiled=False): diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -1,5 +1,6 @@ # Tests command line execution of scripts +import contextlib import unittest import os import os.path @@ -207,18 +208,69 @@ launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg') self._check_import_error(launch_name, msg) + @contextlib.contextmanager + def setup_test_pkg(self, *args): + with temp_dir() as script_dir, \ + test.test_support.change_cwd(script_dir): + pkg_dir = os.path.join(script_dir, 'test_pkg') + make_pkg(pkg_dir, *args) + yield pkg_dir + + def check_dash_m_failure(self, *args): + rc, out, err = assert_python_failure('-m', *args) + if verbose > 1: + print(out) + self.assertEqual(rc, 1) + return err + def test_dash_m_error_code_is_one(self): # If a module is invoked with the -m command line flag # and results in an error that the return code to the # shell is '1' - with temp_dir() as script_dir: - pkg_dir = os.path.join(script_dir, 'test_pkg') - make_pkg(pkg_dir) + with self.setup_test_pkg() as pkg_dir: script_name = _make_test_script(pkg_dir, 'other', "if __name__ == '__main__': raise ValueError") - rc, out, err = assert_python_failure('-m', 'test_pkg.other', *example_args) - if verbose > 1: - print(out) + err = self.check_dash_m_failure('test_pkg.other', *example_args) + self.assertIn(b'ValueError', err) + + def test_dash_m_errors(self): + # Exercise error reporting for various invalid package executions + tests = ( + ('__builtin__', br'No code object available'), + ('__builtin__.x', br'No module named'), + ('__builtin__.x.y', br'No module named'), + ('os.path', br'Loader.*cannot handle'), + ('importlib', br'No module named.*' + br'is a package and cannot be directly executed'), + ('importlib.nonexistant', br'No module named'), + ) + for name, regex in tests: + rc, _, err = assert_python_failure('-m', name) self.assertEqual(rc, 1) + self.assertRegexpMatches(err, regex) + self.assertNotIn(b'Traceback', err) + + def test_dash_m_init_traceback(self): + # These were wrapped in an ImportError and tracebacks were + # suppressed; see Issue 14285 + exceptions = (ImportError, AttributeError, TypeError, ValueError) + for exception in exceptions: + exception = exception.__name__ + init = "raise {0}('Exception in __init__.py')".format(exception) + with self.setup_test_pkg(init) as pkg_dir: + err = self.check_dash_m_failure('test_pkg') + self.assertIn(exception.encode('ascii'), err) + self.assertIn(b'Exception in __init__.py', err) + self.assertIn(b'Traceback', err) + + def test_dash_m_main_traceback(self): + # Ensure that an ImportError's traceback is reported + with self.setup_test_pkg() as pkg_dir: + main = "raise ImportError('Exception in __main__ module')" + _make_test_script(pkg_dir, '__main__', main) + err = self.check_dash_m_failure('test_pkg') + self.assertIn(b'ImportError', err) + self.assertIn(b'Exception in __main__ module', err) + self.assertIn(b'Traceback', err) def test_main(): diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -270,6 +270,30 @@ if verbose: print "Testing package depth:", depth self._check_package(depth) + def test_run_package_init_exceptions(self): + # These were previously wrapped in an ImportError; see Issue 14285 + exceptions = (ImportError, AttributeError, TypeError, ValueError) + for exception in exceptions: + name = exception.__name__ + source = "raise {0}('{0} in __init__.py.')".format(name) + + result = self._make_pkg("", 1, "__main__") + pkg_dir, _, mod_name = result + mod_name = mod_name.replace(".__main__", "") + try: + init = os.path.join(pkg_dir, "__runpy_pkg__", "__init__.py") + with open(init, "wt") as mod_file: + mod_file.write(source) + try: + run_module(mod_name) + except exception as err: + msg = "cannot be directly executed" + self.assertNotIn(msg, format(err)) + else: + self.fail("Nothing raised; expected {}".format(name)) + finally: + self._del_pkg(pkg_dir, 1, mod_name) + def test_explicit_relative_import(self): for depth in range(2, 5): if verbose: print "Testing relative imports at depth:", depth diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,10 @@ Library ------- +- Issue #14285: When executing a package with the "python -m package" option, + and package initialization raises ImportError, a proper traceback is now + reported. + - Issue #6478: _strptime's regexp cache now is reset after changing timezone with time.tzset(). -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 3 20:32:30 2015 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 04 Dec 2015 01:32:30 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Add_Awaitable?= =?utf-8?q?=2C_AsyncIterable=2C_AsyncIterator_to_typing=2Epy=2E?= Message-ID: <20151204013230.29957.74324@psf.io> https://hg.python.org/cpython/rev/e9aeae1b2ea9 changeset: 99429:e9aeae1b2ea9 branch: 3.5 parent: 99426:5fa855d20624 user: Guido van Rossum date: Thu Dec 03 17:31:24 2015 -0800 summary: Add Awaitable, AsyncIterable, AsyncIterator to typing.py. files: Lib/test/test_typing.py | 61 +++++++++++++++++++++++++++++ Lib/typing.py | 15 +++++++ 2 files changed, 76 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -1,3 +1,4 @@ +import asyncio import pickle import re import sys @@ -960,6 +961,36 @@ pass +T_a = TypeVar('T') + + +class AwaitableWrapper(typing.Awaitable[T_a]): + + def __init__(self, value): + self.value = value + + def __await__(self) -> typing.Iterator[T_a]: + yield + return self.value + + +class AsyncIteratorWrapper(typing.AsyncIterator[T_a]): + + def __init__(self, value: typing.Iterable[T_a]): + self.value = value + + def __aiter__(self) -> typing.AsyncIterator[T_a]: + return self + + @asyncio.coroutine + def __anext__(self) -> T_a: + data = yield from self.value + if data: + return data + else: + raise StopAsyncIteration + + class CollectionsAbcTests(TestCase): def test_hashable(self): @@ -984,6 +1015,36 @@ assert isinstance(it, typing.Iterator[int]) assert not isinstance(42, typing.Iterator) + def test_awaitable(self): + async def foo() -> typing.Awaitable[int]: + return await AwaitableWrapper(42) + g = foo() + assert issubclass(type(g), typing.Awaitable[int]) + assert isinstance(g, typing.Awaitable) + assert not isinstance(foo, typing.Awaitable) + assert issubclass(typing.Awaitable[Manager], + typing.Awaitable[Employee]) + assert not issubclass(typing.Awaitable[Employee], + typing.Awaitable[Manager]) + g.send(None) # Run foo() till completion, to avoid warning. + + def test_async_iterable(self): + base_it = range(10) # type: Iterator[int] + it = AsyncIteratorWrapper(base_it) + assert isinstance(it, typing.AsyncIterable) + assert isinstance(it, typing.AsyncIterable) + assert issubclass(typing.AsyncIterable[Manager], + typing.AsyncIterable[Employee]) + assert not isinstance(42, typing.AsyncIterable) + + def test_async_iterator(self): + base_it = range(10) # type: Iterator[int] + it = AsyncIteratorWrapper(base_it) + assert isinstance(it, typing.AsyncIterator) + assert issubclass(typing.AsyncIterator[Manager], + typing.AsyncIterator[Employee]) + assert not isinstance(42, typing.AsyncIterator) + def test_sized(self): assert isinstance([], typing.Sized) assert not isinstance(42, typing.Sized) diff --git a/Lib/typing.py b/Lib/typing.py --- a/Lib/typing.py +++ b/Lib/typing.py @@ -28,6 +28,9 @@ # ABCs (from collections.abc). 'AbstractSet', # collections.abc.Set. + 'Awaitable', + 'AsyncIterator', + 'AsyncIterable', 'ByteString', 'Container', 'Hashable', @@ -1261,6 +1264,18 @@ Hashable = collections_abc.Hashable # Not generic. +class Awaitable(Generic[T_co], extra=collections_abc.Awaitable): + __slots__ = () + + +class AsyncIterable(Generic[T_co], extra=collections_abc.AsyncIterable): + __slots__ = () + + +class AsyncIterator(AsyncIterable[T_co], extra=collections_abc.AsyncIterator): + __slots__ = () + + class Iterable(Generic[T_co], extra=collections_abc.Iterable): __slots__ = () -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 3 20:32:30 2015 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 04 Dec 2015 01:32:30 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Add_Awaitable=2C_AsyncIterable=2C_AsyncIterator_to_typin?= =?utf-8?b?Zy5weS4gKE1lcmdlIDMuNS0+My42KQ==?= Message-ID: <20151204013230.21508.38429@psf.io> https://hg.python.org/cpython/rev/ad855c779bf3 changeset: 99430:ad855c779bf3 parent: 99427:ea576db13827 parent: 99429:e9aeae1b2ea9 user: Guido van Rossum date: Thu Dec 03 17:32:05 2015 -0800 summary: Add Awaitable, AsyncIterable, AsyncIterator to typing.py. (Merge 3.5->3.6) files: Lib/test/test_typing.py | 61 +++++++++++++++++++++++++++++ Lib/typing.py | 15 +++++++ 2 files changed, 76 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -1,3 +1,4 @@ +import asyncio import pickle import re import sys @@ -960,6 +961,36 @@ pass +T_a = TypeVar('T') + + +class AwaitableWrapper(typing.Awaitable[T_a]): + + def __init__(self, value): + self.value = value + + def __await__(self) -> typing.Iterator[T_a]: + yield + return self.value + + +class AsyncIteratorWrapper(typing.AsyncIterator[T_a]): + + def __init__(self, value: typing.Iterable[T_a]): + self.value = value + + def __aiter__(self) -> typing.AsyncIterator[T_a]: + return self + + @asyncio.coroutine + def __anext__(self) -> T_a: + data = yield from self.value + if data: + return data + else: + raise StopAsyncIteration + + class CollectionsAbcTests(TestCase): def test_hashable(self): @@ -984,6 +1015,36 @@ assert isinstance(it, typing.Iterator[int]) assert not isinstance(42, typing.Iterator) + def test_awaitable(self): + async def foo() -> typing.Awaitable[int]: + return await AwaitableWrapper(42) + g = foo() + assert issubclass(type(g), typing.Awaitable[int]) + assert isinstance(g, typing.Awaitable) + assert not isinstance(foo, typing.Awaitable) + assert issubclass(typing.Awaitable[Manager], + typing.Awaitable[Employee]) + assert not issubclass(typing.Awaitable[Employee], + typing.Awaitable[Manager]) + g.send(None) # Run foo() till completion, to avoid warning. + + def test_async_iterable(self): + base_it = range(10) # type: Iterator[int] + it = AsyncIteratorWrapper(base_it) + assert isinstance(it, typing.AsyncIterable) + assert isinstance(it, typing.AsyncIterable) + assert issubclass(typing.AsyncIterable[Manager], + typing.AsyncIterable[Employee]) + assert not isinstance(42, typing.AsyncIterable) + + def test_async_iterator(self): + base_it = range(10) # type: Iterator[int] + it = AsyncIteratorWrapper(base_it) + assert isinstance(it, typing.AsyncIterator) + assert issubclass(typing.AsyncIterator[Manager], + typing.AsyncIterator[Employee]) + assert not isinstance(42, typing.AsyncIterator) + def test_sized(self): assert isinstance([], typing.Sized) assert not isinstance(42, typing.Sized) diff --git a/Lib/typing.py b/Lib/typing.py --- a/Lib/typing.py +++ b/Lib/typing.py @@ -28,6 +28,9 @@ # ABCs (from collections.abc). 'AbstractSet', # collections.abc.Set. + 'Awaitable', + 'AsyncIterator', + 'AsyncIterable', 'ByteString', 'Container', 'Hashable', @@ -1261,6 +1264,18 @@ Hashable = collections_abc.Hashable # Not generic. +class Awaitable(Generic[T_co], extra=collections_abc.Awaitable): + __slots__ = () + + +class AsyncIterable(Generic[T_co], extra=collections_abc.AsyncIterable): + __slots__ = () + + +class AsyncIterator(AsyncIterable[T_co], extra=collections_abc.AsyncIterator): + __slots__ = () + + class Iterable(Generic[T_co], extra=collections_abc.Iterable): __slots__ = () -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Fri Dec 4 03:42:29 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 04 Dec 2015 08:42:29 +0000 Subject: [Python-checkins] Daily reference leaks (ad855c779bf3): sum=4 Message-ID: <20151204084229.93628.73898@psf.io> results for ad855c779bf3 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflog8edhAb', '--timeout', '7200'] From lp_benchmark_robot at intel.com Fri Dec 4 09:32:45 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 4 Dec 2015 14:32:45 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-04 Message-ID: <154b0371-5438-4d8c-8e21-2c3dd59fb1d9@irsmsx104.ger.corp.intel.com> Results for project Python default, build date 2015-12-04 04:02:09 +0000 commit: ad855c779bf33c59d176c23900ec0bc4fca3dfc6 revision date: 2015-12-04 01:32:05 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.35% -0.81% 9.28% 15.27% :-( pybench 0.19% -0.05% -2.11% 8.38% :-( regex_v8 2.72% 0.04% -3.64% 4.58% :-( nbody 0.10% -0.05% -3.14% 10.75% :-| json_dump_v2 0.20% -0.49% -1.58% 11.13% :-| normal_startup 1.01% -0.12% -0.14% 4.46% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Fri Dec 4 09:33:46 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 4 Dec 2015 14:33:46 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-04 Message-ID: Results for project Python 2.7, build date 2015-12-04 04:49:17 +0000 commit: c4e950338e79f475278e4875e4a3a9d607ef7e10 revision date: 2015-12-03 01:23:10 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.34% 0.99% 2.59% 11.27% :-) pybench 0.21% 0.04% 6.12% 7.16% :-( regex_v8 1.39% -0.41% -3.76% 9.58% :-) nbody 0.79% -2.13% 7.58% 5.25% :-) json_dump_v2 0.29% -0.42% 2.33% 15.63% :-( normal_startup 2.01% -0.60% -2.07% 3.26% :-| ssbench 0.52% 0.07% 0.42% 1.96% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Fri Dec 4 17:52:13 2015 From: python-checkins at python.org (brett.cannon) Date: Fri, 04 Dec 2015 22:52:13 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_for_issue_=2325500?= Message-ID: <20151204225213.21231.4683@psf.io> https://hg.python.org/cpython/rev/0259c2c555fb changeset: 99432:0259c2c555fb parent: 99430:ad855c779bf3 parent: 99431:567baf74ebad user: Brett Cannon date: Fri Dec 04 14:52:07 2015 -0800 summary: Merge for issue #25500 files: Doc/reference/import.rst | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -29,11 +29,10 @@ a name binding operation. When calling :func:`__import__` as part of an import statement, the -import system first checks the module global namespace for a function by -that name. If it is not found, then the standard builtin :func:`__import__` -is called. Other mechanisms for invoking the import system (such as -:func:`importlib.import_module`) do not perform this check and will always -use the standard import system. +standard builtin :func:`__import__` is called. Other mechanisms for +invoking the import system (such as :func:`importlib.import_module`) may +choose to subvert :func:`__import__` and use its own solution to +implement import semantics. When a module is first imported, Python searches for the module and if found, it creates a module object [#fnmo]_, initializing it. If the named module -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 4 17:52:15 2015 From: python-checkins at python.org (brett.cannon) Date: Fri, 04 Dec 2015 22:52:15 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NTAw?= =?utf-8?q?=3A_Fix_the_language_reference_to_not_claim_that_import?= Message-ID: <20151204225213.60136.9699@psf.io> https://hg.python.org/cpython/rev/567baf74ebad changeset: 99431:567baf74ebad branch: 3.5 parent: 99429:e9aeae1b2ea9 user: Brett Cannon date: Fri Dec 04 14:51:26 2015 -0800 summary: Issue #25500: Fix the language reference to not claim that import statements search for __import__ in the global scope. Thanks to Sergei Lebedev for finding the documentation bug. files: Doc/reference/import.rst | 9 ++++----- Misc/NEWS | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -29,11 +29,10 @@ a name binding operation. When calling :func:`__import__` as part of an import statement, the -import system first checks the module global namespace for a function by -that name. If it is not found, then the standard builtin :func:`__import__` -is called. Other mechanisms for invoking the import system (such as -:func:`importlib.import_module`) do not perform this check and will always -use the standard import system. +standard builtin :func:`__import__` is called. Other mechanisms for +invoking the import system (such as :func:`importlib.import_module`) may +choose to subvert :func:`__import__` and use its own solution to +implement import semantics. When a module is first imported, Python searches for the module and if found, it creates a module object [#fnmo]_, initializing it. If the named module diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -54,6 +54,12 @@ - Issue #25624: ZipFile now always writes a ZIP_STORED header for directory entries. Patch by Dingyuan Wang. +Documentation +------------- + +- Issue #25500: Fix documentation to not claim that __import__ is searched for + in the global scope. + Tests ----- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 4 18:20:04 2015 From: python-checkins at python.org (brett.cannon) Date: Fri, 04 Dec 2015 23:20:04 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325771=3A_Tweak_Va?= =?utf-8?q?lueError_message_when_package_isn=27t_specified?= Message-ID: <20151204231950.60142.38521@psf.io> https://hg.python.org/cpython/rev/b3a0765671d6 changeset: 99433:b3a0765671d6 user: Brett Cannon date: Fri Dec 04 15:19:42 2015 -0800 summary: Issue #25771: Tweak ValueError message when package isn't specified for importlib.util.resolve_name() but is needed. Thanks to Martin Panter for the bug report. files: Lib/importlib/util.py | 4 ++-- Misc/NEWS | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/importlib/util.py b/Lib/importlib/util.py --- a/Lib/importlib/util.py +++ b/Lib/importlib/util.py @@ -22,8 +22,8 @@ if not name.startswith('.'): return name elif not package: - raise ValueError('{!r} is not a relative name ' - '(no leading dot)'.format(name)) + raise ValueError(f'no package specified for {repr(name)} ' + '(required for relative module names)') level = 0 for character in name: if character != '.': diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -109,6 +109,9 @@ Library ------- +- Issue #25771: Tweak the exception message for importlib.util.resolve_name() + when 'package' isn't specified but necessary. + - Issue #6478: _strptime's regexp cache now is reset after changing timezone with time.tzset(). -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 4 18:46:48 2015 From: python-checkins at python.org (brett.cannon) Date: Fri, 04 Dec 2015 23:46:48 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_for_issue_=2323936?= Message-ID: <20151204234648.29617.99973@psf.io> https://hg.python.org/cpython/rev/1b1900d2a537 changeset: 99435:1b1900d2a537 parent: 99433:b3a0765671d6 parent: 99434:88cee7d16ccb user: Brett Cannon date: Fri Dec 04 15:46:43 2015 -0800 summary: Merge for issue #23936 files: Doc/glossary.rst | 22 ++++++++++++++++------ Doc/library/sys.rst | 33 +++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/Doc/glossary.rst b/Doc/glossary.rst --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -308,10 +308,14 @@ A synonym for :term:`file object`. finder - An object that tries to find the :term:`loader` for a module. It must - implement either a method named :meth:`find_loader` or a method named - :meth:`find_module`. See :pep:`302` and :pep:`420` for details and - :class:`importlib.abc.Finder` for an :term:`abstract base class`. + An object that tries to find the :term:`loader` for a module that is + being imported. + + Since Python 3.3, there are two types of finder: :term:`meta path finders + ` for use with :data:`sys.meta_path`, and :term:`path + entry finders ` for use with :data:`sys.path_hooks`. + + See :pep:`302`, :pep:`420` and :pep:`451` for much more detail. floor division Mathematical division that rounds down to nearest integer. The floor @@ -593,10 +597,13 @@ :class:`collections.OrderedDict` and :class:`collections.Counter`. meta path finder - A finder returned by a search of :data:`sys.meta_path`. Meta path + A :term:`finder` returned by a search of :data:`sys.meta_path`. Meta path finders are related to, but different from :term:`path entry finders `. + See :class:`importlib.abc.MetaPathFinder` for the methods that meta path + finders implement. + metaclass The class of a class. Class definitions create a class name, a class dictionary, and a list of base classes. The metaclass is responsible for @@ -630,7 +637,7 @@ module spec A namespace containing the import-related information used to load a - module. + module. An instance of :class:`importlib.machinery.ModuleSpec`. MRO See :term:`method resolution order`. @@ -757,6 +764,9 @@ (i.e. a :term:`path entry hook`) which knows how to locate modules given a :term:`path entry`. + See :class:`importlib.abc.PathEntryFinder` for the methods that path entry + finders implement. + path entry hook A callable on the :data:`sys.path_hook` list which returns a :term:`path entry finder` if it knows how to find modules on a specific :term:`path diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -779,19 +779,32 @@ .. data:: meta_path - A list of :term:`finder` objects that have their :meth:`find_module` - methods called to see if one of the objects can find the module to be - imported. The :meth:`find_module` method is called at least with the - absolute name of the module being imported. If the module to be imported is - contained in package then the parent package's :attr:`__path__` attribute - is passed in as a second argument. The method returns ``None`` if - the module cannot be found, else returns a :term:`loader`. + A list of :term:`meta path finder` objects that have their + :meth:`~importlib.abc.MetaPathFinder.find_spec` methods called to see if one + of the objects can find the module to be imported. The + :meth:`~importlib.abc.MetaPathFinder.find_spec` method is called with at + least the absolute name of the module being imported. If the module to be + imported is contained in a package, then the parent package's :attr:`__path__` + attribute is passed in as a second argument. The method returns a + :term:`module spec`, or ``None`` if the module cannot be found. - :data:`sys.meta_path` is searched before any implicit default finders or - :data:`sys.path`. + .. seealso:: - See :pep:`302` for the original specification. + :class:`importlib.abc.MetaPathFinder` + The abstract base class defining the interface of finder objects on + :data:`meta_path`. + :class:`importlib.machinery.ModuleSpec` + The concrete class which + :meth:`~importlib.abc.MetaPathFinder.find_spec` should return + instances of. + .. versionchanged:: 3.4 + + :term:`Module specs ` were introduced in Python 3.4, by + :pep:`451`. Earlier versions of Python looked for a method called + :meth:`~importlib.abc.MetaPathFinder.find_module`. + This is still called as a fallback if a :data:`meta_path` entry doesn't + have a :meth:`~importlib.abc.MetaPathFinder.find_spec` method. .. data:: modules -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 4 18:46:48 2015 From: python-checkins at python.org (brett.cannon) Date: Fri, 04 Dec 2015 23:46:48 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIzOTM2?= =?utf-8?q?=3A_Clarify_what_finders_are=2E?= Message-ID: <20151204234647.29961.31679@psf.io> https://hg.python.org/cpython/rev/88cee7d16ccb changeset: 99434:88cee7d16ccb branch: 3.5 parent: 99431:567baf74ebad user: Brett Cannon date: Fri Dec 04 15:46:21 2015 -0800 summary: Issue #23936: Clarify what finders are. Thanks to Ra?l Cumplido for the bug report and Thomas Kluyver for the patch. files: Doc/glossary.rst | 22 ++++++++++++++++------ Doc/library/sys.rst | 33 +++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/Doc/glossary.rst b/Doc/glossary.rst --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -308,10 +308,14 @@ A synonym for :term:`file object`. finder - An object that tries to find the :term:`loader` for a module. It must - implement either a method named :meth:`find_loader` or a method named - :meth:`find_module`. See :pep:`302` and :pep:`420` for details and - :class:`importlib.abc.Finder` for an :term:`abstract base class`. + An object that tries to find the :term:`loader` for a module that is + being imported. + + Since Python 3.3, there are two types of finder: :term:`meta path finders + ` for use with :data:`sys.meta_path`, and :term:`path + entry finders ` for use with :data:`sys.path_hooks`. + + See :pep:`302`, :pep:`420` and :pep:`451` for much more detail. floor division Mathematical division that rounds down to nearest integer. The floor @@ -593,10 +597,13 @@ :class:`collections.OrderedDict` and :class:`collections.Counter`. meta path finder - A finder returned by a search of :data:`sys.meta_path`. Meta path + A :term:`finder` returned by a search of :data:`sys.meta_path`. Meta path finders are related to, but different from :term:`path entry finders `. + See :class:`importlib.abc.MetaPathFinder` for the methods that meta path + finders implement. + metaclass The class of a class. Class definitions create a class name, a class dictionary, and a list of base classes. The metaclass is responsible for @@ -630,7 +637,7 @@ module spec A namespace containing the import-related information used to load a - module. + module. An instance of :class:`importlib.machinery.ModuleSpec`. MRO See :term:`method resolution order`. @@ -757,6 +764,9 @@ (i.e. a :term:`path entry hook`) which knows how to locate modules given a :term:`path entry`. + See :class:`importlib.abc.PathEntryFinder` for the methods that path entry + finders implement. + path entry hook A callable on the :data:`sys.path_hook` list which returns a :term:`path entry finder` if it knows how to find modules on a specific :term:`path diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -774,19 +774,32 @@ .. data:: meta_path - A list of :term:`finder` objects that have their :meth:`find_module` - methods called to see if one of the objects can find the module to be - imported. The :meth:`find_module` method is called at least with the - absolute name of the module being imported. If the module to be imported is - contained in package then the parent package's :attr:`__path__` attribute - is passed in as a second argument. The method returns ``None`` if - the module cannot be found, else returns a :term:`loader`. + A list of :term:`meta path finder` objects that have their + :meth:`~importlib.abc.MetaPathFinder.find_spec` methods called to see if one + of the objects can find the module to be imported. The + :meth:`~importlib.abc.MetaPathFinder.find_spec` method is called with at + least the absolute name of the module being imported. If the module to be + imported is contained in a package, then the parent package's :attr:`__path__` + attribute is passed in as a second argument. The method returns a + :term:`module spec`, or ``None`` if the module cannot be found. - :data:`sys.meta_path` is searched before any implicit default finders or - :data:`sys.path`. + .. seealso:: - See :pep:`302` for the original specification. + :class:`importlib.abc.MetaPathFinder` + The abstract base class defining the interface of finder objects on + :data:`meta_path`. + :class:`importlib.machinery.ModuleSpec` + The concrete class which + :meth:`~importlib.abc.MetaPathFinder.find_spec` should return + instances of. + .. versionchanged:: 3.4 + + :term:`Module specs ` were introduced in Python 3.4, by + :pep:`451`. Earlier versions of Python looked for a method called + :meth:`~importlib.abc.MetaPathFinder.find_module`. + This is still called as a fallback if a :data:`meta_path` entry doesn't + have a :meth:`~importlib.abc.MetaPathFinder.find_spec` method. .. data:: modules -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 4 21:35:35 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 05 Dec 2015 02:35:35 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogSXNzdWUgIzI1NzY0?= =?utf-8?q?=3A_Preserve_subprocess_fork_exception_when_preexec=5Ffn_used?= Message-ID: <20151205023535.33655.40098@psf.io> https://hg.python.org/cpython/rev/4f4e2cbd2138 changeset: 99436:4f4e2cbd2138 branch: 3.4 parent: 99425:4b0a4da1aa27 user: Martin Panter date: Mon Nov 30 02:21:41 2015 +0000 summary: Issue #25764: Preserve subprocess fork exception when preexec_fn used Also fix handling of failure to release the import lock. files: Lib/test/test_subprocess.py | 16 +++++++++++ Misc/NEWS | 3 ++ Modules/_posixsubprocess.c | 35 ++++++++++++------------ 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1416,6 +1416,22 @@ if not enabled: gc.disable() + def test_preexec_fork_failure(self): + # The internal code did not preserve the previous exception when + # re-enabling garbage collection + try: + from resource import getrlimit, setrlimit, RLIMIT_NPROC + except ImportError as err: + self.skipTest(err) # RLIMIT_NPROC is specific to Linux and BSD + limits = getrlimit(RLIMIT_NPROC) + [_, hard] = limits + setrlimit(RLIMIT_NPROC, (0, hard)) + self.addCleanup(setrlimit, RLIMIT_NPROC, limits) + # Forking should raise EAGAIN, translated to BlockingIOError + with self.assertRaises(BlockingIOError): + subprocess.call([sys.executable, '-c', ''], + preexec_fn=lambda: None) + def test_args_string(self): # args is a string fd, fname = tempfile.mkstemp() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -115,6 +115,9 @@ Library ------- +- Issue #25764: In the subprocess module, preserve any exception caused by + fork() failure when preexec_fn is used. + - Issue #6478: _strptime's regexp cache now is reset after changing timezone with time.tzset(). diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -47,17 +47,25 @@ #define POSIX_CALL(call) do { if ((call) == -1) goto error; } while (0) -/* Given the gc module call gc.enable() and return 0 on success. */ +/* If gc was disabled, call gc.enable(). Return 0 on success. */ static int -_enable_gc(PyObject *gc_module) +_enable_gc(int need_to_reenable_gc, PyObject *gc_module) { PyObject *result; _Py_IDENTIFIER(enable); + PyObject *exctype, *val, *tb; - result = _PyObject_CallMethodId(gc_module, &PyId_enable, NULL); - if (result == NULL) - return 1; - Py_DECREF(result); + if (need_to_reenable_gc) { + PyErr_Fetch(&exctype, &val, &tb); + result = _PyObject_CallMethodId(gc_module, &PyId_enable, NULL); + if (exctype != NULL) { + PyErr_Restore(exctype, val, tb); + } + if (result == NULL) { + return 1; + } + Py_DECREF(result); + } return 0; } @@ -691,6 +699,7 @@ _PyImport_ReleaseLock() < 0 && !PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "not holding the import lock"); + pid = -1; } import_lock_held = 0; @@ -702,9 +711,8 @@ _Py_FreeCharPArray(exec_array); /* Reenable gc in the parent process (or if fork failed). */ - if (need_to_reenable_gc && _enable_gc(gc_module)) { - Py_XDECREF(gc_module); - return NULL; + if (_enable_gc(need_to_reenable_gc, gc_module)) { + pid = -1; } Py_XDECREF(preexec_fn_args_tuple); Py_XDECREF(gc_module); @@ -726,14 +734,7 @@ Py_XDECREF(converted_args); Py_XDECREF(fast_args); Py_XDECREF(preexec_fn_args_tuple); - - /* Reenable gc if it was disabled. */ - if (need_to_reenable_gc) { - PyObject *exctype, *val, *tb; - PyErr_Fetch(&exctype, &val, &tb); - _enable_gc(gc_module); - PyErr_Restore(exctype, val, tb); - } + _enable_gc(need_to_reenable_gc, gc_module); Py_XDECREF(gc_module); return NULL; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 4 21:35:35 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 05 Dec 2015 02:35:35 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Issue_=2325764=3A_Merge_subprocess_fix_from_3=2E4_into_3=2E5?= Message-ID: <20151205023535.61827.8920@psf.io> https://hg.python.org/cpython/rev/ae27ad306dbf changeset: 99437:ae27ad306dbf branch: 3.5 parent: 99434:88cee7d16ccb parent: 99436:4f4e2cbd2138 user: Martin Panter date: Sat Dec 05 02:03:42 2015 +0000 summary: Issue #25764: Merge subprocess fix from 3.4 into 3.5 files: Lib/test/test_subprocess.py | 16 +++++++++++ Misc/NEWS | 3 ++ Modules/_posixsubprocess.c | 35 ++++++++++++------------ 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1512,6 +1512,22 @@ if not enabled: gc.disable() + def test_preexec_fork_failure(self): + # The internal code did not preserve the previous exception when + # re-enabling garbage collection + try: + from resource import getrlimit, setrlimit, RLIMIT_NPROC + except ImportError as err: + self.skipTest(err) # RLIMIT_NPROC is specific to Linux and BSD + limits = getrlimit(RLIMIT_NPROC) + [_, hard] = limits + setrlimit(RLIMIT_NPROC, (0, hard)) + self.addCleanup(setrlimit, RLIMIT_NPROC, limits) + # Forking should raise EAGAIN, translated to BlockingIOError + with self.assertRaises(BlockingIOError): + subprocess.call([sys.executable, '-c', ''], + preexec_fn=lambda: None) + def test_args_string(self): # args is a string fd, fname = tempfile.mkstemp() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,9 @@ Library ------- +- Issue #25764: In the subprocess module, preserve any exception caused by + fork() failure when preexec_fn is used. + - Issue #6478: _strptime's regexp cache now is reset after changing timezone with time.tzset(). diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -47,17 +47,25 @@ #define POSIX_CALL(call) do { if ((call) == -1) goto error; } while (0) -/* Given the gc module call gc.enable() and return 0 on success. */ +/* If gc was disabled, call gc.enable(). Return 0 on success. */ static int -_enable_gc(PyObject *gc_module) +_enable_gc(int need_to_reenable_gc, PyObject *gc_module) { PyObject *result; _Py_IDENTIFIER(enable); + PyObject *exctype, *val, *tb; - result = _PyObject_CallMethodId(gc_module, &PyId_enable, NULL); - if (result == NULL) - return 1; - Py_DECREF(result); + if (need_to_reenable_gc) { + PyErr_Fetch(&exctype, &val, &tb); + result = _PyObject_CallMethodId(gc_module, &PyId_enable, NULL); + if (exctype != NULL) { + PyErr_Restore(exctype, val, tb); + } + if (result == NULL) { + return 1; + } + Py_DECREF(result); + } return 0; } @@ -698,6 +706,7 @@ && _PyImport_ReleaseLock() < 0 && !PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "not holding the import lock"); + pid = -1; } import_lock_held = 0; #endif @@ -710,9 +719,8 @@ _Py_FreeCharPArray(exec_array); /* Reenable gc in the parent process (or if fork failed). */ - if (need_to_reenable_gc && _enable_gc(gc_module)) { - Py_XDECREF(gc_module); - return NULL; + if (_enable_gc(need_to_reenable_gc, gc_module)) { + pid = -1; } Py_XDECREF(preexec_fn_args_tuple); Py_XDECREF(gc_module); @@ -736,14 +744,7 @@ Py_XDECREF(converted_args); Py_XDECREF(fast_args); Py_XDECREF(preexec_fn_args_tuple); - - /* Reenable gc if it was disabled. */ - if (need_to_reenable_gc) { - PyObject *exctype, *val, *tb; - PyErr_Fetch(&exctype, &val, &tb); - _enable_gc(gc_module); - PyErr_Restore(exctype, val, tb); - } + _enable_gc(need_to_reenable_gc, gc_module); Py_XDECREF(gc_module); return NULL; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 4 21:35:35 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 05 Dec 2015 02:35:35 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325764=3A_Merge_subprocess_fix_from_3=2E5?= Message-ID: <20151205023535.105477.14377@psf.io> https://hg.python.org/cpython/rev/b10c58a740b9 changeset: 99438:b10c58a740b9 parent: 99435:1b1900d2a537 parent: 99437:ae27ad306dbf user: Martin Panter date: Sat Dec 05 02:27:58 2015 +0000 summary: Issue #25764: Merge subprocess fix from 3.5 files: Lib/test/test_subprocess.py | 16 +++++++++++ Misc/NEWS | 3 ++ Modules/_posixsubprocess.c | 35 ++++++++++++------------ 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1512,6 +1512,22 @@ if not enabled: gc.disable() + def test_preexec_fork_failure(self): + # The internal code did not preserve the previous exception when + # re-enabling garbage collection + try: + from resource import getrlimit, setrlimit, RLIMIT_NPROC + except ImportError as err: + self.skipTest(err) # RLIMIT_NPROC is specific to Linux and BSD + limits = getrlimit(RLIMIT_NPROC) + [_, hard] = limits + setrlimit(RLIMIT_NPROC, (0, hard)) + self.addCleanup(setrlimit, RLIMIT_NPROC, limits) + # Forking should raise EAGAIN, translated to BlockingIOError + with self.assertRaises(BlockingIOError): + subprocess.call([sys.executable, '-c', ''], + preexec_fn=lambda: None) + def test_args_string(self): # args is a string fd, fname = tempfile.mkstemp() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -109,6 +109,9 @@ Library ------- +- Issue #25764: In the subprocess module, preserve any exception caused by + fork() failure when preexec_fn is used. + - Issue #25771: Tweak the exception message for importlib.util.resolve_name() when 'package' isn't specified but necessary. diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -47,17 +47,25 @@ #define POSIX_CALL(call) do { if ((call) == -1) goto error; } while (0) -/* Given the gc module call gc.enable() and return 0 on success. */ +/* If gc was disabled, call gc.enable(). Return 0 on success. */ static int -_enable_gc(PyObject *gc_module) +_enable_gc(int need_to_reenable_gc, PyObject *gc_module) { PyObject *result; _Py_IDENTIFIER(enable); + PyObject *exctype, *val, *tb; - result = _PyObject_CallMethodId(gc_module, &PyId_enable, NULL); - if (result == NULL) - return 1; - Py_DECREF(result); + if (need_to_reenable_gc) { + PyErr_Fetch(&exctype, &val, &tb); + result = _PyObject_CallMethodId(gc_module, &PyId_enable, NULL); + if (exctype != NULL) { + PyErr_Restore(exctype, val, tb); + } + if (result == NULL) { + return 1; + } + Py_DECREF(result); + } return 0; } @@ -698,6 +706,7 @@ && _PyImport_ReleaseLock() < 0 && !PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "not holding the import lock"); + pid = -1; } import_lock_held = 0; #endif @@ -710,9 +719,8 @@ _Py_FreeCharPArray(exec_array); /* Reenable gc in the parent process (or if fork failed). */ - if (need_to_reenable_gc && _enable_gc(gc_module)) { - Py_XDECREF(gc_module); - return NULL; + if (_enable_gc(need_to_reenable_gc, gc_module)) { + pid = -1; } Py_XDECREF(preexec_fn_args_tuple); Py_XDECREF(gc_module); @@ -736,14 +744,7 @@ Py_XDECREF(converted_args); Py_XDECREF(fast_args); Py_XDECREF(preexec_fn_args_tuple); - - /* Reenable gc if it was disabled. */ - if (need_to_reenable_gc) { - PyObject *exctype, *val, *tb; - PyErr_Fetch(&exctype, &val, &tb); - _enable_gc(gc_module); - PyErr_Restore(exctype, val, tb); - } + _enable_gc(need_to_reenable_gc, gc_module); Py_XDECREF(gc_module); return NULL; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 4 23:05:45 2015 From: python-checkins at python.org (r.david.murray) Date: Sat, 05 Dec 2015 04:05:45 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge=3A_=2324903=3A_Remove_misleading_error_message_to_fix_re?= =?utf-8?q?gression=2E?= Message-ID: <20151205040545.29603.55949@psf.io> https://hg.python.org/cpython/rev/c65e135df1dc changeset: 99440:c65e135df1dc branch: 3.5 parent: 99437:ae27ad306dbf parent: 99439:b63fd82a8528 user: R David Murray date: Fri Dec 04 23:04:37 2015 -0500 summary: Merge: #24903: Remove misleading error message to fix regression. files: Lib/compileall.py | 3 --- Lib/test/test_compileall.py | 8 -------- Misc/ACKS | 1 + Misc/NEWS | 4 ++++ 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Lib/compileall.py b/Lib/compileall.py --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -238,9 +238,6 @@ args = parser.parse_args() compile_dests = args.compile_dest - if (args.ddir and (len(compile_dests) != 1 - or not os.path.isdir(compile_dests[0]))): - parser.exit('-d destdir requires exactly one directory argument') if args.rx: import re args.rx = re.compile(args.rx) diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py --- a/Lib/test/test_compileall.py +++ b/Lib/test/test_compileall.py @@ -398,14 +398,6 @@ self.assertCompiled(init2fn) self.assertCompiled(bar2fn) - def test_d_takes_exactly_one_dir(self): - rc, out, err = self.assertRunNotOK('-d', 'foo') - self.assertEqual(out, b'') - self.assertRegex(err, b'-d') - rc, out, err = self.assertRunNotOK('-d', 'foo', 'bar') - self.assertEqual(out, b'') - self.assertRegex(err, b'-d') - def test_d_compile_error(self): script_helper.make_script(self.pkgdir, 'crunchyfrog', 'bad(syntax') rc, out, err = self.assertRunNotOK('-q', '-d', 'dinsdale', self.pkgdir) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -477,6 +477,7 @@ Nitin Ganatra Fred Gansevles Lars Marius Garshol +Jake Garver Dan Gass Andrew Gaul Matthieu Gautier diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,10 @@ Library ------- +- Issue #24903: Fix regression in number of arguments compileall accepts when + '-d' is specified. The check on the number of arguments has been dropped + completely as it never worked correctly anyway. + - Issue #25764: In the subprocess module, preserve any exception caused by fork() failure when preexec_fn is used. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 4 23:05:46 2015 From: python-checkins at python.org (r.david.murray) Date: Sat, 05 Dec 2015 04:05:46 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge=3A_=2324903=3A_Remove_misleading_error_message_to_?= =?utf-8?q?fix_regression=2E?= Message-ID: <20151205040545.105493.61058@psf.io> https://hg.python.org/cpython/rev/1e5aacddb67d changeset: 99441:1e5aacddb67d parent: 99438:b10c58a740b9 parent: 99440:c65e135df1dc user: R David Murray date: Fri Dec 04 23:05:20 2015 -0500 summary: Merge: #24903: Remove misleading error message to fix regression. files: Lib/compileall.py | 3 --- Lib/test/test_compileall.py | 8 -------- Misc/ACKS | 1 + Misc/NEWS | 4 ++++ 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Lib/compileall.py b/Lib/compileall.py --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -238,9 +238,6 @@ args = parser.parse_args() compile_dests = args.compile_dest - if (args.ddir and (len(compile_dests) != 1 - or not os.path.isdir(compile_dests[0]))): - parser.exit('-d destdir requires exactly one directory argument') if args.rx: import re args.rx = re.compile(args.rx) diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py --- a/Lib/test/test_compileall.py +++ b/Lib/test/test_compileall.py @@ -398,14 +398,6 @@ self.assertCompiled(init2fn) self.assertCompiled(bar2fn) - def test_d_takes_exactly_one_dir(self): - rc, out, err = self.assertRunNotOK('-d', 'foo') - self.assertEqual(out, b'') - self.assertRegex(err, b'-d') - rc, out, err = self.assertRunNotOK('-d', 'foo', 'bar') - self.assertEqual(out, b'') - self.assertRegex(err, b'-d') - def test_d_compile_error(self): script_helper.make_script(self.pkgdir, 'crunchyfrog', 'bad(syntax') rc, out, err = self.assertRunNotOK('-q', '-d', 'dinsdale', self.pkgdir) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -478,6 +478,7 @@ Nitin Ganatra Fred Gansevles Lars Marius Garshol +Jake Garver Dan Gass Andrew Gaul Matthieu Gautier diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -109,6 +109,10 @@ Library ------- +- Issue #24903: Fix regression in number of arguments compileall accepts when + '-d' is specified. The check on the number of arguments has been dropped + completely as it never worked correctly anyway. + - Issue #25764: In the subprocess module, preserve any exception caused by fork() failure when preexec_fn is used. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 4 23:05:46 2015 From: python-checkins at python.org (r.david.murray) Date: Sat, 05 Dec 2015 04:05:46 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogIzI0OTAzOiBSZW1v?= =?utf-8?q?ve_misleading_error_message_to_fix_regression=2E?= Message-ID: <20151205040544.61833.24508@psf.io> https://hg.python.org/cpython/rev/b63fd82a8528 changeset: 99439:b63fd82a8528 branch: 3.4 parent: 99436:4f4e2cbd2138 user: R David Murray date: Fri Dec 04 22:54:38 2015 -0500 summary: #24903: Remove misleading error message to fix regression. Before the argparse conversion, compileall would (sometimes) accept multiple paths when -d was specified. Afterward, it does not. The corresponding check in the original code claimed to prevent multiple *directories* from being specified...but it didn't really work even to do that. So this patch fixes the regression by invoking the consenting adults rule: if you specify a combination of arguments to compileall that produces files with inconsistent destdirs (which you could do before), it is on you. Patch by Jake Garver. files: Lib/compileall.py | 3 --- Lib/test/test_compileall.py | 8 -------- Misc/ACKS | 1 + Misc/NEWS | 4 ++++ 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Lib/compileall.py b/Lib/compileall.py --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -196,9 +196,6 @@ compile_dests = args.compile_dest - if (args.ddir and (len(compile_dests) != 1 - or not os.path.isdir(compile_dests[0]))): - parser.exit('-d destdir requires exactly one directory argument') if args.rx: import re args.rx = re.compile(args.rx) diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py --- a/Lib/test/test_compileall.py +++ b/Lib/test/test_compileall.py @@ -323,14 +323,6 @@ self.assertCompiled(init2fn) self.assertCompiled(bar2fn) - def test_d_takes_exactly_one_dir(self): - rc, out, err = self.assertRunNotOK('-d', 'foo') - self.assertEqual(out, b'') - self.assertRegex(err, b'-d') - rc, out, err = self.assertRunNotOK('-d', 'foo', 'bar') - self.assertEqual(out, b'') - self.assertRegex(err, b'-d') - def test_d_compile_error(self): script_helper.make_script(self.pkgdir, 'crunchyfrog', 'bad(syntax') rc, out, err = self.assertRunNotOK('-q', '-d', 'dinsdale', self.pkgdir) diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -470,6 +470,7 @@ Nitin Ganatra Fred Gansevles Lars Marius Garshol +Jake Garver Dan Gass Andrew Gaul Matthieu Gautier diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -115,6 +115,10 @@ Library ------- +- Issue #24903: Fix regression in number of arguments compileall accepts when + '-d' is specified. The check on the number of arguments has been dropped + completely as it never worked correctly anyway. + - Issue #25764: In the subprocess module, preserve any exception caused by fork() failure when preexec_fn is used. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 4 23:18:11 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 05 Dec 2015 04:18:11 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325764=3A_Attempt_?= =?utf-8?q?to_debug_and_skip_OS_X_setrlimit=28=29_failure?= Message-ID: <20151205041810.61843.61976@psf.io> https://hg.python.org/cpython/rev/f53958873fae changeset: 99442:f53958873fae user: Martin Panter date: Sat Dec 05 04:16:45 2015 +0000 summary: Issue #25764: Attempt to debug and skip OS X setrlimit() failure files: Lib/test/test_subprocess.py | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1516,10 +1516,16 @@ # The internal code did not preserve the previous exception when # re-enabling garbage collection try: - from resource import getrlimit, setrlimit, RLIMIT_NPROC + from resource import getrlimit, setrlimit, RLIMIT_NPROC, RLIM_INFINITY except ImportError as err: self.skipTest(err) # RLIMIT_NPROC is specific to Linux and BSD limits = getrlimit(RLIMIT_NPROC) + try: + setrlimit(RLIMIT_NPROC, limits) + except ValueError as err: + # Seems to happen on AMD64 Snow Leop and x86-64 Yosemite buildbots + print(f"Setting NPROC to {limits!r}: {err!r}, RLIM_INFINITY={RLIM_INFINITY!r}") + self.skipTest("Setting existing NPROC limit failed") [_, hard] = limits setrlimit(RLIMIT_NPROC, (0, hard)) self.addCleanup(setrlimit, RLIMIT_NPROC, limits) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 00:34:17 2015 From: python-checkins at python.org (zach.ware) Date: Sat, 05 Dec 2015 05:34:17 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1Nzk1?= =?utf-8?q?=3A_Fix_several_tests_to_run_independently=2E?= Message-ID: <20151205053417.29983.72213@psf.io> https://hg.python.org/cpython/rev/a54ee6a65f10 changeset: 99443:a54ee6a65f10 branch: 3.5 parent: 99440:c65e135df1dc user: Zachary Ware date: Fri Dec 04 23:32:23 2015 -0600 summary: Issue #25795: Fix several tests to run independently. These were broken in 3aec776fc796 when they were converted away from using support.run_unittest(). Oops :) Initial patch by Felippe da Motta Raposo. files: Lib/test/test_fork1.py | 1 + Lib/test/test_list.py | 1 + Lib/test/test_pyclbr.py | 4 ++-- Lib/test/test_telnetlib.py | 10 +++++----- Lib/test/test_tuple.py | 1 + Lib/test/test_userdict.py | 1 + Lib/test/test_userlist.py | 1 + Lib/test/test_wait4.py | 1 + 8 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_fork1.py b/Lib/test/test_fork1.py --- a/Lib/test/test_fork1.py +++ b/Lib/test/test_fork1.py @@ -6,6 +6,7 @@ import signal import sys import time +import unittest from test.fork_wait import ForkWait from test.support import (reap_children, get_attribute, diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py --- a/Lib/test/test_list.py +++ b/Lib/test/test_list.py @@ -1,6 +1,7 @@ import sys from test import support, list_tests import pickle +import unittest class ListTest(list_tests.CommonTest): type2test = list diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py --- a/Lib/test/test_pyclbr.py +++ b/Lib/test/test_pyclbr.py @@ -5,7 +5,7 @@ import sys from types import FunctionType, MethodType, BuiltinFunctionType import pyclbr -from unittest import TestCase +from unittest import TestCase, main as unittest_main StaticMethodType = type(staticmethod(lambda: None)) ClassMethodType = type(classmethod(lambda c: None)) @@ -173,4 +173,4 @@ if __name__ == "__main__": - unittest.main() + unittest_main() diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py --- a/Lib/test/test_telnetlib.py +++ b/Lib/test/test_telnetlib.py @@ -4,8 +4,8 @@ import time import contextlib -from unittest import TestCase from test import support +import unittest threading = support.import_module('threading') HOST = support.HOST @@ -21,7 +21,7 @@ finally: serv.close() -class GeneralTests(TestCase): +class GeneralTests(unittest.TestCase): def setUp(self): self.evt = threading.Event() @@ -165,7 +165,7 @@ telnet._messages = '' # debuglevel output return telnet -class ExpectAndReadTestCase(TestCase): +class ExpectAndReadTestCase(unittest.TestCase): def setUp(self): self.old_selector = telnetlib._TelnetSelector telnetlib._TelnetSelector = MockSelector @@ -284,7 +284,7 @@ tl = telnetlib -class WriteTests(TestCase): +class WriteTests(unittest.TestCase): '''The only thing that write does is replace each tl.IAC for tl.IAC+tl.IAC''' @@ -300,7 +300,7 @@ written = b''.join(telnet.sock.writes) self.assertEqual(data.replace(tl.IAC,tl.IAC+tl.IAC), written) -class OptionTests(TestCase): +class OptionTests(unittest.TestCase): # RFC 854 commands cmds = [tl.AO, tl.AYT, tl.BRK, tl.EC, tl.EL, tl.GA, tl.IP, tl.NOP] diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py --- a/Lib/test/test_tuple.py +++ b/Lib/test/test_tuple.py @@ -1,4 +1,5 @@ from test import support, seq_tests +import unittest import gc import pickle diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py --- a/Lib/test/test_userdict.py +++ b/Lib/test/test_userdict.py @@ -1,6 +1,7 @@ # Check every path through every method of UserDict from test import support, mapping_tests +import unittest import collections d0 = {} diff --git a/Lib/test/test_userlist.py b/Lib/test/test_userlist.py --- a/Lib/test/test_userlist.py +++ b/Lib/test/test_userlist.py @@ -2,6 +2,7 @@ from collections import UserList from test import support, list_tests +import unittest class UserListTest(list_tests.CommonTest): type2test = UserList diff --git a/Lib/test/test_wait4.py b/Lib/test/test_wait4.py --- a/Lib/test/test_wait4.py +++ b/Lib/test/test_wait4.py @@ -4,6 +4,7 @@ import os import time import sys +import unittest from test.fork_wait import ForkWait from test.support import reap_children, get_attribute -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 00:34:17 2015 From: python-checkins at python.org (zach.ware) Date: Sat, 05 Dec 2015 05:34:17 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Closes_=2325795=3A_Merge_with_3=2E5?= Message-ID: <20151205053417.21233.69288@psf.io> https://hg.python.org/cpython/rev/401459dca320 changeset: 99444:401459dca320 parent: 99442:f53958873fae parent: 99443:a54ee6a65f10 user: Zachary Ware date: Fri Dec 04 23:33:59 2015 -0600 summary: Closes #25795: Merge with 3.5 files: Lib/test/test_fork1.py | 1 + Lib/test/test_list.py | 1 + Lib/test/test_pyclbr.py | 4 ++-- Lib/test/test_telnetlib.py | 10 +++++----- Lib/test/test_tuple.py | 1 + Lib/test/test_userdict.py | 1 + Lib/test/test_userlist.py | 1 + Lib/test/test_wait4.py | 1 + 8 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_fork1.py b/Lib/test/test_fork1.py --- a/Lib/test/test_fork1.py +++ b/Lib/test/test_fork1.py @@ -6,6 +6,7 @@ import signal import sys import time +import unittest from test.fork_wait import ForkWait from test.support import (reap_children, get_attribute, diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py --- a/Lib/test/test_list.py +++ b/Lib/test/test_list.py @@ -1,6 +1,7 @@ import sys from test import support, list_tests import pickle +import unittest class ListTest(list_tests.CommonTest): type2test = list diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py --- a/Lib/test/test_pyclbr.py +++ b/Lib/test/test_pyclbr.py @@ -5,7 +5,7 @@ import sys from types import FunctionType, MethodType, BuiltinFunctionType import pyclbr -from unittest import TestCase +from unittest import TestCase, main as unittest_main StaticMethodType = type(staticmethod(lambda: None)) ClassMethodType = type(classmethod(lambda c: None)) @@ -173,4 +173,4 @@ if __name__ == "__main__": - unittest.main() + unittest_main() diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py --- a/Lib/test/test_telnetlib.py +++ b/Lib/test/test_telnetlib.py @@ -4,8 +4,8 @@ import time import contextlib -from unittest import TestCase from test import support +import unittest threading = support.import_module('threading') HOST = support.HOST @@ -21,7 +21,7 @@ finally: serv.close() -class GeneralTests(TestCase): +class GeneralTests(unittest.TestCase): def setUp(self): self.evt = threading.Event() @@ -170,7 +170,7 @@ telnet._messages = '' # debuglevel output return telnet -class ExpectAndReadTestCase(TestCase): +class ExpectAndReadTestCase(unittest.TestCase): def setUp(self): self.old_selector = telnetlib._TelnetSelector telnetlib._TelnetSelector = MockSelector @@ -289,7 +289,7 @@ tl = telnetlib -class WriteTests(TestCase): +class WriteTests(unittest.TestCase): '''The only thing that write does is replace each tl.IAC for tl.IAC+tl.IAC''' @@ -305,7 +305,7 @@ written = b''.join(telnet.sock.writes) self.assertEqual(data.replace(tl.IAC,tl.IAC+tl.IAC), written) -class OptionTests(TestCase): +class OptionTests(unittest.TestCase): # RFC 854 commands cmds = [tl.AO, tl.AYT, tl.BRK, tl.EC, tl.EL, tl.GA, tl.IP, tl.NOP] diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py --- a/Lib/test/test_tuple.py +++ b/Lib/test/test_tuple.py @@ -1,4 +1,5 @@ from test import support, seq_tests +import unittest import gc import pickle diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py --- a/Lib/test/test_userdict.py +++ b/Lib/test/test_userdict.py @@ -1,6 +1,7 @@ # Check every path through every method of UserDict from test import support, mapping_tests +import unittest import collections d0 = {} diff --git a/Lib/test/test_userlist.py b/Lib/test/test_userlist.py --- a/Lib/test/test_userlist.py +++ b/Lib/test/test_userlist.py @@ -2,6 +2,7 @@ from collections import UserList from test import support, list_tests +import unittest class UserListTest(list_tests.CommonTest): type2test = UserList diff --git a/Lib/test/test_wait4.py b/Lib/test/test_wait4.py --- a/Lib/test/test_wait4.py +++ b/Lib/test/test_wait4.py @@ -4,6 +4,7 @@ import os import time import sys +import unittest from test.fork_wait import ForkWait from test.support import reap_children, get_attribute -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 00:48:03 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 05 Dec 2015 05:48:03 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325764=3A_OS_X_now?= =?utf-8?q?_failing_on_the_second_setrlimit=28=29_call?= Message-ID: <20151205054803.4096.76217@psf.io> https://hg.python.org/cpython/rev/ccf42cdffc6d changeset: 99445:ccf42cdffc6d user: Martin Panter date: Sat Dec 05 05:42:18 2015 +0000 summary: Issue #25764: OS X now failing on the second setrlimit() call files: Lib/test/test_subprocess.py | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1520,14 +1520,17 @@ except ImportError as err: self.skipTest(err) # RLIMIT_NPROC is specific to Linux and BSD limits = getrlimit(RLIMIT_NPROC) + [_, hard] = limits try: setrlimit(RLIMIT_NPROC, limits) + setrlimit(RLIMIT_NPROC, (0, hard)) except ValueError as err: - # Seems to happen on AMD64 Snow Leop and x86-64 Yosemite buildbots - print(f"Setting NPROC to {limits!r}: {err!r}, RLIM_INFINITY={RLIM_INFINITY!r}") - self.skipTest("Setting existing NPROC limit failed") - [_, hard] = limits - setrlimit(RLIMIT_NPROC, (0, hard)) + # Seems to happen on various OS X buildbots + print( + f"Setting NPROC failed: {err!r}, limits={limits!r}, " + f"RLIM_INFINITY={RLIM_INFINITY!r}, " + f"getrlimit() -> {getrlimit(RLIMIT_NPROC)!r}") + self.skipTest("Setting NPROC limit failed") self.addCleanup(setrlimit, RLIMIT_NPROC, limits) # Forking should raise EAGAIN, translated to BlockingIOError with self.assertRaises(BlockingIOError): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 01:19:35 2015 From: python-checkins at python.org (zach.ware) Date: Sat, 05 Dec 2015 06:19:35 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogSXNzdWUgIzI1ODAw?= =?utf-8?q?=3A_Fix_running_test=5Fcapi_directly?= Message-ID: <20151205061935.21247.24813@psf.io> https://hg.python.org/cpython/rev/fae5186562d0 changeset: 99446:fae5186562d0 branch: 3.4 parent: 99439:b63fd82a8528 user: Zachary Ware date: Sat Dec 05 00:16:55 2015 -0600 summary: Issue #25800: Fix running test_capi directly files: Lib/test/test_capi.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -257,7 +257,8 @@ class EmbeddingTests(unittest.TestCase): def setUp(self): - basepath = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + here = os.path.abspath(__file__) + basepath = os.path.dirname(os.path.dirname(os.path.dirname(here))) exename = "_testembed" if sys.platform.startswith("win"): ext = ("_d" if "_d" in sys.executable else "") + ".exe" -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 01:19:36 2015 From: python-checkins at python.org (zach.ware) Date: Sat, 05 Dec 2015 06:19:36 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Issue_=2325800=3A_Merge_with_3=2E4?= Message-ID: <20151205061935.105481.1654@psf.io> https://hg.python.org/cpython/rev/de4108db61f7 changeset: 99447:de4108db61f7 branch: 3.5 parent: 99443:a54ee6a65f10 parent: 99446:fae5186562d0 user: Zachary Ware date: Sat Dec 05 00:18:29 2015 -0600 summary: Issue #25800: Merge with 3.4 files: Lib/test/test_capi.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -343,7 +343,8 @@ class EmbeddingTests(unittest.TestCase): def setUp(self): - basepath = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + here = os.path.abspath(__file__) + basepath = os.path.dirname(os.path.dirname(os.path.dirname(here))) exename = "_testembed" if sys.platform.startswith("win"): ext = ("_d" if "_d" in sys.executable else "") + ".exe" -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 01:19:37 2015 From: python-checkins at python.org (zach.ware) Date: Sat, 05 Dec 2015 06:19:37 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Closes_=2325800=3A_Merge_with_3=2E5?= Message-ID: <20151205061935.33661.28299@psf.io> https://hg.python.org/cpython/rev/bf3a7373e11a changeset: 99448:bf3a7373e11a parent: 99445:ccf42cdffc6d parent: 99447:de4108db61f7 user: Zachary Ware date: Sat Dec 05 00:19:08 2015 -0600 summary: Closes #25800: Merge with 3.5 files: Lib/test/test_capi.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -343,7 +343,8 @@ class EmbeddingTests(unittest.TestCase): def setUp(self): - basepath = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + here = os.path.abspath(__file__) + basepath = os.path.dirname(os.path.dirname(os.path.dirname(here))) exename = "_testembed" if sys.platform.startswith("win"): ext = ("_d" if "_d" in sys.executable else "") + ".exe" -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:24:30 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:24:30 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_add_CVE_and_is?= =?utf-8?q?sue_number?= Message-ID: <20151205082430.60140.20073@psf.io> https://hg.python.org/cpython/rev/b2d64aff7225 changeset: 99449:b2d64aff7225 branch: 2.7 parent: 99292:43208b0f2535 user: Benjamin Peterson date: Sat Dec 05 00:17:57 2015 -0800 summary: add CVE and issue number files: Misc/NEWS | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1354,8 +1354,9 @@ - Issue #21349: Passing a memoryview to _winreg.SetValueEx now correctly raises a TypeError where it previously crashed the interpreter. Patch by Brian Kearns -- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second - parameter. Bug reported by Guido Vranken. +- Issue #21529 (CVE-2014-4616): Fix arbitrary memory access in + JSONDecoder.raw_decode with a negative second parameter. Bug reported by Guido + Vranken. - Issue #21172: isinstance check relaxed from dict to collections.Mapping. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:24:30 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:24:30 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4yIC0+IDMuMyk6?= =?utf-8?q?_merge_3=2E2?= Message-ID: <20151205082430.21512.20541@psf.io> https://hg.python.org/cpython/rev/2932933afbe1 changeset: 99452:2932933afbe1 branch: 3.3 parent: 97944:8cc052c28910 parent: 99451:36be496963d1 user: Benjamin Peterson date: Sat Dec 05 00:21:12 2015 -0800 summary: merge 3.2 files: Misc/NEWS | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -47,6 +47,10 @@ - Issue #23365: Fixed possible integer overflow in itertools.combinations_with_replacement. +- Issue #21529 (CVE-2014-4616): Fix arbitrary memory access in + JSONDecoder.raw_decode with a negative second parameter. Bug reported by Guido + Vranken. + C API ----- @@ -97,9 +101,6 @@ - Issue #21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths before checking for a CGI script at that path. -- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second - parameter. Bug reported by Guido Vranken. - - Issue #20633: Replace relative import by absolute import. - Issue #21082: In os.makedirs, do not set the process-wide umask. Note this -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:24:30 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:24:30 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMi43IC0+IDIuNyk6?= =?utf-8?q?_merge_2=2E7=2E11_branch?= Message-ID: <20151205082430.29597.44182@psf.io> https://hg.python.org/cpython/rev/a3aa22a55db3 changeset: 99450:a3aa22a55db3 branch: 2.7 parent: 99428:c4e950338e79 parent: 99449:b2d64aff7225 user: Benjamin Peterson date: Sat Dec 05 00:18:11 2015 -0800 summary: merge 2.7.11 branch files: Misc/NEWS | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1406,8 +1406,9 @@ - Issue #21349: Passing a memoryview to _winreg.SetValueEx now correctly raises a TypeError where it previously crashed the interpreter. Patch by Brian Kearns -- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second - parameter. Bug reported by Guido Vranken. +- Issue #21529 (CVE-2014-4616): Fix arbitrary memory access in + JSONDecoder.raw_decode with a negative second parameter. Bug reported by Guido + Vranken. - Issue #21172: isinstance check relaxed from dict to collections.Mapping. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:24:30 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:24:30 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E2=29=3A_add_CVE_and_is?= =?utf-8?q?sue_number?= Message-ID: <20151205082430.33659.73182@psf.io> https://hg.python.org/cpython/rev/36be496963d1 changeset: 99451:36be496963d1 branch: 3.2 parent: 96289:0cb037bb0f9a user: Benjamin Peterson date: Sat Dec 05 00:17:57 2015 -0800 summary: add CVE and issue number files: Misc/NEWS | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -99,8 +99,9 @@ - Issue #21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths before checking for a CGI script at that path. -- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second - parameter. Bug reported by Guido Vranken. +- Issue #21529 (CVE-2014-4616): Fix arbitrary memory access in + JSONDecoder.raw_decode with a negative second parameter. Bug reported by Guido + Vranken. - Issue #21082: In os.makedirs, do not set the process-wide umask. Note this changes behavior of makedirs when exist_ok=True. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:24:30 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:24:30 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4zIC0+IDMuNCk6?= =?utf-8?q?_merge_3=2E3?= Message-ID: <20151205082430.61845.41640@psf.io> https://hg.python.org/cpython/rev/693d0b030626 changeset: 99453:693d0b030626 branch: 3.4 parent: 99446:fae5186562d0 parent: 99452:2932933afbe1 user: Benjamin Peterson date: Sat Dec 05 00:23:11 2015 -0800 summary: merge 3.3 files: Misc/NEWS | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1841,8 +1841,9 @@ - Issue #20968: unittest.mock.MagicMock now supports division. Patch by Johannes Baiter. -- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second - parameter. Bug reported by Guido Vranken. +- Issue #21529 (CVE-2014-4616): Fix arbitrary memory access in + JSONDecoder.raw_decode with a negative second parameter. Bug reported by Guido + Vranken. - Issue #21169: getpass now handles non-ascii characters that the input stream encoding cannot encode by re-encoding using the -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:24:31 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:24:31 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_merge_3=2E4?= Message-ID: <20151205082431.93636.27407@psf.io> https://hg.python.org/cpython/rev/7984aea3a5e2 changeset: 99454:7984aea3a5e2 branch: 3.5 parent: 99447:de4108db61f7 parent: 99453:693d0b030626 user: Benjamin Peterson date: Sat Dec 05 00:24:01 2015 -0800 summary: merge 3.4 files: Misc/NEWS | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -3062,8 +3062,9 @@ - Issue #20968: unittest.mock.MagicMock now supports division. Patch by Johannes Baiter. -- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second - parameter. Bug reported by Guido Vranken. +- Issue #21529 (CVE-2014-4616): Fix arbitrary memory access in + JSONDecoder.raw_decode with a negative second parameter. Bug reported by Guido + Vranken. - Issue #21169: getpass now handles non-ascii characters that the input stream encoding cannot encode by re-encoding using the -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:24:31 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:24:31 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy41?= Message-ID: <20151205082431.21510.30972@psf.io> https://hg.python.org/cpython/rev/227c1082b6bf changeset: 99455:227c1082b6bf parent: 99448:bf3a7373e11a parent: 99454:7984aea3a5e2 user: Benjamin Peterson date: Sat Dec 05 00:24:10 2015 -0800 summary: merge 3.5 files: Misc/NEWS | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -3483,8 +3483,9 @@ - Issue #20968: unittest.mock.MagicMock now supports division. Patch by Johannes Baiter. -- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second - parameter. Bug reported by Guido Vranken. +- Issue #21529 (CVE-2014-4616): Fix arbitrary memory access in + JSONDecoder.raw_decode with a negative second parameter. Bug reported by Guido + Vranken. - Issue #21169: getpass now handles non-ascii characters that the input stream encoding cannot encode by re-encoding using the -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:27:51 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:27:51 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_merge_3=2E4?= Message-ID: <20151205082751.21243.94369@psf.io> https://hg.python.org/cpython/rev/ec2aa1d6d955 changeset: 99458:ec2aa1d6d955 branch: 3.5 parent: 99454:7984aea3a5e2 parent: 99457:cf86a04d68e7 user: Benjamin Peterson date: Sat Dec 05 00:27:33 2015 -0800 summary: merge 3.4 files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:27:51 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:27:51 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy4zIC0+IDMuNCk6?= =?utf-8?q?_merge_3=2E3?= Message-ID: <20151205082751.21504.70083@psf.io> https://hg.python.org/cpython/rev/cf86a04d68e7 changeset: 99457:cf86a04d68e7 branch: 3.4 parent: 99453:693d0b030626 parent: 99456:39a709f1ca3a user: Benjamin Peterson date: Sat Dec 05 00:27:23 2015 -0800 summary: merge 3.3 files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:27:51 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:27:51 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E3=29=3A_fix_reordering?= Message-ID: <20151205082751.93646.11388@psf.io> https://hg.python.org/cpython/rev/39a709f1ca3a changeset: 99456:39a709f1ca3a branch: 3.3 parent: 99452:2932933afbe1 user: Benjamin Peterson date: Sat Dec 05 00:27:11 2015 -0800 summary: fix reordering files: Misc/NEWS | 144 +++++++++++++++++++++--------------------- 1 files changed, 72 insertions(+), 72 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -47,82 +47,82 @@ - Issue #23365: Fixed possible integer overflow in itertools.combinations_with_replacement. +C API +----- + +- Issue #23998: PyImport_ReInitLock() now checks for lock allocation error + + +What's New in Python 3.3.6? +=========================== + +*Release date: 11-Oct-2014* + +Core and Builtins +----------------- + +- Issue #22643: Fix integer overflow in Unicode case operations (upper, lower, + title, swapcase, casefold). + +- Issue #22518: Fixed integer overflow issues in "backslashreplace", + "xmlcharrefreplace", and "surrogatepass" error handlers. + +- Issue #22520: Fix overflow checking when generating the repr of a unicode + object. + +- Issue #22519: Fix overflow checking in PyBytes_Repr. + +- Issue #22518: Fix integer overflow issues in latin-1 encoding. + +- Issue #23165: Perform overflow checks before allocating memory in the + _Py_char2wchar function. + +Library +------- + +- Issue #16043: Add a default limit for the amount of data xmlrpclib.gzip_decode + will return. This resolves CVE-2013-1753. + +- Issue #22517: When a io.BufferedRWPair object is deallocated, clear its + weakrefs. + +- Issue #22419: Limit the length of incoming HTTP request in wsgiref server to + 65536 bytes and send a 414 error code for higher lengths. Patch contributed + by Devin Cook. + +- Lax cookie parsing in http.cookies could be a security issue when combined + with non-standard cookie handling in some Web browsers. Reported by + Sergey Bobrov. + +- Issue #21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths + before checking for a CGI script at that path. + +- Issue #20633: Replace relative import by absolute import. + +- Issue #21082: In os.makedirs, do not set the process-wide umask. Note this + changes behavior of makedirs when exist_ok=True. + +- Issue #20875: Prevent possible gzip "'read' is not defined" NameError. + Patch by Claudiu Popa. + +- Issue #11599: When an external command (e.g. compiler) fails, distutils now + prints out the whole command line (instead of just the command name) if the + environment variable DISTUTILS_DEBUG is set. + +- Issue #4931: distutils should not produce unhelpful "error: None" messages + anymore. distutils.util.grok_environment_error is kept but doc-deprecated. + +- Issue #20283: RE pattern methods now accept the string keyword parameters + as documented. The pattern and source keyword parameters are left as + deprecated aliases. + +- Issue #21323: Fix http.server to again handle scripts in CGI subdirectories, + broken by the fix for security issue #19435. Patch by Zach Byrne. + - Issue #21529 (CVE-2014-4616): Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second parameter. Bug reported by Guido Vranken. -C API ------ - -- Issue #23998: PyImport_ReInitLock() now checks for lock allocation error - - -What's New in Python 3.3.6? -=========================== - -*Release date: 11-Oct-2014* - -Core and Builtins ------------------ - -- Issue #22643: Fix integer overflow in Unicode case operations (upper, lower, - title, swapcase, casefold). - -- Issue #22518: Fixed integer overflow issues in "backslashreplace", - "xmlcharrefreplace", and "surrogatepass" error handlers. - -- Issue #22520: Fix overflow checking when generating the repr of a unicode - object. - -- Issue #22519: Fix overflow checking in PyBytes_Repr. - -- Issue #22518: Fix integer overflow issues in latin-1 encoding. - -- Issue #23165: Perform overflow checks before allocating memory in the - _Py_char2wchar function. - -Library -------- - -- Issue #16043: Add a default limit for the amount of data xmlrpclib.gzip_decode - will return. This resolves CVE-2013-1753. - -- Issue #22517: When a io.BufferedRWPair object is deallocated, clear its - weakrefs. - -- Issue #22419: Limit the length of incoming HTTP request in wsgiref server to - 65536 bytes and send a 414 error code for higher lengths. Patch contributed - by Devin Cook. - -- Lax cookie parsing in http.cookies could be a security issue when combined - with non-standard cookie handling in some Web browsers. Reported by - Sergey Bobrov. - -- Issue #21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths - before checking for a CGI script at that path. - -- Issue #20633: Replace relative import by absolute import. - -- Issue #21082: In os.makedirs, do not set the process-wide umask. Note this - changes behavior of makedirs when exist_ok=True. - -- Issue #20875: Prevent possible gzip "'read' is not defined" NameError. - Patch by Claudiu Popa. - -- Issue #11599: When an external command (e.g. compiler) fails, distutils now - prints out the whole command line (instead of just the command name) if the - environment variable DISTUTILS_DEBUG is set. - -- Issue #4931: distutils should not produce unhelpful "error: None" messages - anymore. distutils.util.grok_environment_error is kept but doc-deprecated. - -- Issue #20283: RE pattern methods now accept the string keyword parameters - as documented. The pattern and source keyword parameters are left as - deprecated aliases. - -- Issue #21323: Fix http.server to again handle scripts in CGI subdirectories, - broken by the fix for security issue #19435. Patch by Zach Byrne. - Tests ----- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:27:51 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:27:51 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy41?= Message-ID: <20151205082751.33659.79355@psf.io> https://hg.python.org/cpython/rev/4c50ffbcde5c changeset: 99459:4c50ffbcde5c parent: 99455:227c1082b6bf parent: 99458:ec2aa1d6d955 user: Benjamin Peterson date: Sat Dec 05 00:27:40 2015 -0800 summary: merge 3.5 files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 03:31:54 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 08:31:54 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_make_consultin?= =?utf-8?q?g_save=5Fmodules_O=281=29_rather_than_O=28n=29?= Message-ID: <20151205083154.93632.93146@psf.io> https://hg.python.org/cpython/rev/3192e2af7f52 changeset: 99460:3192e2af7f52 branch: 2.7 parent: 99450:a3aa22a55db3 user: Benjamin Peterson date: Sat Dec 05 00:29:56 2015 -0800 summary: make consulting save_modules O(1) rather than O(n) files: Lib/test/regrtest.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -462,7 +462,7 @@ test_times = [] test_support.use_resources = use_resources - save_modules = sys.modules.keys() + save_modules = set(sys.modules.keys()) def accumulate_result(test, result): ok, test_time = result -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sat Dec 5 03:43:34 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 05 Dec 2015 08:43:34 +0000 Subject: [Python-checkins] Daily reference leaks (401459dca320): sum=4 Message-ID: <20151205084334.105501.47823@psf.io> results for 401459dca320 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogwWkZgc', '--timeout', '7200'] From python-checkins at python.org Sat Dec 5 07:43:06 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 05 Dec 2015 12:43:06 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325764=3A_Remove_t?= =?utf-8?q?est_debugging?= Message-ID: <20151205124306.29621.10831@psf.io> https://hg.python.org/cpython/rev/0c9095566f21 changeset: 99464:0c9095566f21 user: Martin Panter date: Sat Dec 05 10:18:25 2015 +0000 summary: Issue #25764: Remove test debugging files: Lib/test/test_subprocess.py | 13 ++----------- 1 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1518,21 +1518,12 @@ # The internal code did not preserve the previous exception when # re-enabling garbage collection try: - from resource import getrlimit, setrlimit, RLIMIT_NPROC, RLIM_INFINITY + from resource import getrlimit, setrlimit, RLIMIT_NPROC except ImportError as err: self.skipTest(err) # RLIMIT_NPROC is specific to Linux and BSD limits = getrlimit(RLIMIT_NPROC) [_, hard] = limits - try: - setrlimit(RLIMIT_NPROC, limits) - setrlimit(RLIMIT_NPROC, (0, hard)) - except ValueError as err: - # Seems to happen on various OS X buildbots - print( - f"Setting NPROC failed: {err!r}, limits={limits!r}, " - f"RLIM_INFINITY={RLIM_INFINITY!r}, " - f"getrlimit() -> {getrlimit(RLIMIT_NPROC)!r}") - self.skipTest("Setting NPROC limit failed") + setrlimit(RLIMIT_NPROC, (0, hard)) self.addCleanup(setrlimit, RLIMIT_NPROC, limits) # Forking should raise EAGAIN, translated to BlockingIOError with self.assertRaises(BlockingIOError): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 07:43:06 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 05 Dec 2015 12:43:06 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Issue_=2325764=3A_Merge_OS_X_test_skipping_from_3=2E4_into_3?= =?utf-8?q?=2E5?= Message-ID: <20151205124305.4092.96694@psf.io> https://hg.python.org/cpython/rev/6211c41106cc changeset: 99462:6211c41106cc branch: 3.5 parent: 99458:ec2aa1d6d955 parent: 99461:6f831de45f43 user: Martin Panter date: Sat Dec 05 12:41:29 2015 +0000 summary: Issue #25764: Merge OS X test skipping from 3.4 into 3.5 files: Lib/test/test_subprocess.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1512,6 +1512,8 @@ if not enabled: gc.disable() + @unittest.skipIf( + sys.platform == 'darwin', 'setrlimit() seems to fail on OS X') def test_preexec_fork_failure(self): # The internal code did not preserve the previous exception when # re-enabling garbage collection -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 07:43:06 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 05 Dec 2015 12:43:06 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325764=3A_Merge_OS_X_test_skipping_from_3=2E5?= Message-ID: <20151205124306.61823.73652@psf.io> https://hg.python.org/cpython/rev/9a847520c40d changeset: 99463:9a847520c40d parent: 99459:4c50ffbcde5c parent: 99462:6211c41106cc user: Martin Panter date: Sat Dec 05 12:41:41 2015 +0000 summary: Issue #25764: Merge OS X test skipping from 3.5 files: Lib/test/test_subprocess.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1512,6 +1512,8 @@ if not enabled: gc.disable() + @unittest.skipIf( + sys.platform == 'darwin', 'setrlimit() seems to fail on OS X') def test_preexec_fork_failure(self): # The internal code did not preserve the previous exception when # re-enabling garbage collection -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 07:43:06 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 05 Dec 2015 12:43:06 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogSXNzdWUgIzI1NzY0?= =?utf-8?q?=3A_Skip_the_test_on_OS_X?= Message-ID: <20151205124305.21486.5806@psf.io> https://hg.python.org/cpython/rev/6f831de45f43 changeset: 99461:6f831de45f43 branch: 3.4 parent: 99457:cf86a04d68e7 user: Martin Panter date: Sat Dec 05 09:51:52 2015 +0000 summary: Issue #25764: Skip the test on OS X The OS X buildbots were failing at the second setrlimit() call with EPERM, as if they were trying to raise the hard limit. The call should be keeping the hard limit the same and raising the soft limit back to its original value, so I don't understand the failure. files: Lib/test/test_subprocess.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1416,6 +1416,8 @@ if not enabled: gc.disable() + @unittest.skipIf( + sys.platform == 'darwin', 'setrlimit() seems to fail on OS X') def test_preexec_fork_failure(self): # The internal code did not preserve the previous exception when # re-enabling garbage collection -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 14:02:53 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 19:02:53 +0000 Subject: [Python-checkins] =?utf-8?q?release=3A_update_sphinx_to_1=2E3=2E3?= Message-ID: <20151205190253.29971.35971@psf.io> https://hg.python.org/release/rev/96c83c0116b9 changeset: 102:96c83c0116b9 user: Benjamin Peterson date: Sat Dec 05 11:02:47 2015 -0800 summary: update sphinx to 1.3.3 files: release.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/release.py b/release.py --- a/release.py +++ b/release.py @@ -283,7 +283,7 @@ with tempfile.TemporaryDirectory() as venv: run_cmd(['python3', '-m', 'venv', venv]) pip = os.path.join(venv, 'bin', 'pip') - run_cmd([pip, 'install', 'Sphinx==1.2.3']) + run_cmd([pip, 'install', 'Sphinx==1.3.3']) # run_cmd([pip, 'install', 'Sphinx']) sphinx_build = os.path.join(venv, 'bin', 'sphinx-build') with changed_dir('Doc'): -- Repository URL: https://hg.python.org/release From python-checkins at python.org Sat Dec 5 14:45:54 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 19:45:54 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogMi43LjExIGZpbmFs?= Message-ID: <20151205194554.21490.69842@psf.io> https://hg.python.org/cpython/rev/6d1b6a68f775 changeset: 99465:6d1b6a68f775 branch: 2.7 tag: v2.7.11 parent: 99449:b2d64aff7225 user: Benjamin Peterson date: Sat Dec 05 11:45:17 2015 -0800 summary: 2.7.11 final files: Include/patchlevel.h | 6 +++--- Misc/NEWS | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -23,11 +23,11 @@ #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 7 #define PY_MICRO_VERSION 11 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "2.7.11rc1+" +#define PY_VERSION "2.7.11" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository). Empty diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -7,9 +7,6 @@ *Release date: 2015-12-05* -Core and Builtins ------------------ - Library ------- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 14:45:54 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 19:45:54 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Added_tag_v2?= =?utf-8?q?=2E7=2E11_for_changeset_6d1b6a68f775?= Message-ID: <20151205194554.4102.49276@psf.io> https://hg.python.org/cpython/rev/53d30ab403f1 changeset: 99466:53d30ab403f1 branch: 2.7 user: Benjamin Peterson date: Sat Dec 05 11:45:22 2015 -0800 summary: Added tag v2.7.11 for changeset 6d1b6a68f775 files: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -171,3 +171,4 @@ 80ccce248ba2657ed5da3ccf7999f35b78827f5e v2.7.10rc1 15c95b7d81dcf821daade360741e00714667653f v2.7.10 82dd9545bd93d6e7a9821e1dabc7b25508d0fa3a v2.7.11rc1 +6d1b6a68f775fada9877d295e62958bafa1ca11e v2.7.11 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 14:45:54 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 19:45:54 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMi43IC0+IDIuNyk6?= =?utf-8?q?_merge_2=2E7=2E11_branch?= Message-ID: <20151205194554.61841.93223@psf.io> https://hg.python.org/cpython/rev/ec0289f3af28 changeset: 99467:ec0289f3af28 branch: 2.7 parent: 99460:3192e2af7f52 parent: 99466:53d30ab403f1 user: Benjamin Peterson date: Sat Dec 05 11:45:48 2015 -0800 summary: merge 2.7.11 branch files: .hgtags | 1 + Include/patchlevel.h | 6 +++--- Misc/NEWS | 3 --- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -171,3 +171,4 @@ 80ccce248ba2657ed5da3ccf7999f35b78827f5e v2.7.10rc1 15c95b7d81dcf821daade360741e00714667653f v2.7.10 82dd9545bd93d6e7a9821e1dabc7b25508d0fa3a v2.7.11rc1 +6d1b6a68f775fada9877d295e62958bafa1ca11e v2.7.11 diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -23,11 +23,11 @@ #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 7 #define PY_MICRO_VERSION 11 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "2.7.11rc1+" +#define PY_VERSION "2.7.11" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository). Empty diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -59,9 +59,6 @@ *Release date: 2015-12-05* -Core and Builtins ------------------ - Library ------- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 14:46:37 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sat, 05 Dec 2015 19:46:37 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogb2ZmIHRvIDIuNy4x?= =?utf-8?q?2_we_go?= Message-ID: <20151205194636.105481.56369@psf.io> https://hg.python.org/cpython/rev/2096109fe812 changeset: 99468:2096109fe812 branch: 2.7 user: Benjamin Peterson date: Sat Dec 05 11:46:21 2015 -0800 summary: off to 2.7.12 we go files: Include/patchlevel.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -27,7 +27,7 @@ #define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "2.7.11" +#define PY_VERSION "2.7.11+" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository). Empty -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 19:54:47 2015 From: python-checkins at python.org (larry.hastings) Date: Sun, 06 Dec 2015 00:54:47 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Updated_the_URL_for_the_build?= =?utf-8?q?bots=2E?= Message-ID: <20151206005447.60132.8687@psf.io> https://hg.python.org/peps/rev/d13b79fa56cc changeset: 6135:d13b79fa56cc user: Larry Hastings date: Sat Dec 05 16:54:44 2015 -0800 summary: Updated the URL for the buildbots. files: pep-0101.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0101.txt b/pep-0101.txt --- a/pep-0101.txt +++ b/pep-0101.txt @@ -129,7 +129,7 @@ ___ Check the stable buildbots. - Go to http://www.python.org/dev/buildbot/stable/ + Go to http://buildbot.python.org/all/waterfall (the trailing slash is required). Look at the buildbots for the release you're making. Ignore any that are offline (or inform the community so -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sat Dec 5 20:04:18 2015 From: python-checkins at python.org (larry.hastings) Date: Sun, 06 Dec 2015 01:04:18 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Updated_another_path_that=27s?= =?utf-8?q?_changed_in_recent=2E=2E=2E_years=3F?= Message-ID: <20151206010418.105483.35903@psf.io> https://hg.python.org/peps/rev/7112c1e639a1 changeset: 6136:7112c1e639a1 user: Larry Hastings date: Sat Dec 05 17:04:15 2015 -0800 summary: Updated another path that's changed in recent... years? files: pep-0101.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0101.txt b/pep-0101.txt --- a/pep-0101.txt +++ b/pep-0101.txt @@ -179,7 +179,7 @@ ___ Commit your changes to pydoc_topics.py (and any fixes you made in the docs). - ___ Make sure the SOURCE_URI in ``Doc/tools/pyspecific.py`` + ___ Make sure the SOURCE_URI in ``Doc/tools/extensions/pyspecific.py`` points to the right branch in the hg repository (or ``default`` for unstable releases of the default branch). -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sat Dec 5 21:01:31 2015 From: python-checkins at python.org (ethan.furman) Date: Sun, 06 Dec 2015 02:01:31 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_the_trailing_slash_is_no_lang?= =?utf-8?q?er_required?= Message-ID: <20151206020131.60140.95669@psf.io> https://hg.python.org/peps/rev/4769e5c2ef8f changeset: 6137:4769e5c2ef8f user: Ethan Furman date: Sat Dec 05 18:01:21 2015 -0800 summary: the trailing slash is no langer required files: pep-0101.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0101.txt b/pep-0101.txt --- a/pep-0101.txt +++ b/pep-0101.txt @@ -131,7 +131,7 @@ Go to http://buildbot.python.org/all/waterfall - (the trailing slash is required). Look at the buildbots for the release + Look at the buildbots for the release you're making. Ignore any that are offline (or inform the community so they can be restarted). If what remains are (mostly) green buildbots, you're good to go. If you have non-offline red buildbots, you may want -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sat Dec 5 22:51:55 2015 From: python-checkins at python.org (martin.panter) Date: Sun, 06 Dec 2015 03:51:55 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NzE3?= =?utf-8?q?=3A_Tolerate_fstat=28=29_failures_in_the_FileIO_constructor?= Message-ID: <20151206035155.60134.75685@psf.io> https://hg.python.org/cpython/rev/20ea12222b0e changeset: 99469:20ea12222b0e branch: 3.5 parent: 99462:6211c41106cc user: Martin Panter date: Sun Dec 06 03:15:05 2015 +0000 summary: Issue #25717: Tolerate fstat() failures in the FileIO constructor This restores 3.4 behaviour, which was removed by revision 3b5279b5bfd1. The fstat() call fails with ENOENT for a Virtual Box shared folder filesystem if the file entry has been unlinked, e.g. for a temporary file. files: Misc/NEWS | 4 +++ Modules/_io/fileio.c | 39 ++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,10 @@ Library ------- +- Issue #25717: Restore the previous behaviour of tolerating most fstat() + errors when opening files. This was a regression in 3.5a1, and stopped + anonymous temporary files from working in special cases. + - Issue #24903: Fix regression in number of arguments compileall accepts when '-d' is specified. The check on the number of arguments has been dropped completely as it never worked correctly anyway. diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -250,6 +250,7 @@ int *atomic_flag_works = NULL; #endif struct _Py_stat_struct fdfstat; + int fstat_result; int async_err = 0; assert(PyFileIO_Check(self)); @@ -438,22 +439,36 @@ } self->blksize = DEFAULT_BUFFER_SIZE; - if (_Py_fstat(self->fd, &fdfstat) < 0) - goto error; + Py_BEGIN_ALLOW_THREADS + fstat_result = _Py_fstat_noraise(self->fd, &fdfstat); + Py_END_ALLOW_THREADS + if (fstat_result < 0) { +#ifdef MS_WINDOWS + if (GetLastError() == ERROR_INVALID_HANDLE) { + PyErr_SetFromWindowsErr(0); +#else + if (errno == EBADF) { + PyErr_SetFromErrno(PyExc_OSError); +#endif + goto error; + } + } + else { #if defined(S_ISDIR) && defined(EISDIR) - /* On Unix, open will succeed for directories. - In Python, there should be no file objects referring to - directories, so we need a check. */ - if (S_ISDIR(fdfstat.st_mode)) { - errno = EISDIR; - PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, nameobj); - goto error; - } + /* On Unix, open will succeed for directories. + In Python, there should be no file objects referring to + directories, so we need a check. */ + if (S_ISDIR(fdfstat.st_mode)) { + errno = EISDIR; + PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, nameobj); + goto error; + } #endif /* defined(S_ISDIR) */ #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE - if (fdfstat.st_blksize > 1) - self->blksize = fdfstat.st_blksize; + if (fdfstat.st_blksize > 1) + self->blksize = fdfstat.st_blksize; #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ + } #if defined(MS_WINDOWS) || defined(__CYGWIN__) /* don't translate newlines (\r\n <=> \n) */ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 22:51:56 2015 From: python-checkins at python.org (martin.panter) Date: Sun, 06 Dec 2015 03:51:56 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325717=3A_Merge_fstat=28=29_fix_from_3=2E5?= Message-ID: <20151206035156.93652.61835@psf.io> https://hg.python.org/cpython/rev/8c978cbe057c changeset: 99470:8c978cbe057c parent: 99464:0c9095566f21 parent: 99469:20ea12222b0e user: Martin Panter date: Sun Dec 06 03:29:54 2015 +0000 summary: Issue #25717: Merge fstat() fix from 3.5 files: Misc/NEWS | 4 +++ Modules/_io/fileio.c | 39 ++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -109,6 +109,10 @@ Library ------- +- Issue #25717: Restore the previous behaviour of tolerating most fstat() + errors when opening files. This was a regression in 3.5a1, and stopped + anonymous temporary files from working in special cases. + - Issue #24903: Fix regression in number of arguments compileall accepts when '-d' is specified. The check on the number of arguments has been dropped completely as it never worked correctly anyway. diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -250,6 +250,7 @@ int *atomic_flag_works = NULL; #endif struct _Py_stat_struct fdfstat; + int fstat_result; int async_err = 0; assert(PyFileIO_Check(self)); @@ -438,22 +439,36 @@ } self->blksize = DEFAULT_BUFFER_SIZE; - if (_Py_fstat(self->fd, &fdfstat) < 0) - goto error; + Py_BEGIN_ALLOW_THREADS + fstat_result = _Py_fstat_noraise(self->fd, &fdfstat); + Py_END_ALLOW_THREADS + if (fstat_result < 0) { +#ifdef MS_WINDOWS + if (GetLastError() == ERROR_INVALID_HANDLE) { + PyErr_SetFromWindowsErr(0); +#else + if (errno == EBADF) { + PyErr_SetFromErrno(PyExc_OSError); +#endif + goto error; + } + } + else { #if defined(S_ISDIR) && defined(EISDIR) - /* On Unix, open will succeed for directories. - In Python, there should be no file objects referring to - directories, so we need a check. */ - if (S_ISDIR(fdfstat.st_mode)) { - errno = EISDIR; - PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, nameobj); - goto error; - } + /* On Unix, open will succeed for directories. + In Python, there should be no file objects referring to + directories, so we need a check. */ + if (S_ISDIR(fdfstat.st_mode)) { + errno = EISDIR; + PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, nameobj); + goto error; + } #endif /* defined(S_ISDIR) */ #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE - if (fdfstat.st_blksize > 1) - self->blksize = fdfstat.st_blksize; + if (fdfstat.st_blksize > 1) + self->blksize = fdfstat.st_blksize; #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ + } #if defined(MS_WINDOWS) || defined(__CYGWIN__) /* don't translate newlines (\r\n <=> \n) */ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 5 23:57:42 2015 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 06 Dec 2015 04:57:42 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_remove_pointle?= =?utf-8?q?ss_keys=28=29_call?= Message-ID: <20151206045742.29601.8823@psf.io> https://hg.python.org/cpython/rev/0ad57f476e64 changeset: 99471:0ad57f476e64 branch: 2.7 parent: 99468:2096109fe812 user: Benjamin Peterson date: Sat Dec 05 20:52:43 2015 -0800 summary: remove pointless keys() call files: Lib/test/regrtest.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -462,7 +462,7 @@ test_times = [] test_support.use_resources = use_resources - save_modules = set(sys.modules.keys()) + save_modules = set(sys.modules) def accumulate_result(test, result): ok, test_time = result -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 00:02:04 2015 From: python-checkins at python.org (ned.deily) Date: Sun, 06 Dec 2015 05:02:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Issue_=2325798=3A_merge_from_3=2E4?= Message-ID: <20151206050203.29979.90063@psf.io> https://hg.python.org/cpython/rev/02d2127fda6c changeset: 99474:02d2127fda6c branch: 3.5 parent: 99469:20ea12222b0e parent: 99473:51a0dd6f7c73 user: Ned Deily date: Sat Dec 05 23:55:33 2015 -0500 summary: Issue #25798: merge from 3.4 files: Mac/BuildScript/build-installer.py | 6 +- Mac/BuildScript/openssl_sdk_makedepend.patch | 18 +++++---- Misc/NEWS | 5 ++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -237,9 +237,9 @@ result.extend([ dict( - name="OpenSSL 1.0.2d", - url="https://www.openssl.org/source/openssl-1.0.2d.tar.gz", - checksum='38dd619b2e77cbac69b99f52a053d25a', + name="OpenSSL 1.0.2e", + url="https://www.openssl.org/source/openssl-1.0.2e.tar.gz", + checksum='5262bfa25b60ed9de9f28d5d52d77fc5', patches=[ "openssl_sdk_makedepend.patch", ], diff --git a/Mac/BuildScript/openssl_sdk_makedepend.patch b/Mac/BuildScript/openssl_sdk_makedepend.patch --- a/Mac/BuildScript/openssl_sdk_makedepend.patch +++ b/Mac/BuildScript/openssl_sdk_makedepend.patch @@ -1,8 +1,8 @@ # HG changeset patch -# Parent 25a9af415e8c3faf591c360d5f0e361d049b2b43 +# Parent ff8a7557607cffd626997e57ed31c1012a3018aa # openssl_sdk_makedepend.patch # -# using openssl 1.0.2d +# using openssl 1.0.2e # # - support building with an OS X SDK # - allow "make depend" to use compilers with names other than "gcc" @@ -12,7 +12,7 @@ diff --git a/Configure b/Configure --- a/Configure +++ b/Configure -@@ -617,12 +617,12 @@ +@@ -635,12 +635,12 @@ ##### MacOS X (a.k.a. Rhapsody or Darwin) setup "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::", @@ -31,24 +31,26 @@ "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", # iPhoneOS/iOS "iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -@@ -1685,7 +1685,7 @@ +@@ -1714,8 +1714,7 @@ s/^CC=.*$/CC= $cc/; s/^AR=\s*ar/AR= $ar/; s/^RANLIB=.*/RANLIB= $ranlib/; - s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc"; -+ s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/; +- s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang"; ++ s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ } s/^CFLAG=.*$/CFLAG= $cflags/; s/^DEPFLAG=.*$/DEPFLAG=$depflags/; diff --git a/util/domd b/util/domd --- a/util/domd +++ b/util/domd -@@ -14,7 +14,7 @@ +@@ -14,8 +14,7 @@ cp Makefile Makefile.save # fake the presence of Kerberos touch $TOP/krb5.h --if expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then -+if true ; then # was: if expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then +-if ${MAKEDEPEND} --version 2>&1 | grep -q "clang" || +- echo $MAKEDEPEND | grep -q "gcc"; then ++if true ; then args="" while [ $# -gt 0 ]; do if [ "$1" != "--" ]; then args="$args $1"; fi diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -77,6 +77,11 @@ - Issue #25616: Tests for OrderedDict are extracted from test_collections into separate file test_ordered_dict. +Build +----- + +- Issue #25798: Update OS X 10.5 installer to use OpenSSL 1.0.2e. + What's New in Python 3.5.1 final? ================================= -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 00:02:04 2015 From: python-checkins at python.org (ned.deily) Date: Sun, 06 Dec 2015 05:02:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogSXNzdWUgIzI1Nzk4?= =?utf-8?q?=3A_Update_OS_X_10=2E5+_32-bit-only_installer_to_build?= Message-ID: <20151206050203.105473.80671@psf.io> https://hg.python.org/cpython/rev/51a0dd6f7c73 changeset: 99473:51a0dd6f7c73 branch: 3.4 parent: 99461:6f831de45f43 user: Ned Deily date: Sat Dec 05 23:51:23 2015 -0500 summary: Issue #25798: Update OS X 10.5+ 32-bit-only installer to build and link with OpenSSL 1.0.2e. files: Mac/BuildScript/build-installer.py | 6 +- Mac/BuildScript/openssl_sdk_makedepend.patch | 18 +++++---- Misc/NEWS | 4 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -237,9 +237,9 @@ result.extend([ dict( - name="OpenSSL 1.0.2d", - url="https://www.openssl.org/source/openssl-1.0.2d.tar.gz", - checksum='38dd619b2e77cbac69b99f52a053d25a', + name="OpenSSL 1.0.2e", + url="https://www.openssl.org/source/openssl-1.0.2e.tar.gz", + checksum='5262bfa25b60ed9de9f28d5d52d77fc5', patches=[ "openssl_sdk_makedepend.patch", ], diff --git a/Mac/BuildScript/openssl_sdk_makedepend.patch b/Mac/BuildScript/openssl_sdk_makedepend.patch --- a/Mac/BuildScript/openssl_sdk_makedepend.patch +++ b/Mac/BuildScript/openssl_sdk_makedepend.patch @@ -1,8 +1,8 @@ # HG changeset patch -# Parent 25a9af415e8c3faf591c360d5f0e361d049b2b43 +# Parent ff8a7557607cffd626997e57ed31c1012a3018aa # openssl_sdk_makedepend.patch # -# using openssl 1.0.2d +# using openssl 1.0.2e # # - support building with an OS X SDK # - allow "make depend" to use compilers with names other than "gcc" @@ -12,7 +12,7 @@ diff --git a/Configure b/Configure --- a/Configure +++ b/Configure -@@ -617,12 +617,12 @@ +@@ -635,12 +635,12 @@ ##### MacOS X (a.k.a. Rhapsody or Darwin) setup "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::", @@ -31,24 +31,26 @@ "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", # iPhoneOS/iOS "iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -@@ -1685,7 +1685,7 @@ +@@ -1714,8 +1714,7 @@ s/^CC=.*$/CC= $cc/; s/^AR=\s*ar/AR= $ar/; s/^RANLIB=.*/RANLIB= $ranlib/; - s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc"; -+ s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/; +- s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang"; ++ s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ } s/^CFLAG=.*$/CFLAG= $cflags/; s/^DEPFLAG=.*$/DEPFLAG=$depflags/; diff --git a/util/domd b/util/domd --- a/util/domd +++ b/util/domd -@@ -14,7 +14,7 @@ +@@ -14,8 +14,7 @@ cp Makefile Makefile.save # fake the presence of Kerberos touch $TOP/krb5.h --if expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then -+if true ; then # was: if expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then +-if ${MAKEDEPEND} --version 2>&1 | grep -q "clang" || +- echo $MAKEDEPEND | grep -q "gcc"; then ++if true ; then args="" while [ $# -gt 0 ]; do if [ "$1" != "--" ]; then args="$args $1"; fi diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -745,8 +745,8 @@ - Issue #23445: pydebug builds now use "gcc -Og" where possible, to make the resulting executable faster. -- Issue #24603: Update Windows builds and OS X 10.5 installer to use OpenSSL - 1.0.2d. +- Issue #24603: Update Windows builds to use OpenSSL1.0.2d + and OS X 10.5 installer to use OpenSSL 1.0.2e. C API ----- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 00:02:03 2015 From: python-checkins at python.org (ned.deily) Date: Sun, 06 Dec 2015 05:02:03 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1Nzk4?= =?utf-8?q?=3A_Update_OS_X_10=2E5+_32-bit-only_installer_to_build?= Message-ID: <20151206050203.61845.10446@psf.io> https://hg.python.org/cpython/rev/f9a0ac60f876 changeset: 99472:f9a0ac60f876 branch: 2.7 parent: 99468:2096109fe812 user: Ned Deily date: Sat Dec 05 23:47:34 2015 -0500 summary: Issue #25798: Update OS X 10.5+ 32-bit-only installer to build and link with OpenSSL 1.0.2e. files: Mac/BuildScript/build-installer.py | 6 +- Mac/BuildScript/openssl_sdk_makedepend.patch | 18 +++++---- Misc/NEWS | 6 +++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -237,9 +237,9 @@ result.extend([ dict( - name="OpenSSL 1.0.2d", - url="https://www.openssl.org/source/openssl-1.0.2d.tar.gz", - checksum='38dd619b2e77cbac69b99f52a053d25a', + name="OpenSSL 1.0.2e", + url="https://www.openssl.org/source/openssl-1.0.2e.tar.gz", + checksum='5262bfa25b60ed9de9f28d5d52d77fc5', patches=[ "openssl_sdk_makedepend.patch", ], diff --git a/Mac/BuildScript/openssl_sdk_makedepend.patch b/Mac/BuildScript/openssl_sdk_makedepend.patch --- a/Mac/BuildScript/openssl_sdk_makedepend.patch +++ b/Mac/BuildScript/openssl_sdk_makedepend.patch @@ -1,8 +1,8 @@ # HG changeset patch -# Parent 25a9af415e8c3faf591c360d5f0e361d049b2b43 +# Parent ff8a7557607cffd626997e57ed31c1012a3018aa # openssl_sdk_makedepend.patch # -# using openssl 1.0.2d +# using openssl 1.0.2e # # - support building with an OS X SDK # - allow "make depend" to use compilers with names other than "gcc" @@ -12,7 +12,7 @@ diff --git a/Configure b/Configure --- a/Configure +++ b/Configure -@@ -617,12 +617,12 @@ +@@ -635,12 +635,12 @@ ##### MacOS X (a.k.a. Rhapsody or Darwin) setup "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::", @@ -31,24 +31,26 @@ "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", # iPhoneOS/iOS "iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -@@ -1685,7 +1685,7 @@ +@@ -1714,8 +1714,7 @@ s/^CC=.*$/CC= $cc/; s/^AR=\s*ar/AR= $ar/; s/^RANLIB=.*/RANLIB= $ranlib/; - s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc"; -+ s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/; +- s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang"; ++ s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ } s/^CFLAG=.*$/CFLAG= $cflags/; s/^DEPFLAG=.*$/DEPFLAG=$depflags/; diff --git a/util/domd b/util/domd --- a/util/domd +++ b/util/domd -@@ -14,7 +14,7 @@ +@@ -14,8 +14,7 @@ cp Makefile Makefile.save # fake the presence of Kerberos touch $TOP/krb5.h --if expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then -+if true ; then # was: if expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then +-if ${MAKEDEPEND} --version 2>&1 | grep -q "clang" || +- echo $MAKEDEPEND | grep -q "gcc"; then ++if true ; then args="" while [ $# -gt 0 ]; do if [ "$1" != "--" ]; then args="$args $1"; fi diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -53,6 +53,12 @@ - Issue #25616: Tests for OrderedDict are extracted from test_collections into separate file test_ordered_dict. +Build +----- + +- Issue #25798: Update OS X 10.5+ 32-bit-only installer to build + and link with OpenSSL 1.0.2e. + What's New in Python 2.7.11? ============================ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 00:02:04 2015 From: python-checkins at python.org (ned.deily) Date: Sun, 06 Dec 2015 05:02:04 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325798=3A_merge_from_3=2E5?= Message-ID: <20151206050204.4078.56438@psf.io> https://hg.python.org/cpython/rev/50a99be891bc changeset: 99475:50a99be891bc parent: 99470:8c978cbe057c parent: 99474:02d2127fda6c user: Ned Deily date: Sat Dec 05 23:57:55 2015 -0500 summary: Issue #25798: merge from 3.5 files: Mac/BuildScript/build-installer.py | 6 +- Mac/BuildScript/openssl_sdk_makedepend.patch | 18 +++++---- Misc/NEWS | 2 + 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -237,9 +237,9 @@ result.extend([ dict( - name="OpenSSL 1.0.2d", - url="https://www.openssl.org/source/openssl-1.0.2d.tar.gz", - checksum='38dd619b2e77cbac69b99f52a053d25a', + name="OpenSSL 1.0.2e", + url="https://www.openssl.org/source/openssl-1.0.2e.tar.gz", + checksum='5262bfa25b60ed9de9f28d5d52d77fc5', patches=[ "openssl_sdk_makedepend.patch", ], diff --git a/Mac/BuildScript/openssl_sdk_makedepend.patch b/Mac/BuildScript/openssl_sdk_makedepend.patch --- a/Mac/BuildScript/openssl_sdk_makedepend.patch +++ b/Mac/BuildScript/openssl_sdk_makedepend.patch @@ -1,8 +1,8 @@ # HG changeset patch -# Parent 25a9af415e8c3faf591c360d5f0e361d049b2b43 +# Parent ff8a7557607cffd626997e57ed31c1012a3018aa # openssl_sdk_makedepend.patch # -# using openssl 1.0.2d +# using openssl 1.0.2e # # - support building with an OS X SDK # - allow "make depend" to use compilers with names other than "gcc" @@ -12,7 +12,7 @@ diff --git a/Configure b/Configure --- a/Configure +++ b/Configure -@@ -617,12 +617,12 @@ +@@ -635,12 +635,12 @@ ##### MacOS X (a.k.a. Rhapsody or Darwin) setup "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::", @@ -31,24 +31,26 @@ "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", # iPhoneOS/iOS "iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -@@ -1685,7 +1685,7 @@ +@@ -1714,8 +1714,7 @@ s/^CC=.*$/CC= $cc/; s/^AR=\s*ar/AR= $ar/; s/^RANLIB=.*/RANLIB= $ranlib/; - s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc"; -+ s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/; +- s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang"; ++ s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ } s/^CFLAG=.*$/CFLAG= $cflags/; s/^DEPFLAG=.*$/DEPFLAG=$depflags/; diff --git a/util/domd b/util/domd --- a/util/domd +++ b/util/domd -@@ -14,7 +14,7 @@ +@@ -14,8 +14,7 @@ cp Makefile Makefile.save # fake the presence of Kerberos touch $TOP/krb5.h --if expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then -+if true ; then # was: if expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then +-if ${MAKEDEPEND} --version 2>&1 | grep -q "clang" || +- echo $MAKEDEPEND | grep -q "gcc"; then ++if true ; then args="" while [ $# -gt 0 ]; do if [ "$1" != "--" ]; then args="$args $1"; fi diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -486,6 +486,8 @@ - Issue #24986: It is now possible to build Python on Windows without errors when external libraries are not available. +- Issue #25798: Update OS X 10.5 installer to use OpenSSL 1.0.2e. + Windows ------- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 00:02:09 2015 From: python-checkins at python.org (ned.deily) Date: Sun, 06 Dec 2015 05:02:09 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMi43IC0+IDIuNyk6?= =?utf-8?q?_merge_heads?= Message-ID: <20151206050209.105501.45341@psf.io> https://hg.python.org/cpython/rev/8ddac065cd3b changeset: 99476:8ddac065cd3b branch: 2.7 parent: 99472:f9a0ac60f876 parent: 99471:0ad57f476e64 user: Ned Deily date: Sun Dec 06 00:00:57 2015 -0500 summary: merge heads files: Lib/test/regrtest.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -462,7 +462,7 @@ test_times = [] test_support.use_resources = use_resources - save_modules = set(sys.modules.keys()) + save_modules = set(sys.modules) def accumulate_result(test, result): ok, test_time = result -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sun Dec 6 03:42:36 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 06 Dec 2015 08:42:36 +0000 Subject: [Python-checkins] Daily reference leaks (50a99be891bc): sum=4 Message-ID: <20151206084235.21237.92601@psf.io> results for 50a99be891bc on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogF9JtOe', '--timeout', '7200'] From python-checkins at python.org Sun Dec 6 06:20:32 2015 From: python-checkins at python.org (martin.panter) Date: Sun, 06 Dec 2015 11:20:32 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NzE3?= =?utf-8?q?=3A_Add_comment_explaining_why_errors_are_ignored?= Message-ID: <20151206112032.29968.40133@psf.io> https://hg.python.org/cpython/rev/e9bf5803b716 changeset: 99477:e9bf5803b716 branch: 3.5 parent: 99474:02d2127fda6c user: Martin Panter date: Sun Dec 06 11:12:15 2015 +0000 summary: Issue #25717: Add comment explaining why errors are ignored files: Modules/_io/fileio.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -443,6 +443,9 @@ fstat_result = _Py_fstat_noraise(self->fd, &fdfstat); Py_END_ALLOW_THREADS if (fstat_result < 0) { + /* Tolerate fstat() errors other than EBADF. See Issue #25717, where + an anonymous file on a Virtual Box shared folder filesystem would + raise ENOENT. */ #ifdef MS_WINDOWS if (GetLastError() == ERROR_INVALID_HANDLE) { PyErr_SetFromWindowsErr(0); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 06:20:33 2015 From: python-checkins at python.org (martin.panter) Date: Sun, 06 Dec 2015 11:20:33 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325717=3A_Merge_comment_from_3=2E5?= Message-ID: <20151206112032.105477.57785@psf.io> https://hg.python.org/cpython/rev/8bf69413ec01 changeset: 99478:8bf69413ec01 parent: 99475:50a99be891bc parent: 99477:e9bf5803b716 user: Martin Panter date: Sun Dec 06 11:19:31 2015 +0000 summary: Issue #25717: Merge comment from 3.5 files: Modules/_io/fileio.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -443,6 +443,9 @@ fstat_result = _Py_fstat_noraise(self->fd, &fdfstat); Py_END_ALLOW_THREADS if (fstat_result < 0) { + /* Tolerate fstat() errors other than EBADF. See Issue #25717, where + an anonymous file on a Virtual Box shared folder filesystem would + raise ENOENT. */ #ifdef MS_WINDOWS if (GetLastError() == ERROR_INVALID_HANDLE) { PyErr_SetFromWindowsErr(0); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 15:02:12 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 06 Dec 2015 20:02:12 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325761=3A_Improved?= =?utf-8?q?_detecting_errors_in_broken_pickle_data=2E?= Message-ID: <20151206200212.33665.61859@psf.io> https://hg.python.org/cpython/rev/5c670af0100f changeset: 99479:5c670af0100f user: Serhiy Storchaka date: Sun Dec 06 22:01:35 2015 +0200 summary: Issue #25761: Improved detecting errors in broken pickle data. files: Lib/pickle.py | 88 ++++++++------------ Lib/test/pickletester.py | 17 +-- Lib/test/test_pickle.py | 5 - Misc/NEWS | 2 + Modules/_pickle.c | 113 ++++++++++++++++---------- 5 files changed, 114 insertions(+), 111 deletions(-) diff --git a/Lib/pickle.py b/Lib/pickle.py --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -1031,7 +1031,7 @@ self._unframer = _Unframer(self._file_read, self._file_readline) self.read = self._unframer.read self.readline = self._unframer.readline - self.mark = object() # any new unique object + self.metastack = [] self.stack = [] self.append = self.stack.append self.proto = 0 @@ -1047,20 +1047,12 @@ except _Stop as stopinst: return stopinst.value - # Return largest index k such that self.stack[k] is self.mark. - # If the stack doesn't contain a mark, eventually raises IndexError. - # This could be sped by maintaining another stack, of indices at which - # the mark appears. For that matter, the latter stack would suffice, - # and we wouldn't need to push mark objects on self.stack at all. - # Doing so is probably a good thing, though, since if the pickle is - # corrupt (or hostile) we may get a clue from finding self.mark embedded - # in unpickled objects. - def marker(self): - stack = self.stack - mark = self.mark - k = len(stack)-1 - while stack[k] is not mark: k = k-1 - return k + # Return a list of items pushed in the stack after last MARK instruction. + def pop_mark(self): + items = self.stack + self.stack = self.metastack.pop() + self.append = self.stack.append + return items def persistent_load(self, pid): raise UnpicklingError("unsupported persistent id encountered") @@ -1237,8 +1229,8 @@ dispatch[SHORT_BINUNICODE[0]] = load_short_binunicode def load_tuple(self): - k = self.marker() - self.stack[k:] = [tuple(self.stack[k+1:])] + items = self.pop_mark() + self.append(tuple(items)) dispatch[TUPLE[0]] = load_tuple def load_empty_tuple(self): @@ -1270,21 +1262,20 @@ dispatch[EMPTY_SET[0]] = load_empty_set def load_frozenset(self): - k = self.marker() - self.stack[k:] = [frozenset(self.stack[k+1:])] + items = self.pop_mark() + self.append(frozenset(items)) dispatch[FROZENSET[0]] = load_frozenset def load_list(self): - k = self.marker() - self.stack[k:] = [self.stack[k+1:]] + items = self.pop_mark() + self.append(items) dispatch[LIST[0]] = load_list def load_dict(self): - k = self.marker() - items = self.stack[k+1:] + items = self.pop_mark() d = {items[i]: items[i+1] for i in range(0, len(items), 2)} - self.stack[k:] = [d] + self.append(d) dispatch[DICT[0]] = load_dict # INST and OBJ differ only in how they get a class object. It's not @@ -1292,9 +1283,7 @@ # previously diverged and grew different bugs. # klass is the class to instantiate, and k points to the topmost mark # object, following which are the arguments for klass.__init__. - def _instantiate(self, klass, k): - args = tuple(self.stack[k+1:]) - del self.stack[k:] + def _instantiate(self, klass, args): if (args or not isinstance(klass, type) or hasattr(klass, "__getinitargs__")): try: @@ -1310,14 +1299,14 @@ module = self.readline()[:-1].decode("ascii") name = self.readline()[:-1].decode("ascii") klass = self.find_class(module, name) - self._instantiate(klass, self.marker()) + self._instantiate(klass, self.pop_mark()) dispatch[INST[0]] = load_inst def load_obj(self): # Stack is ... markobject classobject arg1 arg2 ... - k = self.marker() - klass = self.stack.pop(k+1) - self._instantiate(klass, k) + args = self.pop_mark() + cls = args.pop(0) + self._instantiate(cls, args) dispatch[OBJ[0]] = load_obj def load_newobj(self): @@ -1402,12 +1391,14 @@ dispatch[REDUCE[0]] = load_reduce def load_pop(self): - del self.stack[-1] + if self.stack: + del self.stack[-1] + else: + self.pop_mark() dispatch[POP[0]] = load_pop def load_pop_mark(self): - k = self.marker() - del self.stack[k:] + self.pop_mark() dispatch[POP_MARK[0]] = load_pop_mark def load_dup(self): @@ -1463,17 +1454,14 @@ dispatch[APPEND[0]] = load_append def load_appends(self): - stack = self.stack - mark = self.marker() - list_obj = stack[mark - 1] - items = stack[mark + 1:] + items = self.pop_mark() + list_obj = self.stack[-1] if isinstance(list_obj, list): list_obj.extend(items) else: append = list_obj.append for item in items: append(item) - del stack[mark:] dispatch[APPENDS[0]] = load_appends def load_setitem(self): @@ -1485,27 +1473,21 @@ dispatch[SETITEM[0]] = load_setitem def load_setitems(self): - stack = self.stack - mark = self.marker() - dict = stack[mark - 1] - for i in range(mark + 1, len(stack), 2): - dict[stack[i]] = stack[i + 1] - - del stack[mark:] + items = self.pop_mark() + dict = self.stack[-1] + for i in range(0, len(items), 2): + dict[items[i]] = items[i + 1] dispatch[SETITEMS[0]] = load_setitems def load_additems(self): - stack = self.stack - mark = self.marker() - set_obj = stack[mark - 1] - items = stack[mark + 1:] + items = self.pop_mark() + set_obj = self.stack[-1] if isinstance(set_obj, set): set_obj.update(items) else: add = set_obj.add for item in items: add(item) - del stack[mark:] dispatch[ADDITEMS[0]] = load_additems def load_build(self): @@ -1533,7 +1515,9 @@ dispatch[BUILD[0]] = load_build def load_mark(self): - self.append(self.mark) + self.metastack.append(self.stack) + self.stack = [] + self.append = self.stack.append dispatch[MARK[0]] = load_mark def load_stop(self): diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -1000,7 +1000,7 @@ b'0', # POP b'1', # POP_MARK b'2', # DUP - # b'(2', # PyUnpickler doesn't raise + b'(2', b'R', # REDUCE b')R', b'a', # APPEND @@ -1009,7 +1009,7 @@ b'Nb', b'd', # DICT b'e', # APPENDS - # b'(e', # PyUnpickler raises AttributeError + b'(e', b'ibuiltins\nlist\n', # INST b'l', # LIST b'o', # OBJ @@ -1022,7 +1022,7 @@ b'NNs', b't', # TUPLE b'u', # SETITEMS - # b'(u', # PyUnpickler doesn't raise + b'(u', b'}(Nu', b'\x81', # NEWOBJ b')\x81', @@ -1033,7 +1033,7 @@ b'N\x87', b'NN\x87', b'\x90', # ADDITEMS - # b'(\x90', # PyUnpickler raises AttributeError + b'(\x90', b'\x91', # FROZENSET b'\x92', # NEWOBJ_EX b')}\x92', @@ -1046,7 +1046,7 @@ def test_bad_mark(self): badpickles = [ - # b'N(.', # STOP + b'N(.', # STOP b'N(2', # DUP b'cbuiltins\nlist\n)(R', # REDUCE b'cbuiltins\nlist\n()R', @@ -1081,7 +1081,7 @@ b'N(\x94', # MEMOIZE ] for p in badpickles: - self.check_unpickling_error(self.bad_mark_errors, p) + self.check_unpickling_error(self.bad_stack_errors, p) def test_truncated_data(self): self.check_unpickling_error(EOFError, b'') @@ -2581,11 +2581,6 @@ self.assertRaises(pickle.PicklingError, BadPickler().dump, 0) self.assertRaises(pickle.UnpicklingError, BadUnpickler().load) - def test_bad_input(self): - # Test issue4298 - s = bytes([0x58, 0, 0, 0, 0x54]) - self.assertRaises(EOFError, pickle.loads, s) - class AbstractPersistentPicklerTests(unittest.TestCase): diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -33,8 +33,6 @@ unpickler = pickle._Unpickler bad_stack_errors = (IndexError,) - bad_mark_errors = (IndexError, pickle.UnpicklingError, - TypeError, AttributeError, EOFError) truncated_errors = (pickle.UnpicklingError, EOFError, AttributeError, ValueError, struct.error, IndexError, ImportError) @@ -69,8 +67,6 @@ pickler = pickle._Pickler unpickler = pickle._Unpickler bad_stack_errors = (pickle.UnpicklingError, IndexError) - bad_mark_errors = (pickle.UnpicklingError, IndexError, - TypeError, AttributeError, EOFError) truncated_errors = (pickle.UnpicklingError, EOFError, AttributeError, ValueError, struct.error, IndexError, ImportError) @@ -132,7 +128,6 @@ class CUnpicklerTests(PyUnpicklerTests): unpickler = _pickle.Unpickler bad_stack_errors = (pickle.UnpicklingError,) - bad_mark_errors = (EOFError,) truncated_errors = (pickle.UnpicklingError, EOFError, AttributeError, ValueError) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -109,6 +109,8 @@ Library ------- +- Issue #25761: Improved detecting errors in broken pickle data. + - Issue #25717: Restore the previous behaviour of tolerating most fstat() errors when opening files. This was a regression in 3.5a1, and stopped anonymous temporary files from working in special cases. diff --git a/Modules/_pickle.c b/Modules/_pickle.c --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -370,18 +370,12 @@ /*************************************************************************/ -static int -stack_underflow(void) -{ - PickleState *st = _Pickle_GetGlobalState(); - PyErr_SetString(st->UnpicklingError, "unpickling stack underflow"); - return -1; -} - /* Internal data type used as the unpickling stack. */ typedef struct { PyObject_VAR_HEAD PyObject **data; + int mark_set; /* is MARK set? */ + Py_ssize_t fence; /* position of top MARK or 0 */ Py_ssize_t allocated; /* number of slots in data allocated */ } Pdata; @@ -412,6 +406,8 @@ if (!(self = PyObject_New(Pdata, &Pdata_Type))) return NULL; Py_SIZE(self) = 0; + self->mark_set = 0; + self->fence = 0; self->allocated = 8; self->data = PyMem_MALLOC(self->allocated * sizeof(PyObject *)); if (self->data) @@ -429,8 +425,7 @@ { Py_ssize_t i = Py_SIZE(self); - if (clearto < 0) - return stack_underflow(); + assert(clearto >= self->fence); if (clearto >= i) return 0; @@ -466,6 +461,17 @@ return -1; } +static int +Pdata_stack_underflow(Pdata *self) +{ + PickleState *st = _Pickle_GetGlobalState(); + PyErr_SetString(st->UnpicklingError, + self->mark_set ? + "unexpected MARK found" : + "unpickling stack underflow"); + return -1; +} + /* D is a Pdata*. Pop the topmost element and store it into V, which * must be an lvalue holding PyObject*. On stack underflow, UnpicklingError * is raised and V is set to NULL. @@ -473,9 +479,8 @@ static PyObject * Pdata_pop(Pdata *self) { - if (Py_SIZE(self) == 0) { - PickleState *st = _Pickle_GetGlobalState(); - PyErr_SetString(st->UnpicklingError, "bad pickle data"); + if (Py_SIZE(self) <= self->fence) { + Pdata_stack_underflow(self); return NULL; } return self->data[--Py_SIZE(self)]; @@ -507,6 +512,10 @@ PyObject *tuple; Py_ssize_t len, i, j; + if (start < self->fence) { + Pdata_stack_underflow(self); + return NULL; + } len = Py_SIZE(self) - start; tuple = PyTuple_New(len); if (tuple == NULL) @@ -4585,13 +4594,19 @@ static Py_ssize_t marker(UnpicklerObject *self) { - PickleState *st = _Pickle_GetGlobalState(); + Py_ssize_t mark; + if (self->num_marks < 1) { + PickleState *st = _Pickle_GetGlobalState(); PyErr_SetString(st->UnpicklingError, "could not find MARK"); return -1; } - return self->marks[--self->num_marks]; + mark = self->marks[--self->num_marks]; + self->stack->mark_set = self->num_marks != 0; + self->stack->fence = self->num_marks ? + self->marks[self->num_marks - 1] : 0; + return mark; } static int @@ -5052,7 +5067,7 @@ PyObject *tuple; if (Py_SIZE(self->stack) < len) - return stack_underflow(); + return Pdata_stack_underflow(self->stack); tuple = Pdata_poptuple(self->stack, Py_SIZE(self->stack) - len); if (tuple == NULL) @@ -5134,6 +5149,12 @@ if ((dict = PyDict_New()) == NULL) return -1; + if ((j - i) % 2 != 0) { + PickleState *st = _Pickle_GetGlobalState(); + PyErr_SetString(st->UnpicklingError, "odd number of items for DICT"); + return -1; + } + for (k = i + 1; k < j; k += 2) { key = self->stack->data[k - 1]; value = self->stack->data[k]; @@ -5201,7 +5222,7 @@ return -1; if (Py_SIZE(self->stack) - i < 1) - return stack_underflow(); + return Pdata_stack_underflow(self->stack); args = Pdata_poptuple(self->stack, i + 1); if (args == NULL) @@ -5518,12 +5539,15 @@ */ if (self->num_marks > 0 && self->marks[self->num_marks - 1] == len) { self->num_marks--; - } else if (len > 0) { + self->stack->mark_set = self->num_marks != 0; + self->stack->fence = self->num_marks ? + self->marks[self->num_marks - 1] : 0; + } else if (len <= self->stack->fence) + return Pdata_stack_underflow(self->stack); + else { len--; Py_DECREF(self->stack->data[len]); Py_SIZE(self->stack) = len; - } else { - return stack_underflow(); } return 0; } @@ -5545,10 +5569,10 @@ load_dup(UnpicklerObject *self) { PyObject *last; - Py_ssize_t len; - - if ((len = Py_SIZE(self->stack)) <= 0) - return stack_underflow(); + Py_ssize_t len = Py_SIZE(self->stack); + + if (len <= self->stack->fence) + return Pdata_stack_underflow(self->stack); last = self->stack->data[len - 1]; PDATA_APPEND(self->stack, last, -1); return 0; @@ -5731,8 +5755,8 @@ return -1; if (len < 2) return bad_readline(); - if (Py_SIZE(self->stack) <= 0) - return stack_underflow(); + if (Py_SIZE(self->stack) <= self->stack->fence) + return Pdata_stack_underflow(self->stack); value = self->stack->data[Py_SIZE(self->stack) - 1]; key = PyLong_FromString(s, NULL, 10); @@ -5760,8 +5784,8 @@ if (_Unpickler_Read(self, &s, 1) < 0) return -1; - if (Py_SIZE(self->stack) <= 0) - return stack_underflow(); + if (Py_SIZE(self->stack) <= self->stack->fence) + return Pdata_stack_underflow(self->stack); value = self->stack->data[Py_SIZE(self->stack) - 1]; idx = Py_CHARMASK(s[0]); @@ -5779,8 +5803,8 @@ if (_Unpickler_Read(self, &s, 4) < 0) return -1; - if (Py_SIZE(self->stack) <= 0) - return stack_underflow(); + if (Py_SIZE(self->stack) <= self->stack->fence) + return Pdata_stack_underflow(self->stack); value = self->stack->data[Py_SIZE(self->stack) - 1]; idx = calc_binsize(s, 4); @@ -5798,8 +5822,8 @@ { PyObject *value; - if (Py_SIZE(self->stack) <= 0) - return stack_underflow(); + if (Py_SIZE(self->stack) <= self->stack->fence) + return Pdata_stack_underflow(self->stack); value = self->stack->data[Py_SIZE(self->stack) - 1]; return _Unpickler_MemoPut(self, self->memo_len, value); @@ -5813,8 +5837,8 @@ Py_ssize_t len, i; len = Py_SIZE(self->stack); - if (x > len || x <= 0) - return stack_underflow(); + if (x > len || x <= self->stack->fence) + return Pdata_stack_underflow(self->stack); if (len == x) /* nothing to do */ return 0; @@ -5863,8 +5887,8 @@ static int load_append(UnpicklerObject *self) { - if (Py_SIZE(self->stack) - 1 <= 0) - return stack_underflow(); + if (Py_SIZE(self->stack) - 1 <= self->stack->fence) + return Pdata_stack_underflow(self->stack); return do_append(self, Py_SIZE(self->stack) - 1); } @@ -5886,8 +5910,8 @@ int status = 0; len = Py_SIZE(self->stack); - if (x > len || x <= 0) - return stack_underflow(); + if (x > len || x <= self->stack->fence) + return Pdata_stack_underflow(self->stack); if (len == x) /* nothing to do */ return 0; if ((len - x) % 2 != 0) { @@ -5940,8 +5964,8 @@ if (mark < 0) return -1; len = Py_SIZE(self->stack); - if (mark > len || mark <= 0) - return stack_underflow(); + if (mark > len || mark <= self->stack->fence) + return Pdata_stack_underflow(self->stack); if (len == mark) /* nothing to do */ return 0; @@ -5996,8 +6020,8 @@ /* Stack is ... instance, state. We want to leave instance at * the stack top, possibly mutated via instance.__setstate__(state). */ - if (Py_SIZE(self->stack) < 2) - return stack_underflow(); + if (Py_SIZE(self->stack) - 2 < self->stack->fence) + return Pdata_stack_underflow(self->stack); PDATA_POP(self->stack, state); if (state == NULL) @@ -6133,7 +6157,8 @@ self->marks_size = (Py_ssize_t)alloc; } - self->marks[self->num_marks++] = Py_SIZE(self->stack); + self->stack->mark_set = 1; + self->marks[self->num_marks++] = self->stack->fence = Py_SIZE(self->stack); return 0; } @@ -6216,6 +6241,8 @@ char *s = NULL; self->num_marks = 0; + self->stack->mark_set = 0; + self->stack->fence = 0; self->proto = 0; if (Py_SIZE(self->stack)) Pdata_clear(self->stack, 0); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 17:13:46 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 06 Dec 2015 22:13:46 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Issue25814=3A_Propagate_all_errors_from_custom_XML_parser_hand?= =?utf-8?q?lers?= Message-ID: <20151206221345.21235.78839@psf.io> https://hg.python.org/cpython/rev/0d1bbfe8fd09 changeset: 99482:0d1bbfe8fd09 branch: 3.5 parent: 99477:e9bf5803b716 parent: 99480:2df330606cd0 user: Serhiy Storchaka date: Sun Dec 06 23:54:28 2015 +0200 summary: Issue25814: Propagate all errors from custom XML parser handlers in ElementTree.iterparse(). files: Modules/_elementtree.c | 127 ++++++++-------------------- 1 files changed, 39 insertions(+), 88 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2452,6 +2452,23 @@ } } +LOCAL(int) +treebuilder_append_event(TreeBuilderObject *self, PyObject *action, + PyObject *node) +{ + if (action != NULL) { + PyObject *res = PyTuple_Pack(2, action, node); + if (res == NULL) + return -1; + if (PyList_Append(self->events, res) < 0) { + Py_DECREF(res); + return -1; + } + Py_DECREF(res); + } + return 0; +} + /* -------------------------------------------------------------------- */ /* handlers */ @@ -2519,16 +2536,8 @@ Py_INCREF(node); self->last = node; - if (self->start_event_obj) { - PyObject* res; - PyObject* action = self->start_event_obj; - res = PyTuple_Pack(2, action, node); - if (res) { - PyList_Append(self->events, res); - Py_DECREF(res); - } else - PyErr_Clear(); /* FIXME: propagate error */ - } + if (treebuilder_append_event(self, self->start_event_obj, node) < 0) + goto error; return node; @@ -2608,65 +2617,13 @@ self->last = self->this; self->this = item; - if (self->end_event_obj) { - PyObject* res; - PyObject* action = self->end_event_obj; - PyObject* node = (PyObject*) self->last; - res = PyTuple_Pack(2, action, node); - if (res) { - PyList_Append(self->events, res); - Py_DECREF(res); - } else - PyErr_Clear(); /* FIXME: propagate error */ - } + if (treebuilder_append_event(self, self->end_event_obj, self->last) < 0) + return NULL; Py_INCREF(self->last); return (PyObject*) self->last; } -LOCAL(void) -treebuilder_handle_namespace(TreeBuilderObject* self, int start, - PyObject *prefix, PyObject *uri) -{ - PyObject* res; - PyObject* action; - PyObject* parcel; - - if (!self->events) - return; - - if (start) { - if (!self->start_ns_event_obj) - return; - action = self->start_ns_event_obj; - parcel = Py_BuildValue("OO", prefix, uri); - if (!parcel) - return; - Py_INCREF(action); - } else { - if (!self->end_ns_event_obj) - return; - action = self->end_ns_event_obj; - Py_INCREF(action); - parcel = Py_None; - Py_INCREF(parcel); - } - - res = PyTuple_New(2); - - if (res) { - PyTuple_SET_ITEM(res, 0, action); - PyTuple_SET_ITEM(res, 1, parcel); - PyList_Append(self->events, res); - Py_DECREF(res); - } - else { - Py_DECREF(action); - Py_DECREF(parcel); - PyErr_Clear(); /* FIXME: propagate error */ - } -} - /* -------------------------------------------------------------------- */ /* methods (in alphabetical order) */ @@ -3078,45 +3035,39 @@ expat_start_ns_handler(XMLParserObject* self, const XML_Char* prefix, const XML_Char *uri) { - PyObject* sprefix = NULL; - PyObject* suri = NULL; + TreeBuilderObject *target = (TreeBuilderObject*) self->target; + PyObject *parcel; if (PyErr_Occurred()) return; - if (uri) - suri = PyUnicode_DecodeUTF8(uri, strlen(uri), "strict"); - else - suri = PyUnicode_FromString(""); - if (!suri) + if (!target->events || !target->start_ns_event_obj) return; - if (prefix) - sprefix = PyUnicode_DecodeUTF8(prefix, strlen(prefix), "strict"); - else - sprefix = PyUnicode_FromString(""); - if (!sprefix) { - Py_DECREF(suri); + if (!uri) + uri = ""; + if (!prefix) + prefix = ""; + + parcel = Py_BuildValue("ss", prefix, uri); + if (!parcel) return; - } - - treebuilder_handle_namespace( - (TreeBuilderObject*) self->target, 1, sprefix, suri - ); - - Py_DECREF(sprefix); - Py_DECREF(suri); + treebuilder_append_event(target, target->start_ns_event_obj, parcel); + Py_DECREF(parcel); } static void expat_end_ns_handler(XMLParserObject* self, const XML_Char* prefix_in) { + TreeBuilderObject *target = (TreeBuilderObject*) self->target; + if (PyErr_Occurred()) return; - treebuilder_handle_namespace( - (TreeBuilderObject*) self->target, 0, NULL, NULL - ); + if (!target->events) + return; + + treebuilder_append_event(target, target->end_ns_event_obj, Py_None); } static void -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 17:13:46 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 06 Dec 2015 22:13:46 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogSXNzdWUyNTgxNDog?= =?utf-8?q?Propagate_all_errors_from_custom_XML_parser_handlers?= Message-ID: <20151206221345.33673.61414@psf.io> https://hg.python.org/cpython/rev/2df330606cd0 changeset: 99480:2df330606cd0 branch: 3.4 parent: 99473:51a0dd6f7c73 user: Serhiy Storchaka date: Sun Dec 06 23:51:44 2015 +0200 summary: Issue25814: Propagate all errors from custom XML parser handlers in ElementTree.iterparse(). files: Modules/_elementtree.c | 127 ++++++++-------------------- 1 files changed, 39 insertions(+), 88 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2448,6 +2448,23 @@ } } +LOCAL(int) +treebuilder_append_event(TreeBuilderObject *self, PyObject *action, + PyObject *node) +{ + if (action != NULL) { + PyObject *res = PyTuple_Pack(2, action, node); + if (res == NULL) + return -1; + if (PyList_Append(self->events, res) < 0) { + Py_DECREF(res); + return -1; + } + Py_DECREF(res); + } + return 0; +} + /* -------------------------------------------------------------------- */ /* handlers */ @@ -2515,16 +2532,8 @@ Py_INCREF(node); self->last = node; - if (self->start_event_obj) { - PyObject* res; - PyObject* action = self->start_event_obj; - res = PyTuple_Pack(2, action, node); - if (res) { - PyList_Append(self->events, res); - Py_DECREF(res); - } else - PyErr_Clear(); /* FIXME: propagate error */ - } + if (treebuilder_append_event(self, self->start_event_obj, node) < 0) + goto error; return node; @@ -2604,65 +2613,13 @@ self->last = self->this; self->this = item; - if (self->end_event_obj) { - PyObject* res; - PyObject* action = self->end_event_obj; - PyObject* node = (PyObject*) self->last; - res = PyTuple_Pack(2, action, node); - if (res) { - PyList_Append(self->events, res); - Py_DECREF(res); - } else - PyErr_Clear(); /* FIXME: propagate error */ - } + if (treebuilder_append_event(self, self->end_event_obj, self->last) < 0) + return NULL; Py_INCREF(self->last); return (PyObject*) self->last; } -LOCAL(void) -treebuilder_handle_namespace(TreeBuilderObject* self, int start, - PyObject *prefix, PyObject *uri) -{ - PyObject* res; - PyObject* action; - PyObject* parcel; - - if (!self->events) - return; - - if (start) { - if (!self->start_ns_event_obj) - return; - action = self->start_ns_event_obj; - parcel = Py_BuildValue("OO", prefix, uri); - if (!parcel) - return; - Py_INCREF(action); - } else { - if (!self->end_ns_event_obj) - return; - action = self->end_ns_event_obj; - Py_INCREF(action); - parcel = Py_None; - Py_INCREF(parcel); - } - - res = PyTuple_New(2); - - if (res) { - PyTuple_SET_ITEM(res, 0, action); - PyTuple_SET_ITEM(res, 1, parcel); - PyList_Append(self->events, res); - Py_DECREF(res); - } - else { - Py_DECREF(action); - Py_DECREF(parcel); - PyErr_Clear(); /* FIXME: propagate error */ - } -} - /* -------------------------------------------------------------------- */ /* methods (in alphabetical order) */ @@ -3100,45 +3057,39 @@ expat_start_ns_handler(XMLParserObject* self, const XML_Char* prefix, const XML_Char *uri) { - PyObject* sprefix = NULL; - PyObject* suri = NULL; + TreeBuilderObject *target = (TreeBuilderObject*) self->target; + PyObject *parcel; if (PyErr_Occurred()) return; - if (uri) - suri = PyUnicode_DecodeUTF8(uri, strlen(uri), "strict"); - else - suri = PyUnicode_FromString(""); - if (!suri) + if (!target->events || !target->start_ns_event_obj) return; - if (prefix) - sprefix = PyUnicode_DecodeUTF8(prefix, strlen(prefix), "strict"); - else - sprefix = PyUnicode_FromString(""); - if (!sprefix) { - Py_DECREF(suri); + if (!uri) + uri = ""; + if (!prefix) + prefix = ""; + + parcel = Py_BuildValue("ss", prefix, uri); + if (!parcel) return; - } - - treebuilder_handle_namespace( - (TreeBuilderObject*) self->target, 1, sprefix, suri - ); - - Py_DECREF(sprefix); - Py_DECREF(suri); + treebuilder_append_event(target, target->start_ns_event_obj, parcel); + Py_DECREF(parcel); } static void expat_end_ns_handler(XMLParserObject* self, const XML_Char* prefix_in) { + TreeBuilderObject *target = (TreeBuilderObject*) self->target; + if (PyErr_Occurred()) return; - treebuilder_handle_namespace( - (TreeBuilderObject*) self->target, 0, NULL, NULL - ); + if (!target->events) + return; + + treebuilder_append_event(target, target->end_ns_event_obj, Py_None); } static void -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 17:13:46 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 06 Dec 2015 22:13:46 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUyNTgxNDog?= =?utf-8?q?Propagate_all_errors_from_custom_XML_parser_handlers?= Message-ID: <20151206221345.21233.43634@psf.io> https://hg.python.org/cpython/rev/de9ef294a3ef changeset: 99481:de9ef294a3ef branch: 2.7 parent: 99476:8ddac065cd3b user: Serhiy Storchaka date: Sun Dec 06 23:51:53 2015 +0200 summary: Issue25814: Propagate all errors from custom XML parser handlers in ElementTree.iterparse(). files: Modules/_elementtree.c | 118 +++++++++++----------------- 1 files changed, 45 insertions(+), 73 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1720,6 +1720,23 @@ PyObject_Del(self); } +LOCAL(int) +treebuilder_append_event(TreeBuilderObject *self, PyObject *action, + PyObject *node) +{ + if (action != NULL) { + PyObject *res = PyTuple_Pack(2, action, node); + if (res == NULL) + return -1; + if (PyList_Append(self->events, res) < 0) { + Py_DECREF(res); + return -1; + } + Py_DECREF(res); + } + return 0; +} + /* -------------------------------------------------------------------- */ /* handlers */ @@ -1791,18 +1808,8 @@ Py_INCREF(node); self->last = (ElementObject*) node; - if (self->start_event_obj) { - PyObject* res; - PyObject* action = self->start_event_obj; - res = PyTuple_New(2); - if (res) { - Py_INCREF(action); PyTuple_SET_ITEM(res, 0, (PyObject*) action); - Py_INCREF(node); PyTuple_SET_ITEM(res, 1, (PyObject*) node); - PyList_Append(self->events, res); - Py_DECREF(res); - } else - PyErr_Clear(); /* FIXME: propagate error */ - } + if (treebuilder_append_event(self, self->start_event_obj, node) < 0) + goto error; return node; @@ -1885,63 +1892,13 @@ self->last = (ElementObject*) self->this; self->this = (ElementObject*) item; - if (self->end_event_obj) { - PyObject* res; - PyObject* action = self->end_event_obj; - PyObject* node = (PyObject*) self->last; - res = PyTuple_New(2); - if (res) { - Py_INCREF(action); PyTuple_SET_ITEM(res, 0, (PyObject*) action); - Py_INCREF(node); PyTuple_SET_ITEM(res, 1, (PyObject*) node); - PyList_Append(self->events, res); - Py_DECREF(res); - } else - PyErr_Clear(); /* FIXME: propagate error */ - } + if (treebuilder_append_event(self, self->end_event_obj, (PyObject*)self->last) < 0) + return NULL; Py_INCREF(self->last); return (PyObject*) self->last; } -LOCAL(void) -treebuilder_handle_namespace(TreeBuilderObject* self, int start, - PyObject *prefix, PyObject *uri) -{ - PyObject* res; - PyObject* action; - PyObject* parcel; - - if (!self->events) - return; - - if (start) { - if (!self->start_ns_event_obj) - return; - action = self->start_ns_event_obj; - parcel = Py_BuildValue("OO", prefix, uri); - if (!parcel) - return; - Py_INCREF(action); - } else { - if (!self->end_ns_event_obj) - return; - action = self->end_ns_event_obj; - Py_INCREF(action); - parcel = Py_None; - Py_INCREF(parcel); - } - - res = PyTuple_New(2); - - if (res) { - PyTuple_SET_ITEM(res, 0, action); - PyTuple_SET_ITEM(res, 1, parcel); - PyList_Append(self->events, res); - Py_DECREF(res); - } else - PyErr_Clear(); /* FIXME: propagate error */ -} - /* -------------------------------------------------------------------- */ /* methods (in alphabetical order) */ @@ -2367,8 +2324,16 @@ expat_start_ns_handler(XMLParserObject* self, const XML_Char* prefix, const XML_Char *uri) { - PyObject* sprefix = NULL; - PyObject* suri = NULL; + TreeBuilderObject *target = (TreeBuilderObject*) self->target; + PyObject *parcel; + PyObject *sprefix = NULL; + PyObject *suri = NULL; + + if (PyErr_Occurred()) + return; + + if (!target->events || !target->start_ns_event_obj) + return; if (uri) suri = makestring(uri, strlen(uri)); @@ -2386,20 +2351,27 @@ return; } - treebuilder_handle_namespace( - (TreeBuilderObject*) self->target, 1, sprefix, suri - ); - + parcel = PyTuple_Pack(2, sprefix, suri); Py_DECREF(sprefix); Py_DECREF(suri); + if (!parcel) + return; + treebuilder_append_event(target, target->start_ns_event_obj, parcel); + Py_DECREF(parcel); } static void expat_end_ns_handler(XMLParserObject* self, const XML_Char* prefix_in) { - treebuilder_handle_namespace( - (TreeBuilderObject*) self->target, 0, NULL, NULL - ); + TreeBuilderObject *target = (TreeBuilderObject*) self->target; + + if (PyErr_Occurred()) + return; + + if (!target->events) + return; + + treebuilder_append_event(target, target->end_ns_event_obj, Py_None); } static void -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 17:13:46 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 06 Dec 2015 22:13:46 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue25814=3A_Propagate_all_errors_from_custom_XML_parse?= =?utf-8?q?r_handlers?= Message-ID: <20151206221345.21239.49753@psf.io> https://hg.python.org/cpython/rev/2cf16918b632 changeset: 99483:2cf16918b632 parent: 99479:5c670af0100f parent: 99482:0d1bbfe8fd09 user: Serhiy Storchaka date: Sun Dec 06 23:55:05 2015 +0200 summary: Issue25814: Propagate all errors from custom XML parser handlers in ElementTree.iterparse(). files: Modules/_elementtree.c | 127 ++++++++-------------------- 1 files changed, 39 insertions(+), 88 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2450,6 +2450,23 @@ } } +LOCAL(int) +treebuilder_append_event(TreeBuilderObject *self, PyObject *action, + PyObject *node) +{ + if (action != NULL) { + PyObject *res = PyTuple_Pack(2, action, node); + if (res == NULL) + return -1; + if (PyList_Append(self->events, res) < 0) { + Py_DECREF(res); + return -1; + } + Py_DECREF(res); + } + return 0; +} + /* -------------------------------------------------------------------- */ /* handlers */ @@ -2517,16 +2534,8 @@ Py_INCREF(node); self->last = node; - if (self->start_event_obj) { - PyObject* res; - PyObject* action = self->start_event_obj; - res = PyTuple_Pack(2, action, node); - if (res) { - PyList_Append(self->events, res); - Py_DECREF(res); - } else - PyErr_Clear(); /* FIXME: propagate error */ - } + if (treebuilder_append_event(self, self->start_event_obj, node) < 0) + goto error; return node; @@ -2606,65 +2615,13 @@ self->last = self->this; self->this = item; - if (self->end_event_obj) { - PyObject* res; - PyObject* action = self->end_event_obj; - PyObject* node = (PyObject*) self->last; - res = PyTuple_Pack(2, action, node); - if (res) { - PyList_Append(self->events, res); - Py_DECREF(res); - } else - PyErr_Clear(); /* FIXME: propagate error */ - } + if (treebuilder_append_event(self, self->end_event_obj, self->last) < 0) + return NULL; Py_INCREF(self->last); return (PyObject*) self->last; } -LOCAL(void) -treebuilder_handle_namespace(TreeBuilderObject* self, int start, - PyObject *prefix, PyObject *uri) -{ - PyObject* res; - PyObject* action; - PyObject* parcel; - - if (!self->events) - return; - - if (start) { - if (!self->start_ns_event_obj) - return; - action = self->start_ns_event_obj; - parcel = Py_BuildValue("OO", prefix, uri); - if (!parcel) - return; - Py_INCREF(action); - } else { - if (!self->end_ns_event_obj) - return; - action = self->end_ns_event_obj; - Py_INCREF(action); - parcel = Py_None; - Py_INCREF(parcel); - } - - res = PyTuple_New(2); - - if (res) { - PyTuple_SET_ITEM(res, 0, action); - PyTuple_SET_ITEM(res, 1, parcel); - PyList_Append(self->events, res); - Py_DECREF(res); - } - else { - Py_DECREF(action); - Py_DECREF(parcel); - PyErr_Clear(); /* FIXME: propagate error */ - } -} - /* -------------------------------------------------------------------- */ /* methods (in alphabetical order) */ @@ -3076,45 +3033,39 @@ expat_start_ns_handler(XMLParserObject* self, const XML_Char* prefix, const XML_Char *uri) { - PyObject* sprefix = NULL; - PyObject* suri = NULL; + TreeBuilderObject *target = (TreeBuilderObject*) self->target; + PyObject *parcel; if (PyErr_Occurred()) return; - if (uri) - suri = PyUnicode_DecodeUTF8(uri, strlen(uri), "strict"); - else - suri = PyUnicode_FromString(""); - if (!suri) + if (!target->events || !target->start_ns_event_obj) return; - if (prefix) - sprefix = PyUnicode_DecodeUTF8(prefix, strlen(prefix), "strict"); - else - sprefix = PyUnicode_FromString(""); - if (!sprefix) { - Py_DECREF(suri); + if (!uri) + uri = ""; + if (!prefix) + prefix = ""; + + parcel = Py_BuildValue("ss", prefix, uri); + if (!parcel) return; - } - - treebuilder_handle_namespace( - (TreeBuilderObject*) self->target, 1, sprefix, suri - ); - - Py_DECREF(sprefix); - Py_DECREF(suri); + treebuilder_append_event(target, target->start_ns_event_obj, parcel); + Py_DECREF(parcel); } static void expat_end_ns_handler(XMLParserObject* self, const XML_Char* prefix_in) { + TreeBuilderObject *target = (TreeBuilderObject*) self->target; + if (PyErr_Occurred()) return; - treebuilder_handle_namespace( - (TreeBuilderObject*) self->target, 0, NULL, NULL - ); + if (!target->events) + return; + + treebuilder_append_event(target, target->end_ns_event_obj, Py_None); } static void -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 6 19:31:36 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 07 Dec 2015 00:31:36 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325638=3A_Optimize?= =?utf-8?q?d_ElementTree=2Eiterparse=28=29=3B_it_is_now_2x_faster=2E?= Message-ID: <20151207003135.33677.80229@psf.io> https://hg.python.org/cpython/rev/dd67c8c53aea changeset: 99484:dd67c8c53aea user: Serhiy Storchaka date: Mon Dec 07 02:31:11 2015 +0200 summary: Issue #25638: Optimized ElementTree.iterparse(); it is now 2x faster. ElementTree.XMLParser._setevents now accepts any objects with the append method, not just a list. files: Lib/xml/etree/ElementTree.py | 92 +++++++------------- Misc/NEWS | 2 + Modules/_elementtree.c | 35 ++++--- Modules/clinic/_elementtree.c.h | 7 +- 4 files changed, 56 insertions(+), 80 deletions(-) diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -95,6 +95,7 @@ import re import warnings import io +import collections import contextlib from . import ElementPath @@ -1198,16 +1199,37 @@ Returns an iterator providing (event, elem) pairs. """ + # Use the internal, undocumented _parser argument for now; When the + # parser argument of iterparse is removed, this can be killed. + pullparser = XMLPullParser(events=events, _parser=parser) + def iterator(): + try: + while True: + yield from pullparser.read_events() + # load event buffer + data = source.read(16 * 1024) + if not data: + break + pullparser.feed(data) + root = pullparser._close_and_return_root() + yield from pullparser.read_events() + it.root = root + finally: + if close_source: + source.close() + + class IterParseIterator(collections.Iterator): + __next__ = iterator().__next__ + it = IterParseIterator() + it.root = None + del iterator, IterParseIterator + close_source = False if not hasattr(source, "read"): source = open(source, "rb") close_source = True - try: - return _IterParseIterator(source, events, parser, close_source) - except: - if close_source: - source.close() - raise + + return it class XMLPullParser: @@ -1217,9 +1239,7 @@ # upon in user code. It will be removed in a future release. # See http://bugs.python.org/issue17741 for more details. - # _elementtree.c expects a list, not a deque - self._events_queue = [] - self._index = 0 + self._events_queue = collections.deque() self._parser = _parser or XMLParser(target=TreeBuilder()) # wire up the parser for event reporting if events is None: @@ -1257,64 +1277,14 @@ retrieved from the iterator. """ events = self._events_queue - while True: - index = self._index - try: - event = events[self._index] - # Avoid retaining references to past events - events[self._index] = None - except IndexError: - break - index += 1 - # Compact the list in a O(1) amortized fashion - # As noted above, _elementree.c needs a list, not a deque - if index * 2 >= len(events): - events[:index] = [] - self._index = 0 - else: - self._index = index + while events: + event = events.popleft() if isinstance(event, Exception): raise event else: yield event -class _IterParseIterator: - - def __init__(self, source, events, parser, close_source=False): - # Use the internal, undocumented _parser argument for now; When the - # parser argument of iterparse is removed, this can be killed. - self._parser = XMLPullParser(events=events, _parser=parser) - self._file = source - self._close_file = close_source - self.root = self._root = None - - def __next__(self): - try: - while 1: - for event in self._parser.read_events(): - return event - if self._parser._parser is None: - break - # load event buffer - data = self._file.read(16 * 1024) - if data: - self._parser.feed(data) - else: - self._root = self._parser._close_and_return_root() - self.root = self._root - except: - if self._close_file: - self._file.close() - raise - if self._close_file: - self._file.close() - raise StopIteration - - def __iter__(self): - return self - - def XML(text, parser=None): """Parse XML document from string constant. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -109,6 +109,8 @@ Library ------- +- Issue #25638: Optimized ElementTree.iterparse(); it is now 2x faster. + - Issue #25761: Improved detecting errors in broken pickle data. - Issue #25717: Restore the previous behaviour of tolerating most fstat() diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2289,7 +2289,7 @@ PyObject *element_factory; /* element tracing */ - PyObject *events; /* list of events, or NULL if not collecting */ + PyObject *events_append; /* the append method of the list of events, or NULL */ PyObject *start_event_obj; /* event objects (NULL to ignore) */ PyObject *end_event_obj; PyObject *start_ns_event_obj; @@ -2324,7 +2324,7 @@ } t->index = 0; - t->events = NULL; + t->events_append = NULL; t->start_event_obj = t->end_event_obj = NULL; t->start_ns_event_obj = t->end_ns_event_obj = NULL; } @@ -2374,7 +2374,7 @@ Py_CLEAR(self->start_ns_event_obj); Py_CLEAR(self->end_event_obj); Py_CLEAR(self->start_event_obj); - Py_CLEAR(self->events); + Py_CLEAR(self->events_append); Py_CLEAR(self->stack); Py_CLEAR(self->data); Py_CLEAR(self->last); @@ -2455,13 +2455,14 @@ PyObject *node) { if (action != NULL) { - PyObject *res = PyTuple_Pack(2, action, node); + PyObject *res; + PyObject *event = PyTuple_Pack(2, action, node); + if (event == NULL) + return -1; + res = PyObject_CallFunctionObjArgs(self->events_append, event, NULL); + Py_DECREF(event); if (res == NULL) return -1; - if (PyList_Append(self->events, res) < 0) { - Py_DECREF(res); - return -1; - } Py_DECREF(res); } return 0; @@ -3039,7 +3040,7 @@ if (PyErr_Occurred()) return; - if (!target->events || !target->start_ns_event_obj) + if (!target->events_append || !target->start_ns_event_obj) return; if (!uri) @@ -3062,7 +3063,7 @@ if (PyErr_Occurred()) return; - if (!target->events) + if (!target->events_append) return; treebuilder_append_event(target, target->end_ns_event_obj, Py_None); @@ -3551,7 +3552,7 @@ /*[clinic input] _elementtree.XMLParser._setevents - events_queue: object(subclass_of='&PyList_Type') + events_queue: object events_to_report: object = None / @@ -3561,12 +3562,12 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self, PyObject *events_queue, PyObject *events_to_report) -/*[clinic end generated code: output=1440092922b13ed1 input=59db9742910c6174]*/ +/*[clinic end generated code: output=1440092922b13ed1 input=abf90830a1c3b0fc]*/ { /* activate element event reporting */ Py_ssize_t i, seqlen; TreeBuilderObject *target; - PyObject *events_seq; + PyObject *events_append, *events_seq; if (!TreeBuilder_CheckExact(self->target)) { PyErr_SetString( @@ -3579,9 +3580,11 @@ target = (TreeBuilderObject*) self->target; - Py_INCREF(events_queue); - Py_XDECREF(target->events); - target->events = events_queue; + events_append = PyObject_GetAttrString(events_queue, "append"); + if (events_append == NULL) + return NULL; + Py_XDECREF(target->events_append); + target->events_append = events_append; /* clear out existing events */ Py_CLEAR(target->start_event_obj); diff --git a/Modules/clinic/_elementtree.c.h b/Modules/clinic/_elementtree.c.h --- a/Modules/clinic/_elementtree.c.h +++ b/Modules/clinic/_elementtree.c.h @@ -668,12 +668,13 @@ PyObject *events_queue; PyObject *events_to_report = Py_None; - if (!PyArg_ParseTuple(args, "O!|O:_setevents", - &PyList_Type, &events_queue, &events_to_report)) + if (!PyArg_UnpackTuple(args, "_setevents", + 1, 2, + &events_queue, &events_to_report)) goto exit; return_value = _elementtree_XMLParser__setevents_impl(self, events_queue, events_to_report); exit: return return_value; } -/*[clinic end generated code: output=25b8bf7e7f2151ca input=a9049054013a1b77]*/ +/*[clinic end generated code: output=19d94e2d2726d3aa input=a9049054013a1b77]*/ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:04 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:04 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Version_bump_f?= =?utf-8?b?b3IgMy41LjEgZmluYWwu?= Message-ID: <20151207061604.21231.74565@psf.io> https://hg.python.org/cpython/rev/37a07cee5969 changeset: 99489:37a07cee5969 branch: 3.5 tag: v3.5.1 user: Larry Hastings date: Sat Dec 05 17:05:23 2015 -0800 summary: Version bump for 3.5.1 final. files: Include/patchlevel.h | 6 +++--- Misc/NEWS | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -19,11 +19,11 @@ #define PY_MAJOR_VERSION 3 #define PY_MINOR_VERSION 5 #define PY_MICRO_VERSION 1 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "3.5.1rc1+" +#define PY_VERSION "3.5.1" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,7 +10,8 @@ Core and Builtins ----------------- -- Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. +- Issue #25709: Fixed problem with in-place string concatenation and + utf-8 cache. Windows ------- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:15:59 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:15:59 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NzA5?= =?utf-8?q?=3A_Fixed_problem_with_in-place_string_concatenation_and_utf-8_?= =?utf-8?q?cache=2E?= Message-ID: <20151207061559.29621.15717@psf.io> https://hg.python.org/cpython/rev/376b100107ba changeset: 99487:376b100107ba branch: 3.5 user: Serhiy Storchaka date: Thu Dec 03 01:02:03 2015 +0200 summary: Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. files: Lib/test/test_unicode.py | 17 +++++++++++++++++ Misc/NEWS | 7 ++++++- Objects/unicodeobject.c | 5 +++++ 3 files changed, 28 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -2699,6 +2699,23 @@ self.assertTrue(astral >= bmp2) self.assertFalse(astral >= astral2) + @support.cpython_only + def test_pep393_utf8_caching_bug(self): + # Issue #25709: Problem with string concatenation and utf-8 cache + from _testcapi import getargs_s_hash + for k in 0x24, 0xa4, 0x20ac, 0x1f40d: + s = '' + for i in range(5): + # Due to CPython specific optimization the 's' string can be + # resized in-place. + s += chr(k) + # Parsing with the "s#" format code calls indirectly + # PyUnicode_AsUTF8AndSize() which creates the UTF-8 + # encoded string cached in the Unicode object. + self.assertEqual(getargs_s_hash(s), chr(k).encode() * (i + 1)) + # Check that the second call returns the same result + self.assertEqual(getargs_s_hash(s), chr(k).encode() * (i + 1)) + class StringModuleTest(unittest.TestCase): def test_formatter_parser(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,9 +10,14 @@ Core and Builtins ----------------- -Library +- Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. + +Windows ------- +- Issue #25715: Python 3.5.1 installer shows wrong upgrade path and incorrect + logic for launcher detection. + What's New in Python 3.5.1 release candidate 1? =============================================== diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -722,6 +722,11 @@ } new_size = (struct_size + (length + 1) * char_size); + if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) { + PyObject_DEL(_PyUnicode_UTF8(unicode)); + _PyUnicode_UTF8(unicode) = NULL; + _PyUnicode_UTF8_LENGTH(unicode) = 0; + } _Py_DEC_REFTOTAL; _Py_ForgetReference(unicode); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:05 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:05 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Post-release_f?= =?utf-8?q?ixups_for_Python_3=2E5=2E1=2E?= Message-ID: <20151207061605.29597.15993@psf.io> https://hg.python.org/cpython/rev/536f5be43262 changeset: 99491:536f5be43262 branch: 3.5 user: Larry Hastings date: Sun Dec 06 21:53:27 2015 -0800 summary: Post-release fixups for Python 3.5.1. files: Include/patchlevel.h | 2 +- Misc/NEWS | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -23,7 +23,7 @@ #define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "3.5.1" +#define PY_VERSION "3.5.1+" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -2,6 +2,18 @@ Python News +++++++++++ +What's New in Python 3.5.2 release candidate 1? +=============================================== + +Release date: tba + +Core and Builtins +----------------- + +Library +------- + + What's New in Python 3.5.1 final? ================================= -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:00 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:00 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy41IC0+IDMuNSk6?= =?utf-8?q?_Merge=2E?= Message-ID: <20151207061559.33647.27959@psf.io> https://hg.python.org/cpython/rev/f668f41b378c changeset: 99486:f668f41b378c branch: 3.5 parent: 99302:afc0ad583808 parent: 99485:f278d374da80 user: Larry Hastings date: Sat Dec 05 16:49:19 2015 -0800 summary: Merge. files: Tools/msi/bundle/bundle.targets | 2 +- Tools/msi/uploadrelease.proj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/msi/bundle/bundle.targets b/Tools/msi/bundle/bundle.targets --- a/Tools/msi/bundle/bundle.targets +++ b/Tools/msi/bundle/bundle.targets @@ -18,7 +18,7 @@ $(DownloadUrlBase.TrimEnd(`/`))/{version}/{arch}{releasename}/{msi} - $(DefineConstants);DownloadUrl=$(DownloadUrl.Replace(`{version}`, `$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)`).Replace(`{arch}`, `$(ArchName)`).Replace(`{releasename}`, `$(ReleaseName)`).Replace(`{msi}`, `{2}`)) + $(DefineConstants);DownloadUrl=$(DownloadUrl.Replace(`{version}`, `$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)`).Replace(`{arch}`, `$(ArchName)`).Replace(`{releasename}`, `$(ReleaseLevelName)`).Replace(`{msi}`, `{2}`)) $(DefineConstants);DownloadUrl={2} diff --git a/Tools/msi/uploadrelease.proj b/Tools/msi/uploadrelease.proj --- a/Tools/msi/uploadrelease.proj +++ b/Tools/msi/uploadrelease.proj @@ -16,7 +16,7 @@ $(DownloadUrlBase.TrimEnd(`/`))/$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber) - $(DownloadUrl.TrimEnd(`/`)) + $(DownloadUrl.Replace(`{version}`, `$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)`).Replace(`{arch}`, `$(ArchName)`).Replace(`{releasename}`, `$(ReleaseLevelName)`).Replace(`{msi}`, ``).TrimEnd(`/`)) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:05 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:05 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Added_tag_v3?= =?utf-8?q?=2E5=2E1_for_changeset_37a07cee5969?= Message-ID: <20151207061604.105493.98177@psf.io> https://hg.python.org/cpython/rev/0b1c47f78157 changeset: 99490:0b1c47f78157 branch: 3.5 user: Larry Hastings date: Sat Dec 05 17:05:33 2015 -0800 summary: Added tag v3.5.1 for changeset 37a07cee5969 files: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -158,3 +158,4 @@ 2d033fedfa7f1e325fd14ccdaa9cb42155da206f v3.5.0rc4 374f501f4567b7595f2ad7798aa09afa2456bb28 v3.5.0 948ef16a69513ba1ff15c9d7d0b012b949df4c80 v3.5.1rc1 +37a07cee5969e6d3672583187a73cf636ff28e1b v3.5.1 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:00 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:00 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fixes_upload_d?= =?utf-8?q?irectories_for_Windows_installer=2E?= Message-ID: <20151207061559.61849.29760@psf.io> https://hg.python.org/cpython/rev/f278d374da80 changeset: 99485:f278d374da80 branch: 3.5 parent: 99301:da245b9641d9 user: Steve Dower date: Sun Nov 22 18:20:11 2015 -0800 summary: Fixes upload directories for Windows installer. files: Tools/msi/bundle/bundle.targets | 2 +- Tools/msi/uploadrelease.proj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/msi/bundle/bundle.targets b/Tools/msi/bundle/bundle.targets --- a/Tools/msi/bundle/bundle.targets +++ b/Tools/msi/bundle/bundle.targets @@ -18,7 +18,7 @@ $(DownloadUrlBase.TrimEnd(`/`))/{version}/{arch}{releasename}/{msi} - $(DefineConstants);DownloadUrl=$(DownloadUrl.Replace(`{version}`, `$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)`).Replace(`{arch}`, `$(ArchName)`).Replace(`{releasename}`, `$(ReleaseName)`).Replace(`{msi}`, `{2}`)) + $(DefineConstants);DownloadUrl=$(DownloadUrl.Replace(`{version}`, `$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)`).Replace(`{arch}`, `$(ArchName)`).Replace(`{releasename}`, `$(ReleaseLevelName)`).Replace(`{msi}`, `{2}`)) $(DefineConstants);DownloadUrl={2} diff --git a/Tools/msi/uploadrelease.proj b/Tools/msi/uploadrelease.proj --- a/Tools/msi/uploadrelease.proj +++ b/Tools/msi/uploadrelease.proj @@ -16,7 +16,7 @@ $(DownloadUrlBase.TrimEnd(`/`))/$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber) - $(DownloadUrl.TrimEnd(`/`)) + $(DownloadUrl.Replace(`{version}`, `$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)`).Replace(`{arch}`, `$(ArchName)`).Replace(`{releasename}`, `$(ReleaseLevelName)`).Replace(`{msi}`, ``).TrimEnd(`/`)) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:00 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:00 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Updated_pydoc_?= =?utf-8?q?topics_for_3=2E5=2E1_final=2E?= Message-ID: <20151207061559.33653.88105@psf.io> https://hg.python.org/cpython/rev/5410a923c835 changeset: 99488:5410a923c835 branch: 3.5 user: Larry Hastings date: Sat Dec 05 17:03:20 2015 -0800 summary: Updated pydoc topics for 3.5.1 final. files: Lib/pydoc_data/topics.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py --- a/Lib/pydoc_data/topics.py +++ b/Lib/pydoc_data/topics.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Autogenerated by Sphinx on Sat Nov 21 23:47:52 2015 +# Autogenerated by Sphinx on Sat Dec 5 17:02:49 2015 topics = {'assert': u'\nThe "assert" statement\n**********************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, "assert expression", is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, "assert expression1, expression2", is equivalent to\n\n if __debug__:\n if not expression1: raise AssertionError(expression2)\n\nThese equivalences assume that "__debug__" and "AssertionError" refer\nto the built-in variables with those names. In the current\nimplementation, the built-in variable "__debug__" is "True" under\nnormal circumstances, "False" when optimization is requested (command\nline option -O). The current code generator emits no code for an\nassert statement when optimization is requested at compile time. Note\nthat it is unnecessary to include the source code for the expression\nthat failed in the error message; it will be displayed as part of the\nstack trace.\n\nAssignments to "__debug__" are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n', 'assignment': u'\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n | "*" target\n\n(See section *Primaries* for the syntax definitions for\n*attributeref*, *subscription*, and *slicing*.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list, optionally enclosed in\nparentheses or square brackets, is recursively defined as follows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The\n object must be an iterable with the same number of items as there\n are targets in the target list, and the items are assigned, from\n left to right, to the corresponding targets.\n\n * If the target list contains one target prefixed with an\n asterisk, called a "starred" target: The object must be a sequence\n with at least as many items as there are targets in the target\n list, minus one. The first items of the sequence are assigned,\n from left to right, to the targets before the starred target. The\n final items of the sequence are assigned to the targets after the\n starred target. A list of the remaining items in the sequence is\n then assigned to the starred target (the list can be empty).\n\n * Else: The object must be a sequence with the same number of\n items as there are targets in the target list, and the items are\n assigned, from left to right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a "global" or "nonlocal" statement\n in the current code block: the name is bound to the object in the\n current local namespace.\n\n * Otherwise: the name is bound to the object in the global\n namespace or the outer namespace determined by "nonlocal",\n respectively.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in\n square brackets: The object must be an iterable with the same number\n of items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, "TypeError" is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily "AttributeError").\n\n Note: If the object is a class instance and the attribute reference\n occurs on both sides of the assignment operator, the RHS expression,\n "a.x" can access either an instance attribute or (if no instance\n attribute exists) a class attribute. The LHS target "a.x" is always\n set as an instance attribute, creating it if necessary. Thus, the\n two occurrences of "a.x" do not necessarily refer to the same\n attribute: if the RHS expression refers to a class attribute, the\n LHS creates a new instance attribute as the target of the\n assignment:\n\n class Cls:\n x = 3 # class variable\n inst = Cls()\n inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x as 3\n\n This description does not necessarily apply to descriptor\n attributes, such as properties created with "property()".\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield an integer. If it is negative, the sequence\'s\n length is added to it. The resulting value must be a nonnegative\n integer less than the sequence\'s length, and the sequence is asked\n to assign the assigned object to its item with that index. If the\n index is out of range, "IndexError" is raised (assignment to a\n subscripted sequence cannot add new items to a list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n For user-defined objects, the "__setitem__()" method is called with\n appropriate arguments.\n\n* If the target is a slicing: The primary expression in the\n reference is evaluated. It should yield a mutable sequence object\n (such as a list). The assigned object should be a sequence object\n of the same type. Next, the lower and upper bound expressions are\n evaluated, insofar they are present; defaults are zero and the\n sequence\'s length. The bounds should evaluate to integers. If\n either bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the target\n sequence allows it.\n\n**CPython implementation detail:** In the current implementation, the\nsyntax for targets is taken to be the same as for expressions, and\ninvalid syntax is rejected during the code generation phase, causing\nless detailed error messages.\n\nAlthough the definition of assignment implies that overlaps between\nthe left-hand side and the right-hand side are \'simultanenous\' (for\nexample "a, b = b, a" swaps two variables), overlaps *within* the\ncollection of assigned-to variables occur left-to-right, sometimes\nresulting in confusion. For instance, the following program prints\n"[0, 2]":\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2 # i is updated, then x[i] is updated\n print(x)\n\nSee also: **PEP 3132** - Extended Iterable Unpacking\n\n The specification for the "*target" feature.\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions of the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like "x += 1" can be rewritten as\n"x = x + 1" to achieve a similar, but not exactly equal effect. In the\naugmented version, "x" is only evaluated once. Also, when possible,\nthe actual operation is performed *in-place*, meaning that rather than\ncreating a new object and assigning that to the target, the old object\nis modified instead.\n\nUnlike normal assignments, augmented assignments evaluate the left-\nhand side *before* evaluating the right-hand side. For example, "a[i]\n+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs\nthe addition, and lastly, it writes the result back to "a[i]".\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n', 'atom-identifiers': u'\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a "NameError" exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name, with leading underscores removed and a single underscore\ninserted, in front of the name. For example, the identifier "__spam"\noccurring in a class named "Ham" will be transformed to "_Ham__spam".\nThis transformation is independent of the syntactical context in which\nthe identifier is used. If the transformed name is extremely long\n(longer than 255 characters), implementation defined truncation may\nhappen. If the class name consists only of underscores, no\ntransformation is done.\n', -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:08 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:08 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Version_bump_f?= =?utf-8?b?b3IgMy40LjRyYzEu?= Message-ID: <20151207061608.21245.80111@psf.io> https://hg.python.org/cpython/rev/04f3f725896c changeset: 99493:04f3f725896c branch: 3.4 tag: v3.4.4rc1 user: Larry Hastings date: Sun Dec 06 05:53:35 2015 -0800 summary: Version bump for 3.4.4rc1. files: Include/patchlevel.h | 8 ++++---- Misc/NEWS | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -18,12 +18,12 @@ /*--start constants--*/ #define PY_MAJOR_VERSION 3 #define PY_MINOR_VERSION 4 -#define PY_MICRO_VERSION 3 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL -#define PY_RELEASE_SERIAL 0 +#define PY_MICRO_VERSION 4 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA +#define PY_RELEASE_SERIAL 1 /* Version as a string */ -#define PY_VERSION "3.4.3+" +#define PY_VERSION "3.4.4rc1" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -5,12 +5,13 @@ What's New in Python 3.4.4rc1? ============================== -Release date: tba +Release date: 2015/12/06 Core and Builtins ----------------- -- Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. +- Issue #25709: Fixed problem with in-place string concatenation and utf-8 + cache. - Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside __getattr__. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:08 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:08 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Added_tag_v3?= =?utf-8?q?=2E4=2E4rc1_for_changeset_04f3f725896c?= Message-ID: <20151207061608.21247.53070@psf.io> https://hg.python.org/cpython/rev/981fc41d5bbd changeset: 99494:981fc41d5bbd branch: 3.4 user: Larry Hastings date: Sun Dec 06 05:53:49 2015 -0800 summary: Added tag v3.4.4rc1 for changeset 04f3f725896c files: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -144,3 +144,4 @@ ab2c023a9432f16652e89c404bbc84aa91bf55af v3.4.2 69dd528ca6255a66c37cc5cf680e8357d108b036 v3.4.3rc1 b4cbecbc0781e89a309d03b60a1f75f8499250e6 v3.4.3 +04f3f725896c6961212c3a12e8ac25be6958f4fa v3.4.4rc1 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:08 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:08 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Post-release_f?= =?utf-8?q?ixups_for_Python_3=2E4=2E4rc1=2E?= Message-ID: <20151207061608.105477.29655@psf.io> https://hg.python.org/cpython/rev/04a1f9fd0802 changeset: 99495:04a1f9fd0802 branch: 3.4 user: Larry Hastings date: Sun Dec 06 21:54:29 2015 -0800 summary: Post-release fixups for Python 3.4.4rc1. files: Include/patchlevel.h | 2 +- Misc/NEWS | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -23,7 +23,7 @@ #define PY_RELEASE_SERIAL 1 /* Version as a string */ -#define PY_VERSION "3.4.4rc1" +#define PY_VERSION "3.4.4rc1+" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -2,6 +2,18 @@ Python News +++++++++++ +What's New in Python 3.4.4? +=========================== + +Release date: 2015/12/20 + +Core and Builtins +----------------- + +Library +------- + + What's New in Python 3.4.4rc1? ============================== -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:09 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:09 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Mostly-null_merge_from_3=2E4=2E__=28Only_added_the_tag_for_3?= =?utf-8?b?LjQuNHJjMS4p?= Message-ID: <20151207061609.4092.21735@psf.io> https://hg.python.org/cpython/rev/179cbf430ba7 changeset: 99498:179cbf430ba7 branch: 3.5 parent: 99497:786608c702dc parent: 99496:3b94245f9cf1 user: Larry Hastings date: Sun Dec 06 22:11:21 2015 -0800 summary: Mostly-null merge from 3.4. (Only added the tag for 3.4.4rc1.) files: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -144,6 +144,7 @@ ab2c023a9432f16652e89c404bbc84aa91bf55af v3.4.2 69dd528ca6255a66c37cc5cf680e8357d108b036 v3.4.3rc1 b4cbecbc0781e89a309d03b60a1f75f8499250e6 v3.4.3 +04f3f725896c6961212c3a12e8ac25be6958f4fa v3.4.4rc1 5d4b6a57d5fd7564bf73f3db0e46fe5eeb00bcd8 v3.5.0a1 0337bd7ebcb6559d69679bc7025059ad1ce4f432 v3.5.0a2 82656e28b5e5c4ae48d8dd8b5f0d7968908a82b6 v3.5.0a3 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:09 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:09 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Null_merge_from_3=2E5=2E?= Message-ID: <20151207061609.4080.4416@psf.io> https://hg.python.org/cpython/rev/b4aeb35ab7e1 changeset: 99499:b4aeb35ab7e1 parent: 99484:dd67c8c53aea parent: 99498:179cbf430ba7 user: Larry Hastings date: Sun Dec 06 22:14:58 2015 -0800 summary: Null merge from 3.5. files: .hgtags | 2 ++ Misc/NEWS | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -144,6 +144,7 @@ ab2c023a9432f16652e89c404bbc84aa91bf55af v3.4.2 69dd528ca6255a66c37cc5cf680e8357d108b036 v3.4.3rc1 b4cbecbc0781e89a309d03b60a1f75f8499250e6 v3.4.3 +04f3f725896c6961212c3a12e8ac25be6958f4fa v3.4.4rc1 5d4b6a57d5fd7564bf73f3db0e46fe5eeb00bcd8 v3.5.0a1 0337bd7ebcb6559d69679bc7025059ad1ce4f432 v3.5.0a2 82656e28b5e5c4ae48d8dd8b5f0d7968908a82b6 v3.5.0a3 @@ -158,3 +159,4 @@ 2d033fedfa7f1e325fd14ccdaa9cb42155da206f v3.5.0rc4 374f501f4567b7595f2ad7798aa09afa2456bb28 v3.5.0 948ef16a69513ba1ff15c9d7d0b012b949df4c80 v3.5.1rc1 +37a07cee5969e6d3672583187a73cf636ff28e1b v3.5.1 diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -5,7 +5,7 @@ What's New in Python 3.6.0 alpha 1? =================================== -Release date: XXXX-XX-XX +Release date: tba Core and Builtins ----------------- @@ -514,8 +514,8 @@ Core and Builtins ----------------- -Library -------- +- Issue #25709: Fixed problem with in-place string concatenation and + utf-8 cache. Windows ------- @@ -523,6 +523,7 @@ - Issue #25715: Python 3.5.1 installer shows wrong upgrade path and incorrect logic for launcher detection. + What's New in Python 3.5.1 release candidate 1? =============================================== -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:09 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:09 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy41IC0+IDMuNSk6?= =?utf-8?q?_Merge=2E?= Message-ID: <20151207061609.105503.27153@psf.io> https://hg.python.org/cpython/rev/786608c702dc changeset: 99497:786608c702dc branch: 3.5 parent: 99482:0d1bbfe8fd09 parent: 99491:536f5be43262 user: Larry Hastings date: Sun Dec 06 22:00:57 2015 -0800 summary: Merge. files: .hgtags | 1 + Include/patchlevel.h | 6 +++--- Lib/pydoc_data/topics.py | 2 +- Misc/NEWS | 7 ++++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -158,3 +158,4 @@ 2d033fedfa7f1e325fd14ccdaa9cb42155da206f v3.5.0rc4 374f501f4567b7595f2ad7798aa09afa2456bb28 v3.5.0 948ef16a69513ba1ff15c9d7d0b012b949df4c80 v3.5.1rc1 +37a07cee5969e6d3672583187a73cf636ff28e1b v3.5.1 diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -19,11 +19,11 @@ #define PY_MAJOR_VERSION 3 #define PY_MINOR_VERSION 5 #define PY_MICRO_VERSION 1 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "3.5.1rc1+" +#define PY_VERSION "3.5.1+" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py --- a/Lib/pydoc_data/topics.py +++ b/Lib/pydoc_data/topics.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Autogenerated by Sphinx on Sat Nov 21 23:47:52 2015 +# Autogenerated by Sphinx on Sat Dec 5 17:02:49 2015 topics = {'assert': u'\nThe "assert" statement\n**********************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, "assert expression", is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, "assert expression1, expression2", is equivalent to\n\n if __debug__:\n if not expression1: raise AssertionError(expression2)\n\nThese equivalences assume that "__debug__" and "AssertionError" refer\nto the built-in variables with those names. In the current\nimplementation, the built-in variable "__debug__" is "True" under\nnormal circumstances, "False" when optimization is requested (command\nline option -O). The current code generator emits no code for an\nassert statement when optimization is requested at compile time. Note\nthat it is unnecessary to include the source code for the expression\nthat failed in the error message; it will be displayed as part of the\nstack trace.\n\nAssignments to "__debug__" are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n', 'assignment': u'\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n | "*" target\n\n(See section *Primaries* for the syntax definitions for\n*attributeref*, *subscription*, and *slicing*.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list, optionally enclosed in\nparentheses or square brackets, is recursively defined as follows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The\n object must be an iterable with the same number of items as there\n are targets in the target list, and the items are assigned, from\n left to right, to the corresponding targets.\n\n * If the target list contains one target prefixed with an\n asterisk, called a "starred" target: The object must be a sequence\n with at least as many items as there are targets in the target\n list, minus one. The first items of the sequence are assigned,\n from left to right, to the targets before the starred target. The\n final items of the sequence are assigned to the targets after the\n starred target. A list of the remaining items in the sequence is\n then assigned to the starred target (the list can be empty).\n\n * Else: The object must be a sequence with the same number of\n items as there are targets in the target list, and the items are\n assigned, from left to right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a "global" or "nonlocal" statement\n in the current code block: the name is bound to the object in the\n current local namespace.\n\n * Otherwise: the name is bound to the object in the global\n namespace or the outer namespace determined by "nonlocal",\n respectively.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in\n square brackets: The object must be an iterable with the same number\n of items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, "TypeError" is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily "AttributeError").\n\n Note: If the object is a class instance and the attribute reference\n occurs on both sides of the assignment operator, the RHS expression,\n "a.x" can access either an instance attribute or (if no instance\n attribute exists) a class attribute. The LHS target "a.x" is always\n set as an instance attribute, creating it if necessary. Thus, the\n two occurrences of "a.x" do not necessarily refer to the same\n attribute: if the RHS expression refers to a class attribute, the\n LHS creates a new instance attribute as the target of the\n assignment:\n\n class Cls:\n x = 3 # class variable\n inst = Cls()\n inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x as 3\n\n This description does not necessarily apply to descriptor\n attributes, such as properties created with "property()".\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield an integer. If it is negative, the sequence\'s\n length is added to it. The resulting value must be a nonnegative\n integer less than the sequence\'s length, and the sequence is asked\n to assign the assigned object to its item with that index. If the\n index is out of range, "IndexError" is raised (assignment to a\n subscripted sequence cannot add new items to a list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n For user-defined objects, the "__setitem__()" method is called with\n appropriate arguments.\n\n* If the target is a slicing: The primary expression in the\n reference is evaluated. It should yield a mutable sequence object\n (such as a list). The assigned object should be a sequence object\n of the same type. Next, the lower and upper bound expressions are\n evaluated, insofar they are present; defaults are zero and the\n sequence\'s length. The bounds should evaluate to integers. If\n either bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the target\n sequence allows it.\n\n**CPython implementation detail:** In the current implementation, the\nsyntax for targets is taken to be the same as for expressions, and\ninvalid syntax is rejected during the code generation phase, causing\nless detailed error messages.\n\nAlthough the definition of assignment implies that overlaps between\nthe left-hand side and the right-hand side are \'simultanenous\' (for\nexample "a, b = b, a" swaps two variables), overlaps *within* the\ncollection of assigned-to variables occur left-to-right, sometimes\nresulting in confusion. For instance, the following program prints\n"[0, 2]":\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2 # i is updated, then x[i] is updated\n print(x)\n\nSee also: **PEP 3132** - Extended Iterable Unpacking\n\n The specification for the "*target" feature.\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions of the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like "x += 1" can be rewritten as\n"x = x + 1" to achieve a similar, but not exactly equal effect. In the\naugmented version, "x" is only evaluated once. Also, when possible,\nthe actual operation is performed *in-place*, meaning that rather than\ncreating a new object and assigning that to the target, the old object\nis modified instead.\n\nUnlike normal assignments, augmented assignments evaluate the left-\nhand side *before* evaluating the right-hand side. For example, "a[i]\n+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs\nthe addition, and lastly, it writes the result back to "a[i]".\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n', 'atom-identifiers': u'\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a "NameError" exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name, with leading underscores removed and a single underscore\ninserted, in front of the name. For example, the identifier "__spam"\noccurring in a class named "Ham" will be transformed to "_Ham__spam".\nThis transformation is independent of the syntactical context in which\nthe identifier is used. If the transformed name is extremely long\n(longer than 255 characters), implementation defined truncation may\nhappen. If the class name consists only of underscores, no\ntransformation is done.\n', diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -5,7 +5,7 @@ What's New in Python 3.5.2 release candidate 1? =============================================== -Release date: XXXX-XX-XX +Release date: tba Core and Builtins ----------------- @@ -91,8 +91,8 @@ Core and Builtins ----------------- -Library -------- +- Issue #25709: Fixed problem with in-place string concatenation and + utf-8 cache. Windows ------- @@ -100,6 +100,7 @@ - Issue #25715: Python 3.5.1 installer shows wrong upgrade path and incorrect logic for launcher detection. + What's New in Python 3.5.1 release candidate 1? =============================================== -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:08 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:08 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Rebuilt_pydoc_?= =?utf-8?q?topics_for_3=2E4=2E4rc1=2E?= Message-ID: <20151207061605.29611.16696@psf.io> https://hg.python.org/cpython/rev/933c9f9000ee changeset: 99492:933c9f9000ee branch: 3.4 parent: 99473:51a0dd6f7c73 user: Larry Hastings date: Sun Dec 06 05:51:56 2015 -0800 summary: Rebuilt pydoc topics for 3.4.4rc1. files: Lib/pydoc_data/topics.py | 30 ++++++++++++++-------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py --- a/Lib/pydoc_data/topics.py +++ b/Lib/pydoc_data/topics.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Autogenerated by Sphinx on Sun Feb 22 23:52:05 2015 +# Autogenerated by Sphinx on Sun Dec 6 05:51:21 2015 topics = {'assert': u'\nThe "assert" statement\n**********************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, "assert expression", is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, "assert expression1, expression2", is equivalent to\n\n if __debug__:\n if not expression1: raise AssertionError(expression2)\n\nThese equivalences assume that "__debug__" and "AssertionError" refer\nto the built-in variables with those names. In the current\nimplementation, the built-in variable "__debug__" is "True" under\nnormal circumstances, "False" when optimization is requested (command\nline option -O). The current code generator emits no code for an\nassert statement when optimization is requested at compile time. Note\nthat it is unnecessary to include the source code for the expression\nthat failed in the error message; it will be displayed as part of the\nstack trace.\n\nAssignments to "__debug__" are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n', 'assignment': u'\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n | "*" target\n\n(See section *Primaries* for the syntax definitions for\n*attributeref*, *subscription*, and *slicing*.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list, optionally enclosed in\nparentheses or square brackets, is recursively defined as follows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The\n object must be an iterable with the same number of items as there\n are targets in the target list, and the items are assigned, from\n left to right, to the corresponding targets.\n\n * If the target list contains one target prefixed with an\n asterisk, called a "starred" target: The object must be a sequence\n with at least as many items as there are targets in the target\n list, minus one. The first items of the sequence are assigned,\n from left to right, to the targets before the starred target. The\n final items of the sequence are assigned to the targets after the\n starred target. A list of the remaining items in the sequence is\n then assigned to the starred target (the list can be empty).\n\n * Else: The object must be a sequence with the same number of\n items as there are targets in the target list, and the items are\n assigned, from left to right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a "global" or "nonlocal" statement\n in the current code block: the name is bound to the object in the\n current local namespace.\n\n * Otherwise: the name is bound to the object in the global\n namespace or the outer namespace determined by "nonlocal",\n respectively.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in\n square brackets: The object must be an iterable with the same number\n of items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, "TypeError" is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily "AttributeError").\n\n Note: If the object is a class instance and the attribute reference\n occurs on both sides of the assignment operator, the RHS expression,\n "a.x" can access either an instance attribute or (if no instance\n attribute exists) a class attribute. The LHS target "a.x" is always\n set as an instance attribute, creating it if necessary. Thus, the\n two occurrences of "a.x" do not necessarily refer to the same\n attribute: if the RHS expression refers to a class attribute, the\n LHS creates a new instance attribute as the target of the\n assignment:\n\n class Cls:\n x = 3 # class variable\n inst = Cls()\n inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x as 3\n\n This description does not necessarily apply to descriptor\n attributes, such as properties created with "property()".\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield an integer. If it is negative, the sequence\'s\n length is added to it. The resulting value must be a nonnegative\n integer less than the sequence\'s length, and the sequence is asked\n to assign the assigned object to its item with that index. If the\n index is out of range, "IndexError" is raised (assignment to a\n subscripted sequence cannot add new items to a list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n For user-defined objects, the "__setitem__()" method is called with\n appropriate arguments.\n\n* If the target is a slicing: The primary expression in the\n reference is evaluated. It should yield a mutable sequence object\n (such as a list). The assigned object should be a sequence object\n of the same type. Next, the lower and upper bound expressions are\n evaluated, insofar they are present; defaults are zero and the\n sequence\'s length. The bounds should evaluate to integers. If\n either bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the target\n sequence allows it.\n\n**CPython implementation detail:** In the current implementation, the\nsyntax for targets is taken to be the same as for expressions, and\ninvalid syntax is rejected during the code generation phase, causing\nless detailed error messages.\n\nAlthough the definition of assignment implies that overlaps between\nthe left-hand side and the right-hand side are \'simultanenous\' (for\nexample "a, b = b, a" swaps two variables), overlaps *within* the\ncollection of assigned-to variables occur left-to-right, sometimes\nresulting in confusion. For instance, the following program prints\n"[0, 2]":\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2 # i is updated, then x[i] is updated\n print(x)\n\nSee also: **PEP 3132** - Extended Iterable Unpacking\n\n The specification for the "*target" feature.\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions of the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like "x += 1" can be rewritten as\n"x = x + 1" to achieve a similar, but not exactly equal effect. In the\naugmented version, "x" is only evaluated once. Also, when possible,\nthe actual operation is performed *in-place*, meaning that rather than\ncreating a new object and assigning that to the target, the old object\nis modified instead.\n\nUnlike normal assignments, augmented assignments evaluate the left-\nhand side *before* evaluating the right-hand side. For example, "a[i]\n+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs\nthe addition, and lastly, it writes the result back to "a[i]".\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n', 'atom-identifiers': u'\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a "NameError" exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name, with leading underscores removed and a single underscore\ninserted, in front of the name. For example, the identifier "__spam"\noccurring in a class named "Ham" will be transformed to "_Ham__spam".\nThis transformation is independent of the syntactical context in which\nthe identifier is used. If the transformed name is extremely long\n(longer than 255 characters), implementation defined truncation may\nhappen. If the class name consists only of underscores, no\ntransformation is done.\n', @@ -18,19 +18,19 @@ 'callable-types': u'\nEmulating callable objects\n**************************\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, "x(arg1, arg2, ...)" is a shorthand for\n "x.__call__(arg1, arg2, ...)".\n', 'calls': u'\nCalls\n*****\n\nA call calls a callable object (e.g., a *function*) with a possibly\nempty series of *arguments*:\n\n call ::= primary "(" [argument_list [","] | comprehension] ")"\n argument_list ::= positional_arguments ["," keyword_arguments]\n ["," "*" expression] ["," keyword_arguments]\n ["," "**" expression]\n | keyword_arguments ["," "*" expression]\n ["," keyword_arguments] ["," "**" expression]\n | "*" expression ["," keyword_arguments] ["," "**" expression]\n | "**" expression\n positional_arguments ::= expression ("," expression)*\n keyword_arguments ::= keyword_item ("," keyword_item)*\n keyword_item ::= identifier "=" expression\n\nAn optional trailing comma may be present after the positional and\nkeyword arguments but does not affect the semantics.\n\nThe primary must evaluate to a callable object (user-defined\nfunctions, built-in functions, methods of built-in objects, class\nobjects, methods of class instances, and all objects having a\n"__call__()" method are callable). All argument expressions are\nevaluated before the call is attempted. Please refer to section\n*Function definitions* for the syntax of formal *parameter* lists.\n\nIf keyword arguments are present, they are first converted to\npositional arguments, as follows. First, a list of unfilled slots is\ncreated for the formal parameters. If there are N positional\narguments, they are placed in the first N slots. Next, for each\nkeyword argument, the identifier is used to determine the\ncorresponding slot (if the identifier is the same as the first formal\nparameter name, the first slot is used, and so on). If the slot is\nalready filled, a "TypeError" exception is raised. Otherwise, the\nvalue of the argument is placed in the slot, filling it (even if the\nexpression is "None", it fills the slot). When all arguments have\nbeen processed, the slots that are still unfilled are filled with the\ncorresponding default value from the function definition. (Default\nvalues are calculated, once, when the function is defined; thus, a\nmutable object such as a list or dictionary used as default value will\nbe shared by all calls that don\'t specify an argument value for the\ncorresponding slot; this should usually be avoided.) If there are any\nunfilled slots for which no default value is specified, a "TypeError"\nexception is raised. Otherwise, the list of filled slots is used as\nthe argument list for the call.\n\n**CPython implementation detail:** An implementation may provide\nbuilt-in functions whose positional parameters do not have names, even\nif they are \'named\' for the purpose of documentation, and which\ntherefore cannot be supplied by keyword. In CPython, this is the case\nfor functions implemented in C that use "PyArg_ParseTuple()" to parse\ntheir arguments.\n\nIf there are more positional arguments than there are formal parameter\nslots, a "TypeError" exception is raised, unless a formal parameter\nusing the syntax "*identifier" is present; in this case, that formal\nparameter receives a tuple containing the excess positional arguments\n(or an empty tuple if there were no excess positional arguments).\n\nIf any keyword argument does not correspond to a formal parameter\nname, a "TypeError" exception is raised, unless a formal parameter\nusing the syntax "**identifier" is present; in this case, that formal\nparameter receives a dictionary containing the excess keyword\narguments (using the keywords as keys and the argument values as\ncorresponding values), or a (new) empty dictionary if there were no\nexcess keyword arguments.\n\nIf the syntax "*expression" appears in the function call, "expression"\nmust evaluate to an iterable. Elements from this iterable are treated\nas if they were additional positional arguments; if there are\npositional arguments *x1*, ..., *xN*, and "expression" evaluates to a\nsequence *y1*, ..., *yM*, this is equivalent to a call with M+N\npositional arguments *x1*, ..., *xN*, *y1*, ..., *yM*.\n\nA consequence of this is that although the "*expression" syntax may\nappear *after* some keyword arguments, it is processed *before* the\nkeyword arguments (and the "**expression" argument, if any -- see\nbelow). So:\n\n >>> def f(a, b):\n ... print(a, b)\n ...\n >>> f(b=1, *(2,))\n 2 1\n >>> f(a=1, *(2,))\n Traceback (most recent call last):\n File "", line 1, in ?\n TypeError: f() got multiple values for keyword argument \'a\'\n >>> f(1, *(2,))\n 1 2\n\nIt is unusual for both keyword arguments and the "*expression" syntax\nto be used in the same call, so in practice this confusion does not\narise.\n\nIf the syntax "**expression" appears in the function call,\n"expression" must evaluate to a mapping, the contents of which are\ntreated as additional keyword arguments. In the case of a keyword\nappearing in both "expression" and as an explicit keyword argument, a\n"TypeError" exception is raised.\n\nFormal parameters using the syntax "*identifier" or "**identifier"\ncannot be used as positional argument slots or as keyword argument\nnames.\n\nA call always returns some value, possibly "None", unless it raises an\nexception. How this value is computed depends on the type of the\ncallable object.\n\nIf it is---\n\na user-defined function:\n The code block for the function is executed, passing it the\n argument list. The first thing the code block will do is bind the\n formal parameters to the arguments; this is described in section\n *Function definitions*. When the code block executes a "return"\n statement, this specifies the return value of the function call.\n\na built-in function or method:\n The result is up to the interpreter; see *Built-in Functions* for\n the descriptions of built-in functions and methods.\n\na class object:\n A new instance of that class is returned.\n\na class instance method:\n The corresponding user-defined function is called, with an argument\n list that is one longer than the argument list of the call: the\n instance becomes the first argument.\n\na class instance:\n The class must define a "__call__()" method; the effect is then the\n same as if that method was called.\n', 'class': u'\nClass definitions\n*****************\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [parameter_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing. Classes without an inheritance\nlist inherit, by default, from the base class "object"; hence,\n\n class Foo:\n pass\n\nis equivalent to\n\n class Foo(object):\n pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.) When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators. The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances. Instance attributes\ncan be set in a method with "self.name = value". Both class and\ninstance attributes are accessible through the notation ""self.name"",\nand an instance attribute hides a class attribute with the same name\nwhen accessed in this way. Class attributes can be used as defaults\nfor instance attributes, but using mutable values there can lead to\nunexpected results. *Descriptors* can be used to create instance\nvariables with different implementation details.\n\nSee also: **PEP 3115** - Metaclasses in Python 3 **PEP 3129** -\n Class Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack unless\n there is a "finally" clause which happens to raise another\n exception. That new exception causes the old one to be lost.\n\n[2] Currently, control "flows off the end" except in the case of\n an exception or the execution of a "return", "continue", or\n "break" statement.\n\n[3] A string literal appearing as the first statement in the\n function body is transformed into the function\'s "__doc__"\n attribute and therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s "__doc__" item and\n therefore the class\'s *docstring*.\n', - 'comparisons': u'\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like "a < b < c" have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: "True" or "False".\n\nComparisons can be chained arbitrarily, e.g., "x < y <= z" is\nequivalent to "x < y and y <= z", except that "y" is evaluated only\nonce (but in both cases "z" is not evaluated at all when "x < y" is\nfound to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then "a op1 b op2 c ... y\nopN z" is equivalent to "a op1 b and b op2 c and ... y opN z", except\nthat each expression is evaluated at most once.\n\nNote that "a op1 b op2 c" doesn\'t imply any kind of comparison between\n*a* and *c*, so that, e.g., "x < y > z" is perfectly legal (though\nperhaps not pretty).\n\nThe operators "<", ">", "==", ">=", "<=", and "!=" compare the values\nof two objects. The objects need not have the same type. If both are\nnumbers, they are converted to a common type. Otherwise, the "==" and\n"!=" operators *always* consider objects of different types to be\nunequal, while the "<", ">", ">=" and "<=" operators raise a\n"TypeError" when comparing objects of different types that do not\nimplement these operators for the given pair of types. You can\ncontrol comparison behavior of objects of non-built-in types by\ndefining rich comparison methods like "__gt__()", described in section\n*Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values "float(\'NaN\')" and "Decimal(\'NaN\')" are special. The\n are identical to themselves, "x is x" but are not equal to\n themselves, "x != x". Additionally, comparing any value to a\n not-a-number value will return "False". For example, both "3 <\n float(\'NaN\')" and "float(\'NaN\') < 3" will return "False".\n\n* Bytes objects are compared lexicographically using the numeric\n values of their elements.\n\n* Strings are compared lexicographically using the numeric\n equivalents (the result of the built-in function "ord()") of their\n characters. [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison\n of corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, "[1,2,x] <= [1,2,y]" has the same\n value as "x <= y". If the corresponding element does not exist, the\n shorter sequence is ordered first (for example, "[1,2] < [1,2,3]").\n\n* Mappings (dictionaries) compare equal if and only if they have the\n same "(key, value)" pairs. Order comparisons "(\'<\', \'<=\', \'>=\',\n \'>\')" raise "TypeError".\n\n* Sets and frozensets define comparison operators to mean subset and\n superset tests. Those relations do not define total orderings (the\n two sets "{1,2}" and {2,3} are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering.\n For example, "min()", "max()", and "sorted()" produce undefined\n results given a list of sets as inputs.\n\n* Most other objects of built-in types compare unequal unless they\n are the same object; the choice whether one object is considered\n smaller or larger than another one is made arbitrarily but\n consistently within one execution of a program.\n\nComparison of objects of differing types depends on whether either of\nthe types provide explicit support for the comparison. Most numeric\ntypes can be compared with one another. When cross-type comparison is\nnot supported, the comparison method returns "NotImplemented".\n\nThe operators "in" and "not in" test for membership. "x in s"\nevaluates to true if *x* is a member of *s*, and false otherwise. "x\nnot in s" returns the negation of "x in s". All built-in sequences\nand set types support this as well as dictionary, for which "in" tests\nwhether the dictionary has a given key. For container types such as\nlist, tuple, set, frozenset, dict, or collections.deque, the\nexpression "x in y" is equivalent to "any(x is e or x == e for e in\ny)".\n\nFor the string and bytes types, "x in y" is true if and only if *x* is\na substring of *y*. An equivalent test is "y.find(x) != -1". Empty\nstrings are always considered to be a substring of any other string,\nso """ in "abc"" will return "True".\n\nFor user-defined classes which define the "__contains__()" method, "x\nin y" is true if and only if "y.__contains__(x)" is true.\n\nFor user-defined classes which do not define "__contains__()" but do\ndefine "__iter__()", "x in y" is true if some value "z" with "x == z"\nis produced while iterating over "y". If an exception is raised\nduring the iteration, it is as if "in" raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n"__getitem__()", "x in y" is true if and only if there is a non-\nnegative integer index *i* such that "x == y[i]", and all lower\ninteger indices do not raise "IndexError" exception. (If any other\nexception is raised, it is as if "in" raised that exception).\n\nThe operator "not in" is defined to have the inverse true value of\n"in".\n\nThe operators "is" and "is not" test for object identity: "x is y" is\ntrue if and only if *x* and *y* are the same object. "x is not y"\nyields the inverse truth value. [4]\n', + 'comparisons': u'\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like "a < b < c" have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: "True" or "False".\n\nComparisons can be chained arbitrarily, e.g., "x < y <= z" is\nequivalent to "x < y and y <= z", except that "y" is evaluated only\nonce (but in both cases "z" is not evaluated at all when "x < y" is\nfound to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then "a op1 b op2 c ... y\nopN z" is equivalent to "a op1 b and b op2 c and ... y opN z", except\nthat each expression is evaluated at most once.\n\nNote that "a op1 b op2 c" doesn\'t imply any kind of comparison between\n*a* and *c*, so that, e.g., "x < y > z" is perfectly legal (though\nperhaps not pretty).\n\n\nValue comparisons\n=================\n\nThe operators "<", ">", "==", ">=", "<=", and "!=" compare the values\nof two objects. The objects do not need to have the same type.\n\nChapter *Objects, values and types* states that objects have a value\n(in addition to type and identity). The value of an object is a\nrather abstract notion in Python: For example, there is no canonical\naccess method for an object\'s value. Also, there is no requirement\nthat the value of an object should be constructed in a particular way,\ne.g. comprised of all its data attributes. Comparison operators\nimplement a particular notion of what the value of an object is. One\ncan think of them as defining the value of an object indirectly, by\nmeans of their comparison implementation.\n\nBecause all types are (direct or indirect) subtypes of "object", they\ninherit the default comparison behavior from "object". Types can\ncustomize their comparison behavior by implementing *rich comparison\nmethods* like "__lt__()", described in *Basic customization*.\n\nThe default behavior for equality comparison ("==" and "!=") is based\non the identity of the objects. Hence, equality comparison of\ninstances with the same identity results in equality, and equality\ncomparison of instances with different identities results in\ninequality. A motivation for this default behavior is the desire that\nall objects should be reflexive (i.e. "x is y" implies "x == y").\n\nA default order comparison ("<", ">", "<=", and ">=") is not provided;\nan attempt raises "TypeError". A motivation for this default behavior\nis the lack of a similar invariant as for equality.\n\nThe behavior of the default equality comparison, that instances with\ndifferent identities are always unequal, may be in contrast to what\ntypes will need that have a sensible definition of object value and\nvalue-based equality. Such types will need to customize their\ncomparison behavior, and in fact, a number of built-in types have done\nthat.\n\nThe following list describes the comparison behavior of the most\nimportant built-in types.\n\n* Numbers of built-in numeric types (*Numeric Types --- int, float,\n complex*) and of the standard library types "fractions.Fraction" and\n "decimal.Decimal" can be compared within and across their types,\n with the restriction that complex numbers do not support order\n comparison. Within the limits of the types involved, they compare\n mathematically (algorithmically) correct without loss of precision.\n\n The not-a-number values "float(\'NaN\')" and "Decimal(\'NaN\')" are\n special. They are identical to themselves ("x is x" is true) but\n are not equal to themselves ("x == x" is false). Additionally,\n comparing any number to a not-a-number value will return "False".\n For example, both "3 < float(\'NaN\')" and "float(\'NaN\') < 3" will\n return "False".\n\n* Binary sequences (instances of "bytes" or "bytearray") can be\n compared within and across their types. They compare\n lexicographically using the numeric values of their elements.\n\n* Strings (instances of "str") compare lexicographically using the\n numerical Unicode code points (the result of the built-in function\n "ord()") of their characters. [3]\n\n Strings and binary sequences cannot be directly compared.\n\n* Sequences (instances of "tuple", "list", or "range") can be\n compared only within each of their types, with the restriction that\n ranges do not support order comparison. Equality comparison across\n these types results in unequality, and ordering comparison across\n these types raises "TypeError".\n\n Sequences compare lexicographically using comparison of\n corresponding elements, whereby reflexivity of the elements is\n enforced.\n\n In enforcing reflexivity of elements, the comparison of collections\n assumes that for a collection element "x", "x == x" is always true.\n Based on that assumption, element identity is compared first, and\n element comparison is performed only for distinct elements. This\n approach yields the same result as a strict element comparison\n would, if the compared elements are reflexive. For non-reflexive\n elements, the result is different than for strict element\n comparison, and may be surprising: The non-reflexive not-a-number\n values for example result in the following comparison behavior when\n used in a list:\n\n >>> nan = float(\'NaN\')\n >>> nan is nan\n True\n >>> nan == nan\n False <-- the defined non-reflexive behavior of NaN\n >>> [nan] == [nan]\n True <-- list enforces reflexivity and tests identity first\n\n Lexicographical comparison between built-in collections works as\n follows:\n\n * For two collections to compare equal, they must be of the same\n type, have the same length, and each pair of corresponding\n elements must compare equal (for example, "[1,2] == (1,2)" is\n false because the type is not the same).\n\n * Collections that support order comparison are ordered the same\n as their first unequal elements (for example, "[1,2,x] <= [1,2,y]"\n has the same value as "x <= y"). If a corresponding element does\n not exist, the shorter collection is ordered first (for example,\n "[1,2] < [1,2,3]" is true).\n\n* Mappings (instances of "dict") compare equal if and only if they\n have equal *(key, value)* pairs. Equality comparison of the keys and\n elements enforces reflexivity.\n\n Order comparisons ("<", ">", "<=", and ">=") raise "TypeError".\n\n* Sets (instances of "set" or "frozenset") can be compared within\n and across their types.\n\n They define order comparison operators to mean subset and superset\n tests. Those relations do not define total orderings (for example,\n the two sets "{1,2}" and "{2,3}" are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering\n (for example, "min()", "max()", and "sorted()" produce undefined\n results given a list of sets as inputs).\n\n Comparison of sets enforces reflexivity of its elements.\n\n* Most other built-in types have no comparison methods implemented,\n so they inherit the default comparison behavior.\n\nUser-defined classes that customize their comparison behavior should\nfollow some consistency rules, if possible:\n\n* Equality comparison should be reflexive. In other words, identical\n objects should compare equal:\n\n "x is y" implies "x == y"\n\n* Comparison should be symmetric. In other words, the following\n expressions should have the same result:\n\n "x == y" and "y == x"\n\n "x != y" and "y != x"\n\n "x < y" and "y > x"\n\n "x <= y" and "y >= x"\n\n* Comparison should be transitive. The following (non-exhaustive)\n examples illustrate that:\n\n "x > y and y > z" implies "x > z"\n\n "x < y and y <= z" implies "x < z"\n\n* Inverse comparison should result in the boolean negation. In other\n words, the following expressions should have the same result:\n\n "x == y" and "not x != y"\n\n "x < y" and "not x >= y" (for total ordering)\n\n "x > y" and "not x <= y" (for total ordering)\n\n The last two expressions apply to totally ordered collections (e.g.\n to sequences, but not to sets or mappings). See also the\n "total_ordering()" decorator.\n\nPython does not enforce these consistency rules. In fact, the\nnot-a-number values are an example for not following these rules.\n\n\nMembership test operations\n==========================\n\nThe operators "in" and "not in" test for membership. "x in s"\nevaluates to true if *x* is a member of *s*, and false otherwise. "x\nnot in s" returns the negation of "x in s". All built-in sequences\nand set types support this as well as dictionary, for which "in" tests\nwhether the dictionary has a given key. For container types such as\nlist, tuple, set, frozenset, dict, or collections.deque, the\nexpression "x in y" is equivalent to "any(x is e or x == e for e in\ny)".\n\nFor the string and bytes types, "x in y" is true if and only if *x* is\na substring of *y*. An equivalent test is "y.find(x) != -1". Empty\nstrings are always considered to be a substring of any other string,\nso """ in "abc"" will return "True".\n\nFor user-defined classes which define the "__contains__()" method, "x\nin y" is true if and only if "y.__contains__(x)" is true.\n\nFor user-defined classes which do not define "__contains__()" but do\ndefine "__iter__()", "x in y" is true if some value "z" with "x == z"\nis produced while iterating over "y". If an exception is raised\nduring the iteration, it is as if "in" raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n"__getitem__()", "x in y" is true if and only if there is a non-\nnegative integer index *i* such that "x == y[i]", and all lower\ninteger indices do not raise "IndexError" exception. (If any other\nexception is raised, it is as if "in" raised that exception).\n\nThe operator "not in" is defined to have the inverse true value of\n"in".\n\n\nIdentity comparisons\n====================\n\nThe operators "is" and "is not" test for object identity: "x is y" is\ntrue if and only if *x* and *y* are the same object. "x is not y"\nyields the inverse truth value. [4]\n', 'compound': u'\nCompound statements\n*******************\n\nCompound statements contain (groups of) other statements; they affect\nor control the execution of those other statements in some way. In\ngeneral, compound statements span multiple lines, although in simple\nincarnations a whole compound statement may be contained in one line.\n\nThe "if", "while" and "for" statements implement traditional control\nflow constructs. "try" specifies exception handlers and/or cleanup\ncode for a group of statements, while the "with" statement allows the\nexecution of initialization and finalization code around a block of\ncode. Function and class definitions are also syntactically compound\nstatements.\n\nA compound statement consists of one or more \'clauses.\' A clause\nconsists of a header and a \'suite.\' The clause headers of a\nparticular compound statement are all at the same indentation level.\nEach clause header begins with a uniquely identifying keyword and ends\nwith a colon. A suite is a group of statements controlled by a\nclause. A suite can be one or more semicolon-separated simple\nstatements on the same line as the header, following the header\'s\ncolon, or it can be one or more indented statements on subsequent\nlines. Only the latter form of a suite can contain nested compound\nstatements; the following is illegal, mostly because it wouldn\'t be\nclear to which "if" clause a following "else" clause would belong:\n\n if test1: if test2: print(x)\n\nAlso note that the semicolon binds tighter than the colon in this\ncontext, so that in the following example, either all or none of the\n"print()" calls are executed:\n\n if x < y < z: print(x); print(y); print(z)\n\nSummarizing:\n\n compound_stmt ::= if_stmt\n | while_stmt\n | for_stmt\n | try_stmt\n | with_stmt\n | funcdef\n | classdef\n suite ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT\n statement ::= stmt_list NEWLINE | compound_stmt\n stmt_list ::= simple_stmt (";" simple_stmt)* [";"]\n\nNote that statements always end in a "NEWLINE" possibly followed by a\n"DEDENT". Also note that optional continuation clauses always begin\nwith a keyword that cannot start a statement, thus there are no\nambiguities (the \'dangling "else"\' problem is solved in Python by\nrequiring nested "if" statements to be indented).\n\nThe formatting of the grammar rules in the following sections places\neach clause on a separate line for clarity.\n\n\nThe "if" statement\n==================\n\nThe "if" statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the "if" statement is executed or evaluated).\nIf all expressions are false, the suite of the "else" clause, if\npresent, is executed.\n\n\nThe "while" statement\n=====================\n\nThe "while" statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the "else" clause, if present, is executed\nand the loop terminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and goes back\nto testing the expression.\n\n\nThe "for" statement\n===================\n\nThe "for" statement is used to iterate over the elements of a sequence\n(such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n"expression_list". The suite is then executed once for each item\nprovided by the iterator, in the order returned by the iterator. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted. When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a "StopIteration" exception),\nthe suite in the "else" clause, if present, is executed, and the loop\nterminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and continues\nwith the next item, or with the "else" clause if there is no next\nitem.\n\nThe for-loop makes assignments to the variables(s) in the target list.\nThis overwrites all previous assignments to those variables including\nthose made in the suite of the for-loop:\n\n for i in range(10):\n print(i)\n i = 5 # this will not affect the for-loop\n # because i will be overwritten with the next\n # index in the range\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, they will not have been assigned to at\nall by the loop. Hint: the built-in function "range()" returns an\niterator of integers suitable to emulate the effect of Pascal\'s "for i\n:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".\n\nNote: There is a subtlety when the sequence is being modified by the\n loop (this can only occur for mutable sequences, i.e. lists). An\n internal counter is used to keep track of which item is used next,\n and this is incremented on each iteration. When this counter has\n reached the length of the sequence the loop terminates. This means\n that if the suite deletes the current (or a previous) item from the\n sequence, the next item will be skipped (since it gets the index of\n the current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n\n\nThe "try" statement\n===================\n\nThe "try" statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" identifier]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe "except" clause(s) specify one or more exception handlers. When no\nexception occurs in the "try" clause, no exception handler is\nexecuted. When an exception occurs in the "try" suite, a search for an\nexception handler is started. This search inspects the except clauses\nin turn until one is found that matches the exception. An expression-\nless except clause, if present, must be last; it matches any\nexception. For an except clause with an expression, that expression\nis evaluated, and the clause matches the exception if the resulting\nobject is "compatible" with the exception. An object is compatible\nwith an exception if it is the class or a base class of the exception\nobject or a tuple containing an item compatible with the exception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire "try" statement raised\nthe exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the "as" keyword in that except clause, if\npresent, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using "as target", it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause. Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the "sys" module and can be accessed via\n"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the\nexception class, the exception instance and a traceback object (see\nsection *The standard type hierarchy*) identifying the point in the\nprogram where the exception occurred. "sys.exc_info()" values are\nrestored to their previous values (before the call) when returning\nfrom a function that handled an exception.\n\nThe optional "else" clause is executed if and when control flows off\nthe end of the "try" clause. [2] Exceptions in the "else" clause are\nnot handled by the preceding "except" clauses.\n\nIf "finally" is present, it specifies a \'cleanup\' handler. The "try"\nclause is executed, including any "except" and "else" clauses. If an\nexception occurs in any of the clauses and is not handled, the\nexception is temporarily saved. The "finally" clause is executed. If\nthere is a saved exception it is re-raised at the end of the "finally"\nclause. If the "finally" clause raises another exception, the saved\nexception is set as the context of the new exception. If the "finally"\nclause executes a "return" or "break" statement, the saved exception\nis discarded:\n\n >>> def f():\n ... try:\n ... 1/0\n ... finally:\n ... return 42\n ...\n >>> f()\n 42\n\nThe exception information is not available to the program during\nexecution of the "finally" clause.\n\nWhen a "return", "break" or "continue" statement is executed in the\n"try" suite of a "try"..."finally" statement, the "finally" clause is\nalso executed \'on the way out.\' A "continue" statement is illegal in\nthe "finally" clause. (The reason is a problem with the current\nimplementation --- this restriction may be lifted in the future).\n\nThe return value of a function is determined by the last "return"\nstatement executed. Since the "finally" clause always executes, a\n"return" statement executed in the "finally" clause will always be the\nlast one executed:\n\n >>> def foo():\n ... try:\n ... return \'try\'\n ... finally:\n ... return \'finally\'\n ...\n >>> foo()\n \'finally\'\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the "raise" statement to\ngenerate exceptions may be found in section *The raise statement*.\n\n\nThe "with" statement\n====================\n\nThe "with" statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common "try"..."except"..."finally"\nusage patterns to be encapsulated for convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the "with" statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the "with_item")\n is evaluated to obtain a context manager.\n\n2. The context manager\'s "__exit__()" is loaded for later use.\n\n3. The context manager\'s "__enter__()" method is invoked.\n\n4. If a target was included in the "with" statement, the return\n value from "__enter__()" is assigned to it.\n\n Note: The "with" statement guarantees that if the "__enter__()"\n method returns without an error, then "__exit__()" will always be\n called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s "__exit__()" method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to "__exit__()". Otherwise, three\n "None" arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the "__exit__()" method was false, the exception is reraised.\n If the return value was true, the exception is suppressed, and\n execution continues with the statement following the "with"\n statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from "__exit__()" is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple "with" statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also: **PEP 0343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n\n\nFunction definitions\n====================\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n funcdef ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n decorators ::= decorator+\n decorator ::= "@" dotted_name ["(" [parameter_list [","]] ")"] NEWLINE\n dotted_name ::= identifier ("." identifier)*\n parameter_list ::= (defparameter ",")*\n | "*" [parameter] ("," defparameter)* ["," "**" parameter]\n | "**" parameter\n | defparameter [","] )\n parameter ::= identifier [":" expression]\n defparameter ::= parameter ["=" expression]\n funcname ::= identifier\n\nA function definition is an executable statement. Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function). This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition. The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object. Multiple decorators are applied in\nnested fashion. For example, the following code\n\n @f1(arg)\n @f2\n def func(): pass\n\nis equivalent to\n\n def func(): pass\n func = f1(arg)(f2(func))\n\nWhen one or more *parameters* have the form *parameter* "="\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding *argument* may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted. If a parameter has a default value, all following\nparameters up until the ""*"" must also have a default value --- this\nis a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated from left to right when the\nfunction definition is executed.** This means that the expression is\nevaluated once, when the function is defined, and that the same "pre-\ncomputed" value is used for each call. This is especially important\nto understand when a default parameter is a mutable object, such as a\nlist or a dictionary: if the function modifies the object (e.g. by\nappending an item to a list), the default value is in effect modified.\nThis is generally not what was intended. A way around this is to use\n"None" as the default, and explicitly test for it in the body of the\nfunction, e.g.:\n\n def whats_on_the_telly(penguin=None):\n if penguin is None:\n penguin = []\n penguin.append("property of the zoo")\n return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values. If the form\n""*identifier"" is present, it is initialized to a tuple receiving any\nexcess positional parameters, defaulting to the empty tuple. If the\nform ""**identifier"" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after ""*"" or ""*identifier"" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "": expression"" following\nthe parameter name. Any parameter may have an annotation even those\nof the form "*identifier" or "**identifier". Functions may have\n"return" annotation of the form ""-> expression"" after the parameter\nlist. These annotations can be any valid Python expression and are\nevaluated when the function definition is executed. Annotations may\nbe evaluated in a different order than they appear in the source code.\nThe presence of annotations does not change the semantics of a\nfunction. The annotation values are available as values of a\ndictionary keyed by the parameters\' names in the "__annotations__"\nattribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions. This uses lambda\nexpressions, described in section *Lambdas*. Note that the lambda\nexpression is merely a shorthand for a simplified function definition;\na function defined in a ""def"" statement can be passed around or\nassigned to another name just like a function defined by a lambda\nexpression. The ""def"" form is actually more powerful since it\nallows the execution of multiple statements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects. A ""def""\nstatement executed inside a function definition defines a local\nfunction that can be returned or passed around. Free variables used\nin the nested function can access the local variables of the function\ncontaining the def. See section *Naming and binding* for details.\n\nSee also: **PEP 3107** - Function Annotations\n\n The original specification for function annotations.\n\n\nClass definitions\n=================\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [parameter_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing. Classes without an inheritance\nlist inherit, by default, from the base class "object"; hence,\n\n class Foo:\n pass\n\nis equivalent to\n\n class Foo(object):\n pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.) When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators. The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances. Instance attributes\ncan be set in a method with "self.name = value". Both class and\ninstance attributes are accessible through the notation ""self.name"",\nand an instance attribute hides a class attribute with the same name\nwhen accessed in this way. Class attributes can be used as defaults\nfor instance attributes, but using mutable values there can lead to\nunexpected results. *Descriptors* can be used to create instance\nvariables with different implementation details.\n\nSee also: **PEP 3115** - Metaclasses in Python 3 **PEP 3129** -\n Class Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack unless\n there is a "finally" clause which happens to raise another\n exception. That new exception causes the old one to be lost.\n\n[2] Currently, control "flows off the end" except in the case of\n an exception or the execution of a "return", "continue", or\n "break" statement.\n\n[3] A string literal appearing as the first statement in the\n function body is transformed into the function\'s "__doc__"\n attribute and therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s "__doc__" item and\n therefore the class\'s *docstring*.\n', 'context-managers': u'\nWith Statement Context Managers\n*******************************\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a "with" statement. The context manager\nhandles the entry into, and the exit from, the desired runtime context\nfor the execution of the block of code. Context managers are normally\ninvoked using the "with" statement (described in section *The with\nstatement*), but can also be used by directly invoking their methods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The "with"\n statement will bind this method\'s return value to the target(s)\n specified in the "as" clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be "None".\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that "__exit__()" methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also: **PEP 0343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n', 'continue': u'\nThe "continue" statement\n************************\n\n continue_stmt ::= "continue"\n\n"continue" may only occur syntactically nested in a "for" or "while"\nloop, but not nested in a function or class definition or "finally"\nclause within that loop. It continues with the next cycle of the\nnearest enclosing loop.\n\nWhen "continue" passes control out of a "try" statement with a\n"finally" clause, that "finally" clause is executed before really\nstarting the next loop cycle.\n', 'conversions': u'\nArithmetic conversions\n**********************\n\nWhen a description of an arithmetic operator below uses the phrase\n"the numeric arguments are converted to a common type," this means\nthat the operator implementation for built-in types works as follows:\n\n* If either argument is a complex number, the other is converted to\n complex;\n\n* otherwise, if either argument is a floating point number, the\n other is converted to floating point;\n\n* otherwise, both must be integers and no conversion is necessary.\n\nSome additional rules apply for certain operators (e.g., a string as a\nleft argument to the \'%\' operator). Extensions must define their own\nconversion behavior.\n', - 'customization': u'\nBasic customization\n*******************\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. "__new__()" is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of "__new__()" should be the new object instance (usually an\n instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s "__new__()" method using\n "super(currentclass, cls).__new__(cls[, ...])" with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If "__new__()" returns an instance of *cls*, then the new\n instance\'s "__init__()" method will be invoked like\n "__init__(self[, ...])", where *self* is the new instance and the\n remaining arguments are the same as were passed to "__new__()".\n\n If "__new__()" does not return an instance of *cls*, then the new\n instance\'s "__init__()" method will not be invoked.\n\n "__new__()" is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called after the instance has been created (by "__new__()"), but\n before it is returned to the caller. The arguments are those\n passed to the class constructor expression. If a base class has an\n "__init__()" method, the derived class\'s "__init__()" method, if\n any, must explicitly call it to ensure proper initialization of the\n base class part of the instance; for example:\n "BaseClass.__init__(self, [args...])".\n\n Because "__new__()" and "__init__()" work together in constructing\n objects ("__new__()" to create it, and "__init__()" to customise\n it), no non-"None" value may be returned by "__init__()"; doing so\n will cause a "TypeError" to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a "__del__()" method, the\n derived class\'s "__del__()" method, if any, must explicitly call it\n to ensure proper deletion of the base class part of the instance.\n Note that it is possible (though not recommended!) for the\n "__del__()" method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n "__del__()" methods are called for objects that still exist when\n the interpreter exits.\n\n Note: "del x" doesn\'t directly call "x.__del__()" --- the former\n decrements the reference count for "x" by one, and the latter is\n only called when "x"\'s reference count reaches zero. Some common\n situations that may prevent the reference count of an object from\n going to zero include: circular references between objects (e.g.,\n a doubly-linked list or a tree data structure with parent and\n child pointers); a reference to the object on the stack frame of\n a function that caught an exception (the traceback stored in\n "sys.exc_info()[2]" keeps the stack frame alive); or a reference\n to the object on the stack frame that raised an unhandled\n exception in interactive mode (the traceback stored in\n "sys.last_traceback" keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the second can be resolved by freeing the reference to the\n traceback object when it is no longer useful, and the third can\n be resolved by storing "None" in "sys.last_traceback". Circular\n references which are garbage are detected and cleaned up when the\n cyclic garbage collector is enabled (it\'s on by default). Refer\n to the documentation for the "gc" module for more information\n about this topic.\n\n Warning: Due to the precarious circumstances under which\n "__del__()" methods are invoked, exceptions that occur during\n their execution are ignored, and a warning is printed to\n "sys.stderr" instead. Also, when "__del__()" is invoked in\n response to a module being deleted (e.g., when execution of the\n program is done), other globals referenced by the "__del__()"\n method may already have been deleted or in the process of being\n torn down (e.g. the import machinery shutting down). For this\n reason, "__del__()" methods should do the absolute minimum needed\n to maintain external invariants. Starting with version 1.5,\n Python guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the "__del__()" method is called.\n\nobject.__repr__(self)\n\n Called by the "repr()" built-in function to compute the "official"\n string representation of an object. If at all possible, this\n should look like a valid Python expression that could be used to\n recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n "<...some useful description...>" should be returned. The return\n value must be a string object. If a class defines "__repr__()" but\n not "__str__()", then "__repr__()" is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by "str(object)" and the built-in functions "format()" and\n "print()" to compute the "informal" or nicely printable string\n representation of an object. The return value must be a *string*\n object.\n\n This method differs from "object.__repr__()" in that there is no\n expectation that "__str__()" return a valid Python expression: a\n more convenient or concise representation can be used.\n\n The default implementation defined by the built-in type "object"\n calls "object.__repr__()".\n\nobject.__bytes__(self)\n\n Called by "bytes()" to compute a byte-string representation of an\n object. This should return a "bytes" object.\n\nobject.__format__(self, format_spec)\n\n Called by the "format()" built-in function (and by extension, the\n "str.format()" method of class "str") to produce a "formatted"\n string representation of an object. The "format_spec" argument is a\n string that contains a description of the formatting options\n desired. The interpretation of the "format_spec" argument is up to\n the type implementing "__format__()", however most classes will\n either delegate formatting to one of the built-in types, or use a\n similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\n Changed in version 3.4: The __format__ method of "object" itself\n raises a "TypeError" if passed any non-empty string.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: "xy" calls\n "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n\n A rich comparison method may return the singleton "NotImplemented"\n if it does not implement the operation for a given pair of\n arguments. By convention, "False" and "True" are returned for a\n successful comparison. However, these methods can return any value,\n so if the comparison operator is used in a Boolean context (e.g.,\n in the condition of an "if" statement), Python will call "bool()"\n on the value to determine if the result is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of "x==y" does not imply that "x!=y" is false.\n Accordingly, when defining "__eq__()", one should also define\n "__ne__()" so that the operators will behave as expected. See the\n paragraph on "__hash__()" for some important notes on creating\n *hashable* objects which support custom comparison operations and\n are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, "__lt__()" and "__gt__()" are each other\'s\n reflection, "__le__()" and "__ge__()" are each other\'s reflection,\n and "__eq__()" and "__ne__()" are their own reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see "functools.total_ordering()".\n\nobject.__hash__(self)\n\n Called by built-in function "hash()" and for operations on members\n of hashed collections including "set", "frozenset", and "dict".\n "__hash__()" should return an integer. The only required property\n is that objects which compare equal have the same hash value; it is\n advised to somehow mix together (e.g. using exclusive or) the hash\n values for the components of the object that also play a part in\n comparison of objects.\n\n Note: "hash()" truncates the value returned from an object\'s\n custom "__hash__()" method to the size of a "Py_ssize_t". This\n is typically 8 bytes on 64-bit builds and 4 bytes on 32-bit\n builds. If an object\'s "__hash__()" must interoperate on builds\n of different bit sizes, be sure to check the width on all\n supported builds. An easy way to do this is with "python -c\n "import sys; print(sys.hash_info.width)""\n\n If a class does not define an "__eq__()" method it should not\n define a "__hash__()" operation either; if it defines "__eq__()"\n but not "__hash__()", its instances will not be usable as items in\n hashable collections. If a class defines mutable objects and\n implements an "__eq__()" method, it should not implement\n "__hash__()", since the implementation of hashable collections\n requires that a key\'s hash value is immutable (if the object\'s hash\n value changes, it will be in the wrong hash bucket).\n\n User-defined classes have "__eq__()" and "__hash__()" methods by\n default; with them, all objects compare unequal (except with\n themselves) and "x.__hash__()" returns an appropriate value such\n that "x == y" implies both that "x is y" and "hash(x) == hash(y)".\n\n A class that overrides "__eq__()" and does not define "__hash__()"\n will have its "__hash__()" implicitly set to "None". When the\n "__hash__()" method of a class is "None", instances of the class\n will raise an appropriate "TypeError" when a program attempts to\n retrieve their hash value, and will also be correctly identified as\n unhashable when checking "isinstance(obj, collections.Hashable").\n\n If a class that overrides "__eq__()" needs to retain the\n implementation of "__hash__()" from a parent class, the interpreter\n must be told this explicitly by setting "__hash__ =\n .__hash__".\n\n If a class that does not override "__eq__()" wishes to suppress\n hash support, it should include "__hash__ = None" in the class\n definition. A class which defines its own "__hash__()" that\n explicitly raises a "TypeError" would be incorrectly identified as\n hashable by an "isinstance(obj, collections.Hashable)" call.\n\n Note: By default, the "__hash__()" values of str, bytes and\n datetime objects are "salted" with an unpredictable random value.\n Although they remain constant within an individual Python\n process, they are not predictable between repeated invocations of\n Python.This is intended to provide protection against a denial-\n of-service caused by carefully-chosen inputs that exploit the\n worst case performance of a dict insertion, O(n^2) complexity.\n See http://www.ocert.org/advisories/ocert-2011-003.html for\n details.Changing hash values affects the iteration order of\n dicts, sets and other mappings. Python has never made guarantees\n about this ordering (and it typically varies between 32-bit and\n 64-bit builds).See also "PYTHONHASHSEED".\n\n Changed in version 3.3: Hash randomization is enabled by default.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n "bool()"; should return "False" or "True". When this method is not\n defined, "__len__()" is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither "__len__()" nor "__bool__()", all its instances are\n considered true.\n', - 'debugger': u'\n"pdb" --- The Python Debugger\n*****************************\n\n**Source code:** Lib/pdb.py\n\n======================================================================\n\nThe module "pdb" defines an interactive source code debugger for\nPython programs. It supports setting (conditional) breakpoints and\nsingle stepping at the source line level, inspection of stack frames,\nsource code listing, and evaluation of arbitrary Python code in the\ncontext of any stack frame. It also supports post-mortem debugging\nand can be called under program control.\n\nThe debugger is extensible -- it is actually defined as the class\n"Pdb". This is currently undocumented but easily understood by reading\nthe source. The extension interface uses the modules "bdb" and "cmd".\n\nThe debugger\'s prompt is "(Pdb)". Typical usage to run a program under\ncontrol of the debugger is:\n\n >>> import pdb\n >>> import mymodule\n >>> pdb.run(\'mymodule.test()\')\n > (0)?()\n (Pdb) continue\n > (1)?()\n (Pdb) continue\n NameError: \'spam\'\n > (1)?()\n (Pdb)\n\nChanged in version 3.3: Tab-completion via the "readline" module is\navailable for commands and command arguments, e.g. the current global\nand local names are offered as arguments of the "p" command.\n\n"pdb.py" can also be invoked as a script to debug other scripts. For\nexample:\n\n python3 -m pdb myscript.py\n\nWhen invoked as a script, pdb will automatically enter post-mortem\ndebugging if the program being debugged exits abnormally. After post-\nmortem debugging (or after normal exit of the program), pdb will\nrestart the program. Automatic restarting preserves pdb\'s state (such\nas breakpoints) and in most cases is more useful than quitting the\ndebugger upon program\'s exit.\n\nNew in version 3.2: "pdb.py" now accepts a "-c" option that executes\ncommands as if given in a ".pdbrc" file, see *Debugger Commands*.\n\nThe typical usage to break into the debugger from a running program is\nto insert\n\n import pdb; pdb.set_trace()\n\nat the location you want to break into the debugger. You can then\nstep through the code following this statement, and continue running\nwithout the debugger using the "continue" command.\n\nThe typical usage to inspect a crashed program is:\n\n >>> import pdb\n >>> import mymodule\n >>> mymodule.test()\n Traceback (most recent call last):\n File "", line 1, in ?\n File "./mymodule.py", line 4, in test\n test2()\n File "./mymodule.py", line 3, in test2\n print(spam)\n NameError: spam\n >>> pdb.pm()\n > ./mymodule.py(3)test2()\n -> print(spam)\n (Pdb)\n\nThe module defines the following functions; each enters the debugger\nin a slightly different way:\n\npdb.run(statement, globals=None, locals=None)\n\n Execute the *statement* (given as a string or a code object) under\n debugger control. The debugger prompt appears before any code is\n executed; you can set breakpoints and type "continue", or you can\n step through the statement using "step" or "next" (all these\n commands are explained below). The optional *globals* and *locals*\n arguments specify the environment in which the code is executed; by\n default the dictionary of the module "__main__" is used. (See the\n explanation of the built-in "exec()" or "eval()" functions.)\n\npdb.runeval(expression, globals=None, locals=None)\n\n Evaluate the *expression* (given as a string or a code object)\n under debugger control. When "runeval()" returns, it returns the\n value of the expression. Otherwise this function is similar to\n "run()".\n\npdb.runcall(function, *args, **kwds)\n\n Call the *function* (a function or method object, not a string)\n with the given arguments. When "runcall()" returns, it returns\n whatever the function call returned. The debugger prompt appears\n as soon as the function is entered.\n\npdb.set_trace()\n\n Enter the debugger at the calling stack frame. This is useful to\n hard-code a breakpoint at a given point in a program, even if the\n code is not otherwise being debugged (e.g. when an assertion\n fails).\n\npdb.post_mortem(traceback=None)\n\n Enter post-mortem debugging of the given *traceback* object. If no\n *traceback* is given, it uses the one of the exception that is\n currently being handled (an exception must be being handled if the\n default is to be used).\n\npdb.pm()\n\n Enter post-mortem debugging of the traceback found in\n "sys.last_traceback".\n\nThe "run*" functions and "set_trace()" are aliases for instantiating\nthe "Pdb" class and calling the method of the same name. If you want\nto access further features, you have to do this yourself:\n\nclass class pdb.Pdb(completekey=\'tab\', stdin=None, stdout=None, skip=None, nosigint=False)\n\n "Pdb" is the debugger class.\n\n The *completekey*, *stdin* and *stdout* arguments are passed to the\n underlying "cmd.Cmd" class; see the description there.\n\n The *skip* argument, if given, must be an iterable of glob-style\n module name patterns. The debugger will not step into frames that\n originate in a module that matches one of these patterns. [1]\n\n By default, Pdb sets a handler for the SIGINT signal (which is sent\n when the user presses Ctrl-C on the console) when you give a\n "continue" command. This allows you to break into the debugger\n again by pressing Ctrl-C. If you want Pdb not to touch the SIGINT\n handler, set *nosigint* tot true.\n\n Example call to enable tracing with *skip*:\n\n import pdb; pdb.Pdb(skip=[\'django.*\']).set_trace()\n\n New in version 3.1: The *skip* argument.\n\n New in version 3.2: The *nosigint* argument. Previously, a SIGINT\n handler was never set by Pdb.\n\n run(statement, globals=None, locals=None)\n runeval(expression, globals=None, locals=None)\n runcall(function, *args, **kwds)\n set_trace()\n\n See the documentation for the functions explained above.\n\n\nDebugger Commands\n=================\n\nThe commands recognized by the debugger are listed below. Most\ncommands can be abbreviated to one or two letters as indicated; e.g.\n"h(elp)" means that either "h" or "help" can be used to enter the help\ncommand (but not "he" or "hel", nor "H" or "Help" or "HELP").\nArguments to commands must be separated by whitespace (spaces or\ntabs). Optional arguments are enclosed in square brackets ("[]") in\nthe command syntax; the square brackets must not be typed.\nAlternatives in the command syntax are separated by a vertical bar\n("|").\n\nEntering a blank line repeats the last command entered. Exception: if\nthe last command was a "list" command, the next 11 lines are listed.\n\nCommands that the debugger doesn\'t recognize are assumed to be Python\nstatements and are executed in the context of the program being\ndebugged. Python statements can also be prefixed with an exclamation\npoint ("!"). This is a powerful way to inspect the program being\ndebugged; it is even possible to change a variable or call a function.\nWhen an exception occurs in such a statement, the exception name is\nprinted but the debugger\'s state is not changed.\n\nThe debugger supports *aliases*. Aliases can have parameters which\nallows one a certain level of adaptability to the context under\nexamination.\n\nMultiple commands may be entered on a single line, separated by ";;".\n(A single ";" is not used as it is the separator for multiple commands\nin a line that is passed to the Python parser.) No intelligence is\napplied to separating the commands; the input is split at the first\n";;" pair, even if it is in the middle of a quoted string.\n\nIf a file ".pdbrc" exists in the user\'s home directory or in the\ncurrent directory, it is read in and executed as if it had been typed\nat the debugger prompt. This is particularly useful for aliases. If\nboth files exist, the one in the home directory is read first and\naliases defined there can be overridden by the local file.\n\nChanged in version 3.2: ".pdbrc" can now contain commands that\ncontinue debugging, such as "continue" or "next". Previously, these\ncommands had no effect.\n\nh(elp) [command]\n\n Without argument, print the list of available commands. With a\n *command* as argument, print help about that command. "help pdb"\n displays the full documentation (the docstring of the "pdb"\n module). Since the *command* argument must be an identifier, "help\n exec" must be entered to get help on the "!" command.\n\nw(here)\n\n Print a stack trace, with the most recent frame at the bottom. An\n arrow indicates the current frame, which determines the context of\n most commands.\n\nd(own) [count]\n\n Move the current frame *count* (default one) levels down in the\n stack trace (to a newer frame).\n\nu(p) [count]\n\n Move the current frame *count* (default one) levels up in the stack\n trace (to an older frame).\n\nb(reak) [([filename:]lineno | function) [, condition]]\n\n With a *lineno* argument, set a break there in the current file.\n With a *function* argument, set a break at the first executable\n statement within that function. The line number may be prefixed\n with a filename and a colon, to specify a breakpoint in another\n file (probably one that hasn\'t been loaded yet). The file is\n searched on "sys.path". Note that each breakpoint is assigned a\n number to which all the other breakpoint commands refer.\n\n If a second argument is present, it is an expression which must\n evaluate to true before the breakpoint is honored.\n\n Without argument, list all breaks, including for each breakpoint,\n the number of times that breakpoint has been hit, the current\n ignore count, and the associated condition if any.\n\ntbreak [([filename:]lineno | function) [, condition]]\n\n Temporary breakpoint, which is removed automatically when it is\n first hit. The arguments are the same as for "break".\n\ncl(ear) [filename:lineno | bpnumber [bpnumber ...]]\n\n With a *filename:lineno* argument, clear all the breakpoints at\n this line. With a space separated list of breakpoint numbers, clear\n those breakpoints. Without argument, clear all breaks (but first\n ask confirmation).\n\ndisable [bpnumber [bpnumber ...]]\n\n Disable the breakpoints given as a space separated list of\n breakpoint numbers. Disabling a breakpoint means it cannot cause\n the program to stop execution, but unlike clearing a breakpoint, it\n remains in the list of breakpoints and can be (re-)enabled.\n\nenable [bpnumber [bpnumber ...]]\n\n Enable the breakpoints specified.\n\nignore bpnumber [count]\n\n Set the ignore count for the given breakpoint number. If count is\n omitted, the ignore count is set to 0. A breakpoint becomes active\n when the ignore count is zero. When non-zero, the count is\n decremented each time the breakpoint is reached and the breakpoint\n is not disabled and any associated condition evaluates to true.\n\ncondition bpnumber [condition]\n\n Set a new *condition* for the breakpoint, an expression which must\n evaluate to true before the breakpoint is honored. If *condition*\n is absent, any existing condition is removed; i.e., the breakpoint\n is made unconditional.\n\ncommands [bpnumber]\n\n Specify a list of commands for breakpoint number *bpnumber*. The\n commands themselves appear on the following lines. Type a line\n containing just "end" to terminate the commands. An example:\n\n (Pdb) commands 1\n (com) p some_variable\n (com) end\n (Pdb)\n\n To remove all commands from a breakpoint, type commands and follow\n it immediately with "end"; that is, give no commands.\n\n With no *bpnumber* argument, commands refers to the last breakpoint\n set.\n\n You can use breakpoint commands to start your program up again.\n Simply use the continue command, or step, or any other command that\n resumes execution.\n\n Specifying any command resuming execution (currently continue,\n step, next, return, jump, quit and their abbreviations) terminates\n the command list (as if that command was immediately followed by\n end). This is because any time you resume execution (even with a\n simple next or step), you may encounter another breakpoint--which\n could have its own command list, leading to ambiguities about which\n list to execute.\n\n If you use the \'silent\' command in the command list, the usual\n message about stopping at a breakpoint is not printed. This may be\n desirable for breakpoints that are to print a specific message and\n then continue. If none of the other commands print anything, you\n see no sign that the breakpoint was reached.\n\ns(tep)\n\n Execute the current line, stop at the first possible occasion\n (either in a function that is called or on the next line in the\n current function).\n\nn(ext)\n\n Continue execution until the next line in the current function is\n reached or it returns. (The difference between "next" and "step"\n is that "step" stops inside a called function, while "next"\n executes called functions at (nearly) full speed, only stopping at\n the next line in the current function.)\n\nunt(il) [lineno]\n\n Without argument, continue execution until the line with a number\n greater than the current one is reached.\n\n With a line number, continue execution until a line with a number\n greater or equal to that is reached. In both cases, also stop when\n the current frame returns.\n\n Changed in version 3.2: Allow giving an explicit line number.\n\nr(eturn)\n\n Continue execution until the current function returns.\n\nc(ont(inue))\n\n Continue execution, only stop when a breakpoint is encountered.\n\nj(ump) lineno\n\n Set the next line that will be executed. Only available in the\n bottom-most frame. This lets you jump back and execute code again,\n or jump forward to skip code that you don\'t want to run.\n\n It should be noted that not all jumps are allowed -- for instance\n it is not possible to jump into the middle of a "for" loop or out\n of a "finally" clause.\n\nl(ist) [first[, last]]\n\n List source code for the current file. Without arguments, list 11\n lines around the current line or continue the previous listing.\n With "." as argument, list 11 lines around the current line. With\n one argument, list 11 lines around at that line. With two\n arguments, list the given range; if the second argument is less\n than the first, it is interpreted as a count.\n\n The current line in the current frame is indicated by "->". If an\n exception is being debugged, the line where the exception was\n originally raised or propagated is indicated by ">>", if it differs\n from the current line.\n\n New in version 3.2: The ">>" marker.\n\nll | longlist\n\n List all source code for the current function or frame.\n Interesting lines are marked as for "list".\n\n New in version 3.2.\n\na(rgs)\n\n Print the argument list of the current function.\n\np expression\n\n Evaluate the *expression* in the current context and print its\n value.\n\n Note: "print()" can also be used, but is not a debugger command\n --- this executes the Python "print()" function.\n\npp expression\n\n Like the "p" command, except the value of the expression is pretty-\n printed using the "pprint" module.\n\nwhatis expression\n\n Print the type of the *expression*.\n\nsource expression\n\n Try to get source code for the given object and display it.\n\n New in version 3.2.\n\ndisplay [expression]\n\n Display the value of the expression if it changed, each time\n execution stops in the current frame.\n\n Without expression, list all display expressions for the current\n frame.\n\n New in version 3.2.\n\nundisplay [expression]\n\n Do not display the expression any more in the current frame.\n Without expression, clear all display expressions for the current\n frame.\n\n New in version 3.2.\n\ninteract\n\n Start an interative interpreter (using the "code" module) whose\n global namespace contains all the (global and local) names found in\n the current scope.\n\n New in version 3.2.\n\nalias [name [command]]\n\n Create an alias called *name* that executes *command*. The command\n must *not* be enclosed in quotes. Replaceable parameters can be\n indicated by "%1", "%2", and so on, while "%*" is replaced by all\n the parameters. If no command is given, the current alias for\n *name* is shown. If no arguments are given, all aliases are listed.\n\n Aliases may be nested and can contain anything that can be legally\n typed at the pdb prompt. Note that internal pdb commands *can* be\n overridden by aliases. Such a command is then hidden until the\n alias is removed. Aliasing is recursively applied to the first\n word of the command line; all other words in the line are left\n alone.\n\n As an example, here are two useful aliases (especially when placed\n in the ".pdbrc" file):\n\n # Print instance variables (usage "pi classInst")\n alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])\n # Print instance variables in self\n alias ps pi self\n\nunalias name\n\n Delete the specified alias.\n\n! statement\n\n Execute the (one-line) *statement* in the context of the current\n stack frame. The exclamation point can be omitted unless the first\n word of the statement resembles a debugger command. To set a\n global variable, you can prefix the assignment command with a\n "global" statement on the same line, e.g.:\n\n (Pdb) global list_options; list_options = [\'-l\']\n (Pdb)\n\nrun [args ...]\nrestart [args ...]\n\n Restart the debugged Python program. If an argument is supplied,\n it is split with "shlex" and the result is used as the new\n "sys.argv". History, breakpoints, actions and debugger options are\n preserved. "restart" is an alias for "run".\n\nq(uit)\n\n Quit from the debugger. The program being executed is aborted.\n\n-[ Footnotes ]-\n\n[1] Whether a frame is considered to originate in a certain module\n is determined by the "__name__" in the frame globals.\n', + 'customization': u'\nBasic customization\n*******************\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. "__new__()" is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of "__new__()" should be the new object instance (usually an\n instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s "__new__()" method using\n "super(currentclass, cls).__new__(cls[, ...])" with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If "__new__()" returns an instance of *cls*, then the new\n instance\'s "__init__()" method will be invoked like\n "__init__(self[, ...])", where *self* is the new instance and the\n remaining arguments are the same as were passed to "__new__()".\n\n If "__new__()" does not return an instance of *cls*, then the new\n instance\'s "__init__()" method will not be invoked.\n\n "__new__()" is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called after the instance has been created (by "__new__()"), but\n before it is returned to the caller. The arguments are those\n passed to the class constructor expression. If a base class has an\n "__init__()" method, the derived class\'s "__init__()" method, if\n any, must explicitly call it to ensure proper initialization of the\n base class part of the instance; for example:\n "BaseClass.__init__(self, [args...])".\n\n Because "__new__()" and "__init__()" work together in constructing\n objects ("__new__()" to create it, and "__init__()" to customise\n it), no non-"None" value may be returned by "__init__()"; doing so\n will cause a "TypeError" to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a "__del__()" method, the\n derived class\'s "__del__()" method, if any, must explicitly call it\n to ensure proper deletion of the base class part of the instance.\n Note that it is possible (though not recommended!) for the\n "__del__()" method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n "__del__()" methods are called for objects that still exist when\n the interpreter exits.\n\n Note: "del x" doesn\'t directly call "x.__del__()" --- the former\n decrements the reference count for "x" by one, and the latter is\n only called when "x"\'s reference count reaches zero. Some common\n situations that may prevent the reference count of an object from\n going to zero include: circular references between objects (e.g.,\n a doubly-linked list or a tree data structure with parent and\n child pointers); a reference to the object on the stack frame of\n a function that caught an exception (the traceback stored in\n "sys.exc_info()[2]" keeps the stack frame alive); or a reference\n to the object on the stack frame that raised an unhandled\n exception in interactive mode (the traceback stored in\n "sys.last_traceback" keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the second can be resolved by freeing the reference to the\n traceback object when it is no longer useful, and the third can\n be resolved by storing "None" in "sys.last_traceback". Circular\n references which are garbage are detected and cleaned up when the\n cyclic garbage collector is enabled (it\'s on by default). Refer\n to the documentation for the "gc" module for more information\n about this topic.\n\n Warning: Due to the precarious circumstances under which\n "__del__()" methods are invoked, exceptions that occur during\n their execution are ignored, and a warning is printed to\n "sys.stderr" instead. Also, when "__del__()" is invoked in\n response to a module being deleted (e.g., when execution of the\n program is done), other globals referenced by the "__del__()"\n method may already have been deleted or in the process of being\n torn down (e.g. the import machinery shutting down). For this\n reason, "__del__()" methods should do the absolute minimum needed\n to maintain external invariants. Starting with version 1.5,\n Python guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the "__del__()" method is called.\n\nobject.__repr__(self)\n\n Called by the "repr()" built-in function to compute the "official"\n string representation of an object. If at all possible, this\n should look like a valid Python expression that could be used to\n recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n "<...some useful description...>" should be returned. The return\n value must be a string object. If a class defines "__repr__()" but\n not "__str__()", then "__repr__()" is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by "str(object)" and the built-in functions "format()" and\n "print()" to compute the "informal" or nicely printable string\n representation of an object. The return value must be a *string*\n object.\n\n This method differs from "object.__repr__()" in that there is no\n expectation that "__str__()" return a valid Python expression: a\n more convenient or concise representation can be used.\n\n The default implementation defined by the built-in type "object"\n calls "object.__repr__()".\n\nobject.__bytes__(self)\n\n Called by "bytes()" to compute a byte-string representation of an\n object. This should return a "bytes" object.\n\nobject.__format__(self, format_spec)\n\n Called by the "format()" built-in function (and by extension, the\n "str.format()" method of class "str") to produce a "formatted"\n string representation of an object. The "format_spec" argument is a\n string that contains a description of the formatting options\n desired. The interpretation of the "format_spec" argument is up to\n the type implementing "__format__()", however most classes will\n either delegate formatting to one of the built-in types, or use a\n similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\n Changed in version 3.4: The __format__ method of "object" itself\n raises a "TypeError" if passed any non-empty string.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: "xy" calls\n "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n\n A rich comparison method may return the singleton "NotImplemented"\n if it does not implement the operation for a given pair of\n arguments. By convention, "False" and "True" are returned for a\n successful comparison. However, these methods can return any value,\n so if the comparison operator is used in a Boolean context (e.g.,\n in the condition of an "if" statement), Python will call "bool()"\n on the value to determine if the result is true or false.\n\n By default, "__ne__()" delegates to "__eq__()" and inverts the\n result unless it is "NotImplemented". There are no other implied\n relationships among the comparison operators, for example, the\n truth of "(x.__hash__".\n\n If a class that does not override "__eq__()" wishes to suppress\n hash support, it should include "__hash__ = None" in the class\n definition. A class which defines its own "__hash__()" that\n explicitly raises a "TypeError" would be incorrectly identified as\n hashable by an "isinstance(obj, collections.Hashable)" call.\n\n Note: By default, the "__hash__()" values of str, bytes and\n datetime objects are "salted" with an unpredictable random value.\n Although they remain constant within an individual Python\n process, they are not predictable between repeated invocations of\n Python.This is intended to provide protection against a denial-\n of-service caused by carefully-chosen inputs that exploit the\n worst case performance of a dict insertion, O(n^2) complexity.\n See http://www.ocert.org/advisories/ocert-2011-003.html for\n details.Changing hash values affects the iteration order of\n dicts, sets and other mappings. Python has never made guarantees\n about this ordering (and it typically varies between 32-bit and\n 64-bit builds).See also "PYTHONHASHSEED".\n\n Changed in version 3.3: Hash randomization is enabled by default.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n "bool()"; should return "False" or "True". When this method is not\n defined, "__len__()" is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither "__len__()" nor "__bool__()", all its instances are\n considered true.\n', + 'debugger': u'\n"pdb" --- The Python Debugger\n*****************************\n\n**Source code:** Lib/pdb.py\n\n======================================================================\n\nThe module "pdb" defines an interactive source code debugger for\nPython programs. It supports setting (conditional) breakpoints and\nsingle stepping at the source line level, inspection of stack frames,\nsource code listing, and evaluation of arbitrary Python code in the\ncontext of any stack frame. It also supports post-mortem debugging\nand can be called under program control.\n\nThe debugger is extensible -- it is actually defined as the class\n"Pdb". This is currently undocumented but easily understood by reading\nthe source. The extension interface uses the modules "bdb" and "cmd".\n\nThe debugger\'s prompt is "(Pdb)". Typical usage to run a program under\ncontrol of the debugger is:\n\n >>> import pdb\n >>> import mymodule\n >>> pdb.run(\'mymodule.test()\')\n > (0)?()\n (Pdb) continue\n > (1)?()\n (Pdb) continue\n NameError: \'spam\'\n > (1)?()\n (Pdb)\n\nChanged in version 3.3: Tab-completion via the "readline" module is\navailable for commands and command arguments, e.g. the current global\nand local names are offered as arguments of the "p" command.\n\n"pdb.py" can also be invoked as a script to debug other scripts. For\nexample:\n\n python3 -m pdb myscript.py\n\nWhen invoked as a script, pdb will automatically enter post-mortem\ndebugging if the program being debugged exits abnormally. After post-\nmortem debugging (or after normal exit of the program), pdb will\nrestart the program. Automatic restarting preserves pdb\'s state (such\nas breakpoints) and in most cases is more useful than quitting the\ndebugger upon program\'s exit.\n\nNew in version 3.2: "pdb.py" now accepts a "-c" option that executes\ncommands as if given in a ".pdbrc" file, see *Debugger Commands*.\n\nThe typical usage to break into the debugger from a running program is\nto insert\n\n import pdb; pdb.set_trace()\n\nat the location you want to break into the debugger. You can then\nstep through the code following this statement, and continue running\nwithout the debugger using the "continue" command.\n\nThe typical usage to inspect a crashed program is:\n\n >>> import pdb\n >>> import mymodule\n >>> mymodule.test()\n Traceback (most recent call last):\n File "", line 1, in ?\n File "./mymodule.py", line 4, in test\n test2()\n File "./mymodule.py", line 3, in test2\n print(spam)\n NameError: spam\n >>> pdb.pm()\n > ./mymodule.py(3)test2()\n -> print(spam)\n (Pdb)\n\nThe module defines the following functions; each enters the debugger\nin a slightly different way:\n\npdb.run(statement, globals=None, locals=None)\n\n Execute the *statement* (given as a string or a code object) under\n debugger control. The debugger prompt appears before any code is\n executed; you can set breakpoints and type "continue", or you can\n step through the statement using "step" or "next" (all these\n commands are explained below). The optional *globals* and *locals*\n arguments specify the environment in which the code is executed; by\n default the dictionary of the module "__main__" is used. (See the\n explanation of the built-in "exec()" or "eval()" functions.)\n\npdb.runeval(expression, globals=None, locals=None)\n\n Evaluate the *expression* (given as a string or a code object)\n under debugger control. When "runeval()" returns, it returns the\n value of the expression. Otherwise this function is similar to\n "run()".\n\npdb.runcall(function, *args, **kwds)\n\n Call the *function* (a function or method object, not a string)\n with the given arguments. When "runcall()" returns, it returns\n whatever the function call returned. The debugger prompt appears\n as soon as the function is entered.\n\npdb.set_trace()\n\n Enter the debugger at the calling stack frame. This is useful to\n hard-code a breakpoint at a given point in a program, even if the\n code is not otherwise being debugged (e.g. when an assertion\n fails).\n\npdb.post_mortem(traceback=None)\n\n Enter post-mortem debugging of the given *traceback* object. If no\n *traceback* is given, it uses the one of the exception that is\n currently being handled (an exception must be being handled if the\n default is to be used).\n\npdb.pm()\n\n Enter post-mortem debugging of the traceback found in\n "sys.last_traceback".\n\nThe "run*" functions and "set_trace()" are aliases for instantiating\nthe "Pdb" class and calling the method of the same name. If you want\nto access further features, you have to do this yourself:\n\nclass class pdb.Pdb(completekey=\'tab\', stdin=None, stdout=None, skip=None, nosigint=False)\n\n "Pdb" is the debugger class.\n\n The *completekey*, *stdin* and *stdout* arguments are passed to the\n underlying "cmd.Cmd" class; see the description there.\n\n The *skip* argument, if given, must be an iterable of glob-style\n module name patterns. The debugger will not step into frames that\n originate in a module that matches one of these patterns. [1]\n\n By default, Pdb sets a handler for the SIGINT signal (which is sent\n when the user presses "Ctrl-C" on the console) when you give a\n "continue" command. This allows you to break into the debugger\n again by pressing "Ctrl-C". If you want Pdb not to touch the\n SIGINT handler, set *nosigint* tot true.\n\n Example call to enable tracing with *skip*:\n\n import pdb; pdb.Pdb(skip=[\'django.*\']).set_trace()\n\n New in version 3.1: The *skip* argument.\n\n New in version 3.2: The *nosigint* argument. Previously, a SIGINT\n handler was never set by Pdb.\n\n run(statement, globals=None, locals=None)\n runeval(expression, globals=None, locals=None)\n runcall(function, *args, **kwds)\n set_trace()\n\n See the documentation for the functions explained above.\n\n\nDebugger Commands\n=================\n\nThe commands recognized by the debugger are listed below. Most\ncommands can be abbreviated to one or two letters as indicated; e.g.\n"h(elp)" means that either "h" or "help" can be used to enter the help\ncommand (but not "he" or "hel", nor "H" or "Help" or "HELP").\nArguments to commands must be separated by whitespace (spaces or\ntabs). Optional arguments are enclosed in square brackets ("[]") in\nthe command syntax; the square brackets must not be typed.\nAlternatives in the command syntax are separated by a vertical bar\n("|").\n\nEntering a blank line repeats the last command entered. Exception: if\nthe last command was a "list" command, the next 11 lines are listed.\n\nCommands that the debugger doesn\'t recognize are assumed to be Python\nstatements and are executed in the context of the program being\ndebugged. Python statements can also be prefixed with an exclamation\npoint ("!"). This is a powerful way to inspect the program being\ndebugged; it is even possible to change a variable or call a function.\nWhen an exception occurs in such a statement, the exception name is\nprinted but the debugger\'s state is not changed.\n\nThe debugger supports *aliases*. Aliases can have parameters which\nallows one a certain level of adaptability to the context under\nexamination.\n\nMultiple commands may be entered on a single line, separated by ";;".\n(A single ";" is not used as it is the separator for multiple commands\nin a line that is passed to the Python parser.) No intelligence is\napplied to separating the commands; the input is split at the first\n";;" pair, even if it is in the middle of a quoted string.\n\nIf a file ".pdbrc" exists in the user\'s home directory or in the\ncurrent directory, it is read in and executed as if it had been typed\nat the debugger prompt. This is particularly useful for aliases. If\nboth files exist, the one in the home directory is read first and\naliases defined there can be overridden by the local file.\n\nChanged in version 3.2: ".pdbrc" can now contain commands that\ncontinue debugging, such as "continue" or "next". Previously, these\ncommands had no effect.\n\nh(elp) [command]\n\n Without argument, print the list of available commands. With a\n *command* as argument, print help about that command. "help pdb"\n displays the full documentation (the docstring of the "pdb"\n module). Since the *command* argument must be an identifier, "help\n exec" must be entered to get help on the "!" command.\n\nw(here)\n\n Print a stack trace, with the most recent frame at the bottom. An\n arrow indicates the current frame, which determines the context of\n most commands.\n\nd(own) [count]\n\n Move the current frame *count* (default one) levels down in the\n stack trace (to a newer frame).\n\nu(p) [count]\n\n Move the current frame *count* (default one) levels up in the stack\n trace (to an older frame).\n\nb(reak) [([filename:]lineno | function) [, condition]]\n\n With a *lineno* argument, set a break there in the current file.\n With a *function* argument, set a break at the first executable\n statement within that function. The line number may be prefixed\n with a filename and a colon, to specify a breakpoint in another\n file (probably one that hasn\'t been loaded yet). The file is\n searched on "sys.path". Note that each breakpoint is assigned a\n number to which all the other breakpoint commands refer.\n\n If a second argument is present, it is an expression which must\n evaluate to true before the breakpoint is honored.\n\n Without argument, list all breaks, including for each breakpoint,\n the number of times that breakpoint has been hit, the current\n ignore count, and the associated condition if any.\n\ntbreak [([filename:]lineno | function) [, condition]]\n\n Temporary breakpoint, which is removed automatically when it is\n first hit. The arguments are the same as for "break".\n\ncl(ear) [filename:lineno | bpnumber [bpnumber ...]]\n\n With a *filename:lineno* argument, clear all the breakpoints at\n this line. With a space separated list of breakpoint numbers, clear\n those breakpoints. Without argument, clear all breaks (but first\n ask confirmation).\n\ndisable [bpnumber [bpnumber ...]]\n\n Disable the breakpoints given as a space separated list of\n breakpoint numbers. Disabling a breakpoint means it cannot cause\n the program to stop execution, but unlike clearing a breakpoint, it\n remains in the list of breakpoints and can be (re-)enabled.\n\nenable [bpnumber [bpnumber ...]]\n\n Enable the breakpoints specified.\n\nignore bpnumber [count]\n\n Set the ignore count for the given breakpoint number. If count is\n omitted, the ignore count is set to 0. A breakpoint becomes active\n when the ignore count is zero. When non-zero, the count is\n decremented each time the breakpoint is reached and the breakpoint\n is not disabled and any associated condition evaluates to true.\n\ncondition bpnumber [condition]\n\n Set a new *condition* for the breakpoint, an expression which must\n evaluate to true before the breakpoint is honored. If *condition*\n is absent, any existing condition is removed; i.e., the breakpoint\n is made unconditional.\n\ncommands [bpnumber]\n\n Specify a list of commands for breakpoint number *bpnumber*. The\n commands themselves appear on the following lines. Type a line\n containing just "end" to terminate the commands. An example:\n\n (Pdb) commands 1\n (com) p some_variable\n (com) end\n (Pdb)\n\n To remove all commands from a breakpoint, type commands and follow\n it immediately with "end"; that is, give no commands.\n\n With no *bpnumber* argument, commands refers to the last breakpoint\n set.\n\n You can use breakpoint commands to start your program up again.\n Simply use the continue command, or step, or any other command that\n resumes execution.\n\n Specifying any command resuming execution (currently continue,\n step, next, return, jump, quit and their abbreviations) terminates\n the command list (as if that command was immediately followed by\n end). This is because any time you resume execution (even with a\n simple next or step), you may encounter another breakpoint--which\n could have its own command list, leading to ambiguities about which\n list to execute.\n\n If you use the \'silent\' command in the command list, the usual\n message about stopping at a breakpoint is not printed. This may be\n desirable for breakpoints that are to print a specific message and\n then continue. If none of the other commands print anything, you\n see no sign that the breakpoint was reached.\n\ns(tep)\n\n Execute the current line, stop at the first possible occasion\n (either in a function that is called or on the next line in the\n current function).\n\nn(ext)\n\n Continue execution until the next line in the current function is\n reached or it returns. (The difference between "next" and "step"\n is that "step" stops inside a called function, while "next"\n executes called functions at (nearly) full speed, only stopping at\n the next line in the current function.)\n\nunt(il) [lineno]\n\n Without argument, continue execution until the line with a number\n greater than the current one is reached.\n\n With a line number, continue execution until a line with a number\n greater or equal to that is reached. In both cases, also stop when\n the current frame returns.\n\n Changed in version 3.2: Allow giving an explicit line number.\n\nr(eturn)\n\n Continue execution until the current function returns.\n\nc(ont(inue))\n\n Continue execution, only stop when a breakpoint is encountered.\n\nj(ump) lineno\n\n Set the next line that will be executed. Only available in the\n bottom-most frame. This lets you jump back and execute code again,\n or jump forward to skip code that you don\'t want to run.\n\n It should be noted that not all jumps are allowed -- for instance\n it is not possible to jump into the middle of a "for" loop or out\n of a "finally" clause.\n\nl(ist) [first[, last]]\n\n List source code for the current file. Without arguments, list 11\n lines around the current line or continue the previous listing.\n With "." as argument, list 11 lines around the current line. With\n one argument, list 11 lines around at that line. With two\n arguments, list the given range; if the second argument is less\n than the first, it is interpreted as a count.\n\n The current line in the current frame is indicated by "->". If an\n exception is being debugged, the line where the exception was\n originally raised or propagated is indicated by ">>", if it differs\n from the current line.\n\n New in version 3.2: The ">>" marker.\n\nll | longlist\n\n List all source code for the current function or frame.\n Interesting lines are marked as for "list".\n\n New in version 3.2.\n\na(rgs)\n\n Print the argument list of the current function.\n\np expression\n\n Evaluate the *expression* in the current context and print its\n value.\n\n Note: "print()" can also be used, but is not a debugger command\n --- this executes the Python "print()" function.\n\npp expression\n\n Like the "p" command, except the value of the expression is pretty-\n printed using the "pprint" module.\n\nwhatis expression\n\n Print the type of the *expression*.\n\nsource expression\n\n Try to get source code for the given object and display it.\n\n New in version 3.2.\n\ndisplay [expression]\n\n Display the value of the expression if it changed, each time\n execution stops in the current frame.\n\n Without expression, list all display expressions for the current\n frame.\n\n New in version 3.2.\n\nundisplay [expression]\n\n Do not display the expression any more in the current frame.\n Without expression, clear all display expressions for the current\n frame.\n\n New in version 3.2.\n\ninteract\n\n Start an interative interpreter (using the "code" module) whose\n global namespace contains all the (global and local) names found in\n the current scope.\n\n New in version 3.2.\n\nalias [name [command]]\n\n Create an alias called *name* that executes *command*. The command\n must *not* be enclosed in quotes. Replaceable parameters can be\n indicated by "%1", "%2", and so on, while "%*" is replaced by all\n the parameters. If no command is given, the current alias for\n *name* is shown. If no arguments are given, all aliases are listed.\n\n Aliases may be nested and can contain anything that can be legally\n typed at the pdb prompt. Note that internal pdb commands *can* be\n overridden by aliases. Such a command is then hidden until the\n alias is removed. Aliasing is recursively applied to the first\n word of the command line; all other words in the line are left\n alone.\n\n As an example, here are two useful aliases (especially when placed\n in the ".pdbrc" file):\n\n # Print instance variables (usage "pi classInst")\n alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])\n # Print instance variables in self\n alias ps pi self\n\nunalias name\n\n Delete the specified alias.\n\n! statement\n\n Execute the (one-line) *statement* in the context of the current\n stack frame. The exclamation point can be omitted unless the first\n word of the statement resembles a debugger command. To set a\n global variable, you can prefix the assignment command with a\n "global" statement on the same line, e.g.:\n\n (Pdb) global list_options; list_options = [\'-l\']\n (Pdb)\n\nrun [args ...]\nrestart [args ...]\n\n Restart the debugged Python program. If an argument is supplied,\n it is split with "shlex" and the result is used as the new\n "sys.argv". History, breakpoints, actions and debugger options are\n preserved. "restart" is an alias for "run".\n\nq(uit)\n\n Quit from the debugger. The program being executed is aborted.\n\n-[ Footnotes ]-\n\n[1] Whether a frame is considered to originate in a certain module\n is determined by the "__name__" in the frame globals.\n', 'del': u'\nThe "del" statement\n*******************\n\n del_stmt ::= "del" target_list\n\nDeletion is recursively defined very similar to the way assignment is\ndefined. Rather than spelling it out in full details, here are some\nhints.\n\nDeletion of a target list recursively deletes each target, from left\nto right.\n\nDeletion of a name removes the binding of that name from the local or\nglobal namespace, depending on whether the name occurs in a "global"\nstatement in the same code block. If the name is unbound, a\n"NameError" exception will be raised.\n\nDeletion of attribute references, subscriptions and slicings is passed\nto the primary object involved; deletion of a slicing is in general\nequivalent to assignment of an empty slice of the right type (but even\nthis is determined by the sliced object).\n\nChanged in version 3.2: Previously it was illegal to delete a name\nfrom the local namespace if it occurs as a free variable in a nested\nblock.\n', 'dict': u'\nDictionary displays\n*******************\n\nA dictionary display is a possibly empty series of key/datum pairs\nenclosed in curly braces:\n\n dict_display ::= "{" [key_datum_list | dict_comprehension] "}"\n key_datum_list ::= key_datum ("," key_datum)* [","]\n key_datum ::= expression ":" expression\n dict_comprehension ::= expression ":" expression comp_for\n\nA dictionary display yields a new dictionary object.\n\nIf a comma-separated sequence of key/datum pairs is given, they are\nevaluated from left to right to define the entries of the dictionary:\neach key object is used as a key into the dictionary to store the\ncorresponding datum. This means that you can specify the same key\nmultiple times in the key/datum list, and the final dictionary\'s value\nfor that key will be the last one given.\n\nA dict comprehension, in contrast to list and set comprehensions,\nneeds two expressions separated with a colon followed by the usual\n"for" and "if" clauses. When the comprehension is run, the resulting\nkey and value elements are inserted in the new dictionary in the order\nthey are produced.\n\nRestrictions on the types of the key values are listed earlier in\nsection *The standard type hierarchy*. (To summarize, the key type\nshould be *hashable*, which excludes all mutable objects.) Clashes\nbetween duplicate keys are not detected; the last datum (textually\nrightmost in the display) stored for a given key value prevails.\n', - 'dynamic-features': u'\nInteraction with dynamic features\n*********************************\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- "import *" --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a "SyntaxError".\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n', + 'dynamic-features': u'\nInteraction with dynamic features\n*********************************\n\nName resolution of free variables occurs at runtime, not at compile\ntime. This means that the following code will print 42:\n\n i = 10\n def f():\n print(i)\n i = 42\n f()\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n', 'else': u'\nThe "if" statement\n******************\n\nThe "if" statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the "if" statement is executed or evaluated).\nIf all expressions are false, the suite of the "else" clause, if\npresent, is executed.\n', 'exceptions': u'\nExceptions\n**********\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the "raise" statement. Exception\nhandlers are specified with the "try" ... "except" statement. The\n"finally" clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n"SystemExit".\n\nExceptions are identified by class instances. The "except" clause is\nselected depending on the class of the instance: it must reference the\nclass of the instance or a base class thereof. The instance can be\nreceived by the handler and can carry additional information about the\nexceptional condition.\n\nNote: Exception messages are not part of the Python API. Their\n contents may change from one version of Python to the next without\n warning and should not be relied on by code which will run under\n multiple versions of the interpreter.\n\nSee also the description of the "try" statement in section *The try\nstatement* and "raise" statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by\n these operations is not available at the time the module is\n compiled.\n', - 'execmodel': u'\nExecution model\n***************\n\n\nNaming and binding\n==================\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\nas a command line argument to the interpreter) is a code block. A\nscript command (a command specified on the interpreter command line\nwith the \'**-c**\' option) is a code block. The string argument passed\nto the built-in functions "eval()" and "exec()" is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block\'s execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes comprehensions and generator\nexpressions since they are implemented using a function scope. This\nmeans that the following will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as "nonlocal". If a name is bound at the module\nlevel, it is a global variable. (The variables of the module code\nblock are local and global.) If a variable is used in a code block\nbut not defined there, it is a *free variable*.\n\nWhen a name is not found at all, a "NameError" exception is raised.\nIf the name refers to a local variable that has not been bound, an\n"UnboundLocalError" exception is raised. "UnboundLocalError" is a\nsubclass of "NameError".\n\nThe following constructs bind names: formal parameters to functions,\n"import" statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, "for" loop header, or after\n"as" in a "with" statement or "except" clause. The "import" statement\nof the form "from ... import *" binds all names defined in the\nimported module, except those beginning with an underscore. This form\nmay only be used at the module level.\n\nA target occurring in a "del" statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the "global" statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module "builtins". The global namespace is searched first. If\nthe name is not found there, the builtins namespace is searched. The\n"global" statement must precede all uses of the name.\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name "__builtins__" in its global\nnamespace; this should be a dictionary or a module (in the latter case\nthe module\'s dictionary is used). By default, when in the "__main__"\nmodule, "__builtins__" is the built-in module "builtins"; when in any\nother module, "__builtins__" is an alias for the dictionary of the\n"builtins" module itself. "__builtins__" can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n"__builtins__"; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should "import"\nthe "builtins" module and modify its attributes appropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n"__main__".\n\nThe "global" statement has the same scope as a name binding operation\nin the same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n---------------------------------\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- "import *" --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a "SyntaxError".\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n\n\nExceptions\n==========\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the "raise" statement. Exception\nhandlers are specified with the "try" ... "except" statement. The\n"finally" clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n"SystemExit".\n\nExceptions are identified by class instances. The "except" clause is\nselected depending on the class of the instance: it must reference the\nclass of the instance or a base class thereof. The instance can be\nreceived by the handler and can carry additional information about the\nexceptional condition.\n\nNote: Exception messages are not part of the Python API. Their\n contents may change from one version of Python to the next without\n warning and should not be relied on by code which will run under\n multiple versions of the interpreter.\n\nSee also the description of the "try" statement in section *The try\nstatement* and "raise" statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by\n these operations is not available at the time the module is\n compiled.\n', + 'execmodel': u'\nExecution model\n***************\n\n\nStructure of a program\n======================\n\nA Python program is constructed from code blocks. A *block* is a piece\nof Python program text that is executed as a unit. The following are\nblocks: a module, a function body, and a class definition. Each\ncommand typed interactively is a block. A script file (a file given\nas standard input to the interpreter or specified as a command line\nargument to the interpreter) is a code block. A script command (a\ncommand specified on the interpreter command line with the \'**-c**\'\noption) is a code block. The string argument passed to the built-in\nfunctions "eval()" and "exec()" is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block\'s execution has\ncompleted.\n\n\nNaming and binding\n==================\n\n\nBinding of names\n----------------\n\n*Names* refer to objects. Names are introduced by name binding\noperations.\n\nThe following constructs bind names: formal parameters to functions,\n"import" statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, "for" loop header, or after\n"as" in a "with" statement or "except" clause. The "import" statement\nof the form "from ... import *" binds all names defined in the\nimported module, except those beginning with an underscore. This form\nmay only be used at the module level.\n\nA target occurring in a "del" statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as "nonlocal" or "global". If a name is bound at the\nmodule level, it is a global variable. (The variables of the module\ncode block are local and global.) If a variable is used in a code\nblock but not defined there, it is a *free variable*.\n\nEach occurrence of a name in the program text refers to the *binding*\nof that name established by the following name resolution rules.\n\n\nResolution of names\n-------------------\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name.\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nWhen a name is not found at all, a "NameError" exception is raised. If\nthe current scope is a function scope, and the name refers to a local\nvariable that has not yet been bound to a value at the point where the\nname is used, an "UnboundLocalError" exception is raised.\n"UnboundLocalError" is a subclass of "NameError".\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the "global" statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module "builtins". The global namespace is searched first. If\nthe name is not found there, the builtins namespace is searched. The\n"global" statement must precede all uses of the name.\n\nThe "global" statement has the same scope as a name binding operation\nin the same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nThe "nonlocal" statement causes corresponding names to refer to\npreviously bound variables in the nearest enclosing function scope.\n"SyntaxError" is raised at compile time if the given name does not\nexist in any enclosing function scope.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n"__main__".\n\nClass definition blocks and arguments to "exec()" and "eval()" are\nspecial in the context of name resolution. A class definition is an\nexecutable statement that may use and define names. These references\nfollow the normal rules for name resolution with an exception that\nunbound local variables are looked up in the global namespace. The\nnamespace of the class definition becomes the attribute dictionary of\nthe class. The scope of names defined in a class block is limited to\nthe class block; it does not extend to the code blocks of methods --\nthis includes comprehensions and generator expressions since they are\nimplemented using a function scope. This means that the following\nwill fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\n\nBuiltins and restricted execution\n---------------------------------\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name "__builtins__" in its global\nnamespace; this should be a dictionary or a module (in the latter case\nthe module\'s dictionary is used). By default, when in the "__main__"\nmodule, "__builtins__" is the built-in module "builtins"; when in any\nother module, "__builtins__" is an alias for the dictionary of the\n"builtins" module itself. "__builtins__" can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n"__builtins__"; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should "import"\nthe "builtins" module and modify its attributes appropriately.\n\n\nInteraction with dynamic features\n---------------------------------\n\nName resolution of free variables occurs at runtime, not at compile\ntime. This means that the following code will print 42:\n\n i = 10\n def f():\n print(i)\n i = 42\n f()\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n\n\nExceptions\n==========\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the "raise" statement. Exception\nhandlers are specified with the "try" ... "except" statement. The\n"finally" clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n"SystemExit".\n\nExceptions are identified by class instances. The "except" clause is\nselected depending on the class of the instance: it must reference the\nclass of the instance or a base class thereof. The instance can be\nreceived by the handler and can carry additional information about the\nexceptional condition.\n\nNote: Exception messages are not part of the Python API. Their\n contents may change from one version of Python to the next without\n warning and should not be relied on by code which will run under\n multiple versions of the interpreter.\n\nSee also the description of the "try" statement in section *The try\nstatement* and "raise" statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by\n these operations is not available at the time the module is\n compiled.\n', 'exprlists': u'\nExpression lists\n****************\n\n expression_list ::= expression ( "," expression )* [","]\n\nAn expression list containing at least one comma yields a tuple. The\nlength of the tuple is the number of expressions in the list. The\nexpressions are evaluated from left to right.\n\nThe trailing comma is required only to create a single tuple (a.k.a. a\n*singleton*); it is optional in all other cases. A single expression\nwithout a trailing comma doesn\'t create a tuple, but rather yields the\nvalue of that expression. (To create an empty tuple, use an empty pair\nof parentheses: "()".)\n', 'floating': u'\nFloating point literals\n***********************\n\nFloating point literals are described by the following lexical\ndefinitions:\n\n floatnumber ::= pointfloat | exponentfloat\n pointfloat ::= [intpart] fraction | intpart "."\n exponentfloat ::= (intpart | pointfloat) exponent\n intpart ::= digit+\n fraction ::= "." digit+\n exponent ::= ("e" | "E") ["+" | "-"] digit+\n\nNote that the integer and exponent parts are always interpreted using\nradix 10. For example, "077e010" is legal, and denotes the same number\nas "77e10". The allowed range of floating point literals is\nimplementation-dependent. Some examples of floating point literals:\n\n 3.14 10. .001 1e100 3.14e-10 0e0\n\nNote that numeric literals do not include a sign; a phrase like "-1"\nis actually an expression composed of the unary operator "-" and the\nliteral "1".\n', 'for': u'\nThe "for" statement\n*******************\n\nThe "for" statement is used to iterate over the elements of a sequence\n(such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n"expression_list". The suite is then executed once for each item\nprovided by the iterator, in the order returned by the iterator. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted. When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a "StopIteration" exception),\nthe suite in the "else" clause, if present, is executed, and the loop\nterminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and continues\nwith the next item, or with the "else" clause if there is no next\nitem.\n\nThe for-loop makes assignments to the variables(s) in the target list.\nThis overwrites all previous assignments to those variables including\nthose made in the suite of the for-loop:\n\n for i in range(10):\n print(i)\n i = 5 # this will not affect the for-loop\n # because i will be overwritten with the next\n # index in the range\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, they will not have been assigned to at\nall by the loop. Hint: the built-in function "range()" returns an\niterator of integers suitable to emulate the effect of Pascal\'s "for i\n:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".\n\nNote: There is a subtlety when the sequence is being modified by the\n loop (this can only occur for mutable sequences, i.e. lists). An\n internal counter is used to keep track of which item is used next,\n and this is incremented on each iteration. When this counter has\n reached the length of the sequence the loop terminates. This means\n that if the suite deletes the current (or a previous) item from the\n sequence, the next item will be skipped (since it gets the index of\n the current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n', @@ -42,16 +42,16 @@ 'if': u'\nThe "if" statement\n******************\n\nThe "if" statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the "if" statement is executed or evaluated).\nIf all expressions are false, the suite of the "else" clause, if\npresent, is executed.\n', 'imaginary': u'\nImaginary literals\n******************\n\nImaginary literals are described by the following lexical definitions:\n\n imagnumber ::= (floatnumber | intpart) ("j" | "J")\n\nAn imaginary literal yields a complex number with a real part of 0.0.\nComplex numbers are represented as a pair of floating point numbers\nand have the same restrictions on their range. To create a complex\nnumber with a nonzero real part, add a floating point number to it,\ne.g., "(3+4j)". Some examples of imaginary literals:\n\n 3.14j 10.j 10j .001j 1e100j 3.14e-10j\n', 'import': u'\nThe "import" statement\n**********************\n\n import_stmt ::= "import" module ["as" name] ( "," module ["as" name] )*\n | "from" relative_module "import" identifier ["as" name]\n ( "," identifier ["as" name] )*\n | "from" relative_module "import" "(" identifier ["as" name]\n ( "," identifier ["as" name] )* [","] ")"\n | "from" module "import" "*"\n module ::= (identifier ".")* identifier\n relative_module ::= "."* module | "."+\n name ::= identifier\n\nThe basic import statement (no "from" clause) is executed in two\nsteps:\n\n1. find a module, loading and initializing it if necessary\n\n2. define a name or names in the local namespace for the scope\n where the "import" statement occurs.\n\nWhen the statement contains multiple clauses (separated by commas) the\ntwo steps are carried out separately for each clause, just as though\nthe clauses had been separated out into individiual import statements.\n\nThe details of the first step, finding and loading modules are\ndescribed in greater detail in the section on the *import system*,\nwhich also describes the various types of packages and modules that\ncan be imported, as well as all the hooks that can be used to\ncustomize the import system. Note that failures in this step may\nindicate either that the module could not be located, *or* that an\nerror occurred while initializing the module, which includes execution\nof the module\'s code.\n\nIf the requested module is retrieved successfully, it will be made\navailable in the local namespace in one of three ways:\n\n* If the module name is followed by "as", then the name following\n "as" is bound directly to the imported module.\n\n* If no other name is specified, and the module being imported is a\n top level module, the module\'s name is bound in the local namespace\n as a reference to the imported module\n\n* If the module being imported is *not* a top level module, then the\n name of the top level package that contains the module is bound in\n the local namespace as a reference to the top level package. The\n imported module must be accessed using its full qualified name\n rather than directly\n\nThe "from" form uses a slightly more complex process:\n\n1. find the module specified in the "from" clause, loading and\n initializing it if necessary;\n\n2. for each of the identifiers specified in the "import" clauses:\n\n 1. check if the imported module has an attribute by that name\n\n 2. if not, attempt to import a submodule with that name and then\n check the imported module again for that attribute\n\n 3. if the attribute is not found, "ImportError" is raised.\n\n 4. otherwise, a reference to that value is stored in the local\n namespace, using the name in the "as" clause if it is present,\n otherwise using the attribute name\n\nExamples:\n\n import foo # foo imported and bound locally\n import foo.bar.baz # foo.bar.baz imported, foo bound locally\n import foo.bar.baz as fbb # foo.bar.baz imported and bound as fbb\n from foo.bar import baz # foo.bar.baz imported and bound as baz\n from foo import attr # foo imported and foo.attr bound as attr\n\nIf the list of identifiers is replaced by a star ("\'*\'"), all public\nnames defined in the module are bound in the local namespace for the\nscope where the "import" statement occurs.\n\nThe *public names* defined by a module are determined by checking the\nmodule\'s namespace for a variable named "__all__"; if defined, it must\nbe a sequence of strings which are names defined or imported by that\nmodule. The names given in "__all__" are all considered public and\nare required to exist. If "__all__" is not defined, the set of public\nnames includes all names found in the module\'s namespace which do not\nbegin with an underscore character ("\'_\'"). "__all__" should contain\nthe entire public API. It is intended to avoid accidentally exporting\nitems that are not part of the API (such as library modules which were\nimported and used within the module).\n\nThe wild card form of import --- "from module import *" --- is only\nallowed at the module level. Attempting to use it in class or\nfunction definitions will raise a "SyntaxError".\n\nWhen specifying what module to import you do not have to specify the\nabsolute name of the module. When a module or package is contained\nwithin another package it is possible to make a relative import within\nthe same top package without having to mention the package name. By\nusing leading dots in the specified module or package after "from" you\ncan specify how high to traverse up the current package hierarchy\nwithout specifying exact names. One leading dot means the current\npackage where the module making the import exists. Two dots means up\none package level. Three dots is up two levels, etc. So if you execute\n"from . import mod" from a module in the "pkg" package then you will\nend up importing "pkg.mod". If you execute "from ..subpkg2 import mod"\nfrom within "pkg.subpkg1" you will import "pkg.subpkg2.mod". The\nspecification for relative imports is contained within **PEP 328**.\n\n"importlib.import_module()" is provided to support applications that\ndetermine dynamically the modules to be loaded.\n\n\nFuture statements\n=================\n\nA *future statement* is a directive to the compiler that a particular\nmodule should be compiled using syntax or semantics that will be\navailable in a specified future release of Python where the feature\nbecomes standard.\n\nThe future statement is intended to ease migration to future versions\nof Python that introduce incompatible changes to the language. It\nallows use of the new features on a per-module basis before the\nrelease in which the feature becomes standard.\n\n future_statement ::= "from" "__future__" "import" feature ["as" name]\n ("," feature ["as" name])*\n | "from" "__future__" "import" "(" feature ["as" name]\n ("," feature ["as" name])* [","] ")"\n feature ::= identifier\n name ::= identifier\n\nA future statement must appear near the top of the module. The only\nlines that can appear before a future statement are:\n\n* the module docstring (if any),\n\n* comments,\n\n* blank lines, and\n\n* other future statements.\n\nThe features recognized by Python 3.0 are "absolute_import",\n"division", "generators", "unicode_literals", "print_function",\n"nested_scopes" and "with_statement". They are all redundant because\nthey are always enabled, and only kept for backwards compatibility.\n\nA future statement is recognized and treated specially at compile\ntime: Changes to the semantics of core constructs are often\nimplemented by generating different code. It may even be the case\nthat a new feature introduces new incompatible syntax (such as a new\nreserved word), in which case the compiler may need to parse the\nmodule differently. Such decisions cannot be pushed off until\nruntime.\n\nFor any given release, the compiler knows which feature names have\nbeen defined, and raises a compile-time error if a future statement\ncontains a feature not known to it.\n\nThe direct runtime semantics are the same as for any import statement:\nthere is a standard module "__future__", described later, and it will\nbe imported in the usual way at the time the future statement is\nexecuted.\n\nThe interesting runtime semantics depend on the specific feature\nenabled by the future statement.\n\nNote that there is nothing special about the statement:\n\n import __future__ [as name]\n\nThat is not a future statement; it\'s an ordinary import statement with\nno special semantics or syntax restrictions.\n\nCode compiled by calls to the built-in functions "exec()" and\n"compile()" that occur in a module "M" containing a future statement\nwill, by default, use the new syntax or semantics associated with the\nfuture statement. This can be controlled by optional arguments to\n"compile()" --- see the documentation of that function for details.\n\nA future statement typed at an interactive interpreter prompt will\ntake effect for the rest of the interpreter session. If an\ninterpreter is started with the *-i* option, is passed a script name\nto execute, and the script includes a future statement, it will be in\neffect in the interactive session started after the script is\nexecuted.\n\nSee also: **PEP 236** - Back to the __future__\n\n The original proposal for the __future__ mechanism.\n', - 'in': u'\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like "a < b < c" have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: "True" or "False".\n\nComparisons can be chained arbitrarily, e.g., "x < y <= z" is\nequivalent to "x < y and y <= z", except that "y" is evaluated only\nonce (but in both cases "z" is not evaluated at all when "x < y" is\nfound to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then "a op1 b op2 c ... y\nopN z" is equivalent to "a op1 b and b op2 c and ... y opN z", except\nthat each expression is evaluated at most once.\n\nNote that "a op1 b op2 c" doesn\'t imply any kind of comparison between\n*a* and *c*, so that, e.g., "x < y > z" is perfectly legal (though\nperhaps not pretty).\n\nThe operators "<", ">", "==", ">=", "<=", and "!=" compare the values\nof two objects. The objects need not have the same type. If both are\nnumbers, they are converted to a common type. Otherwise, the "==" and\n"!=" operators *always* consider objects of different types to be\nunequal, while the "<", ">", ">=" and "<=" operators raise a\n"TypeError" when comparing objects of different types that do not\nimplement these operators for the given pair of types. You can\ncontrol comparison behavior of objects of non-built-in types by\ndefining rich comparison methods like "__gt__()", described in section\n*Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values "float(\'NaN\')" and "Decimal(\'NaN\')" are special. The\n are identical to themselves, "x is x" but are not equal to\n themselves, "x != x". Additionally, comparing any value to a\n not-a-number value will return "False". For example, both "3 <\n float(\'NaN\')" and "float(\'NaN\') < 3" will return "False".\n\n* Bytes objects are compared lexicographically using the numeric\n values of their elements.\n\n* Strings are compared lexicographically using the numeric\n equivalents (the result of the built-in function "ord()") of their\n characters. [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison\n of corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, "[1,2,x] <= [1,2,y]" has the same\n value as "x <= y". If the corresponding element does not exist, the\n shorter sequence is ordered first (for example, "[1,2] < [1,2,3]").\n\n* Mappings (dictionaries) compare equal if and only if they have the\n same "(key, value)" pairs. Order comparisons "(\'<\', \'<=\', \'>=\',\n \'>\')" raise "TypeError".\n\n* Sets and frozensets define comparison operators to mean subset and\n superset tests. Those relations do not define total orderings (the\n two sets "{1,2}" and {2,3} are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering.\n For example, "min()", "max()", and "sorted()" produce undefined\n results given a list of sets as inputs.\n\n* Most other objects of built-in types compare unequal unless they\n are the same object; the choice whether one object is considered\n smaller or larger than another one is made arbitrarily but\n consistently within one execution of a program.\n\nComparison of objects of differing types depends on whether either of\nthe types provide explicit support for the comparison. Most numeric\ntypes can be compared with one another. When cross-type comparison is\nnot supported, the comparison method returns "NotImplemented".\n\nThe operators "in" and "not in" test for membership. "x in s"\nevaluates to true if *x* is a member of *s*, and false otherwise. "x\nnot in s" returns the negation of "x in s". All built-in sequences\nand set types support this as well as dictionary, for which "in" tests\nwhether the dictionary has a given key. For container types such as\nlist, tuple, set, frozenset, dict, or collections.deque, the\nexpression "x in y" is equivalent to "any(x is e or x == e for e in\ny)".\n\nFor the string and bytes types, "x in y" is true if and only if *x* is\na substring of *y*. An equivalent test is "y.find(x) != -1". Empty\nstrings are always considered to be a substring of any other string,\nso """ in "abc"" will return "True".\n\nFor user-defined classes which define the "__contains__()" method, "x\nin y" is true if and only if "y.__contains__(x)" is true.\n\nFor user-defined classes which do not define "__contains__()" but do\ndefine "__iter__()", "x in y" is true if some value "z" with "x == z"\nis produced while iterating over "y". If an exception is raised\nduring the iteration, it is as if "in" raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n"__getitem__()", "x in y" is true if and only if there is a non-\nnegative integer index *i* such that "x == y[i]", and all lower\ninteger indices do not raise "IndexError" exception. (If any other\nexception is raised, it is as if "in" raised that exception).\n\nThe operator "not in" is defined to have the inverse true value of\n"in".\n\nThe operators "is" and "is not" test for object identity: "x is y" is\ntrue if and only if *x* and *y* are the same object. "x is not y"\nyields the inverse truth value. [4]\n', - 'integers': u'\nInteger literals\n****************\n\nInteger literals are described by the following lexical definitions:\n\n integer ::= decimalinteger | octinteger | hexinteger | bininteger\n decimalinteger ::= nonzerodigit digit* | "0"+\n nonzerodigit ::= "1"..."9"\n digit ::= "0"..."9"\n octinteger ::= "0" ("o" | "O") octdigit+\n hexinteger ::= "0" ("x" | "X") hexdigit+\n bininteger ::= "0" ("b" | "B") bindigit+\n octdigit ::= "0"..."7"\n hexdigit ::= digit | "a"..."f" | "A"..."F"\n bindigit ::= "0" | "1"\n\nThere is no limit for the length of integer literals apart from what\ncan be stored in available memory.\n\nNote that leading zeros in a non-zero decimal number are not allowed.\nThis is for disambiguation with C-style octal literals, which Python\nused before version 3.0.\n\nSome examples of integer literals:\n\n 7 2147483647 0o177 0b100110111\n 3 79228162514264337593543950336 0o377 0x100000000\n 79228162514264337593543950336 0xdeadbeef\n', + 'in': u'\nMembership test operations\n**************************\n\nThe operators "in" and "not in" test for membership. "x in s"\nevaluates to true if *x* is a member of *s*, and false otherwise. "x\nnot in s" returns the negation of "x in s". All built-in sequences\nand set types support this as well as dictionary, for which "in" tests\nwhether the dictionary has a given key. For container types such as\nlist, tuple, set, frozenset, dict, or collections.deque, the\nexpression "x in y" is equivalent to "any(x is e or x == e for e in\ny)".\n\nFor the string and bytes types, "x in y" is true if and only if *x* is\na substring of *y*. An equivalent test is "y.find(x) != -1". Empty\nstrings are always considered to be a substring of any other string,\nso """ in "abc"" will return "True".\n\nFor user-defined classes which define the "__contains__()" method, "x\nin y" is true if and only if "y.__contains__(x)" is true.\n\nFor user-defined classes which do not define "__contains__()" but do\ndefine "__iter__()", "x in y" is true if some value "z" with "x == z"\nis produced while iterating over "y". If an exception is raised\nduring the iteration, it is as if "in" raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n"__getitem__()", "x in y" is true if and only if there is a non-\nnegative integer index *i* such that "x == y[i]", and all lower\ninteger indices do not raise "IndexError" exception. (If any other\nexception is raised, it is as if "in" raised that exception).\n\nThe operator "not in" is defined to have the inverse true value of\n"in".\n', + 'integers': u'\nInteger literals\n****************\n\nInteger literals are described by the following lexical definitions:\n\n integer ::= decimalinteger | octinteger | hexinteger | bininteger\n decimalinteger ::= nonzerodigit digit* | "0"+\n nonzerodigit ::= "1"..."9"\n digit ::= "0"..."9"\n octinteger ::= "0" ("o" | "O") octdigit+\n hexinteger ::= "0" ("x" | "X") hexdigit+\n bininteger ::= "0" ("b" | "B") bindigit+\n octdigit ::= "0"..."7"\n hexdigit ::= digit | "a"..."f" | "A"..."F"\n bindigit ::= "0" | "1"\n\nThere is no limit for the length of integer literals apart from what\ncan be stored in available memory.\n\nNote that leading zeros in a non-zero decimal number are not allowed.\nThis is for disambiguation with C-style octal literals, which Python\nused before version 3.0.\n\nSome examples of integer literals:\n\n 7 2147483647 0o177 0b100110111\n 3 79228162514264337593543950336 0o377 0xdeadbeef\n', 'lambda': u'\nLambdas\n*******\n\n lambda_expr ::= "lambda" [parameter_list]: expression\n lambda_expr_nocond ::= "lambda" [parameter_list]: expression_nocond\n\nLambda expressions (sometimes called lambda forms) are used to create\nanonymous functions. The expression "lambda arguments: expression"\nyields a function object. The unnamed object behaves like a function\nobject defined with\n\n def (arguments):\n return expression\n\nSee section *Function definitions* for the syntax of parameter lists.\nNote that functions created with lambda expressions cannot contain\nstatements or annotations.\n', 'lists': u'\nList displays\n*************\n\nA list display is a possibly empty series of expressions enclosed in\nsquare brackets:\n\n list_display ::= "[" [expression_list | comprehension] "]"\n\nA list display yields a new list object, the contents being specified\nby either a list of expressions or a comprehension. When a comma-\nseparated list of expressions is supplied, its elements are evaluated\nfrom left to right and placed into the list object in that order.\nWhen a comprehension is supplied, the list is constructed from the\nelements resulting from the comprehension.\n', - 'naming': u'\nNaming and binding\n******************\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\nas a command line argument to the interpreter) is a code block. A\nscript command (a command specified on the interpreter command line\nwith the \'**-c**\' option) is a code block. The string argument passed\nto the built-in functions "eval()" and "exec()" is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block\'s execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes comprehensions and generator\nexpressions since they are implemented using a function scope. This\nmeans that the following will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as "nonlocal". If a name is bound at the module\nlevel, it is a global variable. (The variables of the module code\nblock are local and global.) If a variable is used in a code block\nbut not defined there, it is a *free variable*.\n\nWhen a name is not found at all, a "NameError" exception is raised.\nIf the name refers to a local variable that has not been bound, an\n"UnboundLocalError" exception is raised. "UnboundLocalError" is a\nsubclass of "NameError".\n\nThe following constructs bind names: formal parameters to functions,\n"import" statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, "for" loop header, or after\n"as" in a "with" statement or "except" clause. The "import" statement\nof the form "from ... import *" binds all names defined in the\nimported module, except those beginning with an underscore. This form\nmay only be used at the module level.\n\nA target occurring in a "del" statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the "global" statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module "builtins". The global namespace is searched first. If\nthe name is not found there, the builtins namespace is searched. The\n"global" statement must precede all uses of the name.\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name "__builtins__" in its global\nnamespace; this should be a dictionary or a module (in the latter case\nthe module\'s dictionary is used). By default, when in the "__main__"\nmodule, "__builtins__" is the built-in module "builtins"; when in any\nother module, "__builtins__" is an alias for the dictionary of the\n"builtins" module itself. "__builtins__" can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n"__builtins__"; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should "import"\nthe "builtins" module and modify its attributes appropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n"__main__".\n\nThe "global" statement has the same scope as a name binding operation\nin the same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n=================================\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- "import *" --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a "SyntaxError".\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n', + 'naming': u'\nNaming and binding\n******************\n\n\nBinding of names\n================\n\n*Names* refer to objects. Names are introduced by name binding\noperations.\n\nThe following constructs bind names: formal parameters to functions,\n"import" statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, "for" loop header, or after\n"as" in a "with" statement or "except" clause. The "import" statement\nof the form "from ... import *" binds all names defined in the\nimported module, except those beginning with an underscore. This form\nmay only be used at the module level.\n\nA target occurring in a "del" statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as "nonlocal" or "global". If a name is bound at the\nmodule level, it is a global variable. (The variables of the module\ncode block are local and global.) If a variable is used in a code\nblock but not defined there, it is a *free variable*.\n\nEach occurrence of a name in the program text refers to the *binding*\nof that name established by the following name resolution rules.\n\n\nResolution of names\n===================\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name.\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nWhen a name is not found at all, a "NameError" exception is raised. If\nthe current scope is a function scope, and the name refers to a local\nvariable that has not yet been bound to a value at the point where the\nname is used, an "UnboundLocalError" exception is raised.\n"UnboundLocalError" is a subclass of "NameError".\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the "global" statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module "builtins". The global namespace is searched first. If\nthe name is not found there, the builtins namespace is searched. The\n"global" statement must precede all uses of the name.\n\nThe "global" statement has the same scope as a name binding operation\nin the same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nThe "nonlocal" statement causes corresponding names to refer to\npreviously bound variables in the nearest enclosing function scope.\n"SyntaxError" is raised at compile time if the given name does not\nexist in any enclosing function scope.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n"__main__".\n\nClass definition blocks and arguments to "exec()" and "eval()" are\nspecial in the context of name resolution. A class definition is an\nexecutable statement that may use and define names. These references\nfollow the normal rules for name resolution with an exception that\nunbound local variables are looked up in the global namespace. The\nnamespace of the class definition becomes the attribute dictionary of\nthe class. The scope of names defined in a class block is limited to\nthe class block; it does not extend to the code blocks of methods --\nthis includes comprehensions and generator expressions since they are\nimplemented using a function scope. This means that the following\nwill fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\n\nBuiltins and restricted execution\n=================================\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name "__builtins__" in its global\nnamespace; this should be a dictionary or a module (in the latter case\nthe module\'s dictionary is used). By default, when in the "__main__"\nmodule, "__builtins__" is the built-in module "builtins"; when in any\nother module, "__builtins__" is an alias for the dictionary of the\n"builtins" module itself. "__builtins__" can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n"__builtins__"; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should "import"\nthe "builtins" module and modify its attributes appropriately.\n\n\nInteraction with dynamic features\n=================================\n\nName resolution of free variables occurs at runtime, not at compile\ntime. This means that the following code will print 42:\n\n i = 10\n def f():\n print(i)\n i = 42\n f()\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n', 'nonlocal': u'\nThe "nonlocal" statement\n************************\n\n nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*\n\nThe "nonlocal" statement causes the listed identifiers to refer to\npreviously bound variables in the nearest enclosing scope excluding\nglobals. This is important because the default behavior for binding is\nto search the local namespace first. The statement allows\nencapsulated code to rebind variables outside of the local scope\nbesides the global (module) scope.\n\nNames listed in a "nonlocal" statement, unlike those listed in a\n"global" statement, must refer to pre-existing bindings in an\nenclosing scope (the scope in which a new binding should be created\ncannot be determined unambiguously).\n\nNames listed in a "nonlocal" statement must not collide with pre-\nexisting bindings in the local scope.\n\nSee also: **PEP 3104** - Access to Names in Outer Scopes\n\n The specification for the "nonlocal" statement.\n', 'numbers': u'\nNumeric literals\n****************\n\nThere are three types of numeric literals: integers, floating point\nnumbers, and imaginary numbers. There are no complex literals\n(complex numbers can be formed by adding a real number and an\nimaginary number).\n\nNote that numeric literals do not include a sign; a phrase like "-1"\nis actually an expression composed of the unary operator \'"-"\' and the\nliteral "1".\n', 'numeric-types': u'\nEmulating numeric types\n***********************\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|"). For instance, to evaluate the\n expression "x + y", where *x* is an instance of a class that has an\n "__add__()" method, "x.__add__(y)" is called. The "__divmod__()"\n method should be the equivalent to using "__floordiv__()" and\n "__mod__()"; it should not be related to "__truediv__()". Note\n that "__pow__()" should be defined to accept an optional third\n argument if the ternary version of the built-in "pow()" function is\n to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return "NotImplemented".\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|") with reflected (swapped) operands.\n These functions are only called if the left operand does not\n support the corresponding operation and the operands are of\n different types. [2] For instance, to evaluate the expression "x -\n y", where *y* is an instance of a class that has an "__rsub__()"\n method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns\n *NotImplemented*.\n\n Note that ternary "pow()" will not try calling "__rpow__()" (the\n coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left\n operand\'s type and that subclass provides the reflected method\n for the operation, this method will be called before the left\n operand\'s non-reflected method. This behavior allows subclasses\n to override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments ("+=", "-=", "*=", "/=", "//=", "%=", "**=", "<<=",\n ">>=", "&=", "^=", "|="). These methods should attempt to do the\n operation in-place (modifying *self*) and return the result (which\n could be, but does not have to be, *self*). If a specific method\n is not defined, the augmented assignment falls back to the normal\n methods. For instance, if *x* is an instance of a class with an\n "__iadd__()" method, "x += y" is equivalent to "x = x.__iadd__(y)"\n . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are considered, as\n with the evaluation of "x + y". In certain situations, augmented\n assignment can result in unexpected errors (see *Why does\n a_tuple[i] += [\'item\'] raise an exception when the addition\n works?*), but this behavior is in fact part of the data model.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations ("-", "+",\n "abs()" and "~").\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions "complex()", "int()",\n "float()" and "round()". Should return a value of the appropriate\n type.\n\nobject.__index__(self)\n\n Called to implement "operator.index()", and whenever Python needs\n to losslessly convert the numeric object to an integer object (such\n as in slicing, or in the built-in "bin()", "hex()" and "oct()"\n functions). Presence of this method indicates that the numeric\n object is an integer type. Must return an integer.\n\n Note: In order to have a coherent integer type class, when\n "__index__()" is defined "__int__()" should also be defined, and\n both should return the same value.\n', 'objects': u'\nObjects, values and types\n*************************\n\n*Objects* are Python\'s abstraction for data. All data in a Python\nprogram is represented by objects or by relations between objects. (In\na sense, and in conformance to Von Neumann\'s model of a "stored\nprogram computer," code is also represented by objects.)\n\nEvery object has an identity, a type and a value. An object\'s\n*identity* never changes once it has been created; you may think of it\nas the object\'s address in memory. The \'"is"\' operator compares the\nidentity of two objects; the "id()" function returns an integer\nrepresenting its identity.\n\n**CPython implementation detail:** For CPython, "id(x)" is the memory\naddress where "x" is stored.\n\nAn object\'s type determines the operations that the object supports\n(e.g., "does it have a length?") and also defines the possible values\nfor objects of that type. The "type()" function returns an object\'s\ntype (which is an object itself). Like its identity, an object\'s\n*type* is also unchangeable. [1]\n\nThe *value* of some objects can change. Objects whose value can\nchange are said to be *mutable*; objects whose value is unchangeable\nonce they are created are called *immutable*. (The value of an\nimmutable container object that contains a reference to a mutable\nobject can change when the latter\'s value is changed; however the\ncontainer is still considered immutable, because the collection of\nobjects it contains cannot be changed. So, immutability is not\nstrictly the same as having an unchangeable value, it is more subtle.)\nAn object\'s mutability is determined by its type; for instance,\nnumbers, strings and tuples are immutable, while dictionaries and\nlists are mutable.\n\nObjects are never explicitly destroyed; however, when they become\nunreachable they may be garbage-collected. An implementation is\nallowed to postpone garbage collection or omit it altogether --- it is\na matter of implementation quality how garbage collection is\nimplemented, as long as no objects are collected that are still\nreachable.\n\n**CPython implementation detail:** CPython currently uses a reference-\ncounting scheme with (optional) delayed detection of cyclically linked\ngarbage, which collects most objects as soon as they become\nunreachable, but is not guaranteed to collect garbage containing\ncircular references. See the documentation of the "gc" module for\ninformation on controlling the collection of cyclic garbage. Other\nimplementations act differently and CPython may change. Do not depend\non immediate finalization of objects when they become unreachable (so\nyou should always close files explicitly).\n\nNote that the use of the implementation\'s tracing or debugging\nfacilities may keep objects alive that would normally be collectable.\nAlso note that catching an exception with a \'"try"..."except"\'\nstatement may keep objects alive.\n\nSome objects contain references to "external" resources such as open\nfiles or windows. It is understood that these resources are freed\nwhen the object is garbage-collected, but since garbage collection is\nnot guaranteed to happen, such objects also provide an explicit way to\nrelease the external resource, usually a "close()" method. Programs\nare strongly recommended to explicitly close such objects. The\n\'"try"..."finally"\' statement and the \'"with"\' statement provide\nconvenient ways to do this.\n\nSome objects contain references to other objects; these are called\n*containers*. Examples of containers are tuples, lists and\ndictionaries. The references are part of a container\'s value. In\nmost cases, when we talk about the value of a container, we imply the\nvalues, not the identities of the contained objects; however, when we\ntalk about the mutability of a container, only the identities of the\nimmediately contained objects are implied. So, if an immutable\ncontainer (like a tuple) contains a reference to a mutable object, its\nvalue changes if that mutable object is changed.\n\nTypes affect almost all aspects of object behavior. Even the\nimportance of object identity is affected in some sense: for immutable\ntypes, operations that compute new values may actually return a\nreference to any existing object with the same type and value, while\nfor mutable objects this is not allowed. E.g., after "a = 1; b = 1",\n"a" and "b" may or may not refer to the same object with the value\none, depending on the implementation, but after "c = []; d = []", "c"\nand "d" are guaranteed to refer to two different, unique, newly\ncreated empty lists. (Note that "c = d = []" assigns the same object\nto both "c" and "d".)\n', - 'operator-summary': u'\nOperator precedence\n*******************\n\nThe following table summarizes the operator precedence in Python, from\nlowest precedence (least binding) to highest precedence (most\nbinding). Operators in the same box have the same precedence. Unless\nthe syntax is explicitly given, operators are binary. Operators in\nthe same box group left to right (except for exponentiation, which\ngroups from right to left).\n\nNote that comparisons, membership tests, and identity tests, all have\nthe same precedence and have a left-to-right chaining feature as\ndescribed in the *Comparisons* section.\n\n+-------------------------------------------------+---------------------------------------+\n| Operator | Description |\n+=================================================+=======================================+\n| "lambda" | Lambda expression |\n+-------------------------------------------------+---------------------------------------+\n| "if" -- "else" | Conditional expression |\n+-------------------------------------------------+---------------------------------------+\n| "or" | Boolean OR |\n+-------------------------------------------------+---------------------------------------+\n| "and" | Boolean AND |\n+-------------------------------------------------+---------------------------------------+\n| "not" "x" | Boolean NOT |\n+-------------------------------------------------+---------------------------------------+\n| "in", "not in", "is", "is not", "<", "<=", ">", | Comparisons, including membership |\n| ">=", "!=", "==" | tests and identity tests |\n+-------------------------------------------------+---------------------------------------+\n| "|" | Bitwise OR |\n+-------------------------------------------------+---------------------------------------+\n| "^" | Bitwise XOR |\n+-------------------------------------------------+---------------------------------------+\n| "&" | Bitwise AND |\n+-------------------------------------------------+---------------------------------------+\n| "<<", ">>" | Shifts |\n+-------------------------------------------------+---------------------------------------+\n| "+", "-" | Addition and subtraction |\n+-------------------------------------------------+---------------------------------------+\n| "*", "/", "//", "%" | Multiplication, division, remainder |\n| | [5] |\n+-------------------------------------------------+---------------------------------------+\n| "+x", "-x", "~x" | Positive, negative, bitwise NOT |\n+-------------------------------------------------+---------------------------------------+\n| "**" | Exponentiation [6] |\n+-------------------------------------------------+---------------------------------------+\n| "x[index]", "x[index:index]", | Subscription, slicing, call, |\n| "x(arguments...)", "x.attribute" | attribute reference |\n+-------------------------------------------------+---------------------------------------+\n| "(expressions...)", "[expressions...]", "{key: | Binding or tuple display, list |\n| value...}", "{expressions...}" | display, dictionary display, set |\n| | display |\n+-------------------------------------------------+---------------------------------------+\n\n-[ Footnotes ]-\n\n[1] While "abs(x%y) < abs(y)" is true mathematically, for floats\n it may not be true numerically due to roundoff. For example, and\n assuming a platform on which a Python float is an IEEE 754 double-\n precision number, in order that "-1e-100 % 1e100" have the same\n sign as "1e100", the computed result is "-1e-100 + 1e100", which\n is numerically exactly equal to "1e100". The function\n "math.fmod()" returns a result whose sign matches the sign of the\n first argument instead, and so returns "-1e-100" in this case.\n Which approach is more appropriate depends on the application.\n\n[2] If x is very close to an exact integer multiple of y, it\'s\n possible for "x//y" to be one larger than "(x-x%y)//y" due to\n rounding. In such cases, Python returns the latter result, in\n order to preserve that "divmod(x,y)[0] * y + x % y" be very close\n to "x".\n\n[3] While comparisons between strings make sense at the byte\n level, they may be counter-intuitive to users. For example, the\n strings ""\\u00C7"" and ""\\u0327\\u0043"" compare differently, even\n though they both represent the same unicode character (LATIN\n CAPITAL LETTER C WITH CEDILLA). To compare strings in a human\n recognizable way, compare using "unicodedata.normalize()".\n\n[4] Due to automatic garbage-collection, free lists, and the\n dynamic nature of descriptors, you may notice seemingly unusual\n behaviour in certain uses of the "is" operator, like those\n involving comparisons between instance methods, or constants.\n Check their documentation for more info.\n\n[5] The "%" operator is also used for string formatting; the same\n precedence applies.\n\n[6] The power operator "**" binds less tightly than an arithmetic\n or bitwise unary operator on its right, that is, "2**-1" is "0.5".\n', + 'operator-summary': u'\nOperator precedence\n*******************\n\nThe following table summarizes the operator precedence in Python, from\nlowest precedence (least binding) to highest precedence (most\nbinding). Operators in the same box have the same precedence. Unless\nthe syntax is explicitly given, operators are binary. Operators in\nthe same box group left to right (except for exponentiation, which\ngroups from right to left).\n\nNote that comparisons, membership tests, and identity tests, all have\nthe same precedence and have a left-to-right chaining feature as\ndescribed in the *Comparisons* section.\n\n+-------------------------------------------------+---------------------------------------+\n| Operator | Description |\n+=================================================+=======================================+\n| "lambda" | Lambda expression |\n+-------------------------------------------------+---------------------------------------+\n| "if" -- "else" | Conditional expression |\n+-------------------------------------------------+---------------------------------------+\n| "or" | Boolean OR |\n+-------------------------------------------------+---------------------------------------+\n| "and" | Boolean AND |\n+-------------------------------------------------+---------------------------------------+\n| "not" "x" | Boolean NOT |\n+-------------------------------------------------+---------------------------------------+\n| "in", "not in", "is", "is not", "<", "<=", ">", | Comparisons, including membership |\n| ">=", "!=", "==" | tests and identity tests |\n+-------------------------------------------------+---------------------------------------+\n| "|" | Bitwise OR |\n+-------------------------------------------------+---------------------------------------+\n| "^" | Bitwise XOR |\n+-------------------------------------------------+---------------------------------------+\n| "&" | Bitwise AND |\n+-------------------------------------------------+---------------------------------------+\n| "<<", ">>" | Shifts |\n+-------------------------------------------------+---------------------------------------+\n| "+", "-" | Addition and subtraction |\n+-------------------------------------------------+---------------------------------------+\n| "*", "/", "//", "%" | Multiplication, division, remainder |\n| | [5] |\n+-------------------------------------------------+---------------------------------------+\n| "+x", "-x", "~x" | Positive, negative, bitwise NOT |\n+-------------------------------------------------+---------------------------------------+\n| "**" | Exponentiation [6] |\n+-------------------------------------------------+---------------------------------------+\n| "x[index]", "x[index:index]", | Subscription, slicing, call, |\n| "x(arguments...)", "x.attribute" | attribute reference |\n+-------------------------------------------------+---------------------------------------+\n| "(expressions...)", "[expressions...]", "{key: | Binding or tuple display, list |\n| value...}", "{expressions...}" | display, dictionary display, set |\n| | display |\n+-------------------------------------------------+---------------------------------------+\n\n-[ Footnotes ]-\n\n[1] While "abs(x%y) < abs(y)" is true mathematically, for floats\n it may not be true numerically due to roundoff. For example, and\n assuming a platform on which a Python float is an IEEE 754 double-\n precision number, in order that "-1e-100 % 1e100" have the same\n sign as "1e100", the computed result is "-1e-100 + 1e100", which\n is numerically exactly equal to "1e100". The function\n "math.fmod()" returns a result whose sign matches the sign of the\n first argument instead, and so returns "-1e-100" in this case.\n Which approach is more appropriate depends on the application.\n\n[2] If x is very close to an exact integer multiple of y, it\'s\n possible for "x//y" to be one larger than "(x-x%y)//y" due to\n rounding. In such cases, Python returns the latter result, in\n order to preserve that "divmod(x,y)[0] * y + x % y" be very close\n to "x".\n\n[3] The Unicode standard distinguishes between *code points* (e.g.\n U+0041) and *abstract characters* (e.g. "LATIN CAPITAL LETTER A").\n While most abstract characters in Unicode are only represented\n using one code point, there is a number of abstract characters\n that can in addition be represented using a sequence of more than\n one code point. For example, the abstract character "LATIN\n CAPITAL LETTER C WITH CEDILLA" can be represented as a single\n *precomposed character* at code position U+00C7, or as a sequence\n of a *base character* at code position U+0043 (LATIN CAPITAL\n LETTER C), followed by a *combining character* at code position\n U+0327 (COMBINING CEDILLA).\n\n The comparison operators on strings compare at the level of\n Unicode code points. This may be counter-intuitive to humans. For\n example, ""\\u00C7" == "\\u0043\\u0327"" is "False", even though both\n strings represent the same abstract character "LATIN CAPITAL\n LETTER C WITH CEDILLA".\n\n To compare strings at the level of abstract characters (that is,\n in a way intuitive to humans), use "unicodedata.normalize()".\n\n[4] Due to automatic garbage-collection, free lists, and the\n dynamic nature of descriptors, you may notice seemingly unusual\n behaviour in certain uses of the "is" operator, like those\n involving comparisons between instance methods, or constants.\n Check their documentation for more info.\n\n[5] The "%" operator is also used for string formatting; the same\n precedence applies.\n\n[6] The power operator "**" binds less tightly than an arithmetic\n or bitwise unary operator on its right, that is, "2**-1" is "0.5".\n', 'pass': u'\nThe "pass" statement\n********************\n\n pass_stmt ::= "pass"\n\n"pass" is a null operation --- when it is executed, nothing happens.\nIt is useful as a placeholder when a statement is required\nsyntactically, but no code needs to be executed, for example:\n\n def f(arg): pass # a function that does nothing (yet)\n\n class C: pass # a class with no methods (yet)\n', 'power': u'\nThe power operator\n******************\n\nThe power operator binds more tightly than unary operators on its\nleft; it binds less tightly than unary operators on its right. The\nsyntax is:\n\n power ::= primary ["**" u_expr]\n\nThus, in an unparenthesized sequence of power and unary operators, the\noperators are evaluated from right to left (this does not constrain\nthe evaluation order for the operands): "-1**2" results in "-1".\n\nThe power operator has the same semantics as the built-in "pow()"\nfunction, when called with two arguments: it yields its left argument\nraised to the power of its right argument. The numeric arguments are\nfirst converted to a common type, and the result is of that type.\n\nFor int operands, the result has the same type as the operands unless\nthe second argument is negative; in that case, all arguments are\nconverted to float and a float result is delivered. For example,\n"10**2" returns "100", but "10**-2" returns "0.01".\n\nRaising "0.0" to a negative power results in a "ZeroDivisionError".\nRaising a negative number to a fractional power results in a "complex"\nnumber. (In earlier versions it raised a "ValueError".)\n', 'raise': u'\nThe "raise" statement\n*********************\n\n raise_stmt ::= "raise" [expression ["from" expression]]\n\nIf no expressions are present, "raise" re-raises the last exception\nthat was active in the current scope. If no exception is active in\nthe current scope, a "RuntimeError" exception is raised indicating\nthat this is an error.\n\nOtherwise, "raise" evaluates the first expression as the exception\nobject. It must be either a subclass or an instance of\n"BaseException". If it is a class, the exception instance will be\nobtained when needed by instantiating the class with no arguments.\n\nThe *type* of the exception is the exception instance\'s class, the\n*value* is the instance itself.\n\nA traceback object is normally created automatically when an exception\nis raised and attached to it as the "__traceback__" attribute, which\nis writable. You can create an exception and set your own traceback in\none step using the "with_traceback()" exception method (which returns\nthe same exception instance, with its traceback set to its argument),\nlike so:\n\n raise Exception("foo occurred").with_traceback(tracebackobj)\n\nThe "from" clause is used for exception chaining: if given, the second\n*expression* must be another exception class or instance, which will\nthen be attached to the raised exception as the "__cause__" attribute\n(which is writable). If the raised exception is not handled, both\nexceptions will be printed:\n\n >>> try:\n ... print(1 / 0)\n ... except Exception as exc:\n ... raise RuntimeError("Something bad happened") from exc\n ...\n Traceback (most recent call last):\n File "", line 2, in \n ZeroDivisionError: int division or modulo by zero\n\n The above exception was the direct cause of the following exception:\n\n Traceback (most recent call last):\n File "", line 4, in \n RuntimeError: Something bad happened\n\nA similar mechanism works implicitly if an exception is raised inside\nan exception handler or a "finally" clause: the previous exception is\nthen attached as the new exception\'s "__context__" attribute:\n\n >>> try:\n ... print(1 / 0)\n ... except:\n ... raise RuntimeError("Something bad happened")\n ...\n Traceback (most recent call last):\n File "", line 2, in \n ZeroDivisionError: int division or modulo by zero\n\n During handling of the above exception, another exception occurred:\n\n Traceback (most recent call last):\n File "", line 4, in \n RuntimeError: Something bad happened\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information about handling exceptions is in section\n*The try statement*.\n', @@ -60,19 +60,19 @@ 'shifting': u'\nShifting operations\n*******************\n\nThe shifting operations have lower priority than the arithmetic\noperations:\n\n shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr\n\nThese operators accept integers as arguments. They shift the first\nargument to the left or right by the number of bits given by the\nsecond argument.\n\nA right shift by *n* bits is defined as floor division by "pow(2,n)".\nA left shift by *n* bits is defined as multiplication with "pow(2,n)".\n\nNote: In the current implementation, the right-hand operand is\n required to be at most "sys.maxsize". If the right-hand operand is\n larger than "sys.maxsize" an "OverflowError" exception is raised.\n', 'slicings': u'\nSlicings\n********\n\nA slicing selects a range of items in a sequence object (e.g., a\nstring, tuple or list). Slicings may be used as expressions or as\ntargets in assignment or "del" statements. The syntax for a slicing:\n\n slicing ::= primary "[" slice_list "]"\n slice_list ::= slice_item ("," slice_item)* [","]\n slice_item ::= expression | proper_slice\n proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" [stride] ]\n lower_bound ::= expression\n upper_bound ::= expression\n stride ::= expression\n\nThere is ambiguity in the formal syntax here: anything that looks like\nan expression list also looks like a slice list, so any subscription\ncan be interpreted as a slicing. Rather than further complicating the\nsyntax, this is disambiguated by defining that in this case the\ninterpretation as a subscription takes priority over the\ninterpretation as a slicing (this is the case if the slice list\ncontains no proper slice).\n\nThe semantics for a slicing are as follows. The primary is indexed\n(using the same "__getitem__()" method as normal subscription) with a\nkey that is constructed from the slice list, as follows. If the slice\nlist contains at least one comma, the key is a tuple containing the\nconversion of the slice items; otherwise, the conversion of the lone\nslice item is the key. The conversion of a slice item that is an\nexpression is that expression. The conversion of a proper slice is a\nslice object (see section *The standard type hierarchy*) whose\n"start", "stop" and "step" attributes are the values of the\nexpressions given as lower bound, upper bound and stride,\nrespectively, substituting "None" for missing expressions.\n', 'specialattrs': u'\nSpecial Attributes\n******************\n\nThe implementation adds a few special read-only attributes to several\nobject types, where they are relevant. Some of these are not reported\nby the "dir()" built-in function.\n\nobject.__dict__\n\n A dictionary or other mapping object used to store an object\'s\n (writable) attributes.\n\ninstance.__class__\n\n The class to which a class instance belongs.\n\nclass.__bases__\n\n The tuple of base classes of a class object.\n\nclass.__name__\n\n The name of the class or type.\n\nclass.__qualname__\n\n The *qualified name* of the class or type.\n\n New in version 3.3.\n\nclass.__mro__\n\n This attribute is a tuple of classes that are considered when\n looking for base classes during method resolution.\n\nclass.mro()\n\n This method can be overridden by a metaclass to customize the\n method resolution order for its instances. It is called at class\n instantiation, and its result is stored in "__mro__".\n\nclass.__subclasses__()\n\n Each class keeps a list of weak references to its immediate\n subclasses. This method returns a list of all those references\n still alive. Example:\n\n >>> int.__subclasses__()\n []\n\n-[ Footnotes ]-\n\n[1] Additional information on these special methods may be found\n in the Python Reference Manual (*Basic customization*).\n\n[2] As a consequence, the list "[1, 2]" is considered equal to\n "[1.0, 2.0]", and similarly for tuples.\n\n[3] They must have since the parser can\'t tell the type of the\n operands.\n\n[4] Cased characters are those with general category property\n being one of "Lu" (Letter, uppercase), "Ll" (Letter, lowercase),\n or "Lt" (Letter, titlecase).\n\n[5] To format only a tuple you should therefore provide a\n singleton tuple whose only element is the tuple to be formatted.\n', - 'specialnames': u'\nSpecial method names\n********************\n\nA class can implement certain operations that are invoked by special\nsyntax (such as arithmetic operations or subscripting and slicing) by\ndefining methods with special names. This is Python\'s approach to\n*operator overloading*, allowing classes to define their own behavior\nwith respect to language operators. For instance, if a class defines\na method named "__getitem__()", and "x" is an instance of this class,\nthen "x[i]" is roughly equivalent to "type(x).__getitem__(x, i)".\nExcept where mentioned, attempts to execute an operation raise an\nexception when no appropriate method is defined (typically\n"AttributeError" or "TypeError").\n\nWhen implementing a class that emulates any built-in type, it is\nimportant that the emulation only be implemented to the degree that it\nmakes sense for the object being modelled. For example, some\nsequences may work well with retrieval of individual elements, but\nextracting a slice may not make sense. (One example of this is the\n"NodeList" interface in the W3C\'s Document Object Model.)\n\n\nBasic customization\n===================\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. "__new__()" is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of "__new__()" should be the new object instance (usually an\n instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s "__new__()" method using\n "super(currentclass, cls).__new__(cls[, ...])" with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If "__new__()" returns an instance of *cls*, then the new\n instance\'s "__init__()" method will be invoked like\n "__init__(self[, ...])", where *self* is the new instance and the\n remaining arguments are the same as were passed to "__new__()".\n\n If "__new__()" does not return an instance of *cls*, then the new\n instance\'s "__init__()" method will not be invoked.\n\n "__new__()" is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called after the instance has been created (by "__new__()"), but\n before it is returned to the caller. The arguments are those\n passed to the class constructor expression. If a base class has an\n "__init__()" method, the derived class\'s "__init__()" method, if\n any, must explicitly call it to ensure proper initialization of the\n base class part of the instance; for example:\n "BaseClass.__init__(self, [args...])".\n\n Because "__new__()" and "__init__()" work together in constructing\n objects ("__new__()" to create it, and "__init__()" to customise\n it), no non-"None" value may be returned by "__init__()"; doing so\n will cause a "TypeError" to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a "__del__()" method, the\n derived class\'s "__del__()" method, if any, must explicitly call it\n to ensure proper deletion of the base class part of the instance.\n Note that it is possible (though not recommended!) for the\n "__del__()" method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n "__del__()" methods are called for objects that still exist when\n the interpreter exits.\n\n Note: "del x" doesn\'t directly call "x.__del__()" --- the former\n decrements the reference count for "x" by one, and the latter is\n only called when "x"\'s reference count reaches zero. Some common\n situations that may prevent the reference count of an object from\n going to zero include: circular references between objects (e.g.,\n a doubly-linked list or a tree data structure with parent and\n child pointers); a reference to the object on the stack frame of\n a function that caught an exception (the traceback stored in\n "sys.exc_info()[2]" keeps the stack frame alive); or a reference\n to the object on the stack frame that raised an unhandled\n exception in interactive mode (the traceback stored in\n "sys.last_traceback" keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the second can be resolved by freeing the reference to the\n traceback object when it is no longer useful, and the third can\n be resolved by storing "None" in "sys.last_traceback". Circular\n references which are garbage are detected and cleaned up when the\n cyclic garbage collector is enabled (it\'s on by default). Refer\n to the documentation for the "gc" module for more information\n about this topic.\n\n Warning: Due to the precarious circumstances under which\n "__del__()" methods are invoked, exceptions that occur during\n their execution are ignored, and a warning is printed to\n "sys.stderr" instead. Also, when "__del__()" is invoked in\n response to a module being deleted (e.g., when execution of the\n program is done), other globals referenced by the "__del__()"\n method may already have been deleted or in the process of being\n torn down (e.g. the import machinery shutting down). For this\n reason, "__del__()" methods should do the absolute minimum needed\n to maintain external invariants. Starting with version 1.5,\n Python guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the "__del__()" method is called.\n\nobject.__repr__(self)\n\n Called by the "repr()" built-in function to compute the "official"\n string representation of an object. If at all possible, this\n should look like a valid Python expression that could be used to\n recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n "<...some useful description...>" should be returned. The return\n value must be a string object. If a class defines "__repr__()" but\n not "__str__()", then "__repr__()" is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by "str(object)" and the built-in functions "format()" and\n "print()" to compute the "informal" or nicely printable string\n representation of an object. The return value must be a *string*\n object.\n\n This method differs from "object.__repr__()" in that there is no\n expectation that "__str__()" return a valid Python expression: a\n more convenient or concise representation can be used.\n\n The default implementation defined by the built-in type "object"\n calls "object.__repr__()".\n\nobject.__bytes__(self)\n\n Called by "bytes()" to compute a byte-string representation of an\n object. This should return a "bytes" object.\n\nobject.__format__(self, format_spec)\n\n Called by the "format()" built-in function (and by extension, the\n "str.format()" method of class "str") to produce a "formatted"\n string representation of an object. The "format_spec" argument is a\n string that contains a description of the formatting options\n desired. The interpretation of the "format_spec" argument is up to\n the type implementing "__format__()", however most classes will\n either delegate formatting to one of the built-in types, or use a\n similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\n Changed in version 3.4: The __format__ method of "object" itself\n raises a "TypeError" if passed any non-empty string.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: "xy" calls\n "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n\n A rich comparison method may return the singleton "NotImplemented"\n if it does not implement the operation for a given pair of\n arguments. By convention, "False" and "True" are returned for a\n successful comparison. However, these methods can return any value,\n so if the comparison operator is used in a Boolean context (e.g.,\n in the condition of an "if" statement), Python will call "bool()"\n on the value to determine if the result is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of "x==y" does not imply that "x!=y" is false.\n Accordingly, when defining "__eq__()", one should also define\n "__ne__()" so that the operators will behave as expected. See the\n paragraph on "__hash__()" for some important notes on creating\n *hashable* objects which support custom comparison operations and\n are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, "__lt__()" and "__gt__()" are each other\'s\n reflection, "__le__()" and "__ge__()" are each other\'s reflection,\n and "__eq__()" and "__ne__()" are their own reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see "functools.total_ordering()".\n\nobject.__hash__(self)\n\n Called by built-in function "hash()" and for operations on members\n of hashed collections including "set", "frozenset", and "dict".\n "__hash__()" should return an integer. The only required property\n is that objects which compare equal have the same hash value; it is\n advised to somehow mix together (e.g. using exclusive or) the hash\n values for the components of the object that also play a part in\n comparison of objects.\n\n Note: "hash()" truncates the value returned from an object\'s\n custom "__hash__()" method to the size of a "Py_ssize_t". This\n is typically 8 bytes on 64-bit builds and 4 bytes on 32-bit\n builds. If an object\'s "__hash__()" must interoperate on builds\n of different bit sizes, be sure to check the width on all\n supported builds. An easy way to do this is with "python -c\n "import sys; print(sys.hash_info.width)""\n\n If a class does not define an "__eq__()" method it should not\n define a "__hash__()" operation either; if it defines "__eq__()"\n but not "__hash__()", its instances will not be usable as items in\n hashable collections. If a class defines mutable objects and\n implements an "__eq__()" method, it should not implement\n "__hash__()", since the implementation of hashable collections\n requires that a key\'s hash value is immutable (if the object\'s hash\n value changes, it will be in the wrong hash bucket).\n\n User-defined classes have "__eq__()" and "__hash__()" methods by\n default; with them, all objects compare unequal (except with\n themselves) and "x.__hash__()" returns an appropriate value such\n that "x == y" implies both that "x is y" and "hash(x) == hash(y)".\n\n A class that overrides "__eq__()" and does not define "__hash__()"\n will have its "__hash__()" implicitly set to "None". When the\n "__hash__()" method of a class is "None", instances of the class\n will raise an appropriate "TypeError" when a program attempts to\n retrieve their hash value, and will also be correctly identified as\n unhashable when checking "isinstance(obj, collections.Hashable").\n\n If a class that overrides "__eq__()" needs to retain the\n implementation of "__hash__()" from a parent class, the interpreter\n must be told this explicitly by setting "__hash__ =\n .__hash__".\n\n If a class that does not override "__eq__()" wishes to suppress\n hash support, it should include "__hash__ = None" in the class\n definition. A class which defines its own "__hash__()" that\n explicitly raises a "TypeError" would be incorrectly identified as\n hashable by an "isinstance(obj, collections.Hashable)" call.\n\n Note: By default, the "__hash__()" values of str, bytes and\n datetime objects are "salted" with an unpredictable random value.\n Although they remain constant within an individual Python\n process, they are not predictable between repeated invocations of\n Python.This is intended to provide protection against a denial-\n of-service caused by carefully-chosen inputs that exploit the\n worst case performance of a dict insertion, O(n^2) complexity.\n See http://www.ocert.org/advisories/ocert-2011-003.html for\n details.Changing hash values affects the iteration order of\n dicts, sets and other mappings. Python has never made guarantees\n about this ordering (and it typically varies between 32-bit and\n 64-bit builds).See also "PYTHONHASHSEED".\n\n Changed in version 3.3: Hash randomization is enabled by default.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n "bool()"; should return "False" or "True". When this method is not\n defined, "__len__()" is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither "__len__()" nor "__bool__()", all its instances are\n considered true.\n\n\nCustomizing attribute access\n============================\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of "x.name") for\nclass instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for "self"). "name" is the attribute name. This\n method should return the (computed) attribute value or raise an\n "AttributeError" exception.\n\n Note that if the attribute is found through the normal mechanism,\n "__getattr__()" is not called. (This is an intentional asymmetry\n between "__getattr__()" and "__setattr__()".) This is done both for\n efficiency reasons and because otherwise "__getattr__()" would have\n no way to access other attributes of the instance. Note that at\n least for instance variables, you can fake total control by not\n inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n "__getattribute__()" method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines "__getattr__()",\n the latter will not be called unless "__getattribute__()" either\n calls it explicitly or raises an "AttributeError". This method\n should return the (computed) attribute value or raise an\n "AttributeError" exception. In order to avoid infinite recursion in\n this method, its implementation should always call the base class\n method with the same name to access any attributes it needs, for\n example, "object.__getattribute__(self, name)".\n\n Note: This method may still be bypassed when looking up special\n methods as the result of implicit invocation via language syntax\n or built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If "__setattr__()" wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n "object.__setattr__(self, name, value)".\n\nobject.__delattr__(self, name)\n\n Like "__setattr__()" but for attribute deletion instead of\n assignment. This should only be implemented if "del obj.name" is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when "dir()" is called on the object. A sequence must be\n returned. "dir()" converts the returned sequence to a list and\n sorts it.\n\n\nImplementing Descriptors\n------------------------\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in an\n*owner* class (the descriptor must be in either the owner\'s class\ndictionary or in the class dictionary for one of its parents). In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' "__dict__".\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or "None" when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an "AttributeError"\n exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\nThe attribute "__objclass__" is interpreted by the "inspect" module as\nspecifying the class where this object was defined (setting this\nappropriately can assist in runtime introspection of dynamic class\nattributes). For callables, it may indicate that an instance of the\ngiven type (or a subclass) is expected or required as the first\npositional argument (for example, CPython sets this attribute for\nunbound methods that are implemented in C).\n\n\nInvoking Descriptors\n--------------------\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: "__get__()", "__set__()", and\n"__delete__()". If any of those methods are defined for an object, it\nis said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, "a.x" has a\nlookup chain starting with "a.__dict__[\'x\']", then\n"type(a).__dict__[\'x\']", and continuing through the base classes of\n"type(a)" excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, "a.x". How\nthe arguments are assembled depends on "a":\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: "x.__get__(a)".\n\nInstance Binding\n If binding to an object instance, "a.x" is transformed into the\n call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n\nClass Binding\n If binding to a class, "A.x" is transformed into the call:\n "A.__dict__[\'x\'].__get__(None, A)".\n\nSuper Binding\n If "a" is an instance of "super", then the binding "super(B,\n obj).m()" searches "obj.__class__.__mro__" for the base class "A"\n immediately preceding "B" and then invokes the descriptor with the\n call: "A.__dict__[\'m\'].__get__(obj, obj.__class__)".\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of "__get__()", "__set__()" and "__delete__()". If it\ndoes not define "__get__()", then accessing the attribute will return\nthe descriptor object itself unless there is a value in the object\'s\ninstance dictionary. If the descriptor defines "__set__()" and/or\n"__delete__()", it is a data descriptor; if it defines neither, it is\na non-data descriptor. Normally, data descriptors define both\n"__get__()" and "__set__()", while non-data descriptors have just the\n"__get__()" method. Data descriptors with "__set__()" and "__get__()"\ndefined always override a redefinition in an instance dictionary. In\ncontrast, non-data descriptors can be overridden by instances.\n\nPython methods (including "staticmethod()" and "classmethod()") are\nimplemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe "property()" function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n---------\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. *__slots__*\n reserves space for the declared variables and prevents the\n automatic creation of *__dict__* and *__weakref__* for each\n instance.\n\n\nNotes on using *__slots__*\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises "AttributeError". If\n dynamic assignment of new variables is desired, then add\n "\'__dict__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes\n defining *__slots__* do not support weak references to its\n instances. If weak reference support is needed, then add\n "\'__weakref__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the\n instance variable defined by the base class slot is inaccessible\n (except by retrieving its descriptor directly from the base class).\n This renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as "int", "bytes" and "tuple".\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings\n may also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n\n\nCustomizing class creation\n==========================\n\nBy default, classes are constructed using "type()". The class body is\nexecuted in a new namespace and the class name is bound locally to the\nresult of "type(name, bases, namespace)".\n\nThe class creation process can be customised by passing the\n"metaclass" keyword argument in the class definition line, or by\ninheriting from an existing class that included such an argument. In\nthe following example, both "MyClass" and "MySubclass" are instances\nof "Meta":\n\n class Meta(type):\n pass\n\n class MyClass(metaclass=Meta):\n pass\n\n class MySubclass(MyClass):\n pass\n\nAny other keyword arguments that are specified in the class definition\nare passed through to all metaclass operations described below.\n\nWhen a class definition is executed, the following steps occur:\n\n* the appropriate metaclass is determined\n\n* the class namespace is prepared\n\n* the class body is executed\n\n* the class object is created\n\n\nDetermining the appropriate metaclass\n-------------------------------------\n\nThe appropriate metaclass for a class definition is determined as\nfollows:\n\n* if no bases and no explicit metaclass are given, then "type()" is\n used\n\n* if an explicit metaclass is given and it is *not* an instance of\n "type()", then it is used directly as the metaclass\n\n* if an instance of "type()" is given as the explicit metaclass, or\n bases are defined, then the most derived metaclass is used\n\nThe most derived metaclass is selected from the explicitly specified\nmetaclass (if any) and the metaclasses (i.e. "type(cls)") of all\nspecified base classes. The most derived metaclass is one which is a\nsubtype of *all* of these candidate metaclasses. If none of the\ncandidate metaclasses meets that criterion, then the class definition\nwill fail with "TypeError".\n\n\nPreparing the class namespace\n-----------------------------\n\nOnce the appropriate metaclass has been identified, then the class\nnamespace is prepared. If the metaclass has a "__prepare__" attribute,\nit is called as "namespace = metaclass.__prepare__(name, bases,\n**kwds)" (where the additional keyword arguments, if any, come from\nthe class definition).\n\nIf the metaclass has no "__prepare__" attribute, then the class\nnamespace is initialised as an empty "dict()" instance.\n\nSee also: **PEP 3115** - Metaclasses in Python 3000\n\n Introduced the "__prepare__" namespace hook\n\n\nExecuting the class body\n------------------------\n\nThe class body is executed (approximately) as "exec(body, globals(),\nnamespace)". The key difference from a normal call to "exec()" is that\nlexical scoping allows the class body (including any methods) to\nreference names from the current and outer scopes when the class\ndefinition occurs inside a function.\n\nHowever, even when the class definition occurs inside the function,\nmethods defined inside the class still cannot see names defined at the\nclass scope. Class variables must be accessed through the first\nparameter of instance or class methods, and cannot be accessed at all\nfrom static methods.\n\n\nCreating the class object\n-------------------------\n\nOnce the class namespace has been populated by executing the class\nbody, the class object is created by calling "metaclass(name, bases,\nnamespace, **kwds)" (the additional keywords passed here are the same\nas those passed to "__prepare__").\n\nThis class object is the one that will be referenced by the zero-\nargument form of "super()". "__class__" is an implicit closure\nreference created by the compiler if any methods in a class body refer\nto either "__class__" or "super". This allows the zero argument form\nof "super()" to correctly identify the class being defined based on\nlexical scoping, while the class or instance that was used to make the\ncurrent call is identified based on the first argument passed to the\nmethod.\n\nAfter the class object is created, it is passed to the class\ndecorators included in the class definition (if any) and the resulting\nobject is bound in the local namespace as the defined class.\n\nSee also: **PEP 3135** - New super\n\n Describes the implicit "__class__" closure reference\n\n\nMetaclass example\n-----------------\n\nThe potential uses for metaclasses are boundless. Some ideas that have\nbeen explored include logging, interface checking, automatic\ndelegation, automatic property creation, proxies, frameworks, and\nautomatic resource locking/synchronization.\n\nHere is an example of a metaclass that uses an\n"collections.OrderedDict" to remember the order that class variables\nare defined:\n\n class OrderedClass(type):\n\n @classmethod\n def __prepare__(metacls, name, bases, **kwds):\n return collections.OrderedDict()\n\n def __new__(cls, name, bases, namespace, **kwds):\n result = type.__new__(cls, name, bases, dict(namespace))\n result.members = tuple(namespace)\n return result\n\n class A(metaclass=OrderedClass):\n def one(self): pass\n def two(self): pass\n def three(self): pass\n def four(self): pass\n\n >>> A.members\n (\'__module__\', \'one\', \'two\', \'three\', \'four\')\n\nWhen the class definition for *A* gets executed, the process begins\nwith calling the metaclass\'s "__prepare__()" method which returns an\nempty "collections.OrderedDict". That mapping records the methods and\nattributes of *A* as they are defined within the body of the class\nstatement. Once those definitions are executed, the ordered dictionary\nis fully populated and the metaclass\'s "__new__()" method gets\ninvoked. That method builds the new type and it saves the ordered\ndictionary keys in an attribute called "members".\n\n\nCustomizing instance and subclass checks\n========================================\n\nThe following methods are used to override the default behavior of the\n"isinstance()" and "issubclass()" built-in functions.\n\nIn particular, the metaclass "abc.ABCMeta" implements these methods in\norder to allow the addition of Abstract Base Classes (ABCs) as\n"virtual base classes" to any class or type (including built-in\ntypes), including other ABCs.\n\nclass.__instancecheck__(self, instance)\n\n Return true if *instance* should be considered a (direct or\n indirect) instance of *class*. If defined, called to implement\n "isinstance(instance, class)".\n\nclass.__subclasscheck__(self, subclass)\n\n Return true if *subclass* should be considered a (direct or\n indirect) subclass of *class*. If defined, called to implement\n "issubclass(subclass, class)".\n\nNote that these methods are looked up on the type (metaclass) of a\nclass. They cannot be defined as class methods in the actual class.\nThis is consistent with the lookup of special methods that are called\non instances, only in this case the instance is itself a class.\n\nSee also: **PEP 3119** - Introducing Abstract Base Classes\n\n Includes the specification for customizing "isinstance()" and\n "issubclass()" behavior through "__instancecheck__()" and\n "__subclasscheck__()", with motivation for this functionality in\n the context of adding Abstract Base Classes (see the "abc"\n module) to the language.\n\n\nEmulating callable objects\n==========================\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, "x(arg1, arg2, ...)" is a shorthand for\n "x.__call__(arg1, arg2, ...)".\n\n\nEmulating container types\n=========================\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which "0 <= k < N" where\n*N* is the length of the sequence, or slice objects, which define a\nrange of items. It is also recommended that mappings provide the\nmethods "keys()", "values()", "items()", "get()", "clear()",\n"setdefault()", "pop()", "popitem()", "copy()", and "update()"\nbehaving similar to those for Python\'s standard dictionary objects.\nThe "collections" module provides a "MutableMapping" abstract base\nclass to help create those methods from a base set of "__getitem__()",\n"__setitem__()", "__delitem__()", and "keys()". Mutable sequences\nshould provide methods "append()", "count()", "index()", "extend()",\n"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python\nstandard list objects. Finally, sequence types should implement\naddition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods "__add__()", "__radd__()",\n"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described\nbelow; they should not define other numerical operators. It is\nrecommended that both mappings and sequences implement the\n"__contains__()" method to allow efficient use of the "in" operator;\nfor mappings, "in" should search the mapping\'s keys; for sequences, it\nshould search through the values. It is further recommended that both\nmappings and sequences implement the "__iter__()" method to allow\nefficient iteration through the container; for mappings, "__iter__()"\nshould be the same as "keys()"; for sequences, it should iterate\nthrough the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function "len()". Should return\n the length of the object, an integer ">=" 0. Also, an object that\n doesn\'t define a "__bool__()" method and whose "__len__()" method\n returns zero is considered to be false in a Boolean context.\n\nobject.__length_hint__(self)\n\n Called to implement "operator.length_hint()". Should return an\n estimated length for the object (which may be greater or less than\n the actual length). The length must be an integer ">=" 0. This\n method is purely an optimization and is never required for\n correctness.\n\n New in version 3.4.\n\nNote: Slicing is done exclusively with the following three methods.\n A call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with "None".\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of "self[key]". For sequence types,\n the accepted keys should be integers and slice objects. Note that\n the special interpretation of negative indexes (if the class wishes\n to emulate a sequence type) is up to the "__getitem__()" method. If\n *key* is of an inappropriate type, "TypeError" may be raised; if of\n a value outside the set of indexes for the sequence (after any\n special interpretation of negative values), "IndexError" should be\n raised. For mapping types, if *key* is missing (not in the\n container), "KeyError" should be raised.\n\n Note: "for" loops expect that an "IndexError" will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__missing__(self, key)\n\n Called by "dict"."__getitem__()" to implement "self[key]" for dict\n subclasses when key is not in the dictionary.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the "__getitem__()" method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the "__getitem__()" method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the "reversed()" built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the "__reversed__()" method is not provided, the "reversed()"\n built-in will fall back to using the sequence protocol ("__len__()"\n and "__getitem__()"). Objects that support the sequence protocol\n should only provide "__reversed__()" if they can provide an\n implementation that is more efficient than the one provided by\n "reversed()".\n\nThe membership test operators ("in" and "not in") are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don\'t define "__contains__()", the membership test\n first tries iteration via "__iter__()", then the old sequence\n iteration protocol via "__getitem__()", see *this section in the\n language reference*.\n\n\nEmulating numeric types\n=======================\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|"). For instance, to evaluate the\n expression "x + y", where *x* is an instance of a class that has an\n "__add__()" method, "x.__add__(y)" is called. The "__divmod__()"\n method should be the equivalent to using "__floordiv__()" and\n "__mod__()"; it should not be related to "__truediv__()". Note\n that "__pow__()" should be defined to accept an optional third\n argument if the ternary version of the built-in "pow()" function is\n to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return "NotImplemented".\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|") with reflected (swapped) operands.\n These functions are only called if the left operand does not\n support the corresponding operation and the operands are of\n different types. [2] For instance, to evaluate the expression "x -\n y", where *y* is an instance of a class that has an "__rsub__()"\n method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns\n *NotImplemented*.\n\n Note that ternary "pow()" will not try calling "__rpow__()" (the\n coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left\n operand\'s type and that subclass provides the reflected method\n for the operation, this method will be called before the left\n operand\'s non-reflected method. This behavior allows subclasses\n to override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments ("+=", "-=", "*=", "/=", "//=", "%=", "**=", "<<=",\n ">>=", "&=", "^=", "|="). These methods should attempt to do the\n operation in-place (modifying *self*) and return the result (which\n could be, but does not have to be, *self*). If a specific method\n is not defined, the augmented assignment falls back to the normal\n methods. For instance, if *x* is an instance of a class with an\n "__iadd__()" method, "x += y" is equivalent to "x = x.__iadd__(y)"\n . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are considered, as\n with the evaluation of "x + y". In certain situations, augmented\n assignment can result in unexpected errors (see *Why does\n a_tuple[i] += [\'item\'] raise an exception when the addition\n works?*), but this behavior is in fact part of the data model.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations ("-", "+",\n "abs()" and "~").\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions "complex()", "int()",\n "float()" and "round()". Should return a value of the appropriate\n type.\n\nobject.__index__(self)\n\n Called to implement "operator.index()", and whenever Python needs\n to losslessly convert the numeric object to an integer object (such\n as in slicing, or in the built-in "bin()", "hex()" and "oct()"\n functions). Presence of this method indicates that the numeric\n object is an integer type. Must return an integer.\n\n Note: In order to have a coherent integer type class, when\n "__index__()" is defined "__int__()" should also be defined, and\n both should return the same value.\n\n\nWith Statement Context Managers\n===============================\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a "with" statement. The context manager\nhandles the entry into, and the exit from, the desired runtime context\nfor the execution of the block of code. Context managers are normally\ninvoked using the "with" statement (described in section *The with\nstatement*), but can also be used by directly invoking their methods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The "with"\n statement will bind this method\'s return value to the target(s)\n specified in the "as" clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be "None".\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that "__exit__()" methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also: **PEP 0343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n\n\nSpecial method lookup\n=====================\n\nFor custom classes, implicit invocations of special methods are only\nguaranteed to work correctly if defined on an object\'s type, not in\nthe object\'s instance dictionary. That behaviour is the reason why\nthe following code raises an exception:\n\n >>> class C:\n ... pass\n ...\n >>> c = C()\n >>> c.__len__ = lambda: 5\n >>> len(c)\n Traceback (most recent call last):\n File "", line 1, in \n TypeError: object of type \'C\' has no len()\n\nThe rationale behind this behaviour lies with a number of special\nmethods such as "__hash__()" and "__repr__()" that are implemented by\nall objects, including type objects. If the implicit lookup of these\nmethods used the conventional lookup process, they would fail when\ninvoked on the type object itself:\n\n >>> 1 .__hash__() == hash(1)\n True\n >>> int.__hash__() == hash(int)\n Traceback (most recent call last):\n File "", line 1, in \n TypeError: descriptor \'__hash__\' of \'int\' object needs an argument\n\nIncorrectly attempting to invoke an unbound method of a class in this\nway is sometimes referred to as \'metaclass confusion\', and is avoided\nby bypassing the instance when looking up special methods:\n\n >>> type(1).__hash__(1) == hash(1)\n True\n >>> type(int).__hash__(int) == hash(int)\n True\n\nIn addition to bypassing any instance attributes in the interest of\ncorrectness, implicit special method lookup generally also bypasses\nthe "__getattribute__()" method even of the object\'s metaclass:\n\n >>> class Meta(type):\n ... def __getattribute__(*args):\n ... print("Metaclass getattribute invoked")\n ... return type.__getattribute__(*args)\n ...\n >>> class C(object, metaclass=Meta):\n ... def __len__(self):\n ... return 10\n ... def __getattribute__(*args):\n ... print("Class getattribute invoked")\n ... return object.__getattribute__(*args)\n ...\n >>> c = C()\n >>> c.__len__() # Explicit lookup via instance\n Class getattribute invoked\n 10\n >>> type(c).__len__(c) # Explicit lookup via type\n Metaclass getattribute invoked\n 10\n >>> len(c) # Implicit lookup\n 10\n\nBypassing the "__getattribute__()" machinery in this fashion provides\nsignificant scope for speed optimisations within the interpreter, at\nthe cost of some flexibility in the handling of special methods (the\nspecial method *must* be set on the class object itself in order to be\nconsistently invoked by the interpreter).\n\n-[ Footnotes ]-\n\n[1] It *is* possible in some cases to change an object\'s type,\n under certain controlled conditions. It generally isn\'t a good\n idea though, since it can lead to some very strange behaviour if\n it is handled incorrectly.\n\n[2] For operands of the same type, it is assumed that if the non-\n reflected method (such as "__add__()") fails the operation is not\n supported, which is why the reflected method is not called.\n', - 'string-methods': u'\nString Methods\n**************\n\nStrings implement all of the *common* sequence operations, along with\nthe additional methods described below.\n\nStrings also support two styles of string formatting, one providing a\nlarge degree of flexibility and customization (see "str.format()",\n*Format String Syntax* and *String Formatting*) and the other based on\nC "printf" style formatting that handles a narrower range of types and\nis slightly harder to use correctly, but is often faster for the cases\nit can handle (*printf-style String Formatting*).\n\nThe *Text Processing Services* section of the standard library covers\na number of other modules that provide various text related utilities\n(including regular expression support in the "re" module).\n\nstr.capitalize()\n\n Return a copy of the string with its first character capitalized\n and the rest lowercased.\n\nstr.casefold()\n\n Return a casefolded copy of the string. Casefolded strings may be\n used for caseless matching.\n\n Casefolding is similar to lowercasing but more aggressive because\n it is intended to remove all case distinctions in a string. For\n example, the German lowercase letter "\'\xdf\'" is equivalent to ""ss"".\n Since it is already lowercase, "lower()" would do nothing to "\'\xdf\'";\n "casefold()" converts it to ""ss"".\n\n The casefolding algorithm is described in section 3.13 of the\n Unicode Standard.\n\n New in version 3.3.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is an ASCII space). The\n original string is returned if *width* is less than or equal to\n "len(s)".\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n Return an encoded version of the string as a bytes object. Default\n encoding is "\'utf-8\'". *errors* may be given to set a different\n error handling scheme. The default for *errors* is "\'strict\'",\n meaning that encoding errors raise a "UnicodeError". Other possible\n values are "\'ignore\'", "\'replace\'", "\'xmlcharrefreplace\'",\n "\'backslashreplace\'" and any other name registered via\n "codecs.register_error()", see section *Error Handlers*. For a list\n of possible encodings, see section *Standard Encodings*.\n\n Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n Return "True" if the string ends with the specified *suffix*,\n otherwise return "False". *suffix* can also be a tuple of suffixes\n to look for. With optional *start*, test beginning at that\n position. With optional *end*, stop comparing at that position.\n\nstr.expandtabs(tabsize=8)\n\n Return a copy of the string where all tab characters are replaced\n by one or more spaces, depending on the current column and the\n given tab size. Tab positions occur every *tabsize* characters\n (default is 8, giving tab positions at columns 0, 8, 16 and so on).\n To expand the string, the current column is set to zero and the\n string is examined character by character. If the character is a\n tab ("\\t"), one or more space characters are inserted in the result\n until the current column is equal to the next tab position. (The\n tab character itself is not copied.) If the character is a newline\n ("\\n") or return ("\\r"), it is copied and the current column is\n reset to zero. Any other character is copied unchanged and the\n current column is incremented by one regardless of how the\n character is represented when printed.\n\n >>> \'01\\t012\\t0123\\t01234\'.expandtabs()\n \'01 012 0123 01234\'\n >>> \'01\\t012\\t0123\\t01234\'.expandtabs(4)\n \'01 012 0123 01234\'\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the slice "s[start:end]".\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return "-1" if *sub* is not found.\n\n Note: The "find()" method should be used only if you need to know\n the position of *sub*. To check if *sub* is a substring or not,\n use the "in" operator:\n\n >>> \'Py\' in \'Python\'\n True\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The string on which this\n method is called can contain literal text or replacement fields\n delimited by braces "{}". Each replacement field contains either\n the numeric index of a positional argument, or the name of a\n keyword argument. Returns a copy of the string where each\n replacement field is replaced with the string value of the\n corresponding argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n Similar to "str.format(**mapping)", except that "mapping" is used\n directly and not copied to a "dict". This is useful if for example\n "mapping" is a dict subclass:\n\n >>> class Default(dict):\n ... def __missing__(self, key):\n ... return key\n ...\n >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n \'Guido was born in country\'\n\n New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n Like "find()", but raise "ValueError" when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise. A character "c"\n is alphanumeric if one of the following returns "True":\n "c.isalpha()", "c.isdecimal()", "c.isdigit()", or "c.isnumeric()".\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise. Alphabetic\n characters are those characters defined in the Unicode character\n database as "Letter", i.e., those with general category property\n being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is\n different from the "Alphabetic" property defined in the Unicode\n Standard.\n\nstr.isdecimal()\n\n Return true if all characters in the string are decimal characters\n and there is at least one character, false otherwise. Decimal\n characters are those from general category "Nd". This category\n includes digit characters, and all characters that can be used to\n form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise. Digits include decimal\n characters and digits that need special handling, such as the\n compatibility superscript digits. Formally, a digit is a character\n that has the property value Numeric_Type=Digit or\n Numeric_Type=Decimal.\n\nstr.isidentifier()\n\n Return true if the string is a valid identifier according to the\n language definition, section *Identifiers and keywords*.\n\n Use "keyword.iskeyword()" to test for reserved identifiers such as\n "def" and "class".\n\nstr.islower()\n\n Return true if all cased characters [4] in the string are lowercase\n and there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n Return true if all characters in the string are numeric characters,\n and there is at least one character, false otherwise. Numeric\n characters include digit characters, and all characters that have\n the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n ONE FIFTH. Formally, numeric characters are those with the\n property value Numeric_Type=Digit, Numeric_Type=Decimal or\n Numeric_Type=Numeric.\n\nstr.isprintable()\n\n Return true if all characters in the string are printable or the\n string is empty, false otherwise. Nonprintable characters are\n those characters defined in the Unicode character database as\n "Other" or "Separator", excepting the ASCII space (0x20) which is\n considered printable. (Note that printable characters in this\n context are those which should not be escaped when "repr()" is\n invoked on a string. It has no bearing on the handling of strings\n written to "sys.stdout" or "sys.stderr".)\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise. Whitespace\n characters are those characters defined in the Unicode character\n database as "Other" or "Separator" and those with bidirectional\n property being one of "WS", "B", or "S".\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\nstr.isupper()\n\n Return true if all cased characters [4] in the string are uppercase\n and there is at least one cased character, false otherwise.\n\nstr.join(iterable)\n\n Return a string which is the concatenation of the strings in the\n *iterable* *iterable*. A "TypeError" will be raised if there are\n any non-string values in *iterable*, including "bytes" objects.\n The separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is an ASCII\n space). The original string is returned if *width* is less than or\n equal to "len(s)".\n\nstr.lower()\n\n Return a copy of the string with all the cased characters [4]\n converted to lowercase.\n\n The lowercasing algorithm used is described in section 3.13 of the\n Unicode Standard.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or "None", the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n This static method returns a translation table usable for\n "str.translate()".\n\n If there is only one argument, it must be a dictionary mapping\n Unicode ordinals (integers) or characters (strings of length 1) to\n Unicode ordinals, strings (of arbitrary lengths) or None.\n Character keys will then be converted to ordinals.\n\n If there are two arguments, they must be strings of equal length,\n and in the resulting dictionary, each character in x will be mapped\n to the character at the same position in y. If there is a third\n argument, it must be a string, whose characters will be mapped to\n None in the result.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within "s[start:end]".\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return "-1" on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like "rfind()" but raises "ValueError" when the substring *sub* is\n not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is an ASCII\n space). The original string is returned if *width* is less than or\n equal to "len(s)".\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\nstr.rsplit(sep=None, maxsplit=-1)\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n "None", any whitespace string is a separator. Except for splitting\n from the right, "rsplit()" behaves like "split()" which is\n described in detail below.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or "None", the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\nstr.split(sep=None, maxsplit=-1)\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most "maxsplit+1"\n elements). If *maxsplit* is not specified or "-1", then there is\n no limit on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n "\'1,,2\'.split(\',\')" returns "[\'1\', \'\', \'2\']"). The *sep* argument\n may consist of multiple characters (for example,\n "\'1<>2<>3\'.split(\'<>\')" returns "[\'1\', \'2\', \'3\']"). Splitting an\n empty string with a specified separator returns "[\'\']".\n\n For example:\n\n >>> \'1,2,3\'.split(\',\')\n [\'1\', \'2\', \'3\']\n >>> \'1,2,3\'.split(\',\', maxsplit=1)\n [\'1\', \'2,3\']\n >>> \'1,2,,3,\'.split(\',\')\n [\'1\', \'2\', \'\', \'3\', \'\']\n\n If *sep* is not specified or is "None", a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a "None" separator returns "[]".\n\n For example:\n\n >>> \'1 2 3\'.split()\n [\'1\', \'2\', \'3\']\n >>> \'1 2 3\'.split(maxsplit=1)\n [\'1\', \'2 3\']\n >>> \' 1 2 3 \'.split()\n [\'1\', \'2\', \'3\']\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. This method uses the *universal newlines* approach to\n splitting lines. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\n For example:\n\n >>> \'ab c\\n\\nde fg\\rkl\\r\\n\'.splitlines()\n [\'ab c\', \'\', \'de fg\', \'kl\']\n >>> \'ab c\\n\\nde fg\\rkl\\r\\n\'.splitlines(keepends=True)\n [\'ab c\\n\', \'\\n\', \'de fg\\r\', \'kl\\r\\n\']\n\n Unlike "split()" when a delimiter string *sep* is given, this\n method returns an empty list for the empty string, and a terminal\n line break does not result in an extra line:\n\n >>> "".splitlines()\n []\n >>> "One line\\n".splitlines()\n [\'One line\']\n\n For comparison, "split(\'\\n\')" gives:\n\n >>> \'\'.split(\'\\n\')\n [\'\']\n >>> \'Two lines\\n\'.split(\'\\n\')\n [\'Two lines\', \'\']\n\nstr.startswith(prefix[, start[, end]])\n\n Return "True" if string starts with the *prefix*, otherwise return\n "False". *prefix* can also be a tuple of prefixes to look for.\n With optional *start*, test string beginning at that position.\n With optional *end*, stop comparing string at that position.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or "None", the *chars*\n argument defaults to removing whitespace. The *chars* argument is\n not a prefix or suffix; rather, all combinations of its values are\n stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa. Note that it is not necessarily true that\n "s.swapcase().swapcase() == s".\n\nstr.title()\n\n Return a titlecased version of the string where words start with an\n uppercase character and the remaining characters are lowercase.\n\n For example:\n\n >>> \'Hello world\'.title()\n \'Hello World\'\n\n The algorithm uses a simple language-independent definition of a\n word as groups of consecutive letters. The definition works in\n many contexts but it means that apostrophes in contractions and\n possessives form word boundaries, which may not be the desired\n result:\n\n >>> "they\'re bill\'s friends from the UK".title()\n "They\'Re Bill\'S Friends From The Uk"\n\n A workaround for apostrophes can be constructed using regular\n expressions:\n\n >>> import re\n >>> def titlecase(s):\n ... return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n ... lambda mo: mo.group(0)[0].upper() +\n ... mo.group(0)[1:].lower(),\n ... s)\n ...\n >>> titlecase("they\'re bill\'s friends.")\n "They\'re Bill\'s Friends."\n\nstr.translate(map)\n\n Return a copy of the *s* where all characters have been mapped\n through the *map* which must be a dictionary of Unicode ordinals\n (integers) to Unicode ordinals, strings or "None". Unmapped\n characters are left untouched. Characters mapped to "None" are\n deleted.\n\n You can use "str.maketrans()" to create a translation map from\n character-to-character mappings in different formats.\n\n Note: An even more flexible approach is to create a custom\n character mapping codec using the "codecs" module (see\n "encodings.cp1251" for an example).\n\nstr.upper()\n\n Return a copy of the string with all the cased characters [4]\n converted to uppercase. Note that "str.upper().isupper()" might be\n "False" if "s" contains uncased characters or if the Unicode\n category of the resulting character(s) is not "Lu" (Letter,\n uppercase), but e.g. "Lt" (Letter, titlecase).\n\n The uppercasing algorithm used is described in section 3.13 of the\n Unicode Standard.\n\nstr.zfill(width)\n\n Return a copy of the string left filled with ASCII "\'0\'" digits to\n make a string of length *width*. A leading sign prefix ("\'+\'"/"\'-\'"\n is handled by inserting the padding *after* the sign character\n rather than before. The original string is returned if *width* is\n less than or equal to "len(s)".\n\n For example:\n\n >>> "42".zfill(5)\n \'00042\'\n >>> "-42".zfill(5)\n \'-0042\'\n', + 'specialnames': u'\nSpecial method names\n********************\n\nA class can implement certain operations that are invoked by special\nsyntax (such as arithmetic operations or subscripting and slicing) by\ndefining methods with special names. This is Python\'s approach to\n*operator overloading*, allowing classes to define their own behavior\nwith respect to language operators. For instance, if a class defines\na method named "__getitem__()", and "x" is an instance of this class,\nthen "x[i]" is roughly equivalent to "type(x).__getitem__(x, i)".\nExcept where mentioned, attempts to execute an operation raise an\nexception when no appropriate method is defined (typically\n"AttributeError" or "TypeError").\n\nWhen implementing a class that emulates any built-in type, it is\nimportant that the emulation only be implemented to the degree that it\nmakes sense for the object being modelled. For example, some\nsequences may work well with retrieval of individual elements, but\nextracting a slice may not make sense. (One example of this is the\n"NodeList" interface in the W3C\'s Document Object Model.)\n\n\nBasic customization\n===================\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. "__new__()" is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of "__new__()" should be the new object instance (usually an\n instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s "__new__()" method using\n "super(currentclass, cls).__new__(cls[, ...])" with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If "__new__()" returns an instance of *cls*, then the new\n instance\'s "__init__()" method will be invoked like\n "__init__(self[, ...])", where *self* is the new instance and the\n remaining arguments are the same as were passed to "__new__()".\n\n If "__new__()" does not return an instance of *cls*, then the new\n instance\'s "__init__()" method will not be invoked.\n\n "__new__()" is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called after the instance has been created (by "__new__()"), but\n before it is returned to the caller. The arguments are those\n passed to the class constructor expression. If a base class has an\n "__init__()" method, the derived class\'s "__init__()" method, if\n any, must explicitly call it to ensure proper initialization of the\n base class part of the instance; for example:\n "BaseClass.__init__(self, [args...])".\n\n Because "__new__()" and "__init__()" work together in constructing\n objects ("__new__()" to create it, and "__init__()" to customise\n it), no non-"None" value may be returned by "__init__()"; doing so\n will cause a "TypeError" to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a "__del__()" method, the\n derived class\'s "__del__()" method, if any, must explicitly call it\n to ensure proper deletion of the base class part of the instance.\n Note that it is possible (though not recommended!) for the\n "__del__()" method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n "__del__()" methods are called for objects that still exist when\n the interpreter exits.\n\n Note: "del x" doesn\'t directly call "x.__del__()" --- the former\n decrements the reference count for "x" by one, and the latter is\n only called when "x"\'s reference count reaches zero. Some common\n situations that may prevent the reference count of an object from\n going to zero include: circular references between objects (e.g.,\n a doubly-linked list or a tree data structure with parent and\n child pointers); a reference to the object on the stack frame of\n a function that caught an exception (the traceback stored in\n "sys.exc_info()[2]" keeps the stack frame alive); or a reference\n to the object on the stack frame that raised an unhandled\n exception in interactive mode (the traceback stored in\n "sys.last_traceback" keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the second can be resolved by freeing the reference to the\n traceback object when it is no longer useful, and the third can\n be resolved by storing "None" in "sys.last_traceback". Circular\n references which are garbage are detected and cleaned up when the\n cyclic garbage collector is enabled (it\'s on by default). Refer\n to the documentation for the "gc" module for more information\n about this topic.\n\n Warning: Due to the precarious circumstances under which\n "__del__()" methods are invoked, exceptions that occur during\n their execution are ignored, and a warning is printed to\n "sys.stderr" instead. Also, when "__del__()" is invoked in\n response to a module being deleted (e.g., when execution of the\n program is done), other globals referenced by the "__del__()"\n method may already have been deleted or in the process of being\n torn down (e.g. the import machinery shutting down). For this\n reason, "__del__()" methods should do the absolute minimum needed\n to maintain external invariants. Starting with version 1.5,\n Python guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the "__del__()" method is called.\n\nobject.__repr__(self)\n\n Called by the "repr()" built-in function to compute the "official"\n string representation of an object. If at all possible, this\n should look like a valid Python expression that could be used to\n recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n "<...some useful description...>" should be returned. The return\n value must be a string object. If a class defines "__repr__()" but\n not "__str__()", then "__repr__()" is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by "str(object)" and the built-in functions "format()" and\n "print()" to compute the "informal" or nicely printable string\n representation of an object. The return value must be a *string*\n object.\n\n This method differs from "object.__repr__()" in that there is no\n expectation that "__str__()" return a valid Python expression: a\n more convenient or concise representation can be used.\n\n The default implementation defined by the built-in type "object"\n calls "object.__repr__()".\n\nobject.__bytes__(self)\n\n Called by "bytes()" to compute a byte-string representation of an\n object. This should return a "bytes" object.\n\nobject.__format__(self, format_spec)\n\n Called by the "format()" built-in function (and by extension, the\n "str.format()" method of class "str") to produce a "formatted"\n string representation of an object. The "format_spec" argument is a\n string that contains a description of the formatting options\n desired. The interpretation of the "format_spec" argument is up to\n the type implementing "__format__()", however most classes will\n either delegate formatting to one of the built-in types, or use a\n similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\n Changed in version 3.4: The __format__ method of "object" itself\n raises a "TypeError" if passed any non-empty string.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: "xy" calls\n "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n\n A rich comparison method may return the singleton "NotImplemented"\n if it does not implement the operation for a given pair of\n arguments. By convention, "False" and "True" are returned for a\n successful comparison. However, these methods can return any value,\n so if the comparison operator is used in a Boolean context (e.g.,\n in the condition of an "if" statement), Python will call "bool()"\n on the value to determine if the result is true or false.\n\n By default, "__ne__()" delegates to "__eq__()" and inverts the\n result unless it is "NotImplemented". There are no other implied\n relationships among the comparison operators, for example, the\n truth of "(x.__hash__".\n\n If a class that does not override "__eq__()" wishes to suppress\n hash support, it should include "__hash__ = None" in the class\n definition. A class which defines its own "__hash__()" that\n explicitly raises a "TypeError" would be incorrectly identified as\n hashable by an "isinstance(obj, collections.Hashable)" call.\n\n Note: By default, the "__hash__()" values of str, bytes and\n datetime objects are "salted" with an unpredictable random value.\n Although they remain constant within an individual Python\n process, they are not predictable between repeated invocations of\n Python.This is intended to provide protection against a denial-\n of-service caused by carefully-chosen inputs that exploit the\n worst case performance of a dict insertion, O(n^2) complexity.\n See http://www.ocert.org/advisories/ocert-2011-003.html for\n details.Changing hash values affects the iteration order of\n dicts, sets and other mappings. Python has never made guarantees\n about this ordering (and it typically varies between 32-bit and\n 64-bit builds).See also "PYTHONHASHSEED".\n\n Changed in version 3.3: Hash randomization is enabled by default.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n "bool()"; should return "False" or "True". When this method is not\n defined, "__len__()" is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither "__len__()" nor "__bool__()", all its instances are\n considered true.\n\n\nCustomizing attribute access\n============================\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of "x.name") for\nclass instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for "self"). "name" is the attribute name. This\n method should return the (computed) attribute value or raise an\n "AttributeError" exception.\n\n Note that if the attribute is found through the normal mechanism,\n "__getattr__()" is not called. (This is an intentional asymmetry\n between "__getattr__()" and "__setattr__()".) This is done both for\n efficiency reasons and because otherwise "__getattr__()" would have\n no way to access other attributes of the instance. Note that at\n least for instance variables, you can fake total control by not\n inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n "__getattribute__()" method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines "__getattr__()",\n the latter will not be called unless "__getattribute__()" either\n calls it explicitly or raises an "AttributeError". This method\n should return the (computed) attribute value or raise an\n "AttributeError" exception. In order to avoid infinite recursion in\n this method, its implementation should always call the base class\n method with the same name to access any attributes it needs, for\n example, "object.__getattribute__(self, name)".\n\n Note: This method may still be bypassed when looking up special\n methods as the result of implicit invocation via language syntax\n or built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If "__setattr__()" wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n "object.__setattr__(self, name, value)".\n\nobject.__delattr__(self, name)\n\n Like "__setattr__()" but for attribute deletion instead of\n assignment. This should only be implemented if "del obj.name" is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when "dir()" is called on the object. A sequence must be\n returned. "dir()" converts the returned sequence to a list and\n sorts it.\n\n\nImplementing Descriptors\n------------------------\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in an\n*owner* class (the descriptor must be in either the owner\'s class\ndictionary or in the class dictionary for one of its parents). In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' "__dict__".\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or "None" when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an "AttributeError"\n exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\nThe attribute "__objclass__" is interpreted by the "inspect" module as\nspecifying the class where this object was defined (setting this\nappropriately can assist in runtime introspection of dynamic class\nattributes). For callables, it may indicate that an instance of the\ngiven type (or a subclass) is expected or required as the first\npositional argument (for example, CPython sets this attribute for\nunbound methods that are implemented in C).\n\n\nInvoking Descriptors\n--------------------\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: "__get__()", "__set__()", and\n"__delete__()". If any of those methods are defined for an object, it\nis said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, "a.x" has a\nlookup chain starting with "a.__dict__[\'x\']", then\n"type(a).__dict__[\'x\']", and continuing through the base classes of\n"type(a)" excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, "a.x". How\nthe arguments are assembled depends on "a":\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: "x.__get__(a)".\n\nInstance Binding\n If binding to an object instance, "a.x" is transformed into the\n call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n\nClass Binding\n If binding to a class, "A.x" is transformed into the call:\n "A.__dict__[\'x\'].__get__(None, A)".\n\nSuper Binding\n If "a" is an instance of "super", then the binding "super(B,\n obj).m()" searches "obj.__class__.__mro__" for the base class "A"\n immediately preceding "B" and then invokes the descriptor with the\n call: "A.__dict__[\'m\'].__get__(obj, obj.__class__)".\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of "__get__()", "__set__()" and "__delete__()". If it\ndoes not define "__get__()", then accessing the attribute will return\nthe descriptor object itself unless there is a value in the object\'s\ninstance dictionary. If the descriptor defines "__set__()" and/or\n"__delete__()", it is a data descriptor; if it defines neither, it is\na non-data descriptor. Normally, data descriptors define both\n"__get__()" and "__set__()", while non-data descriptors have just the\n"__get__()" method. Data descriptors with "__set__()" and "__get__()"\ndefined always override a redefinition in an instance dictionary. In\ncontrast, non-data descriptors can be overridden by instances.\n\nPython methods (including "staticmethod()" and "classmethod()") are\nimplemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe "property()" function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n---------\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. *__slots__*\n reserves space for the declared variables and prevents the\n automatic creation of *__dict__* and *__weakref__* for each\n instance.\n\n\nNotes on using *__slots__*\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises "AttributeError". If\n dynamic assignment of new variables is desired, then add\n "\'__dict__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes\n defining *__slots__* do not support weak references to its\n instances. If weak reference support is needed, then add\n "\'__weakref__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the\n instance variable defined by the base class slot is inaccessible\n (except by retrieving its descriptor directly from the base class).\n This renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as "int", "bytes" and "tuple".\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings\n may also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n\n\nCustomizing class creation\n==========================\n\nBy default, classes are constructed using "type()". The class body is\nexecuted in a new namespace and the class name is bound locally to the\nresult of "type(name, bases, namespace)".\n\nThe class creation process can be customised by passing the\n"metaclass" keyword argument in the class definition line, or by\ninheriting from an existing class that included such an argument. In\nthe following example, both "MyClass" and "MySubclass" are instances\nof "Meta":\n\n class Meta(type):\n pass\n\n class MyClass(metaclass=Meta):\n pass\n\n class MySubclass(MyClass):\n pass\n\nAny other keyword arguments that are specified in the class definition\nare passed through to all metaclass operations described below.\n\nWhen a class definition is executed, the following steps occur:\n\n* the appropriate metaclass is determined\n\n* the class namespace is prepared\n\n* the class body is executed\n\n* the class object is created\n\n\nDetermining the appropriate metaclass\n-------------------------------------\n\nThe appropriate metaclass for a class definition is determined as\nfollows:\n\n* if no bases and no explicit metaclass are given, then "type()" is\n used\n\n* if an explicit metaclass is given and it is *not* an instance of\n "type()", then it is used directly as the metaclass\n\n* if an instance of "type()" is given as the explicit metaclass, or\n bases are defined, then the most derived metaclass is used\n\nThe most derived metaclass is selected from the explicitly specified\nmetaclass (if any) and the metaclasses (i.e. "type(cls)") of all\nspecified base classes. The most derived metaclass is one which is a\nsubtype of *all* of these candidate metaclasses. If none of the\ncandidate metaclasses meets that criterion, then the class definition\nwill fail with "TypeError".\n\n\nPreparing the class namespace\n-----------------------------\n\nOnce the appropriate metaclass has been identified, then the class\nnamespace is prepared. If the metaclass has a "__prepare__" attribute,\nit is called as "namespace = metaclass.__prepare__(name, bases,\n**kwds)" (where the additional keyword arguments, if any, come from\nthe class definition).\n\nIf the metaclass has no "__prepare__" attribute, then the class\nnamespace is initialised as an empty "dict()" instance.\n\nSee also: **PEP 3115** - Metaclasses in Python 3000\n\n Introduced the "__prepare__" namespace hook\n\n\nExecuting the class body\n------------------------\n\nThe class body is executed (approximately) as "exec(body, globals(),\nnamespace)". The key difference from a normal call to "exec()" is that\nlexical scoping allows the class body (including any methods) to\nreference names from the current and outer scopes when the class\ndefinition occurs inside a function.\n\nHowever, even when the class definition occurs inside the function,\nmethods defined inside the class still cannot see names defined at the\nclass scope. Class variables must be accessed through the first\nparameter of instance or class methods, and cannot be accessed at all\nfrom static methods.\n\n\nCreating the class object\n-------------------------\n\nOnce the class namespace has been populated by executing the class\nbody, the class object is created by calling "metaclass(name, bases,\nnamespace, **kwds)" (the additional keywords passed here are the same\nas those passed to "__prepare__").\n\nThis class object is the one that will be referenced by the zero-\nargument form of "super()". "__class__" is an implicit closure\nreference created by the compiler if any methods in a class body refer\nto either "__class__" or "super". This allows the zero argument form\nof "super()" to correctly identify the class being defined based on\nlexical scoping, while the class or instance that was used to make the\ncurrent call is identified based on the first argument passed to the\nmethod.\n\nAfter the class object is created, it is passed to the class\ndecorators included in the class definition (if any) and the resulting\nobject is bound in the local namespace as the defined class.\n\nSee also: **PEP 3135** - New super\n\n Describes the implicit "__class__" closure reference\n\n\nMetaclass example\n-----------------\n\nThe potential uses for metaclasses are boundless. Some ideas that have\nbeen explored include logging, interface checking, automatic\ndelegation, automatic property creation, proxies, frameworks, and\nautomatic resource locking/synchronization.\n\nHere is an example of a metaclass that uses an\n"collections.OrderedDict" to remember the order that class variables\nare defined:\n\n class OrderedClass(type):\n\n @classmethod\n def __prepare__(metacls, name, bases, **kwds):\n return collections.OrderedDict()\n\n def __new__(cls, name, bases, namespace, **kwds):\n result = type.__new__(cls, name, bases, dict(namespace))\n result.members = tuple(namespace)\n return result\n\n class A(metaclass=OrderedClass):\n def one(self): pass\n def two(self): pass\n def three(self): pass\n def four(self): pass\n\n >>> A.members\n (\'__module__\', \'one\', \'two\', \'three\', \'four\')\n\nWhen the class definition for *A* gets executed, the process begins\nwith calling the metaclass\'s "__prepare__()" method which returns an\nempty "collections.OrderedDict". That mapping records the methods and\nattributes of *A* as they are defined within the body of the class\nstatement. Once those definitions are executed, the ordered dictionary\nis fully populated and the metaclass\'s "__new__()" method gets\ninvoked. That method builds the new type and it saves the ordered\ndictionary keys in an attribute called "members".\n\n\nCustomizing instance and subclass checks\n========================================\n\nThe following methods are used to override the default behavior of the\n"isinstance()" and "issubclass()" built-in functions.\n\nIn particular, the metaclass "abc.ABCMeta" implements these methods in\norder to allow the addition of Abstract Base Classes (ABCs) as\n"virtual base classes" to any class or type (including built-in\ntypes), including other ABCs.\n\nclass.__instancecheck__(self, instance)\n\n Return true if *instance* should be considered a (direct or\n indirect) instance of *class*. If defined, called to implement\n "isinstance(instance, class)".\n\nclass.__subclasscheck__(self, subclass)\n\n Return true if *subclass* should be considered a (direct or\n indirect) subclass of *class*. If defined, called to implement\n "issubclass(subclass, class)".\n\nNote that these methods are looked up on the type (metaclass) of a\nclass. They cannot be defined as class methods in the actual class.\nThis is consistent with the lookup of special methods that are called\non instances, only in this case the instance is itself a class.\n\nSee also: **PEP 3119** - Introducing Abstract Base Classes\n\n Includes the specification for customizing "isinstance()" and\n "issubclass()" behavior through "__instancecheck__()" and\n "__subclasscheck__()", with motivation for this functionality in\n the context of adding Abstract Base Classes (see the "abc"\n module) to the language.\n\n\nEmulating callable objects\n==========================\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, "x(arg1, arg2, ...)" is a shorthand for\n "x.__call__(arg1, arg2, ...)".\n\n\nEmulating container types\n=========================\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which "0 <= k < N" where\n*N* is the length of the sequence, or slice objects, which define a\nrange of items. It is also recommended that mappings provide the\nmethods "keys()", "values()", "items()", "get()", "clear()",\n"setdefault()", "pop()", "popitem()", "copy()", and "update()"\nbehaving similar to those for Python\'s standard dictionary objects.\nThe "collections" module provides a "MutableMapping" abstract base\nclass to help create those methods from a base set of "__getitem__()",\n"__setitem__()", "__delitem__()", and "keys()". Mutable sequences\nshould provide methods "append()", "count()", "index()", "extend()",\n"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python\nstandard list objects. Finally, sequence types should implement\naddition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods "__add__()", "__radd__()",\n"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described\nbelow; they should not define other numerical operators. It is\nrecommended that both mappings and sequences implement the\n"__contains__()" method to allow efficient use of the "in" operator;\nfor mappings, "in" should search the mapping\'s keys; for sequences, it\nshould search through the values. It is further recommended that both\nmappings and sequences implement the "__iter__()" method to allow\nefficient iteration through the container; for mappings, "__iter__()"\nshould be the same as "keys()"; for sequences, it should iterate\nthrough the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function "len()". Should return\n the length of the object, an integer ">=" 0. Also, an object that\n doesn\'t define a "__bool__()" method and whose "__len__()" method\n returns zero is considered to be false in a Boolean context.\n\nobject.__length_hint__(self)\n\n Called to implement "operator.length_hint()". Should return an\n estimated length for the object (which may be greater or less than\n the actual length). The length must be an integer ">=" 0. This\n method is purely an optimization and is never required for\n correctness.\n\n New in version 3.4.\n\nNote: Slicing is done exclusively with the following three methods.\n A call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with "None".\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of "self[key]". For sequence types,\n the accepted keys should be integers and slice objects. Note that\n the special interpretation of negative indexes (if the class wishes\n to emulate a sequence type) is up to the "__getitem__()" method. If\n *key* is of an inappropriate type, "TypeError" may be raised; if of\n a value outside the set of indexes for the sequence (after any\n special interpretation of negative values), "IndexError" should be\n raised. For mapping types, if *key* is missing (not in the\n container), "KeyError" should be raised.\n\n Note: "for" loops expect that an "IndexError" will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__missing__(self, key)\n\n Called by "dict"."__getitem__()" to implement "self[key]" for dict\n subclasses when key is not in the dictionary.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the "__getitem__()" method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the "__getitem__()" method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the "reversed()" built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the "__reversed__()" method is not provided, the "reversed()"\n built-in will fall back to using the sequence protocol ("__len__()"\n and "__getitem__()"). Objects that support the sequence protocol\n should only provide "__reversed__()" if they can provide an\n implementation that is more efficient than the one provided by\n "reversed()".\n\nThe membership test operators ("in" and "not in") are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don\'t define "__contains__()", the membership test\n first tries iteration via "__iter__()", then the old sequence\n iteration protocol via "__getitem__()", see *this section in the\n language reference*.\n\n\nEmulating numeric types\n=======================\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|"). For instance, to evaluate the\n expression "x + y", where *x* is an instance of a class that has an\n "__add__()" method, "x.__add__(y)" is called. The "__divmod__()"\n method should be the equivalent to using "__floordiv__()" and\n "__mod__()"; it should not be related to "__truediv__()". Note\n that "__pow__()" should be defined to accept an optional third\n argument if the ternary version of the built-in "pow()" function is\n to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return "NotImplemented".\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|") with reflected (swapped) operands.\n These functions are only called if the left operand does not\n support the corresponding operation and the operands are of\n different types. [2] For instance, to evaluate the expression "x -\n y", where *y* is an instance of a class that has an "__rsub__()"\n method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns\n *NotImplemented*.\n\n Note that ternary "pow()" will not try calling "__rpow__()" (the\n coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left\n operand\'s type and that subclass provides the reflected method\n for the operation, this method will be called before the left\n operand\'s non-reflected method. This behavior allows subclasses\n to override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments ("+=", "-=", "*=", "/=", "//=", "%=", "**=", "<<=",\n ">>=", "&=", "^=", "|="). These methods should attempt to do the\n operation in-place (modifying *self*) and return the result (which\n could be, but does not have to be, *self*). If a specific method\n is not defined, the augmented assignment falls back to the normal\n methods. For instance, if *x* is an instance of a class with an\n "__iadd__()" method, "x += y" is equivalent to "x = x.__iadd__(y)"\n . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are considered, as\n with the evaluation of "x + y". In certain situations, augmented\n assignment can result in unexpected errors (see *Why does\n a_tuple[i] += [\'item\'] raise an exception when the addition\n works?*), but this behavior is in fact part of the data model.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations ("-", "+",\n "abs()" and "~").\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions "complex()", "int()",\n "float()" and "round()". Should return a value of the appropriate\n type.\n\nobject.__index__(self)\n\n Called to implement "operator.index()", and whenever Python needs\n to losslessly convert the numeric object to an integer object (such\n as in slicing, or in the built-in "bin()", "hex()" and "oct()"\n functions). Presence of this method indicates that the numeric\n object is an integer type. Must return an integer.\n\n Note: In order to have a coherent integer type class, when\n "__index__()" is defined "__int__()" should also be defined, and\n both should return the same value.\n\n\nWith Statement Context Managers\n===============================\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a "with" statement. The context manager\nhandles the entry into, and the exit from, the desired runtime context\nfor the execution of the block of code. Context managers are normally\ninvoked using the "with" statement (described in section *The with\nstatement*), but can also be used by directly invoking their methods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The "with"\n statement will bind this method\'s return value to the target(s)\n specified in the "as" clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be "None".\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that "__exit__()" methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also: **PEP 0343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n\n\nSpecial method lookup\n=====================\n\nFor custom classes, implicit invocations of special methods are only\nguaranteed to work correctly if defined on an object\'s type, not in\nthe object\'s instance dictionary. That behaviour is the reason why\nthe following code raises an exception:\n\n >>> class C:\n ... pass\n ...\n >>> c = C()\n >>> c.__len__ = lambda: 5\n >>> len(c)\n Traceback (most recent call last):\n File "", line 1, in \n TypeError: object of type \'C\' has no len()\n\nThe rationale behind this behaviour lies with a number of special\nmethods such as "__hash__()" and "__repr__()" that are implemented by\nall objects, including type objects. If the implicit lookup of these\nmethods used the conventional lookup process, they would fail when\ninvoked on the type object itself:\n\n >>> 1 .__hash__() == hash(1)\n True\n >>> int.__hash__() == hash(int)\n Traceback (most recent call last):\n File "", line 1, in \n TypeError: descriptor \'__hash__\' of \'int\' object needs an argument\n\nIncorrectly attempting to invoke an unbound method of a class in this\nway is sometimes referred to as \'metaclass confusion\', and is avoided\nby bypassing the instance when looking up special methods:\n\n >>> type(1).__hash__(1) == hash(1)\n True\n >>> type(int).__hash__(int) == hash(int)\n True\n\nIn addition to bypassing any instance attributes in the interest of\ncorrectness, implicit special method lookup generally also bypasses\nthe "__getattribute__()" method even of the object\'s metaclass:\n\n >>> class Meta(type):\n ... def __getattribute__(*args):\n ... print("Metaclass getattribute invoked")\n ... return type.__getattribute__(*args)\n ...\n >>> class C(object, metaclass=Meta):\n ... def __len__(self):\n ... return 10\n ... def __getattribute__(*args):\n ... print("Class getattribute invoked")\n ... return object.__getattribute__(*args)\n ...\n >>> c = C()\n >>> c.__len__() # Explicit lookup via instance\n Class getattribute invoked\n 10\n >>> type(c).__len__(c) # Explicit lookup via type\n Metaclass getattribute invoked\n 10\n >>> len(c) # Implicit lookup\n 10\n\nBypassing the "__getattribute__()" machinery in this fashion provides\nsignificant scope for speed optimisations within the interpreter, at\nthe cost of some flexibility in the handling of special methods (the\nspecial method *must* be set on the class object itself in order to be\nconsistently invoked by the interpreter).\n\n-[ Footnotes ]-\n\n[1] It *is* possible in some cases to change an object\'s type,\n under certain controlled conditions. It generally isn\'t a good\n idea though, since it can lead to some very strange behaviour if\n it is handled incorrectly.\n\n[2] For operands of the same type, it is assumed that if the non-\n reflected method (such as "__add__()") fails the operation is not\n supported, which is why the reflected method is not called.\n', + 'string-methods': u'\nString Methods\n**************\n\nStrings implement all of the *common* sequence operations, along with\nthe additional methods described below.\n\nStrings also support two styles of string formatting, one providing a\nlarge degree of flexibility and customization (see "str.format()",\n*Format String Syntax* and *String Formatting*) and the other based on\nC "printf" style formatting that handles a narrower range of types and\nis slightly harder to use correctly, but is often faster for the cases\nit can handle (*printf-style String Formatting*).\n\nThe *Text Processing Services* section of the standard library covers\na number of other modules that provide various text related utilities\n(including regular expression support in the "re" module).\n\nstr.capitalize()\n\n Return a copy of the string with its first character capitalized\n and the rest lowercased.\n\nstr.casefold()\n\n Return a casefolded copy of the string. Casefolded strings may be\n used for caseless matching.\n\n Casefolding is similar to lowercasing but more aggressive because\n it is intended to remove all case distinctions in a string. For\n example, the German lowercase letter "\'\xdf\'" is equivalent to ""ss"".\n Since it is already lowercase, "lower()" would do nothing to "\'\xdf\'";\n "casefold()" converts it to ""ss"".\n\n The casefolding algorithm is described in section 3.13 of the\n Unicode Standard.\n\n New in version 3.3.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is an ASCII space). The\n original string is returned if *width* is less than or equal to\n "len(s)".\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n Return an encoded version of the string as a bytes object. Default\n encoding is "\'utf-8\'". *errors* may be given to set a different\n error handling scheme. The default for *errors* is "\'strict\'",\n meaning that encoding errors raise a "UnicodeError". Other possible\n values are "\'ignore\'", "\'replace\'", "\'xmlcharrefreplace\'",\n "\'backslashreplace\'" and any other name registered via\n "codecs.register_error()", see section *Error Handlers*. For a list\n of possible encodings, see section *Standard Encodings*.\n\n Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n Return "True" if the string ends with the specified *suffix*,\n otherwise return "False". *suffix* can also be a tuple of suffixes\n to look for. With optional *start*, test beginning at that\n position. With optional *end*, stop comparing at that position.\n\nstr.expandtabs(tabsize=8)\n\n Return a copy of the string where all tab characters are replaced\n by one or more spaces, depending on the current column and the\n given tab size. Tab positions occur every *tabsize* characters\n (default is 8, giving tab positions at columns 0, 8, 16 and so on).\n To expand the string, the current column is set to zero and the\n string is examined character by character. If the character is a\n tab ("\\t"), one or more space characters are inserted in the result\n until the current column is equal to the next tab position. (The\n tab character itself is not copied.) If the character is a newline\n ("\\n") or return ("\\r"), it is copied and the current column is\n reset to zero. Any other character is copied unchanged and the\n current column is incremented by one regardless of how the\n character is represented when printed.\n\n >>> \'01\\t012\\t0123\\t01234\'.expandtabs()\n \'01 012 0123 01234\'\n >>> \'01\\t012\\t0123\\t01234\'.expandtabs(4)\n \'01 012 0123 01234\'\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the slice "s[start:end]".\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return "-1" if *sub* is not found.\n\n Note: The "find()" method should be used only if you need to know\n the position of *sub*. To check if *sub* is a substring or not,\n use the "in" operator:\n\n >>> \'Py\' in \'Python\'\n True\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The string on which this\n method is called can contain literal text or replacement fields\n delimited by braces "{}". Each replacement field contains either\n the numeric index of a positional argument, or the name of a\n keyword argument. Returns a copy of the string where each\n replacement field is replaced with the string value of the\n corresponding argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n Similar to "str.format(**mapping)", except that "mapping" is used\n directly and not copied to a "dict". This is useful if for example\n "mapping" is a dict subclass:\n\n >>> class Default(dict):\n ... def __missing__(self, key):\n ... return key\n ...\n >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n \'Guido was born in country\'\n\n New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n Like "find()", but raise "ValueError" when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise. A character "c"\n is alphanumeric if one of the following returns "True":\n "c.isalpha()", "c.isdecimal()", "c.isdigit()", or "c.isnumeric()".\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise. Alphabetic\n characters are those characters defined in the Unicode character\n database as "Letter", i.e., those with general category property\n being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is\n different from the "Alphabetic" property defined in the Unicode\n Standard.\n\nstr.isdecimal()\n\n Return true if all characters in the string are decimal characters\n and there is at least one character, false otherwise. Decimal\n characters are those from general category "Nd". This category\n includes digit characters, and all characters that can be used to\n form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise. Digits include decimal\n characters and digits that need special handling, such as the\n compatibility superscript digits. Formally, a digit is a character\n that has the property value Numeric_Type=Digit or\n Numeric_Type=Decimal.\n\nstr.isidentifier()\n\n Return true if the string is a valid identifier according to the\n language definition, section *Identifiers and keywords*.\n\n Use "keyword.iskeyword()" to test for reserved identifiers such as\n "def" and "class".\n\nstr.islower()\n\n Return true if all cased characters [4] in the string are lowercase\n and there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n Return true if all characters in the string are numeric characters,\n and there is at least one character, false otherwise. Numeric\n characters include digit characters, and all characters that have\n the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n ONE FIFTH. Formally, numeric characters are those with the\n property value Numeric_Type=Digit, Numeric_Type=Decimal or\n Numeric_Type=Numeric.\n\nstr.isprintable()\n\n Return true if all characters in the string are printable or the\n string is empty, false otherwise. Nonprintable characters are\n those characters defined in the Unicode character database as\n "Other" or "Separator", excepting the ASCII space (0x20) which is\n considered printable. (Note that printable characters in this\n context are those which should not be escaped when "repr()" is\n invoked on a string. It has no bearing on the handling of strings\n written to "sys.stdout" or "sys.stderr".)\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise. Whitespace\n characters are those characters defined in the Unicode character\n database as "Other" or "Separator" and those with bidirectional\n property being one of "WS", "B", or "S".\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\nstr.isupper()\n\n Return true if all cased characters [4] in the string are uppercase\n and there is at least one cased character, false otherwise.\n\nstr.join(iterable)\n\n Return a string which is the concatenation of the strings in the\n *iterable* *iterable*. A "TypeError" will be raised if there are\n any non-string values in *iterable*, including "bytes" objects.\n The separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is an ASCII\n space). The original string is returned if *width* is less than or\n equal to "len(s)".\n\nstr.lower()\n\n Return a copy of the string with all the cased characters [4]\n converted to lowercase.\n\n The lowercasing algorithm used is described in section 3.13 of the\n Unicode Standard.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or "None", the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n This static method returns a translation table usable for\n "str.translate()".\n\n If there is only one argument, it must be a dictionary mapping\n Unicode ordinals (integers) or characters (strings of length 1) to\n Unicode ordinals, strings (of arbitrary lengths) or None.\n Character keys will then be converted to ordinals.\n\n If there are two arguments, they must be strings of equal length,\n and in the resulting dictionary, each character in x will be mapped\n to the character at the same position in y. If there is a third\n argument, it must be a string, whose characters will be mapped to\n None in the result.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within "s[start:end]".\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return "-1" on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like "rfind()" but raises "ValueError" when the substring *sub* is\n not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is an ASCII\n space). The original string is returned if *width* is less than or\n equal to "len(s)".\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\nstr.rsplit(sep=None, maxsplit=-1)\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n "None", any whitespace string is a separator. Except for splitting\n from the right, "rsplit()" behaves like "split()" which is\n described in detail below.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or "None", the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\nstr.split(sep=None, maxsplit=-1)\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most "maxsplit+1"\n elements). If *maxsplit* is not specified or "-1", then there is\n no limit on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n "\'1,,2\'.split(\',\')" returns "[\'1\', \'\', \'2\']"). The *sep* argument\n may consist of multiple characters (for example,\n "\'1<>2<>3\'.split(\'<>\')" returns "[\'1\', \'2\', \'3\']"). Splitting an\n empty string with a specified separator returns "[\'\']".\n\n For example:\n\n >>> \'1,2,3\'.split(\',\')\n [\'1\', \'2\', \'3\']\n >>> \'1,2,3\'.split(\',\', maxsplit=1)\n [\'1\', \'2,3\']\n >>> \'1,2,,3,\'.split(\',\')\n [\'1\', \'2\', \'\', \'3\', \'\']\n\n If *sep* is not specified or is "None", a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a "None" separator returns "[]".\n\n For example:\n\n >>> \'1 2 3\'.split()\n [\'1\', \'2\', \'3\']\n >>> \'1 2 3\'.split(maxsplit=1)\n [\'1\', \'2 3\']\n >>> \' 1 2 3 \'.split()\n [\'1\', \'2\', \'3\']\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\n This method splits on the following line boundaries. In\n particular, the boundaries are a superset of *universal newlines*.\n\n +-------------------------+-------------------------------+\n | Representation | Description |\n +=========================+===============================+\n | "\\n" | Line Feed |\n +-------------------------+-------------------------------+\n | "\\r" | Carriage Return |\n +-------------------------+-------------------------------+\n | "\\r\\n" | Carriage Return + Line Feed |\n +-------------------------+-------------------------------+\n | "\\v" or "\\x0b" | Line Tabulation |\n +-------------------------+-------------------------------+\n | "\\f" or "\\x0c" | Form Feed |\n +-------------------------+-------------------------------+\n | "\\x1c" | File Separator |\n +-------------------------+-------------------------------+\n | "\\x1d" | Group Separator |\n +-------------------------+-------------------------------+\n | "\\x1e" | Record Separator |\n +-------------------------+-------------------------------+\n | "\\x85" | Next Line (C1 Control Code) |\n +-------------------------+-------------------------------+\n | "\\u2028" | Line Separator |\n +-------------------------+-------------------------------+\n | "\\u2029" | Paragraph Separator |\n +-------------------------+-------------------------------+\n\n Changed in version 3.2: "\\v" and "\\f" added to list of line\n boundaries.\n\n For example:\n\n >>> \'ab c\\n\\nde fg\\rkl\\r\\n\'.splitlines()\n [\'ab c\', \'\', \'de fg\', \'kl\']\n >>> \'ab c\\n\\nde fg\\rkl\\r\\n\'.splitlines(keepends=True)\n [\'ab c\\n\', \'\\n\', \'de fg\\r\', \'kl\\r\\n\']\n\n Unlike "split()" when a delimiter string *sep* is given, this\n method returns an empty list for the empty string, and a terminal\n line break does not result in an extra line:\n\n >>> "".splitlines()\n []\n >>> "One line\\n".splitlines()\n [\'One line\']\n\n For comparison, "split(\'\\n\')" gives:\n\n >>> \'\'.split(\'\\n\')\n [\'\']\n >>> \'Two lines\\n\'.split(\'\\n\')\n [\'Two lines\', \'\']\n\nstr.startswith(prefix[, start[, end]])\n\n Return "True" if string starts with the *prefix*, otherwise return\n "False". *prefix* can also be a tuple of prefixes to look for.\n With optional *start*, test string beginning at that position.\n With optional *end*, stop comparing string at that position.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or "None", the *chars*\n argument defaults to removing whitespace. The *chars* argument is\n not a prefix or suffix; rather, all combinations of its values are\n stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa. Note that it is not necessarily true that\n "s.swapcase().swapcase() == s".\n\nstr.title()\n\n Return a titlecased version of the string where words start with an\n uppercase character and the remaining characters are lowercase.\n\n For example:\n\n >>> \'Hello world\'.title()\n \'Hello World\'\n\n The algorithm uses a simple language-independent definition of a\n word as groups of consecutive letters. The definition works in\n many contexts but it means that apostrophes in contractions and\n possessives form word boundaries, which may not be the desired\n result:\n\n >>> "they\'re bill\'s friends from the UK".title()\n "They\'Re Bill\'S Friends From The Uk"\n\n A workaround for apostrophes can be constructed using regular\n expressions:\n\n >>> import re\n >>> def titlecase(s):\n ... return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n ... lambda mo: mo.group(0)[0].upper() +\n ... mo.group(0)[1:].lower(),\n ... s)\n ...\n >>> titlecase("they\'re bill\'s friends.")\n "They\'re Bill\'s Friends."\n\nstr.translate(table)\n\n Return a copy of the string in which each character has been mapped\n through the given translation table. The table must be an object\n that implements indexing via "__getitem__()", typically a *mapping*\n or *sequence*. When indexed by a Unicode ordinal (an integer), the\n table object can do any of the following: return a Unicode ordinal\n or a string, to map the character to one or more other characters;\n return "None", to delete the character from the return string; or\n raise a "LookupError" exception, to map the character to itself.\n\n You can use "str.maketrans()" to create a translation map from\n character-to-character mappings in different formats.\n\n See also the "codecs" module for a more flexible approach to custom\n character mappings.\n\nstr.upper()\n\n Return a copy of the string with all the cased characters [4]\n converted to uppercase. Note that "str.upper().isupper()" might be\n "False" if "s" contains uncased characters or if the Unicode\n category of the resulting character(s) is not "Lu" (Letter,\n uppercase), but e.g. "Lt" (Letter, titlecase).\n\n The uppercasing algorithm used is described in section 3.13 of the\n Unicode Standard.\n\nstr.zfill(width)\n\n Return a copy of the string left filled with ASCII "\'0\'" digits to\n make a string of length *width*. A leading sign prefix\n ("\'+\'"/"\'-\'") is handled by inserting the padding *after* the sign\n character rather than before. The original string is returned if\n *width* is less than or equal to "len(s)".\n\n For example:\n\n >>> "42".zfill(5)\n \'00042\'\n >>> "-42".zfill(5)\n \'-0042\'\n', 'strings': u'\nString and Bytes literals\n*************************\n\nString literals are described by the following lexical definitions:\n\n stringliteral ::= [stringprefix](shortstring | longstring)\n stringprefix ::= "r" | "u" | "R" | "U"\n shortstring ::= "\'" shortstringitem* "\'" | \'"\' shortstringitem* \'"\'\n longstring ::= "\'\'\'" longstringitem* "\'\'\'" | \'"""\' longstringitem* \'"""\'\n shortstringitem ::= shortstringchar | stringescapeseq\n longstringitem ::= longstringchar | stringescapeseq\n shortstringchar ::= \n longstringchar ::= \n stringescapeseq ::= "\\" \n\n bytesliteral ::= bytesprefix(shortbytes | longbytes)\n bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB"\n shortbytes ::= "\'" shortbytesitem* "\'" | \'"\' shortbytesitem* \'"\'\n longbytes ::= "\'\'\'" longbytesitem* "\'\'\'" | \'"""\' longbytesitem* \'"""\'\n shortbytesitem ::= shortbyteschar | bytesescapeseq\n longbytesitem ::= longbyteschar | bytesescapeseq\n shortbyteschar ::= \n longbyteschar ::= \n bytesescapeseq ::= "\\" \n\nOne syntactic restriction not indicated by these productions is that\nwhitespace is not allowed between the "stringprefix" or "bytesprefix"\nand the rest of the literal. The source character set is defined by\nthe encoding declaration; it is UTF-8 if no encoding declaration is\ngiven in the source file; see section *Encoding declarations*.\n\nIn plain English: Both types of literals can be enclosed in matching\nsingle quotes ("\'") or double quotes ("""). They can also be enclosed\nin matching groups of three single or double quotes (these are\ngenerally referred to as *triple-quoted strings*). The backslash\n("\\") character is used to escape characters that otherwise have a\nspecial meaning, such as newline, backslash itself, or the quote\ncharacter.\n\nBytes literals are always prefixed with "\'b\'" or "\'B\'"; they produce\nan instance of the "bytes" type instead of the "str" type. They may\nonly contain ASCII characters; bytes with a numeric value of 128 or\ngreater must be expressed with escapes.\n\nAs of Python 3.3 it is possible again to prefix string literals with a\n"u" prefix to simplify maintenance of dual 2.x and 3.x codebases.\n\nBoth string and bytes literals may optionally be prefixed with a\nletter "\'r\'" or "\'R\'"; such strings are called *raw strings* and treat\nbackslashes as literal characters. As a result, in string literals,\n"\'\\U\'" and "\'\\u\'" escapes in raw strings are not treated specially.\nGiven that Python 2.x\'s raw unicode literals behave differently than\nPython 3.x\'s the "\'ur\'" syntax is not supported.\n\nNew in version 3.3: The "\'rb\'" prefix of raw bytes literals has been\nadded as a synonym of "\'br\'".\n\nNew in version 3.3: Support for the unicode legacy literal\n("u\'value\'") was reintroduced to simplify the maintenance of dual\nPython 2.x and 3.x codebases. See **PEP 414** for more information.\n\nIn triple-quoted literals, unescaped newlines and quotes are allowed\n(and are retained), except that three unescaped quotes in a row\nterminate the literal. (A "quote" is the character used to open the\nliteral, i.e. either "\'" or """.)\n\nUnless an "\'r\'" or "\'R\'" prefix is present, escape sequences in string\nand bytes literals are interpreted according to rules similar to those\nused by Standard C. The recognized escape sequences are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| "\\newline" | Backslash and newline ignored | |\n+-------------------+-----------------------------------+---------+\n| "\\\\" | Backslash ("\\") | |\n+-------------------+-----------------------------------+---------+\n| "\\\'" | Single quote ("\'") | |\n+-------------------+-----------------------------------+---------+\n| "\\"" | Double quote (""") | |\n+-------------------+-----------------------------------+---------+\n| "\\a" | ASCII Bell (BEL) | |\n+-------------------+-----------------------------------+---------+\n| "\\b" | ASCII Backspace (BS) | |\n+-------------------+-----------------------------------+---------+\n| "\\f" | ASCII Formfeed (FF) | |\n+-------------------+-----------------------------------+---------+\n| "\\n" | ASCII Linefeed (LF) | |\n+-------------------+-----------------------------------+---------+\n| "\\r" | ASCII Carriage Return (CR) | |\n+-------------------+-----------------------------------+---------+\n| "\\t" | ASCII Horizontal Tab (TAB) | |\n+-------------------+-----------------------------------+---------+\n| "\\v" | ASCII Vertical Tab (VT) | |\n+-------------------+-----------------------------------+---------+\n| "\\ooo" | Character with octal value *ooo* | (1,3) |\n+-------------------+-----------------------------------+---------+\n| "\\xhh" | Character with hex value *hh* | (2,3) |\n+-------------------+-----------------------------------+---------+\n\nEscape sequences only recognized in string literals are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| "\\N{name}" | Character named *name* in the | (4) |\n| | Unicode database | |\n+-------------------+-----------------------------------+---------+\n| "\\uxxxx" | Character with 16-bit hex value | (5) |\n| | *xxxx* | |\n+-------------------+-----------------------------------+---------+\n| "\\Uxxxxxxxx" | Character with 32-bit hex value | (6) |\n| | *xxxxxxxx* | |\n+-------------------+-----------------------------------+---------+\n\nNotes:\n\n1. As in Standard C, up to three octal digits are accepted.\n\n2. Unlike in Standard C, exactly two hex digits are required.\n\n3. In a bytes literal, hexadecimal and octal escapes denote the\n byte with the given value. In a string literal, these escapes\n denote a Unicode character with the given value.\n\n4. Changed in version 3.3: Support for name aliases [1] has been\n added.\n\n5. Individual code units which form parts of a surrogate pair can\n be encoded using this escape sequence. Exactly four hex digits are\n required.\n\n6. Any Unicode character can be encoded this way. Exactly eight\n hex digits are required.\n\nUnlike Standard C, all unrecognized escape sequences are left in the\nstring unchanged, i.e., *the backslash is left in the result*. (This\nbehavior is useful when debugging: if an escape sequence is mistyped,\nthe resulting output is more easily recognized as broken.) It is also\nimportant to note that the escape sequences only recognized in string\nliterals fall into the category of unrecognized escapes for bytes\nliterals.\n\nEven in a raw literal, quotes can be escaped with a backslash, but the\nbackslash remains in the result; for example, "r"\\""" is a valid\nstring literal consisting of two characters: a backslash and a double\nquote; "r"\\"" is not a valid string literal (even a raw string cannot\nend in an odd number of backslashes). Specifically, *a raw literal\ncannot end in a single backslash* (since the backslash would escape\nthe following quote character). Note also that a single backslash\nfollowed by a newline is interpreted as those two characters as part\nof the literal, *not* as a line continuation.\n', 'subscriptions': u'\nSubscriptions\n*************\n\nA subscription selects an item of a sequence (string, tuple or list)\nor mapping (dictionary) object:\n\n subscription ::= primary "[" expression_list "]"\n\nThe primary must evaluate to an object that supports subscription\n(lists or dictionaries for example). User-defined objects can support\nsubscription by defining a "__getitem__()" method.\n\nFor built-in objects, there are two types of objects that support\nsubscription:\n\nIf the primary is a mapping, the expression list must evaluate to an\nobject whose value is one of the keys of the mapping, and the\nsubscription selects the value in the mapping that corresponds to that\nkey. (The expression list is a tuple except if it has exactly one\nitem.)\n\nIf the primary is a sequence, the expression (list) must evaluate to\nan integer or a slice (as discussed in the following section).\n\nThe formal syntax makes no special provision for negative indices in\nsequences; however, built-in sequences all provide a "__getitem__()"\nmethod that interprets negative indices by adding the length of the\nsequence to the index (so that "x[-1]" selects the last item of "x").\nThe resulting value must be a nonnegative integer less than the number\nof items in the sequence, and the subscription selects the item whose\nindex is that value (counting from zero). Since the support for\nnegative indices and slicing occurs in the object\'s "__getitem__()"\nmethod, subclasses overriding this method will need to explicitly add\nthat support.\n\nA string\'s items are characters. A character is not a separate data\ntype but a string of exactly one character.\n', 'truth': u'\nTruth Value Testing\n*******************\n\nAny object can be tested for truth value, for use in an "if" or\n"while" condition or as operand of the Boolean operations below. The\nfollowing values are considered false:\n\n* "None"\n\n* "False"\n\n* zero of any numeric type, for example, "0", "0.0", "0j".\n\n* any empty sequence, for example, "\'\'", "()", "[]".\n\n* any empty mapping, for example, "{}".\n\n* instances of user-defined classes, if the class defines a\n "__bool__()" or "__len__()" method, when that method returns the\n integer zero or "bool" value "False". [1]\n\nAll other values are considered true --- so objects of many types are\nalways true.\n\nOperations and built-in functions that have a Boolean result always\nreturn "0" or "False" for false and "1" or "True" for true, unless\notherwise stated. (Important exception: the Boolean operations "or"\nand "and" always return one of their operands.)\n', 'try': u'\nThe "try" statement\n*******************\n\nThe "try" statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" identifier]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe "except" clause(s) specify one or more exception handlers. When no\nexception occurs in the "try" clause, no exception handler is\nexecuted. When an exception occurs in the "try" suite, a search for an\nexception handler is started. This search inspects the except clauses\nin turn until one is found that matches the exception. An expression-\nless except clause, if present, must be last; it matches any\nexception. For an except clause with an expression, that expression\nis evaluated, and the clause matches the exception if the resulting\nobject is "compatible" with the exception. An object is compatible\nwith an exception if it is the class or a base class of the exception\nobject or a tuple containing an item compatible with the exception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire "try" statement raised\nthe exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the "as" keyword in that except clause, if\npresent, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using "as target", it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause. Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the "sys" module and can be accessed via\n"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the\nexception class, the exception instance and a traceback object (see\nsection *The standard type hierarchy*) identifying the point in the\nprogram where the exception occurred. "sys.exc_info()" values are\nrestored to their previous values (before the call) when returning\nfrom a function that handled an exception.\n\nThe optional "else" clause is executed if and when control flows off\nthe end of the "try" clause. [2] Exceptions in the "else" clause are\nnot handled by the preceding "except" clauses.\n\nIf "finally" is present, it specifies a \'cleanup\' handler. The "try"\nclause is executed, including any "except" and "else" clauses. If an\nexception occurs in any of the clauses and is not handled, the\nexception is temporarily saved. The "finally" clause is executed. If\nthere is a saved exception it is re-raised at the end of the "finally"\nclause. If the "finally" clause raises another exception, the saved\nexception is set as the context of the new exception. If the "finally"\nclause executes a "return" or "break" statement, the saved exception\nis discarded:\n\n >>> def f():\n ... try:\n ... 1/0\n ... finally:\n ... return 42\n ...\n >>> f()\n 42\n\nThe exception information is not available to the program during\nexecution of the "finally" clause.\n\nWhen a "return", "break" or "continue" statement is executed in the\n"try" suite of a "try"..."finally" statement, the "finally" clause is\nalso executed \'on the way out.\' A "continue" statement is illegal in\nthe "finally" clause. (The reason is a problem with the current\nimplementation --- this restriction may be lifted in the future).\n\nThe return value of a function is determined by the last "return"\nstatement executed. Since the "finally" clause always executes, a\n"return" statement executed in the "finally" clause will always be the\nlast one executed:\n\n >>> def foo():\n ... try:\n ... return \'try\'\n ... finally:\n ... return \'finally\'\n ...\n >>> foo()\n \'finally\'\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the "raise" statement to\ngenerate exceptions may be found in section *The raise statement*.\n', 'types': u'\nThe standard type hierarchy\n***************************\n\nBelow is a list of the types that are built into Python. Extension\nmodules (written in C, Java, or other languages, depending on the\nimplementation) can define additional types. Future versions of\nPython may add types to the type hierarchy (e.g., rational numbers,\nefficiently stored arrays of integers, etc.), although such additions\nwill often be provided via the standard library instead.\n\nSome of the type descriptions below contain a paragraph listing\n\'special attributes.\' These are attributes that provide access to the\nimplementation and are not intended for general use. Their definition\nmay change in the future.\n\nNone\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name "None". It\n is used to signify the absence of a value in many situations, e.g.,\n it is returned from functions that don\'t explicitly return\n anything. Its truth value is false.\n\nNotImplemented\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name\n "NotImplemented". Numeric methods and rich comparison methods\n should return this value if they do not implement the operation for\n the operands provided. (The interpreter will then try the\n reflected operation, or some other fallback, depending on the\n operator.) Its truth value is true.\n\n See *Implementing the arithmetic operations* for more details.\n\nEllipsis\n This type has a single value. There is a single object with this\n value. This object is accessed through the literal "..." or the\n built-in name "Ellipsis". Its truth value is true.\n\n"numbers.Number"\n These are created by numeric literals and returned as results by\n arithmetic operators and arithmetic built-in functions. Numeric\n objects are immutable; once created their value never changes.\n Python numbers are of course strongly related to mathematical\n numbers, but subject to the limitations of numerical representation\n in computers.\n\n Python distinguishes between integers, floating point numbers, and\n complex numbers:\n\n "numbers.Integral"\n These represent elements from the mathematical set of integers\n (positive and negative).\n\n There are two types of integers:\n\n Integers ("int")\n\n These represent numbers in an unlimited range, subject to\n available (virtual) memory only. For the purpose of shift\n and mask operations, a binary representation is assumed, and\n negative numbers are represented in a variant of 2\'s\n complement which gives the illusion of an infinite string of\n sign bits extending to the left.\n\n Booleans ("bool")\n These represent the truth values False and True. The two\n objects representing the values "False" and "True" are the\n only Boolean objects. The Boolean type is a subtype of the\n integer type, and Boolean values behave like the values 0 and\n 1, respectively, in almost all contexts, the exception being\n that when converted to a string, the strings ""False"" or\n ""True"" are returned, respectively.\n\n The rules for integer representation are intended to give the\n most meaningful interpretation of shift and mask operations\n involving negative integers.\n\n "numbers.Real" ("float")\n These represent machine-level double precision floating point\n numbers. You are at the mercy of the underlying machine\n architecture (and C or Java implementation) for the accepted\n range and handling of overflow. Python does not support single-\n precision floating point numbers; the savings in processor and\n memory usage that are usually the reason for using these are\n dwarfed by the overhead of using objects in Python, so there is\n no reason to complicate the language with two kinds of floating\n point numbers.\n\n "numbers.Complex" ("complex")\n These represent complex numbers as a pair of machine-level\n double precision floating point numbers. The same caveats apply\n as for floating point numbers. The real and imaginary parts of a\n complex number "z" can be retrieved through the read-only\n attributes "z.real" and "z.imag".\n\nSequences\n These represent finite ordered sets indexed by non-negative\n numbers. The built-in function "len()" returns the number of items\n of a sequence. When the length of a sequence is *n*, the index set\n contains the numbers 0, 1, ..., *n*-1. Item *i* of sequence *a* is\n selected by "a[i]".\n\n Sequences also support slicing: "a[i:j]" selects all items with\n index *k* such that *i* "<=" *k* "<" *j*. When used as an\n expression, a slice is a sequence of the same type. This implies\n that the index set is renumbered so that it starts at 0.\n\n Some sequences also support "extended slicing" with a third "step"\n parameter: "a[i:j:k]" selects all items of *a* with index *x* where\n "x = i + n*k", *n* ">=" "0" and *i* "<=" *x* "<" *j*.\n\n Sequences are distinguished according to their mutability:\n\n Immutable sequences\n An object of an immutable sequence type cannot change once it is\n created. (If the object contains references to other objects,\n these other objects may be mutable and may be changed; however,\n the collection of objects directly referenced by an immutable\n object cannot change.)\n\n The following types are immutable sequences:\n\n Strings\n A string is a sequence of values that represent Unicode code\n points. All the code points in the range "U+0000 - U+10FFFF"\n can be represented in a string. Python doesn\'t have a "char"\n type; instead, every code point in the string is represented\n as a string object with length "1". The built-in function\n "ord()" converts a code point from its string form to an\n integer in the range "0 - 10FFFF"; "chr()" converts an\n integer in the range "0 - 10FFFF" to the corresponding length\n "1" string object. "str.encode()" can be used to convert a\n "str" to "bytes" using the given text encoding, and\n "bytes.decode()" can be used to achieve the opposite.\n\n Tuples\n The items of a tuple are arbitrary Python objects. Tuples of\n two or more items are formed by comma-separated lists of\n expressions. A tuple of one item (a \'singleton\') can be\n formed by affixing a comma to an expression (an expression by\n itself does not create a tuple, since parentheses must be\n usable for grouping of expressions). An empty tuple can be\n formed by an empty pair of parentheses.\n\n Bytes\n A bytes object is an immutable array. The items are 8-bit\n bytes, represented by integers in the range 0 <= x < 256.\n Bytes literals (like "b\'abc\'") and the built-in function\n "bytes()" can be used to construct bytes objects. Also,\n bytes objects can be decoded to strings via the "decode()"\n method.\n\n Mutable sequences\n Mutable sequences can be changed after they are created. The\n subscription and slicing notations can be used as the target of\n assignment and "del" (delete) statements.\n\n There are currently two intrinsic mutable sequence types:\n\n Lists\n The items of a list are arbitrary Python objects. Lists are\n formed by placing a comma-separated list of expressions in\n square brackets. (Note that there are no special cases needed\n to form lists of length 0 or 1.)\n\n Byte Arrays\n A bytearray object is a mutable array. They are created by\n the built-in "bytearray()" constructor. Aside from being\n mutable (and hence unhashable), byte arrays otherwise provide\n the same interface and functionality as immutable bytes\n objects.\n\n The extension module "array" provides an additional example of a\n mutable sequence type, as does the "collections" module.\n\nSet types\n These represent unordered, finite sets of unique, immutable\n objects. As such, they cannot be indexed by any subscript. However,\n they can be iterated over, and the built-in function "len()"\n returns the number of items in a set. Common uses for sets are fast\n membership testing, removing duplicates from a sequence, and\n computing mathematical operations such as intersection, union,\n difference, and symmetric difference.\n\n For set elements, the same immutability rules apply as for\n dictionary keys. Note that numeric types obey the normal rules for\n numeric comparison: if two numbers compare equal (e.g., "1" and\n "1.0"), only one of them can be contained in a set.\n\n There are currently two intrinsic set types:\n\n Sets\n These represent a mutable set. They are created by the built-in\n "set()" constructor and can be modified afterwards by several\n methods, such as "add()".\n\n Frozen sets\n These represent an immutable set. They are created by the\n built-in "frozenset()" constructor. As a frozenset is immutable\n and *hashable*, it can be used again as an element of another\n set, or as a dictionary key.\n\nMappings\n These represent finite sets of objects indexed by arbitrary index\n sets. The subscript notation "a[k]" selects the item indexed by "k"\n from the mapping "a"; this can be used in expressions and as the\n target of assignments or "del" statements. The built-in function\n "len()" returns the number of items in a mapping.\n\n There is currently a single intrinsic mapping type:\n\n Dictionaries\n These represent finite sets of objects indexed by nearly\n arbitrary values. The only types of values not acceptable as\n keys are values containing lists or dictionaries or other\n mutable types that are compared by value rather than by object\n identity, the reason being that the efficient implementation of\n dictionaries requires a key\'s hash value to remain constant.\n Numeric types used for keys obey the normal rules for numeric\n comparison: if two numbers compare equal (e.g., "1" and "1.0")\n then they can be used interchangeably to index the same\n dictionary entry.\n\n Dictionaries are mutable; they can be created by the "{...}"\n notation (see section *Dictionary displays*).\n\n The extension modules "dbm.ndbm" and "dbm.gnu" provide\n additional examples of mapping types, as does the "collections"\n module.\n\nCallable types\n These are the types to which the function call operation (see\n section *Calls*) can be applied:\n\n User-defined functions\n A user-defined function object is created by a function\n definition (see section *Function definitions*). It should be\n called with an argument list containing the same number of items\n as the function\'s formal parameter list.\n\n Special attributes:\n\n +---------------------------+---------------------------------+-------------+\n | Attribute | Meaning | |\n +===========================+=================================+=============+\n | "__doc__" | The function\'s documentation | Writable |\n | | string, or "None" if | |\n | | unavailable; not inherited by | |\n | | subclasses | |\n +---------------------------+---------------------------------+-------------+\n | "__name__" | The function\'s name | Writable |\n +---------------------------+---------------------------------+-------------+\n | "__qualname__" | The function\'s *qualified name* | Writable |\n | | New in version 3.3. | |\n +---------------------------+---------------------------------+-------------+\n | "__module__" | The name of the module the | Writable |\n | | function was defined in, or | |\n | | "None" if unavailable. | |\n +---------------------------+---------------------------------+-------------+\n | "__defaults__" | A tuple containing default | Writable |\n | | argument values for those | |\n | | arguments that have defaults, | |\n | | or "None" if no arguments have | |\n | | a default value | |\n +---------------------------+---------------------------------+-------------+\n | "__code__" | The code object representing | Writable |\n | | the compiled function body. | |\n +---------------------------+---------------------------------+-------------+\n | "__globals__" | A reference to the dictionary | Read-only |\n | | that holds the function\'s | |\n | | global variables --- the global | |\n | | namespace of the module in | |\n | | which the function was defined. | |\n +---------------------------+---------------------------------+-------------+\n | "__dict__" | The namespace supporting | Writable |\n | | arbitrary function attributes. | |\n +---------------------------+---------------------------------+-------------+\n | "__closure__" | "None" or a tuple of cells that | Read-only |\n | | contain bindings for the | |\n | | function\'s free variables. | |\n +---------------------------+---------------------------------+-------------+\n | "__annotations__" | A dict containing annotations | Writable |\n | | of parameters. The keys of the | |\n | | dict are the parameter names, | |\n | | and "\'return\'" for the return | |\n | | annotation, if provided. | |\n +---------------------------+---------------------------------+-------------+\n | "__kwdefaults__" | A dict containing defaults for | Writable |\n | | keyword-only parameters. | |\n +---------------------------+---------------------------------+-------------+\n\n Most of the attributes labelled "Writable" check the type of the\n assigned value.\n\n Function objects also support getting and setting arbitrary\n attributes, which can be used, for example, to attach metadata\n to functions. Regular attribute dot-notation is used to get and\n set such attributes. *Note that the current implementation only\n supports function attributes on user-defined functions. Function\n attributes on built-in functions may be supported in the\n future.*\n\n Additional information about a function\'s definition can be\n retrieved from its code object; see the description of internal\n types below.\n\n Instance methods\n An instance method object combines a class, a class instance and\n any callable object (normally a user-defined function).\n\n Special read-only attributes: "__self__" is the class instance\n object, "__func__" is the function object; "__doc__" is the\n method\'s documentation (same as "__func__.__doc__"); "__name__"\n is the method name (same as "__func__.__name__"); "__module__"\n is the name of the module the method was defined in, or "None"\n if unavailable.\n\n Methods also support accessing (but not setting) the arbitrary\n function attributes on the underlying function object.\n\n User-defined method objects may be created when getting an\n attribute of a class (perhaps via an instance of that class), if\n that attribute is a user-defined function object or a class\n method object.\n\n When an instance method object is created by retrieving a user-\n defined function object from a class via one of its instances,\n its "__self__" attribute is the instance, and the method object\n is said to be bound. The new method\'s "__func__" attribute is\n the original function object.\n\n When a user-defined method object is created by retrieving\n another method object from a class or instance, the behaviour is\n the same as for a function object, except that the "__func__"\n attribute of the new instance is not the original method object\n but its "__func__" attribute.\n\n When an instance method object is created by retrieving a class\n method object from a class or instance, its "__self__" attribute\n is the class itself, and its "__func__" attribute is the\n function object underlying the class method.\n\n When an instance method object is called, the underlying\n function ("__func__") is called, inserting the class instance\n ("__self__") in front of the argument list. For instance, when\n "C" is a class which contains a definition for a function "f()",\n and "x" is an instance of "C", calling "x.f(1)" is equivalent to\n calling "C.f(x, 1)".\n\n When an instance method object is derived from a class method\n object, the "class instance" stored in "__self__" will actually\n be the class itself, so that calling either "x.f(1)" or "C.f(1)"\n is equivalent to calling "f(C,1)" where "f" is the underlying\n function.\n\n Note that the transformation from function object to instance\n method object happens each time the attribute is retrieved from\n the instance. In some cases, a fruitful optimization is to\n assign the attribute to a local variable and call that local\n variable. Also notice that this transformation only happens for\n user-defined functions; other callable objects (and all non-\n callable objects) are retrieved without transformation. It is\n also important to note that user-defined functions which are\n attributes of a class instance are not converted to bound\n methods; this *only* happens when the function is an attribute\n of the class.\n\n Generator functions\n A function or method which uses the "yield" statement (see\n section *The yield statement*) is called a *generator function*.\n Such a function, when called, always returns an iterator object\n which can be used to execute the body of the function: calling\n the iterator\'s "iterator.__next__()" method will cause the\n function to execute until it provides a value using the "yield"\n statement. When the function executes a "return" statement or\n falls off the end, a "StopIteration" exception is raised and the\n iterator will have reached the end of the set of values to be\n returned.\n\n Built-in functions\n A built-in function object is a wrapper around a C function.\n Examples of built-in functions are "len()" and "math.sin()"\n ("math" is a standard built-in module). The number and type of\n the arguments are determined by the C function. Special read-\n only attributes: "__doc__" is the function\'s documentation\n string, or "None" if unavailable; "__name__" is the function\'s\n name; "__self__" is set to "None" (but see the next item);\n "__module__" is the name of the module the function was defined\n in or "None" if unavailable.\n\n Built-in methods\n This is really a different disguise of a built-in function, this\n time containing an object passed to the C function as an\n implicit extra argument. An example of a built-in method is\n "alist.append()", assuming *alist* is a list object. In this\n case, the special read-only attribute "__self__" is set to the\n object denoted by *alist*.\n\n Classes\n Classes are callable. These objects normally act as factories\n for new instances of themselves, but variations are possible for\n class types that override "__new__()". The arguments of the\n call are passed to "__new__()" and, in the typical case, to\n "__init__()" to initialize the new instance.\n\n Class Instances\n Instances of arbitrary classes can be made callable by defining\n a "__call__()" method in their class.\n\nModules\n Modules are a basic organizational unit of Python code, and are\n created by the *import system* as invoked either by the "import"\n statement (see "import"), or by calling functions such as\n "importlib.import_module()" and built-in "__import__()". A module\n object has a namespace implemented by a dictionary object (this is\n the dictionary referenced by the "__globals__" attribute of\n functions defined in the module). Attribute references are\n translated to lookups in this dictionary, e.g., "m.x" is equivalent\n to "m.__dict__["x"]". A module object does not contain the code\n object used to initialize the module (since it isn\'t needed once\n the initialization is done).\n\n Attribute assignment updates the module\'s namespace dictionary,\n e.g., "m.x = 1" is equivalent to "m.__dict__["x"] = 1".\n\n Special read-only attribute: "__dict__" is the module\'s namespace\n as a dictionary object.\n\n **CPython implementation detail:** Because of the way CPython\n clears module dictionaries, the module dictionary will be cleared\n when the module falls out of scope even if the dictionary still has\n live references. To avoid this, copy the dictionary or keep the\n module around while using its dictionary directly.\n\n Predefined (writable) attributes: "__name__" is the module\'s name;\n "__doc__" is the module\'s documentation string, or "None" if\n unavailable; "__file__" is the pathname of the file from which the\n module was loaded, if it was loaded from a file. The "__file__"\n attribute may be missing for certain types of modules, such as C\n modules that are statically linked into the interpreter; for\n extension modules loaded dynamically from a shared library, it is\n the pathname of the shared library file.\n\nCustom classes\n Custom class types are typically created by class definitions (see\n section *Class definitions*). A class has a namespace implemented\n by a dictionary object. Class attribute references are translated\n to lookups in this dictionary, e.g., "C.x" is translated to\n "C.__dict__["x"]" (although there are a number of hooks which allow\n for other means of locating attributes). When the attribute name is\n not found there, the attribute search continues in the base\n classes. This search of the base classes uses the C3 method\n resolution order which behaves correctly even in the presence of\n \'diamond\' inheritance structures where there are multiple\n inheritance paths leading back to a common ancestor. Additional\n details on the C3 MRO used by Python can be found in the\n documentation accompanying the 2.3 release at\n https://www.python.org/download/releases/2.3/mro/.\n\n When a class attribute reference (for class "C", say) would yield a\n class method object, it is transformed into an instance method\n object whose "__self__" attributes is "C". When it would yield a\n static method object, it is transformed into the object wrapped by\n the static method object. See section *Implementing Descriptors*\n for another way in which attributes retrieved from a class may\n differ from those actually contained in its "__dict__".\n\n Class attribute assignments update the class\'s dictionary, never\n the dictionary of a base class.\n\n A class object can be called (see above) to yield a class instance\n (see below).\n\n Special attributes: "__name__" is the class name; "__module__" is\n the module name in which the class was defined; "__dict__" is the\n dictionary containing the class\'s namespace; "__bases__" is a tuple\n (possibly empty or a singleton) containing the base classes, in the\n order of their occurrence in the base class list; "__doc__" is the\n class\'s documentation string, or None if undefined.\n\nClass instances\n A class instance is created by calling a class object (see above).\n A class instance has a namespace implemented as a dictionary which\n is the first place in which attribute references are searched.\n When an attribute is not found there, and the instance\'s class has\n an attribute by that name, the search continues with the class\n attributes. If a class attribute is found that is a user-defined\n function object, it is transformed into an instance method object\n whose "__self__" attribute is the instance. Static method and\n class method objects are also transformed; see above under\n "Classes". See section *Implementing Descriptors* for another way\n in which attributes of a class retrieved via its instances may\n differ from the objects actually stored in the class\'s "__dict__".\n If no class attribute is found, and the object\'s class has a\n "__getattr__()" method, that is called to satisfy the lookup.\n\n Attribute assignments and deletions update the instance\'s\n dictionary, never a class\'s dictionary. If the class has a\n "__setattr__()" or "__delattr__()" method, this is called instead\n of updating the instance dictionary directly.\n\n Class instances can pretend to be numbers, sequences, or mappings\n if they have methods with certain special names. See section\n *Special method names*.\n\n Special attributes: "__dict__" is the attribute dictionary;\n "__class__" is the instance\'s class.\n\nI/O objects (also known as file objects)\n A *file object* represents an open file. Various shortcuts are\n available to create file objects: the "open()" built-in function,\n and also "os.popen()", "os.fdopen()", and the "makefile()" method\n of socket objects (and perhaps by other functions or methods\n provided by extension modules).\n\n The objects "sys.stdin", "sys.stdout" and "sys.stderr" are\n initialized to file objects corresponding to the interpreter\'s\n standard input, output and error streams; they are all open in text\n mode and therefore follow the interface defined by the\n "io.TextIOBase" abstract class.\n\nInternal types\n A few types used internally by the interpreter are exposed to the\n user. Their definitions may change with future versions of the\n interpreter, but they are mentioned here for completeness.\n\n Code objects\n Code objects represent *byte-compiled* executable Python code,\n or *bytecode*. The difference between a code object and a\n function object is that the function object contains an explicit\n reference to the function\'s globals (the module in which it was\n defined), while a code object contains no context; also the\n default argument values are stored in the function object, not\n in the code object (because they represent values calculated at\n run-time). Unlike function objects, code objects are immutable\n and contain no references (directly or indirectly) to mutable\n objects.\n\n Special read-only attributes: "co_name" gives the function name;\n "co_argcount" is the number of positional arguments (including\n arguments with default values); "co_nlocals" is the number of\n local variables used by the function (including arguments);\n "co_varnames" is a tuple containing the names of the local\n variables (starting with the argument names); "co_cellvars" is a\n tuple containing the names of local variables that are\n referenced by nested functions; "co_freevars" is a tuple\n containing the names of free variables; "co_code" is a string\n representing the sequence of bytecode instructions; "co_consts"\n is a tuple containing the literals used by the bytecode;\n "co_names" is a tuple containing the names used by the bytecode;\n "co_filename" is the filename from which the code was compiled;\n "co_firstlineno" is the first line number of the function;\n "co_lnotab" is a string encoding the mapping from bytecode\n offsets to line numbers (for details see the source code of the\n interpreter); "co_stacksize" is the required stack size\n (including local variables); "co_flags" is an integer encoding a\n number of flags for the interpreter.\n\n The following flag bits are defined for "co_flags": bit "0x04"\n is set if the function uses the "*arguments" syntax to accept an\n arbitrary number of positional arguments; bit "0x08" is set if\n the function uses the "**keywords" syntax to accept arbitrary\n keyword arguments; bit "0x20" is set if the function is a\n generator.\n\n Future feature declarations ("from __future__ import division")\n also use bits in "co_flags" to indicate whether a code object\n was compiled with a particular feature enabled: bit "0x2000" is\n set if the function was compiled with future division enabled;\n bits "0x10" and "0x1000" were used in earlier versions of\n Python.\n\n Other bits in "co_flags" are reserved for internal use.\n\n If a code object represents a function, the first item in\n "co_consts" is the documentation string of the function, or\n "None" if undefined.\n\n Frame objects\n Frame objects represent execution frames. They may occur in\n traceback objects (see below).\n\n Special read-only attributes: "f_back" is to the previous stack\n frame (towards the caller), or "None" if this is the bottom\n stack frame; "f_code" is the code object being executed in this\n frame; "f_locals" is the dictionary used to look up local\n variables; "f_globals" is used for global variables;\n "f_builtins" is used for built-in (intrinsic) names; "f_lasti"\n gives the precise instruction (this is an index into the\n bytecode string of the code object).\n\n Special writable attributes: "f_trace", if not "None", is a\n function called at the start of each source code line (this is\n used by the debugger); "f_lineno" is the current line number of\n the frame --- writing to this from within a trace function jumps\n to the given line (only for the bottom-most frame). A debugger\n can implement a Jump command (aka Set Next Statement) by writing\n to f_lineno.\n\n Frame objects support one method:\n\n frame.clear()\n\n This method clears all references to local variables held by\n the frame. Also, if the frame belonged to a generator, the\n generator is finalized. This helps break reference cycles\n involving frame objects (for example when catching an\n exception and storing its traceback for later use).\n\n "RuntimeError" is raised if the frame is currently executing.\n\n New in version 3.4.\n\n Traceback objects\n Traceback objects represent a stack trace of an exception. A\n traceback object is created when an exception occurs. When the\n search for an exception handler unwinds the execution stack, at\n each unwound level a traceback object is inserted in front of\n the current traceback. When an exception handler is entered,\n the stack trace is made available to the program. (See section\n *The try statement*.) It is accessible as the third item of the\n tuple returned by "sys.exc_info()". When the program contains no\n suitable handler, the stack trace is written (nicely formatted)\n to the standard error stream; if the interpreter is interactive,\n it is also made available to the user as "sys.last_traceback".\n\n Special read-only attributes: "tb_next" is the next level in the\n stack trace (towards the frame where the exception occurred), or\n "None" if there is no next level; "tb_frame" points to the\n execution frame of the current level; "tb_lineno" gives the line\n number where the exception occurred; "tb_lasti" indicates the\n precise instruction. The line number and last instruction in\n the traceback may differ from the line number of its frame\n object if the exception occurred in a "try" statement with no\n matching except clause or with a finally clause.\n\n Slice objects\n Slice objects are used to represent slices for "__getitem__()"\n methods. They are also created by the built-in "slice()"\n function.\n\n Special read-only attributes: "start" is the lower bound; "stop"\n is the upper bound; "step" is the step value; each is "None" if\n omitted. These attributes can have any type.\n\n Slice objects support one method:\n\n slice.indices(self, length)\n\n This method takes a single integer argument *length* and\n computes information about the slice that the slice object\n would describe if applied to a sequence of *length* items.\n It returns a tuple of three integers; respectively these are\n the *start* and *stop* indices and the *step* or stride\n length of the slice. Missing or out-of-bounds indices are\n handled in a manner consistent with regular slices.\n\n Static method objects\n Static method objects provide a way of defeating the\n transformation of function objects to method objects described\n above. A static method object is a wrapper around any other\n object, usually a user-defined method object. When a static\n method object is retrieved from a class or a class instance, the\n object actually returned is the wrapped object, which is not\n subject to any further transformation. Static method objects are\n not themselves callable, although the objects they wrap usually\n are. Static method objects are created by the built-in\n "staticmethod()" constructor.\n\n Class method objects\n A class method object, like a static method object, is a wrapper\n around another object that alters the way in which that object\n is retrieved from classes and class instances. The behaviour of\n class method objects upon such retrieval is described above,\n under "User-defined methods". Class method objects are created\n by the built-in "classmethod()" constructor.\n', 'typesfunctions': u'\nFunctions\n*********\n\nFunction objects are created by function definitions. The only\noperation on a function object is to call it: "func(argument-list)".\n\nThere are really two flavors of function objects: built-in functions\nand user-defined functions. Both support the same operation (to call\nthe function), but the implementation is different, hence the\ndifferent object types.\n\nSee *Function definitions* for more information.\n', - 'typesmapping': u'\nMapping Types --- "dict"\n************************\n\nA *mapping* object maps *hashable* values to arbitrary objects.\nMappings are mutable objects. There is currently only one standard\nmapping type, the *dictionary*. (For other containers see the built-\nin "list", "set", and "tuple" classes, and the "collections" module.)\n\nA dictionary\'s keys are *almost* arbitrary values. Values that are\nnot *hashable*, that is, values containing lists, dictionaries or\nother mutable types (that are compared by value rather than by object\nidentity) may not be used as keys. Numeric types used for keys obey\nthe normal rules for numeric comparison: if two numbers compare equal\n(such as "1" and "1.0") then they can be used interchangeably to index\nthe same dictionary entry. (Note however, that since computers store\nfloating-point numbers as approximations it is usually unwise to use\nthem as dictionary keys.)\n\nDictionaries can be created by placing a comma-separated list of "key:\nvalue" pairs within braces, for example: "{\'jack\': 4098, \'sjoerd\':\n4127}" or "{4098: \'jack\', 4127: \'sjoerd\'}", or by the "dict"\nconstructor.\n\nclass class dict(**kwarg)\nclass class dict(mapping, **kwarg)\nclass class dict(iterable, **kwarg)\n\n Return a new dictionary initialized from an optional positional\n argument and a possibly empty set of keyword arguments.\n\n If no positional argument is given, an empty dictionary is created.\n If a positional argument is given and it is a mapping object, a\n dictionary is created with the same key-value pairs as the mapping\n object. Otherwise, the positional argument must be an *iterable*\n object. Each item in the iterable must itself be an iterable with\n exactly two objects. The first object of each item becomes a key\n in the new dictionary, and the second object the corresponding\n value. If a key occurs more than once, the last value for that key\n becomes the corresponding value in the new dictionary.\n\n If keyword arguments are given, the keyword arguments and their\n values are added to the dictionary created from the positional\n argument. If a key being added is already present, the value from\n the keyword argument replaces the value from the positional\n argument.\n\n To illustrate, the following examples all return a dictionary equal\n to "{"one": 1, "two": 2, "three": 3}":\n\n >>> a = dict(one=1, two=2, three=3)\n >>> b = {\'one\': 1, \'two\': 2, \'three\': 3}\n >>> c = dict(zip([\'one\', \'two\', \'three\'], [1, 2, 3]))\n >>> d = dict([(\'two\', 2), (\'one\', 1), (\'three\', 3)])\n >>> e = dict({\'three\': 3, \'one\': 1, \'two\': 2})\n >>> a == b == c == d == e\n True\n\n Providing keyword arguments as in the first example only works for\n keys that are valid Python identifiers. Otherwise, any valid keys\n can be used.\n\n These are the operations that dictionaries support (and therefore,\n custom mapping types should support too):\n\n len(d)\n\n Return the number of items in the dictionary *d*.\n\n d[key]\n\n Return the item of *d* with key *key*. Raises a "KeyError" if\n *key* is not in the map.\n\n If a subclass of dict defines a method "__missing__()" and *key*\n is not present, the "d[key]" operation calls that method with\n the key *key* as argument. The "d[key]" operation then returns\n or raises whatever is returned or raised by the\n "__missing__(key)" call. No other operations or methods invoke\n "__missing__()". If "__missing__()" is not defined, "KeyError"\n is raised. "__missing__()" must be a method; it cannot be an\n instance variable:\n\n >>> class Counter(dict):\n ... def __missing__(self, key):\n ... return 0\n >>> c = Counter()\n >>> c[\'red\']\n 0\n >>> c[\'red\'] += 1\n >>> c[\'red\']\n 1\n\n The example above shows part of the implementation of\n "collections.Counter". A different "__missing__" method is used\n by "collections.defaultdict".\n\n d[key] = value\n\n Set "d[key]" to *value*.\n\n del d[key]\n\n Remove "d[key]" from *d*. Raises a "KeyError" if *key* is not\n in the map.\n\n key in d\n\n Return "True" if *d* has a key *key*, else "False".\n\n key not in d\n\n Equivalent to "not key in d".\n\n iter(d)\n\n Return an iterator over the keys of the dictionary. This is a\n shortcut for "iter(d.keys())".\n\n clear()\n\n Remove all items from the dictionary.\n\n copy()\n\n Return a shallow copy of the dictionary.\n\n classmethod fromkeys(seq[, value])\n\n Create a new dictionary with keys from *seq* and values set to\n *value*.\n\n "fromkeys()" is a class method that returns a new dictionary.\n *value* defaults to "None".\n\n get(key[, default])\n\n Return the value for *key* if *key* is in the dictionary, else\n *default*. If *default* is not given, it defaults to "None", so\n that this method never raises a "KeyError".\n\n items()\n\n Return a new view of the dictionary\'s items ("(key, value)"\n pairs). See the *documentation of view objects*.\n\n keys()\n\n Return a new view of the dictionary\'s keys. See the\n *documentation of view objects*.\n\n pop(key[, default])\n\n If *key* is in the dictionary, remove it and return its value,\n else return *default*. If *default* is not given and *key* is\n not in the dictionary, a "KeyError" is raised.\n\n popitem()\n\n Remove and return an arbitrary "(key, value)" pair from the\n dictionary.\n\n "popitem()" is useful to destructively iterate over a\n dictionary, as often used in set algorithms. If the dictionary\n is empty, calling "popitem()" raises a "KeyError".\n\n setdefault(key[, default])\n\n If *key* is in the dictionary, return its value. If not, insert\n *key* with a value of *default* and return *default*. *default*\n defaults to "None".\n\n update([other])\n\n Update the dictionary with the key/value pairs from *other*,\n overwriting existing keys. Return "None".\n\n "update()" accepts either another dictionary object or an\n iterable of key/value pairs (as tuples or other iterables of\n length two). If keyword arguments are specified, the dictionary\n is then updated with those key/value pairs: "d.update(red=1,\n blue=2)".\n\n values()\n\n Return a new view of the dictionary\'s values. See the\n *documentation of view objects*.\n\nSee also: "types.MappingProxyType" can be used to create a read-only\n view of a "dict".\n\n\nDictionary view objects\n=======================\n\nThe objects returned by "dict.keys()", "dict.values()" and\n"dict.items()" are *view objects*. They provide a dynamic view on the\ndictionary\'s entries, which means that when the dictionary changes,\nthe view reflects these changes.\n\nDictionary views can be iterated over to yield their respective data,\nand support membership tests:\n\nlen(dictview)\n\n Return the number of entries in the dictionary.\n\niter(dictview)\n\n Return an iterator over the keys, values or items (represented as\n tuples of "(key, value)") in the dictionary.\n\n Keys and values are iterated over in an arbitrary order which is\n non-random, varies across Python implementations, and depends on\n the dictionary\'s history of insertions and deletions. If keys,\n values and items views are iterated over with no intervening\n modifications to the dictionary, the order of items will directly\n correspond. This allows the creation of "(value, key)" pairs using\n "zip()": "pairs = zip(d.values(), d.keys())". Another way to\n create the same list is "pairs = [(v, k) for (k, v) in d.items()]".\n\n Iterating views while adding or deleting entries in the dictionary\n may raise a "RuntimeError" or fail to iterate over all entries.\n\nx in dictview\n\n Return "True" if *x* is in the underlying dictionary\'s keys, values\n or items (in the latter case, *x* should be a "(key, value)"\n tuple).\n\nKeys views are set-like since their entries are unique and hashable.\nIf all values are hashable, so that "(key, value)" pairs are unique\nand hashable, then the items view is also set-like. (Values views are\nnot treated as set-like since the entries are generally not unique.)\nFor set-like views, all of the operations defined for the abstract\nbase class "collections.abc.Set" are available (for example, "==",\n"<", or "^").\n\nAn example of dictionary view usage:\n\n >>> dishes = {\'eggs\': 2, \'sausage\': 1, \'bacon\': 1, \'spam\': 500}\n >>> keys = dishes.keys()\n >>> values = dishes.values()\n\n >>> # iteration\n >>> n = 0\n >>> for val in values:\n ... n += val\n >>> print(n)\n 504\n\n >>> # keys and values are iterated over in the same order\n >>> list(keys)\n [\'eggs\', \'bacon\', \'sausage\', \'spam\']\n >>> list(values)\n [2, 1, 1, 500]\n\n >>> # view objects are dynamic and reflect dict changes\n >>> del dishes[\'eggs\']\n >>> del dishes[\'sausage\']\n >>> list(keys)\n [\'spam\', \'bacon\']\n\n >>> # set operations\n >>> keys & {\'eggs\', \'bacon\', \'salad\'}\n {\'bacon\'}\n >>> keys ^ {\'sausage\', \'juice\'}\n {\'juice\', \'sausage\', \'bacon\', \'spam\'}\n', + 'typesmapping': u'\nMapping Types --- "dict"\n************************\n\nA *mapping* object maps *hashable* values to arbitrary objects.\nMappings are mutable objects. There is currently only one standard\nmapping type, the *dictionary*. (For other containers see the built-\nin "list", "set", and "tuple" classes, and the "collections" module.)\n\nA dictionary\'s keys are *almost* arbitrary values. Values that are\nnot *hashable*, that is, values containing lists, dictionaries or\nother mutable types (that are compared by value rather than by object\nidentity) may not be used as keys. Numeric types used for keys obey\nthe normal rules for numeric comparison: if two numbers compare equal\n(such as "1" and "1.0") then they can be used interchangeably to index\nthe same dictionary entry. (Note however, that since computers store\nfloating-point numbers as approximations it is usually unwise to use\nthem as dictionary keys.)\n\nDictionaries can be created by placing a comma-separated list of "key:\nvalue" pairs within braces, for example: "{\'jack\': 4098, \'sjoerd\':\n4127}" or "{4098: \'jack\', 4127: \'sjoerd\'}", or by the "dict"\nconstructor.\n\nclass class dict(**kwarg)\nclass class dict(mapping, **kwarg)\nclass class dict(iterable, **kwarg)\n\n Return a new dictionary initialized from an optional positional\n argument and a possibly empty set of keyword arguments.\n\n If no positional argument is given, an empty dictionary is created.\n If a positional argument is given and it is a mapping object, a\n dictionary is created with the same key-value pairs as the mapping\n object. Otherwise, the positional argument must be an *iterable*\n object. Each item in the iterable must itself be an iterable with\n exactly two objects. The first object of each item becomes a key\n in the new dictionary, and the second object the corresponding\n value. If a key occurs more than once, the last value for that key\n becomes the corresponding value in the new dictionary.\n\n If keyword arguments are given, the keyword arguments and their\n values are added to the dictionary created from the positional\n argument. If a key being added is already present, the value from\n the keyword argument replaces the value from the positional\n argument.\n\n To illustrate, the following examples all return a dictionary equal\n to "{"one": 1, "two": 2, "three": 3}":\n\n >>> a = dict(one=1, two=2, three=3)\n >>> b = {\'one\': 1, \'two\': 2, \'three\': 3}\n >>> c = dict(zip([\'one\', \'two\', \'three\'], [1, 2, 3]))\n >>> d = dict([(\'two\', 2), (\'one\', 1), (\'three\', 3)])\n >>> e = dict({\'three\': 3, \'one\': 1, \'two\': 2})\n >>> a == b == c == d == e\n True\n\n Providing keyword arguments as in the first example only works for\n keys that are valid Python identifiers. Otherwise, any valid keys\n can be used.\n\n These are the operations that dictionaries support (and therefore,\n custom mapping types should support too):\n\n len(d)\n\n Return the number of items in the dictionary *d*.\n\n d[key]\n\n Return the item of *d* with key *key*. Raises a "KeyError" if\n *key* is not in the map.\n\n If a subclass of dict defines a method "__missing__()" and *key*\n is not present, the "d[key]" operation calls that method with\n the key *key* as argument. The "d[key]" operation then returns\n or raises whatever is returned or raised by the\n "__missing__(key)" call. No other operations or methods invoke\n "__missing__()". If "__missing__()" is not defined, "KeyError"\n is raised. "__missing__()" must be a method; it cannot be an\n instance variable:\n\n >>> class Counter(dict):\n ... def __missing__(self, key):\n ... return 0\n >>> c = Counter()\n >>> c[\'red\']\n 0\n >>> c[\'red\'] += 1\n >>> c[\'red\']\n 1\n\n The example above shows part of the implementation of\n "collections.Counter". A different "__missing__" method is used\n by "collections.defaultdict".\n\n d[key] = value\n\n Set "d[key]" to *value*.\n\n del d[key]\n\n Remove "d[key]" from *d*. Raises a "KeyError" if *key* is not\n in the map.\n\n key in d\n\n Return "True" if *d* has a key *key*, else "False".\n\n key not in d\n\n Equivalent to "not key in d".\n\n iter(d)\n\n Return an iterator over the keys of the dictionary. This is a\n shortcut for "iter(d.keys())".\n\n clear()\n\n Remove all items from the dictionary.\n\n copy()\n\n Return a shallow copy of the dictionary.\n\n classmethod fromkeys(seq[, value])\n\n Create a new dictionary with keys from *seq* and values set to\n *value*.\n\n "fromkeys()" is a class method that returns a new dictionary.\n *value* defaults to "None".\n\n get(key[, default])\n\n Return the value for *key* if *key* is in the dictionary, else\n *default*. If *default* is not given, it defaults to "None", so\n that this method never raises a "KeyError".\n\n items()\n\n Return a new view of the dictionary\'s items ("(key, value)"\n pairs). See the *documentation of view objects*.\n\n keys()\n\n Return a new view of the dictionary\'s keys. See the\n *documentation of view objects*.\n\n pop(key[, default])\n\n If *key* is in the dictionary, remove it and return its value,\n else return *default*. If *default* is not given and *key* is\n not in the dictionary, a "KeyError" is raised.\n\n popitem()\n\n Remove and return an arbitrary "(key, value)" pair from the\n dictionary.\n\n "popitem()" is useful to destructively iterate over a\n dictionary, as often used in set algorithms. If the dictionary\n is empty, calling "popitem()" raises a "KeyError".\n\n setdefault(key[, default])\n\n If *key* is in the dictionary, return its value. If not, insert\n *key* with a value of *default* and return *default*. *default*\n defaults to "None".\n\n update([other])\n\n Update the dictionary with the key/value pairs from *other*,\n overwriting existing keys. Return "None".\n\n "update()" accepts either another dictionary object or an\n iterable of key/value pairs (as tuples or other iterables of\n length two). If keyword arguments are specified, the dictionary\n is then updated with those key/value pairs: "d.update(red=1,\n blue=2)".\n\n values()\n\n Return a new view of the dictionary\'s values. See the\n *documentation of view objects*.\n\n Dictionaries compare equal if and only if they have the same "(key,\n value)" pairs. Order comparisons (\'<\', \'<=\', \'>=\', \'>\') raise\n "TypeError".\n\nSee also: "types.MappingProxyType" can be used to create a read-only\n view of a "dict".\n\n\nDictionary view objects\n=======================\n\nThe objects returned by "dict.keys()", "dict.values()" and\n"dict.items()" are *view objects*. They provide a dynamic view on the\ndictionary\'s entries, which means that when the dictionary changes,\nthe view reflects these changes.\n\nDictionary views can be iterated over to yield their respective data,\nand support membership tests:\n\nlen(dictview)\n\n Return the number of entries in the dictionary.\n\niter(dictview)\n\n Return an iterator over the keys, values or items (represented as\n tuples of "(key, value)") in the dictionary.\n\n Keys and values are iterated over in an arbitrary order which is\n non-random, varies across Python implementations, and depends on\n the dictionary\'s history of insertions and deletions. If keys,\n values and items views are iterated over with no intervening\n modifications to the dictionary, the order of items will directly\n correspond. This allows the creation of "(value, key)" pairs using\n "zip()": "pairs = zip(d.values(), d.keys())". Another way to\n create the same list is "pairs = [(v, k) for (k, v) in d.items()]".\n\n Iterating views while adding or deleting entries in the dictionary\n may raise a "RuntimeError" or fail to iterate over all entries.\n\nx in dictview\n\n Return "True" if *x* is in the underlying dictionary\'s keys, values\n or items (in the latter case, *x* should be a "(key, value)"\n tuple).\n\nKeys views are set-like since their entries are unique and hashable.\nIf all values are hashable, so that "(key, value)" pairs are unique\nand hashable, then the items view is also set-like. (Values views are\nnot treated as set-like since the entries are generally not unique.)\nFor set-like views, all of the operations defined for the abstract\nbase class "collections.abc.Set" are available (for example, "==",\n"<", or "^").\n\nAn example of dictionary view usage:\n\n >>> dishes = {\'eggs\': 2, \'sausage\': 1, \'bacon\': 1, \'spam\': 500}\n >>> keys = dishes.keys()\n >>> values = dishes.values()\n\n >>> # iteration\n >>> n = 0\n >>> for val in values:\n ... n += val\n >>> print(n)\n 504\n\n >>> # keys and values are iterated over in the same order\n >>> list(keys)\n [\'eggs\', \'bacon\', \'sausage\', \'spam\']\n >>> list(values)\n [2, 1, 1, 500]\n\n >>> # view objects are dynamic and reflect dict changes\n >>> del dishes[\'eggs\']\n >>> del dishes[\'sausage\']\n >>> list(keys)\n [\'spam\', \'bacon\']\n\n >>> # set operations\n >>> keys & {\'eggs\', \'bacon\', \'salad\'}\n {\'bacon\'}\n >>> keys ^ {\'sausage\', \'juice\'}\n {\'juice\', \'sausage\', \'bacon\', \'spam\'}\n', 'typesmethods': u'\nMethods\n*******\n\nMethods are functions that are called using the attribute notation.\nThere are two flavors: built-in methods (such as "append()" on lists)\nand class instance methods. Built-in methods are described with the\ntypes that support them.\n\nIf you access a method (a function defined in a class namespace)\nthrough an instance, you get a special object: a *bound method* (also\ncalled *instance method*) object. When called, it will add the "self"\nargument to the argument list. Bound methods have two special read-\nonly attributes: "m.__self__" is the object on which the method\noperates, and "m.__func__" is the function implementing the method.\nCalling "m(arg-1, arg-2, ..., arg-n)" is completely equivalent to\ncalling "m.__func__(m.__self__, arg-1, arg-2, ..., arg-n)".\n\nLike function objects, bound method objects support getting arbitrary\nattributes. However, since method attributes are actually stored on\nthe underlying function object ("meth.__func__"), setting method\nattributes on bound methods is disallowed. Attempting to set an\nattribute on a method results in an "AttributeError" being raised. In\norder to set a method attribute, you need to explicitly set it on the\nunderlying function object:\n\n >>> class C:\n ... def method(self):\n ... pass\n ...\n >>> c = C()\n >>> c.method.whoami = \'my name is method\' # can\'t set on the method\n Traceback (most recent call last):\n File "", line 1, in \n AttributeError: \'method\' object has no attribute \'whoami\'\n >>> c.method.__func__.whoami = \'my name is method\'\n >>> c.method.whoami\n \'my name is method\'\n\nSee *The standard type hierarchy* for more information.\n', 'typesmodules': u'\nModules\n*******\n\nThe only special operation on a module is attribute access: "m.name",\nwhere *m* is a module and *name* accesses a name defined in *m*\'s\nsymbol table. Module attributes can be assigned to. (Note that the\n"import" statement is not, strictly speaking, an operation on a module\nobject; "import foo" does not require a module object named *foo* to\nexist, rather it requires an (external) *definition* for a module\nnamed *foo* somewhere.)\n\nA special attribute of every module is "__dict__". This is the\ndictionary containing the module\'s symbol table. Modifying this\ndictionary will actually change the module\'s symbol table, but direct\nassignment to the "__dict__" attribute is not possible (you can write\n"m.__dict__[\'a\'] = 1", which defines "m.a" to be "1", but you can\'t\nwrite "m.__dict__ = {}"). Modifying "__dict__" directly is not\nrecommended.\n\nModules built into the interpreter are written like this: "". If loaded from a file, they are written as\n"".\n', - 'typesseq': u'\nSequence Types --- "list", "tuple", "range"\n*******************************************\n\nThere are three basic sequence types: lists, tuples, and range\nobjects. Additional sequence types tailored for processing of *binary\ndata* and *text strings* are described in dedicated sections.\n\n\nCommon Sequence Operations\n==========================\n\nThe operations in the following table are supported by most sequence\ntypes, both mutable and immutable. The "collections.abc.Sequence" ABC\nis provided to make it easier to correctly implement these operations\non custom sequence types.\n\nThis table lists the sequence operations sorted in ascending priority.\nIn the table, *s* and *t* are sequences of the same type, *n*, *i*,\n*j* and *k* are integers and *x* is an arbitrary object that meets any\ntype and value restrictions imposed by *s*.\n\nThe "in" and "not in" operations have the same priorities as the\ncomparison operations. The "+" (concatenation) and "*" (repetition)\noperations have the same priority as the corresponding numeric\noperations.\n\n+----------------------------+----------------------------------+------------+\n| Operation | Result | Notes |\n+============================+==================================+============+\n| "x in s" | "True" if an item of *s* is | (1) |\n| | equal to *x*, else "False" | |\n+----------------------------+----------------------------------+------------+\n| "x not in s" | "False" if an item of *s* is | (1) |\n| | equal to *x*, else "True" | |\n+----------------------------+----------------------------------+------------+\n| "s + t" | the concatenation of *s* and *t* | (6)(7) |\n+----------------------------+----------------------------------+------------+\n| "s * n" or "n * s" | *n* shallow copies of *s* | (2)(7) |\n| | concatenated | |\n+----------------------------+----------------------------------+------------+\n| "s[i]" | *i*th item of *s*, origin 0 | (3) |\n+----------------------------+----------------------------------+------------+\n| "s[i:j]" | slice of *s* from *i* to *j* | (3)(4) |\n+----------------------------+----------------------------------+------------+\n| "s[i:j:k]" | slice of *s* from *i* to *j* | (3)(5) |\n| | with step *k* | |\n+----------------------------+----------------------------------+------------+\n| "len(s)" | length of *s* | |\n+----------------------------+----------------------------------+------------+\n| "min(s)" | smallest item of *s* | |\n+----------------------------+----------------------------------+------------+\n| "max(s)" | largest item of *s* | |\n+----------------------------+----------------------------------+------------+\n| "s.index(x[, i[, j]])" | index of the first occurrence of | (8) |\n| | *x* in *s* (at or after index | |\n| | *i* and before index *j*) | |\n+----------------------------+----------------------------------+------------+\n| "s.count(x)" | total number of occurrences of | |\n| | *x* in *s* | |\n+----------------------------+----------------------------------+------------+\n\nSequences of the same type also support comparisons. In particular,\ntuples and lists are compared lexicographically by comparing\ncorresponding elements. This means that to compare equal, every\nelement must compare equal and the two sequences must be of the same\ntype and have the same length. (For full details see *Comparisons* in\nthe language reference.)\n\nNotes:\n\n1. While the "in" and "not in" operations are used only for simple\n containment testing in the general case, some specialised sequences\n (such as "str", "bytes" and "bytearray") also use them for\n subsequence testing:\n\n >>> "gg" in "eggs"\n True\n\n2. Values of *n* less than "0" are treated as "0" (which yields an\n empty sequence of the same type as *s*). Note also that the copies\n are shallow; nested structures are not copied. This often haunts\n new Python programmers; consider:\n\n >>> lists = [[]] * 3\n >>> lists\n [[], [], []]\n >>> lists[0].append(3)\n >>> lists\n [[3], [3], [3]]\n\n What has happened is that "[[]]" is a one-element list containing\n an empty list, so all three elements of "[[]] * 3" are (pointers\n to) this single empty list. Modifying any of the elements of\n "lists" modifies this single list. You can create a list of\n different lists this way:\n\n >>> lists = [[] for i in range(3)]\n >>> lists[0].append(3)\n >>> lists[1].append(5)\n >>> lists[2].append(7)\n >>> lists\n [[3], [5], [7]]\n\n3. If *i* or *j* is negative, the index is relative to the end of\n the string: "len(s) + i" or "len(s) + j" is substituted. But note\n that "-0" is still "0".\n\n4. The slice of *s* from *i* to *j* is defined as the sequence of\n items with index *k* such that "i <= k < j". If *i* or *j* is\n greater than "len(s)", use "len(s)". If *i* is omitted or "None",\n use "0". If *j* is omitted or "None", use "len(s)". If *i* is\n greater than or equal to *j*, the slice is empty.\n\n5. The slice of *s* from *i* to *j* with step *k* is defined as the\n sequence of items with index "x = i + n*k" such that "0 <= n <\n (j-i)/k". In other words, the indices are "i", "i+k", "i+2*k",\n "i+3*k" and so on, stopping when *j* is reached (but never\n including *j*). If *i* or *j* is greater than "len(s)", use\n "len(s)". If *i* or *j* are omitted or "None", they become "end"\n values (which end depends on the sign of *k*). Note, *k* cannot be\n zero. If *k* is "None", it is treated like "1".\n\n6. Concatenating immutable sequences always results in a new\n object. This means that building up a sequence by repeated\n concatenation will have a quadratic runtime cost in the total\n sequence length. To get a linear runtime cost, you must switch to\n one of the alternatives below:\n\n * if concatenating "str" objects, you can build a list and use\n "str.join()" at the end or else write to a "io.StringIO" instance\n and retrieve its value when complete\n\n * if concatenating "bytes" objects, you can similarly use\n "bytes.join()" or "io.BytesIO", or you can do in-place\n concatenation with a "bytearray" object. "bytearray" objects are\n mutable and have an efficient overallocation mechanism\n\n * if concatenating "tuple" objects, extend a "list" instead\n\n * for other types, investigate the relevant class documentation\n\n7. Some sequence types (such as "range") only support item\n sequences that follow specific patterns, and hence don\'t support\n sequence concatenation or repetition.\n\n8. "index" raises "ValueError" when *x* is not found in *s*. When\n supported, the additional arguments to the index method allow\n efficient searching of subsections of the sequence. Passing the\n extra arguments is roughly equivalent to using "s[i:j].index(x)",\n only without copying any data and with the returned index being\n relative to the start of the sequence rather than the start of the\n slice.\n\n\nImmutable Sequence Types\n========================\n\nThe only operation that immutable sequence types generally implement\nthat is not also implemented by mutable sequence types is support for\nthe "hash()" built-in.\n\nThis support allows immutable sequences, such as "tuple" instances, to\nbe used as "dict" keys and stored in "set" and "frozenset" instances.\n\nAttempting to hash an immutable sequence that contains unhashable\nvalues will result in "TypeError".\n\n\nMutable Sequence Types\n======================\n\nThe operations in the following table are defined on mutable sequence\ntypes. The "collections.abc.MutableSequence" ABC is provided to make\nit easier to correctly implement these operations on custom sequence\ntypes.\n\nIn the table *s* is an instance of a mutable sequence type, *t* is any\niterable object and *x* is an arbitrary object that meets any type and\nvalue restrictions imposed by *s* (for example, "bytearray" only\naccepts integers that meet the value restriction "0 <= x <= 255").\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| "s[i] = x" | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j] = t" | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j]" | same as "s[i:j] = []" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j:k] = t" | the elements of "s[i:j:k]" are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j:k]" | removes the elements of | |\n| | "s[i:j:k]" from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.append(x)" | appends *x* to the end of the | |\n| | sequence (same as | |\n| | "s[len(s):len(s)] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.clear()" | removes all items from "s" (same | (5) |\n| | as "del s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.copy()" | creates a shallow copy of "s" | (5) |\n| | (same as "s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.extend(t)" | extends *s* with the contents of | |\n| | *t* (same as "s[len(s):len(s)] = | |\n| | t") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.insert(i, x)" | inserts *x* into *s* at the | |\n| | index given by *i* (same as | |\n| | "s[i:i] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.pop([i])" | retrieves the item at *i* and | (2) |\n| | also removes it from *s* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.remove(x)" | remove the first item from *s* | (3) |\n| | where "s[i] == x" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.reverse()" | reverses the items of *s* in | (4) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The optional argument *i* defaults to "-1", so that by default\n the last item is removed and returned.\n\n3. "remove" raises "ValueError" when *x* is not found in *s*.\n\n4. The "reverse()" method modifies the sequence in place for\n economy of space when reversing a large sequence. To remind users\n that it operates by side effect, it does not return the reversed\n sequence.\n\n5. "clear()" and "copy()" are included for consistency with the\n interfaces of mutable containers that don\'t support slicing\n operations (such as "dict" and "set")\n\n New in version 3.3: "clear()" and "copy()" methods.\n\n\nLists\n=====\n\nLists are mutable sequences, typically used to store collections of\nhomogeneous items (where the precise degree of similarity will vary by\napplication).\n\nclass class list([iterable])\n\n Lists may be constructed in several ways:\n\n * Using a pair of square brackets to denote the empty list: "[]"\n\n * Using square brackets, separating items with commas: "[a]",\n "[a, b, c]"\n\n * Using a list comprehension: "[x for x in iterable]"\n\n * Using the type constructor: "list()" or "list(iterable)"\n\n The constructor builds a list whose items are the same and in the\n same order as *iterable*\'s items. *iterable* may be either a\n sequence, a container that supports iteration, or an iterator\n object. If *iterable* is already a list, a copy is made and\n returned, similar to "iterable[:]". For example, "list(\'abc\')"\n returns "[\'a\', \'b\', \'c\']" and "list( (1, 2, 3) )" returns "[1, 2,\n 3]". If no argument is given, the constructor creates a new empty\n list, "[]".\n\n Many other operations also produce lists, including the "sorted()"\n built-in.\n\n Lists implement all of the *common* and *mutable* sequence\n operations. Lists also provide the following additional method:\n\n sort(*, key=None, reverse=None)\n\n This method sorts the list in place, using only "<" comparisons\n between items. Exceptions are not suppressed - if any comparison\n operations fail, the entire sort operation will fail (and the\n list will likely be left in a partially modified state).\n\n "sort()" accepts two arguments that can only be passed by\n keyword (*keyword-only arguments*):\n\n *key* specifies a function of one argument that is used to\n extract a comparison key from each list element (for example,\n "key=str.lower"). The key corresponding to each item in the list\n is calculated once and then used for the entire sorting process.\n The default value of "None" means that list items are sorted\n directly without calculating a separate key value.\n\n The "functools.cmp_to_key()" utility is available to convert a\n 2.x style *cmp* function to a *key* function.\n\n *reverse* is a boolean value. If set to "True", then the list\n elements are sorted as if each comparison were reversed.\n\n This method modifies the sequence in place for economy of space\n when sorting a large sequence. To remind users that it operates\n by side effect, it does not return the sorted sequence (use\n "sorted()" to explicitly request a new sorted list instance).\n\n The "sort()" method is guaranteed to be stable. A sort is\n stable if it guarantees not to change the relative order of\n elements that compare equal --- this is helpful for sorting in\n multiple passes (for example, sort by department, then by salary\n grade).\n\n **CPython implementation detail:** While a list is being sorted,\n the effect of attempting to mutate, or even inspect, the list is\n undefined. The C implementation of Python makes the list appear\n empty for the duration, and raises "ValueError" if it can detect\n that the list has been mutated during a sort.\n\n\nTuples\n======\n\nTuples are immutable sequences, typically used to store collections of\nheterogeneous data (such as the 2-tuples produced by the "enumerate()"\nbuilt-in). Tuples are also used for cases where an immutable sequence\nof homogeneous data is needed (such as allowing storage in a "set" or\n"dict" instance).\n\nclass class tuple([iterable])\n\n Tuples may be constructed in a number of ways:\n\n * Using a pair of parentheses to denote the empty tuple: "()"\n\n * Using a trailing comma for a singleton tuple: "a," or "(a,)"\n\n * Separating items with commas: "a, b, c" or "(a, b, c)"\n\n * Using the "tuple()" built-in: "tuple()" or "tuple(iterable)"\n\n The constructor builds a tuple whose items are the same and in the\n same order as *iterable*\'s items. *iterable* may be either a\n sequence, a container that supports iteration, or an iterator\n object. If *iterable* is already a tuple, it is returned\n unchanged. For example, "tuple(\'abc\')" returns "(\'a\', \'b\', \'c\')"\n and "tuple( [1, 2, 3] )" returns "(1, 2, 3)". If no argument is\n given, the constructor creates a new empty tuple, "()".\n\n Note that it is actually the comma which makes a tuple, not the\n parentheses. The parentheses are optional, except in the empty\n tuple case, or when they are needed to avoid syntactic ambiguity.\n For example, "f(a, b, c)" is a function call with three arguments,\n while "f((a, b, c))" is a function call with a 3-tuple as the sole\n argument.\n\n Tuples implement all of the *common* sequence operations.\n\nFor heterogeneous collections of data where access by name is clearer\nthan access by index, "collections.namedtuple()" may be a more\nappropriate choice than a simple tuple object.\n\n\nRanges\n======\n\nThe "range" type represents an immutable sequence of numbers and is\ncommonly used for looping a specific number of times in "for" loops.\n\nclass class range(stop)\nclass class range(start, stop[, step])\n\n The arguments to the range constructor must be integers (either\n built-in "int" or any object that implements the "__index__"\n special method). If the *step* argument is omitted, it defaults to\n "1". If the *start* argument is omitted, it defaults to "0". If\n *step* is zero, "ValueError" is raised.\n\n For a positive *step*, the contents of a range "r" are determined\n by the formula "r[i] = start + step*i" where "i >= 0" and "r[i] <\n stop".\n\n For a negative *step*, the contents of the range are still\n determined by the formula "r[i] = start + step*i", but the\n constraints are "i >= 0" and "r[i] > stop".\n\n A range object will be empty if "r[0]" does not meet the value\n constraint. Ranges do support negative indices, but these are\n interpreted as indexing from the end of the sequence determined by\n the positive indices.\n\n Ranges containing absolute values larger than "sys.maxsize" are\n permitted but some features (such as "len()") may raise\n "OverflowError".\n\n Range examples:\n\n >>> list(range(10))\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n >>> list(range(1, 11))\n [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n >>> list(range(0, 30, 5))\n [0, 5, 10, 15, 20, 25]\n >>> list(range(0, 10, 3))\n [0, 3, 6, 9]\n >>> list(range(0, -10, -1))\n [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n >>> list(range(0))\n []\n >>> list(range(1, 0))\n []\n\n Ranges implement all of the *common* sequence operations except\n concatenation and repetition (due to the fact that range objects\n can only represent sequences that follow a strict pattern and\n repetition and concatenation will usually violate that pattern).\n\nThe advantage of the "range" type over a regular "list" or "tuple" is\nthat a "range" object will always take the same (small) amount of\nmemory, no matter the size of the range it represents (as it only\nstores the "start", "stop" and "step" values, calculating individual\nitems and subranges as needed).\n\nRange objects implement the "collections.abc.Sequence" ABC, and\nprovide features such as containment tests, element index lookup,\nslicing and support for negative indices (see *Sequence Types ---\nlist, tuple, range*):\n\n>>> r = range(0, 20, 2)\n>>> r\nrange(0, 20, 2)\n>>> 11 in r\nFalse\n>>> 10 in r\nTrue\n>>> r.index(10)\n5\n>>> r[5]\n10\n>>> r[:5]\nrange(0, 10, 2)\n>>> r[-1]\n18\n\nTesting range objects for equality with "==" and "!=" compares them as\nsequences. That is, two range objects are considered equal if they\nrepresent the same sequence of values. (Note that two range objects\nthat compare equal might have different "start", "stop" and "step"\nattributes, for example "range(0) == range(2, 1, 3)" or "range(0, 3,\n2) == range(0, 4, 2)".)\n\nChanged in version 3.2: Implement the Sequence ABC. Support slicing\nand negative indices. Test "int" objects for membership in constant\ntime instead of iterating through all items.\n\nChanged in version 3.3: Define \'==\' and \'!=\' to compare range objects\nbased on the sequence of values they define (instead of comparing\nbased on object identity).\n\nNew in version 3.3: The "start", "stop" and "step" attributes.\n', - 'typesseq-mutable': u'\nMutable Sequence Types\n**********************\n\nThe operations in the following table are defined on mutable sequence\ntypes. The "collections.abc.MutableSequence" ABC is provided to make\nit easier to correctly implement these operations on custom sequence\ntypes.\n\nIn the table *s* is an instance of a mutable sequence type, *t* is any\niterable object and *x* is an arbitrary object that meets any type and\nvalue restrictions imposed by *s* (for example, "bytearray" only\naccepts integers that meet the value restriction "0 <= x <= 255").\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| "s[i] = x" | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j] = t" | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j]" | same as "s[i:j] = []" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j:k] = t" | the elements of "s[i:j:k]" are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j:k]" | removes the elements of | |\n| | "s[i:j:k]" from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.append(x)" | appends *x* to the end of the | |\n| | sequence (same as | |\n| | "s[len(s):len(s)] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.clear()" | removes all items from "s" (same | (5) |\n| | as "del s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.copy()" | creates a shallow copy of "s" | (5) |\n| | (same as "s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.extend(t)" | extends *s* with the contents of | |\n| | *t* (same as "s[len(s):len(s)] = | |\n| | t") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.insert(i, x)" | inserts *x* into *s* at the | |\n| | index given by *i* (same as | |\n| | "s[i:i] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.pop([i])" | retrieves the item at *i* and | (2) |\n| | also removes it from *s* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.remove(x)" | remove the first item from *s* | (3) |\n| | where "s[i] == x" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.reverse()" | reverses the items of *s* in | (4) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The optional argument *i* defaults to "-1", so that by default\n the last item is removed and returned.\n\n3. "remove" raises "ValueError" when *x* is not found in *s*.\n\n4. The "reverse()" method modifies the sequence in place for\n economy of space when reversing a large sequence. To remind users\n that it operates by side effect, it does not return the reversed\n sequence.\n\n5. "clear()" and "copy()" are included for consistency with the\n interfaces of mutable containers that don\'t support slicing\n operations (such as "dict" and "set")\n\n New in version 3.3: "clear()" and "copy()" methods.\n', + 'typesseq': u'\nSequence Types --- "list", "tuple", "range"\n*******************************************\n\nThere are three basic sequence types: lists, tuples, and range\nobjects. Additional sequence types tailored for processing of *binary\ndata* and *text strings* are described in dedicated sections.\n\n\nCommon Sequence Operations\n==========================\n\nThe operations in the following table are supported by most sequence\ntypes, both mutable and immutable. The "collections.abc.Sequence" ABC\nis provided to make it easier to correctly implement these operations\non custom sequence types.\n\nThis table lists the sequence operations sorted in ascending priority.\nIn the table, *s* and *t* are sequences of the same type, *n*, *i*,\n*j* and *k* are integers and *x* is an arbitrary object that meets any\ntype and value restrictions imposed by *s*.\n\nThe "in" and "not in" operations have the same priorities as the\ncomparison operations. The "+" (concatenation) and "*" (repetition)\noperations have the same priority as the corresponding numeric\noperations.\n\n+----------------------------+----------------------------------+------------+\n| Operation | Result | Notes |\n+============================+==================================+============+\n| "x in s" | "True" if an item of *s* is | (1) |\n| | equal to *x*, else "False" | |\n+----------------------------+----------------------------------+------------+\n| "x not in s" | "False" if an item of *s* is | (1) |\n| | equal to *x*, else "True" | |\n+----------------------------+----------------------------------+------------+\n| "s + t" | the concatenation of *s* and *t* | (6)(7) |\n+----------------------------+----------------------------------+------------+\n| "s * n" or "n * s" | equivalent to adding *s* to | (2)(7) |\n| | itself *n* times | |\n+----------------------------+----------------------------------+------------+\n| "s[i]" | *i*th item of *s*, origin 0 | (3) |\n+----------------------------+----------------------------------+------------+\n| "s[i:j]" | slice of *s* from *i* to *j* | (3)(4) |\n+----------------------------+----------------------------------+------------+\n| "s[i:j:k]" | slice of *s* from *i* to *j* | (3)(5) |\n| | with step *k* | |\n+----------------------------+----------------------------------+------------+\n| "len(s)" | length of *s* | |\n+----------------------------+----------------------------------+------------+\n| "min(s)" | smallest item of *s* | |\n+----------------------------+----------------------------------+------------+\n| "max(s)" | largest item of *s* | |\n+----------------------------+----------------------------------+------------+\n| "s.index(x[, i[, j]])" | index of the first occurrence of | (8) |\n| | *x* in *s* (at or after index | |\n| | *i* and before index *j*) | |\n+----------------------------+----------------------------------+------------+\n| "s.count(x)" | total number of occurrences of | |\n| | *x* in *s* | |\n+----------------------------+----------------------------------+------------+\n\nSequences of the same type also support comparisons. In particular,\ntuples and lists are compared lexicographically by comparing\ncorresponding elements. This means that to compare equal, every\nelement must compare equal and the two sequences must be of the same\ntype and have the same length. (For full details see *Comparisons* in\nthe language reference.)\n\nNotes:\n\n1. While the "in" and "not in" operations are used only for simple\n containment testing in the general case, some specialised sequences\n (such as "str", "bytes" and "bytearray") also use them for\n subsequence testing:\n\n >>> "gg" in "eggs"\n True\n\n2. Values of *n* less than "0" are treated as "0" (which yields an\n empty sequence of the same type as *s*). Note that items in the\n sequence *s* are not copied; they are referenced multiple times.\n This often haunts new Python programmers; consider:\n\n >>> lists = [[]] * 3\n >>> lists\n [[], [], []]\n >>> lists[0].append(3)\n >>> lists\n [[3], [3], [3]]\n\n What has happened is that "[[]]" is a one-element list containing\n an empty list, so all three elements of "[[]] * 3" are references\n to this single empty list. Modifying any of the elements of\n "lists" modifies this single list. You can create a list of\n different lists this way:\n\n >>> lists = [[] for i in range(3)]\n >>> lists[0].append(3)\n >>> lists[1].append(5)\n >>> lists[2].append(7)\n >>> lists\n [[3], [5], [7]]\n\n Further explanation is available in the FAQ entry *How do I create\n a multidimensional list?*.\n\n3. If *i* or *j* is negative, the index is relative to the end of\n the string: "len(s) + i" or "len(s) + j" is substituted. But note\n that "-0" is still "0".\n\n4. The slice of *s* from *i* to *j* is defined as the sequence of\n items with index *k* such that "i <= k < j". If *i* or *j* is\n greater than "len(s)", use "len(s)". If *i* is omitted or "None",\n use "0". If *j* is omitted or "None", use "len(s)". If *i* is\n greater than or equal to *j*, the slice is empty.\n\n5. The slice of *s* from *i* to *j* with step *k* is defined as the\n sequence of items with index "x = i + n*k" such that "0 <= n <\n (j-i)/k". In other words, the indices are "i", "i+k", "i+2*k",\n "i+3*k" and so on, stopping when *j* is reached (but never\n including *j*). If *i* or *j* is greater than "len(s)", use\n "len(s)". If *i* or *j* are omitted or "None", they become "end"\n values (which end depends on the sign of *k*). Note, *k* cannot be\n zero. If *k* is "None", it is treated like "1".\n\n6. Concatenating immutable sequences always results in a new\n object. This means that building up a sequence by repeated\n concatenation will have a quadratic runtime cost in the total\n sequence length. To get a linear runtime cost, you must switch to\n one of the alternatives below:\n\n * if concatenating "str" objects, you can build a list and use\n "str.join()" at the end or else write to an "io.StringIO"\n instance and retrieve its value when complete\n\n * if concatenating "bytes" objects, you can similarly use\n "bytes.join()" or "io.BytesIO", or you can do in-place\n concatenation with a "bytearray" object. "bytearray" objects are\n mutable and have an efficient overallocation mechanism\n\n * if concatenating "tuple" objects, extend a "list" instead\n\n * for other types, investigate the relevant class documentation\n\n7. Some sequence types (such as "range") only support item\n sequences that follow specific patterns, and hence don\'t support\n sequence concatenation or repetition.\n\n8. "index" raises "ValueError" when *x* is not found in *s*. When\n supported, the additional arguments to the index method allow\n efficient searching of subsections of the sequence. Passing the\n extra arguments is roughly equivalent to using "s[i:j].index(x)",\n only without copying any data and with the returned index being\n relative to the start of the sequence rather than the start of the\n slice.\n\n\nImmutable Sequence Types\n========================\n\nThe only operation that immutable sequence types generally implement\nthat is not also implemented by mutable sequence types is support for\nthe "hash()" built-in.\n\nThis support allows immutable sequences, such as "tuple" instances, to\nbe used as "dict" keys and stored in "set" and "frozenset" instances.\n\nAttempting to hash an immutable sequence that contains unhashable\nvalues will result in "TypeError".\n\n\nMutable Sequence Types\n======================\n\nThe operations in the following table are defined on mutable sequence\ntypes. The "collections.abc.MutableSequence" ABC is provided to make\nit easier to correctly implement these operations on custom sequence\ntypes.\n\nIn the table *s* is an instance of a mutable sequence type, *t* is any\niterable object and *x* is an arbitrary object that meets any type and\nvalue restrictions imposed by *s* (for example, "bytearray" only\naccepts integers that meet the value restriction "0 <= x <= 255").\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| "s[i] = x" | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j] = t" | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j]" | same as "s[i:j] = []" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j:k] = t" | the elements of "s[i:j:k]" are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j:k]" | removes the elements of | |\n| | "s[i:j:k]" from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.append(x)" | appends *x* to the end of the | |\n| | sequence (same as | |\n| | "s[len(s):len(s)] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.clear()" | removes all items from "s" (same | (5) |\n| | as "del s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.copy()" | creates a shallow copy of "s" | (5) |\n| | (same as "s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.extend(t)" or "s += t" | extends *s* with the contents of | |\n| | *t* (for the most part the same | |\n| | as "s[len(s):len(s)] = t") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s *= n" | updates *s* with its contents | (6) |\n| | repeated *n* times | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.insert(i, x)" | inserts *x* into *s* at the | |\n| | index given by *i* (same as | |\n| | "s[i:i] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.pop([i])" | retrieves the item at *i* and | (2) |\n| | also removes it from *s* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.remove(x)" | remove the first item from *s* | (3) |\n| | where "s[i] == x" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.reverse()" | reverses the items of *s* in | (4) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The optional argument *i* defaults to "-1", so that by default\n the last item is removed and returned.\n\n3. "remove" raises "ValueError" when *x* is not found in *s*.\n\n4. The "reverse()" method modifies the sequence in place for\n economy of space when reversing a large sequence. To remind users\n that it operates by side effect, it does not return the reversed\n sequence.\n\n5. "clear()" and "copy()" are included for consistency with the\n interfaces of mutable containers that don\'t support slicing\n operations (such as "dict" and "set")\n\n New in version 3.3: "clear()" and "copy()" methods.\n\n6. The value *n* is an integer, or an object implementing\n "__index__()". Zero and negative values of *n* clear the sequence.\n Items in the sequence are not copied; they are referenced multiple\n times, as explained for "s * n" under *Common Sequence Operations*.\n\n\nLists\n=====\n\nLists are mutable sequences, typically used to store collections of\nhomogeneous items (where the precise degree of similarity will vary by\napplication).\n\nclass class list([iterable])\n\n Lists may be constructed in several ways:\n\n * Using a pair of square brackets to denote the empty list: "[]"\n\n * Using square brackets, separating items with commas: "[a]",\n "[a, b, c]"\n\n * Using a list comprehension: "[x for x in iterable]"\n\n * Using the type constructor: "list()" or "list(iterable)"\n\n The constructor builds a list whose items are the same and in the\n same order as *iterable*\'s items. *iterable* may be either a\n sequence, a container that supports iteration, or an iterator\n object. If *iterable* is already a list, a copy is made and\n returned, similar to "iterable[:]". For example, "list(\'abc\')"\n returns "[\'a\', \'b\', \'c\']" and "list( (1, 2, 3) )" returns "[1, 2,\n 3]". If no argument is given, the constructor creates a new empty\n list, "[]".\n\n Many other operations also produce lists, including the "sorted()"\n built-in.\n\n Lists implement all of the *common* and *mutable* sequence\n operations. Lists also provide the following additional method:\n\n sort(*, key=None, reverse=None)\n\n This method sorts the list in place, using only "<" comparisons\n between items. Exceptions are not suppressed - if any comparison\n operations fail, the entire sort operation will fail (and the\n list will likely be left in a partially modified state).\n\n "sort()" accepts two arguments that can only be passed by\n keyword (*keyword-only arguments*):\n\n *key* specifies a function of one argument that is used to\n extract a comparison key from each list element (for example,\n "key=str.lower"). The key corresponding to each item in the list\n is calculated once and then used for the entire sorting process.\n The default value of "None" means that list items are sorted\n directly without calculating a separate key value.\n\n The "functools.cmp_to_key()" utility is available to convert a\n 2.x style *cmp* function to a *key* function.\n\n *reverse* is a boolean value. If set to "True", then the list\n elements are sorted as if each comparison were reversed.\n\n This method modifies the sequence in place for economy of space\n when sorting a large sequence. To remind users that it operates\n by side effect, it does not return the sorted sequence (use\n "sorted()" to explicitly request a new sorted list instance).\n\n The "sort()" method is guaranteed to be stable. A sort is\n stable if it guarantees not to change the relative order of\n elements that compare equal --- this is helpful for sorting in\n multiple passes (for example, sort by department, then by salary\n grade).\n\n **CPython implementation detail:** While a list is being sorted,\n the effect of attempting to mutate, or even inspect, the list is\n undefined. The C implementation of Python makes the list appear\n empty for the duration, and raises "ValueError" if it can detect\n that the list has been mutated during a sort.\n\n\nTuples\n======\n\nTuples are immutable sequences, typically used to store collections of\nheterogeneous data (such as the 2-tuples produced by the "enumerate()"\nbuilt-in). Tuples are also used for cases where an immutable sequence\nof homogeneous data is needed (such as allowing storage in a "set" or\n"dict" instance).\n\nclass class tuple([iterable])\n\n Tuples may be constructed in a number of ways:\n\n * Using a pair of parentheses to denote the empty tuple: "()"\n\n * Using a trailing comma for a singleton tuple: "a," or "(a,)"\n\n * Separating items with commas: "a, b, c" or "(a, b, c)"\n\n * Using the "tuple()" built-in: "tuple()" or "tuple(iterable)"\n\n The constructor builds a tuple whose items are the same and in the\n same order as *iterable*\'s items. *iterable* may be either a\n sequence, a container that supports iteration, or an iterator\n object. If *iterable* is already a tuple, it is returned\n unchanged. For example, "tuple(\'abc\')" returns "(\'a\', \'b\', \'c\')"\n and "tuple( [1, 2, 3] )" returns "(1, 2, 3)". If no argument is\n given, the constructor creates a new empty tuple, "()".\n\n Note that it is actually the comma which makes a tuple, not the\n parentheses. The parentheses are optional, except in the empty\n tuple case, or when they are needed to avoid syntactic ambiguity.\n For example, "f(a, b, c)" is a function call with three arguments,\n while "f((a, b, c))" is a function call with a 3-tuple as the sole\n argument.\n\n Tuples implement all of the *common* sequence operations.\n\nFor heterogeneous collections of data where access by name is clearer\nthan access by index, "collections.namedtuple()" may be a more\nappropriate choice than a simple tuple object.\n\n\nRanges\n======\n\nThe "range" type represents an immutable sequence of numbers and is\ncommonly used for looping a specific number of times in "for" loops.\n\nclass class range(stop)\nclass class range(start, stop[, step])\n\n The arguments to the range constructor must be integers (either\n built-in "int" or any object that implements the "__index__"\n special method). If the *step* argument is omitted, it defaults to\n "1". If the *start* argument is omitted, it defaults to "0". If\n *step* is zero, "ValueError" is raised.\n\n For a positive *step*, the contents of a range "r" are determined\n by the formula "r[i] = start + step*i" where "i >= 0" and "r[i] <\n stop".\n\n For a negative *step*, the contents of the range are still\n determined by the formula "r[i] = start + step*i", but the\n constraints are "i >= 0" and "r[i] > stop".\n\n A range object will be empty if "r[0]" does not meet the value\n constraint. Ranges do support negative indices, but these are\n interpreted as indexing from the end of the sequence determined by\n the positive indices.\n\n Ranges containing absolute values larger than "sys.maxsize" are\n permitted but some features (such as "len()") may raise\n "OverflowError".\n\n Range examples:\n\n >>> list(range(10))\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n >>> list(range(1, 11))\n [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n >>> list(range(0, 30, 5))\n [0, 5, 10, 15, 20, 25]\n >>> list(range(0, 10, 3))\n [0, 3, 6, 9]\n >>> list(range(0, -10, -1))\n [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n >>> list(range(0))\n []\n >>> list(range(1, 0))\n []\n\n Ranges implement all of the *common* sequence operations except\n concatenation and repetition (due to the fact that range objects\n can only represent sequences that follow a strict pattern and\n repetition and concatenation will usually violate that pattern).\n\nThe advantage of the "range" type over a regular "list" or "tuple" is\nthat a "range" object will always take the same (small) amount of\nmemory, no matter the size of the range it represents (as it only\nstores the "start", "stop" and "step" values, calculating individual\nitems and subranges as needed).\n\nRange objects implement the "collections.abc.Sequence" ABC, and\nprovide features such as containment tests, element index lookup,\nslicing and support for negative indices (see *Sequence Types ---\nlist, tuple, range*):\n\n>>> r = range(0, 20, 2)\n>>> r\nrange(0, 20, 2)\n>>> 11 in r\nFalse\n>>> 10 in r\nTrue\n>>> r.index(10)\n5\n>>> r[5]\n10\n>>> r[:5]\nrange(0, 10, 2)\n>>> r[-1]\n18\n\nTesting range objects for equality with "==" and "!=" compares them as\nsequences. That is, two range objects are considered equal if they\nrepresent the same sequence of values. (Note that two range objects\nthat compare equal might have different "start", "stop" and "step"\nattributes, for example "range(0) == range(2, 1, 3)" or "range(0, 3,\n2) == range(0, 4, 2)".)\n\nChanged in version 3.2: Implement the Sequence ABC. Support slicing\nand negative indices. Test "int" objects for membership in constant\ntime instead of iterating through all items.\n\nChanged in version 3.3: Define \'==\' and \'!=\' to compare range objects\nbased on the sequence of values they define (instead of comparing\nbased on object identity).\n\nNew in version 3.3: The "start", "stop" and "step" attributes.\n', + 'typesseq-mutable': u'\nMutable Sequence Types\n**********************\n\nThe operations in the following table are defined on mutable sequence\ntypes. The "collections.abc.MutableSequence" ABC is provided to make\nit easier to correctly implement these operations on custom sequence\ntypes.\n\nIn the table *s* is an instance of a mutable sequence type, *t* is any\niterable object and *x* is an arbitrary object that meets any type and\nvalue restrictions imposed by *s* (for example, "bytearray" only\naccepts integers that meet the value restriction "0 <= x <= 255").\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| "s[i] = x" | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j] = t" | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j]" | same as "s[i:j] = []" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j:k] = t" | the elements of "s[i:j:k]" are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j:k]" | removes the elements of | |\n| | "s[i:j:k]" from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.append(x)" | appends *x* to the end of the | |\n| | sequence (same as | |\n| | "s[len(s):len(s)] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.clear()" | removes all items from "s" (same | (5) |\n| | as "del s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.copy()" | creates a shallow copy of "s" | (5) |\n| | (same as "s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.extend(t)" or "s += t" | extends *s* with the contents of | |\n| | *t* (for the most part the same | |\n| | as "s[len(s):len(s)] = t") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s *= n" | updates *s* with its contents | (6) |\n| | repeated *n* times | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.insert(i, x)" | inserts *x* into *s* at the | |\n| | index given by *i* (same as | |\n| | "s[i:i] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.pop([i])" | retrieves the item at *i* and | (2) |\n| | also removes it from *s* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.remove(x)" | remove the first item from *s* | (3) |\n| | where "s[i] == x" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.reverse()" | reverses the items of *s* in | (4) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The optional argument *i* defaults to "-1", so that by default\n the last item is removed and returned.\n\n3. "remove" raises "ValueError" when *x* is not found in *s*.\n\n4. The "reverse()" method modifies the sequence in place for\n economy of space when reversing a large sequence. To remind users\n that it operates by side effect, it does not return the reversed\n sequence.\n\n5. "clear()" and "copy()" are included for consistency with the\n interfaces of mutable containers that don\'t support slicing\n operations (such as "dict" and "set")\n\n New in version 3.3: "clear()" and "copy()" methods.\n\n6. The value *n* is an integer, or an object implementing\n "__index__()". Zero and negative values of *n* clear the sequence.\n Items in the sequence are not copied; they are referenced multiple\n times, as explained for "s * n" under *Common Sequence Operations*.\n', 'unary': u'\nUnary arithmetic and bitwise operations\n***************************************\n\nAll unary arithmetic and bitwise operations have the same priority:\n\n u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr\n\nThe unary "-" (minus) operator yields the negation of its numeric\nargument.\n\nThe unary "+" (plus) operator yields its numeric argument unchanged.\n\nThe unary "~" (invert) operator yields the bitwise inversion of its\ninteger argument. The bitwise inversion of "x" is defined as\n"-(x+1)". It only applies to integral numbers.\n\nIn all three cases, if the argument does not have the proper type, a\n"TypeError" exception is raised.\n', 'while': u'\nThe "while" statement\n*********************\n\nThe "while" statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the "else" clause, if present, is executed\nand the loop terminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and goes back\nto testing the expression.\n', 'with': u'\nThe "with" statement\n********************\n\nThe "with" statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common "try"..."except"..."finally"\nusage patterns to be encapsulated for convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the "with" statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the "with_item")\n is evaluated to obtain a context manager.\n\n2. The context manager\'s "__exit__()" is loaded for later use.\n\n3. The context manager\'s "__enter__()" method is invoked.\n\n4. If a target was included in the "with" statement, the return\n value from "__enter__()" is assigned to it.\n\n Note: The "with" statement guarantees that if the "__enter__()"\n method returns without an error, then "__exit__()" will always be\n called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s "__exit__()" method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to "__exit__()". Otherwise, three\n "None" arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the "__exit__()" method was false, the exception is reraised.\n If the return value was true, the exception is suppressed, and\n execution continues with the statement following the "with"\n statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from "__exit__()" is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple "with" statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also: **PEP 0343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n', -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:16:09 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:16:09 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNCk6?= =?utf-8?q?_Merge=2E?= Message-ID: <20151207061609.33677.68544@psf.io> https://hg.python.org/cpython/rev/3b94245f9cf1 changeset: 99496:3b94245f9cf1 branch: 3.4 parent: 99480:2df330606cd0 parent: 99495:04a1f9fd0802 user: Larry Hastings date: Sun Dec 06 21:58:18 2015 -0800 summary: Merge. files: .hgtags | 1 + Include/patchlevel.h | 8 +++--- Lib/pydoc_data/topics.py | 30 ++++++++++++++-------------- Misc/NEWS | 17 ++++++++++++++- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -144,3 +144,4 @@ ab2c023a9432f16652e89c404bbc84aa91bf55af v3.4.2 69dd528ca6255a66c37cc5cf680e8357d108b036 v3.4.3rc1 b4cbecbc0781e89a309d03b60a1f75f8499250e6 v3.4.3 +04f3f725896c6961212c3a12e8ac25be6958f4fa v3.4.4rc1 diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -18,12 +18,12 @@ /*--start constants--*/ #define PY_MAJOR_VERSION 3 #define PY_MINOR_VERSION 4 -#define PY_MICRO_VERSION 3 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL -#define PY_RELEASE_SERIAL 0 +#define PY_MICRO_VERSION 4 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA +#define PY_RELEASE_SERIAL 1 /* Version as a string */ -#define PY_VERSION "3.4.3+" +#define PY_VERSION "3.4.4rc1+" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py --- a/Lib/pydoc_data/topics.py +++ b/Lib/pydoc_data/topics.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Autogenerated by Sphinx on Sun Feb 22 23:52:05 2015 +# Autogenerated by Sphinx on Sun Dec 6 05:51:21 2015 topics = {'assert': u'\nThe "assert" statement\n**********************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, "assert expression", is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, "assert expression1, expression2", is equivalent to\n\n if __debug__:\n if not expression1: raise AssertionError(expression2)\n\nThese equivalences assume that "__debug__" and "AssertionError" refer\nto the built-in variables with those names. In the current\nimplementation, the built-in variable "__debug__" is "True" under\nnormal circumstances, "False" when optimization is requested (command\nline option -O). The current code generator emits no code for an\nassert statement when optimization is requested at compile time. Note\nthat it is unnecessary to include the source code for the expression\nthat failed in the error message; it will be displayed as part of the\nstack trace.\n\nAssignments to "__debug__" are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n', 'assignment': u'\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n | "*" target\n\n(See section *Primaries* for the syntax definitions for\n*attributeref*, *subscription*, and *slicing*.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list, optionally enclosed in\nparentheses or square brackets, is recursively defined as follows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The\n object must be an iterable with the same number of items as there\n are targets in the target list, and the items are assigned, from\n left to right, to the corresponding targets.\n\n * If the target list contains one target prefixed with an\n asterisk, called a "starred" target: The object must be a sequence\n with at least as many items as there are targets in the target\n list, minus one. The first items of the sequence are assigned,\n from left to right, to the targets before the starred target. The\n final items of the sequence are assigned to the targets after the\n starred target. A list of the remaining items in the sequence is\n then assigned to the starred target (the list can be empty).\n\n * Else: The object must be a sequence with the same number of\n items as there are targets in the target list, and the items are\n assigned, from left to right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a "global" or "nonlocal" statement\n in the current code block: the name is bound to the object in the\n current local namespace.\n\n * Otherwise: the name is bound to the object in the global\n namespace or the outer namespace determined by "nonlocal",\n respectively.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in\n square brackets: The object must be an iterable with the same number\n of items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, "TypeError" is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily "AttributeError").\n\n Note: If the object is a class instance and the attribute reference\n occurs on both sides of the assignment operator, the RHS expression,\n "a.x" can access either an instance attribute or (if no instance\n attribute exists) a class attribute. The LHS target "a.x" is always\n set as an instance attribute, creating it if necessary. Thus, the\n two occurrences of "a.x" do not necessarily refer to the same\n attribute: if the RHS expression refers to a class attribute, the\n LHS creates a new instance attribute as the target of the\n assignment:\n\n class Cls:\n x = 3 # class variable\n inst = Cls()\n inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x as 3\n\n This description does not necessarily apply to descriptor\n attributes, such as properties created with "property()".\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield an integer. If it is negative, the sequence\'s\n length is added to it. The resulting value must be a nonnegative\n integer less than the sequence\'s length, and the sequence is asked\n to assign the assigned object to its item with that index. If the\n index is out of range, "IndexError" is raised (assignment to a\n subscripted sequence cannot add new items to a list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n For user-defined objects, the "__setitem__()" method is called with\n appropriate arguments.\n\n* If the target is a slicing: The primary expression in the\n reference is evaluated. It should yield a mutable sequence object\n (such as a list). The assigned object should be a sequence object\n of the same type. Next, the lower and upper bound expressions are\n evaluated, insofar they are present; defaults are zero and the\n sequence\'s length. The bounds should evaluate to integers. If\n either bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the target\n sequence allows it.\n\n**CPython implementation detail:** In the current implementation, the\nsyntax for targets is taken to be the same as for expressions, and\ninvalid syntax is rejected during the code generation phase, causing\nless detailed error messages.\n\nAlthough the definition of assignment implies that overlaps between\nthe left-hand side and the right-hand side are \'simultanenous\' (for\nexample "a, b = b, a" swaps two variables), overlaps *within* the\ncollection of assigned-to variables occur left-to-right, sometimes\nresulting in confusion. For instance, the following program prints\n"[0, 2]":\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2 # i is updated, then x[i] is updated\n print(x)\n\nSee also: **PEP 3132** - Extended Iterable Unpacking\n\n The specification for the "*target" feature.\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions of the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like "x += 1" can be rewritten as\n"x = x + 1" to achieve a similar, but not exactly equal effect. In the\naugmented version, "x" is only evaluated once. Also, when possible,\nthe actual operation is performed *in-place*, meaning that rather than\ncreating a new object and assigning that to the target, the old object\nis modified instead.\n\nUnlike normal assignments, augmented assignments evaluate the left-\nhand side *before* evaluating the right-hand side. For example, "a[i]\n+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs\nthe addition, and lastly, it writes the result back to "a[i]".\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n', 'atom-identifiers': u'\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a "NameError" exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name, with leading underscores removed and a single underscore\ninserted, in front of the name. For example, the identifier "__spam"\noccurring in a class named "Ham" will be transformed to "_Ham__spam".\nThis transformation is independent of the syntactical context in which\nthe identifier is used. If the transformed name is extremely long\n(longer than 255 characters), implementation defined truncation may\nhappen. If the class name consists only of underscores, no\ntransformation is done.\n', @@ -18,19 +18,19 @@ 'callable-types': u'\nEmulating callable objects\n**************************\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, "x(arg1, arg2, ...)" is a shorthand for\n "x.__call__(arg1, arg2, ...)".\n', 'calls': u'\nCalls\n*****\n\nA call calls a callable object (e.g., a *function*) with a possibly\nempty series of *arguments*:\n\n call ::= primary "(" [argument_list [","] | comprehension] ")"\n argument_list ::= positional_arguments ["," keyword_arguments]\n ["," "*" expression] ["," keyword_arguments]\n ["," "**" expression]\n | keyword_arguments ["," "*" expression]\n ["," keyword_arguments] ["," "**" expression]\n | "*" expression ["," keyword_arguments] ["," "**" expression]\n | "**" expression\n positional_arguments ::= expression ("," expression)*\n keyword_arguments ::= keyword_item ("," keyword_item)*\n keyword_item ::= identifier "=" expression\n\nAn optional trailing comma may be present after the positional and\nkeyword arguments but does not affect the semantics.\n\nThe primary must evaluate to a callable object (user-defined\nfunctions, built-in functions, methods of built-in objects, class\nobjects, methods of class instances, and all objects having a\n"__call__()" method are callable). All argument expressions are\nevaluated before the call is attempted. Please refer to section\n*Function definitions* for the syntax of formal *parameter* lists.\n\nIf keyword arguments are present, they are first converted to\npositional arguments, as follows. First, a list of unfilled slots is\ncreated for the formal parameters. If there are N positional\narguments, they are placed in the first N slots. Next, for each\nkeyword argument, the identifier is used to determine the\ncorresponding slot (if the identifier is the same as the first formal\nparameter name, the first slot is used, and so on). If the slot is\nalready filled, a "TypeError" exception is raised. Otherwise, the\nvalue of the argument is placed in the slot, filling it (even if the\nexpression is "None", it fills the slot). When all arguments have\nbeen processed, the slots that are still unfilled are filled with the\ncorresponding default value from the function definition. (Default\nvalues are calculated, once, when the function is defined; thus, a\nmutable object such as a list or dictionary used as default value will\nbe shared by all calls that don\'t specify an argument value for the\ncorresponding slot; this should usually be avoided.) If there are any\nunfilled slots for which no default value is specified, a "TypeError"\nexception is raised. Otherwise, the list of filled slots is used as\nthe argument list for the call.\n\n**CPython implementation detail:** An implementation may provide\nbuilt-in functions whose positional parameters do not have names, even\nif they are \'named\' for the purpose of documentation, and which\ntherefore cannot be supplied by keyword. In CPython, this is the case\nfor functions implemented in C that use "PyArg_ParseTuple()" to parse\ntheir arguments.\n\nIf there are more positional arguments than there are formal parameter\nslots, a "TypeError" exception is raised, unless a formal parameter\nusing the syntax "*identifier" is present; in this case, that formal\nparameter receives a tuple containing the excess positional arguments\n(or an empty tuple if there were no excess positional arguments).\n\nIf any keyword argument does not correspond to a formal parameter\nname, a "TypeError" exception is raised, unless a formal parameter\nusing the syntax "**identifier" is present; in this case, that formal\nparameter receives a dictionary containing the excess keyword\narguments (using the keywords as keys and the argument values as\ncorresponding values), or a (new) empty dictionary if there were no\nexcess keyword arguments.\n\nIf the syntax "*expression" appears in the function call, "expression"\nmust evaluate to an iterable. Elements from this iterable are treated\nas if they were additional positional arguments; if there are\npositional arguments *x1*, ..., *xN*, and "expression" evaluates to a\nsequence *y1*, ..., *yM*, this is equivalent to a call with M+N\npositional arguments *x1*, ..., *xN*, *y1*, ..., *yM*.\n\nA consequence of this is that although the "*expression" syntax may\nappear *after* some keyword arguments, it is processed *before* the\nkeyword arguments (and the "**expression" argument, if any -- see\nbelow). So:\n\n >>> def f(a, b):\n ... print(a, b)\n ...\n >>> f(b=1, *(2,))\n 2 1\n >>> f(a=1, *(2,))\n Traceback (most recent call last):\n File "", line 1, in ?\n TypeError: f() got multiple values for keyword argument \'a\'\n >>> f(1, *(2,))\n 1 2\n\nIt is unusual for both keyword arguments and the "*expression" syntax\nto be used in the same call, so in practice this confusion does not\narise.\n\nIf the syntax "**expression" appears in the function call,\n"expression" must evaluate to a mapping, the contents of which are\ntreated as additional keyword arguments. In the case of a keyword\nappearing in both "expression" and as an explicit keyword argument, a\n"TypeError" exception is raised.\n\nFormal parameters using the syntax "*identifier" or "**identifier"\ncannot be used as positional argument slots or as keyword argument\nnames.\n\nA call always returns some value, possibly "None", unless it raises an\nexception. How this value is computed depends on the type of the\ncallable object.\n\nIf it is---\n\na user-defined function:\n The code block for the function is executed, passing it the\n argument list. The first thing the code block will do is bind the\n formal parameters to the arguments; this is described in section\n *Function definitions*. When the code block executes a "return"\n statement, this specifies the return value of the function call.\n\na built-in function or method:\n The result is up to the interpreter; see *Built-in Functions* for\n the descriptions of built-in functions and methods.\n\na class object:\n A new instance of that class is returned.\n\na class instance method:\n The corresponding user-defined function is called, with an argument\n list that is one longer than the argument list of the call: the\n instance becomes the first argument.\n\na class instance:\n The class must define a "__call__()" method; the effect is then the\n same as if that method was called.\n', 'class': u'\nClass definitions\n*****************\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [parameter_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing. Classes without an inheritance\nlist inherit, by default, from the base class "object"; hence,\n\n class Foo:\n pass\n\nis equivalent to\n\n class Foo(object):\n pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.) When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators. The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances. Instance attributes\ncan be set in a method with "self.name = value". Both class and\ninstance attributes are accessible through the notation ""self.name"",\nand an instance attribute hides a class attribute with the same name\nwhen accessed in this way. Class attributes can be used as defaults\nfor instance attributes, but using mutable values there can lead to\nunexpected results. *Descriptors* can be used to create instance\nvariables with different implementation details.\n\nSee also: **PEP 3115** - Metaclasses in Python 3 **PEP 3129** -\n Class Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack unless\n there is a "finally" clause which happens to raise another\n exception. That new exception causes the old one to be lost.\n\n[2] Currently, control "flows off the end" except in the case of\n an exception or the execution of a "return", "continue", or\n "break" statement.\n\n[3] A string literal appearing as the first statement in the\n function body is transformed into the function\'s "__doc__"\n attribute and therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s "__doc__" item and\n therefore the class\'s *docstring*.\n', - 'comparisons': u'\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like "a < b < c" have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: "True" or "False".\n\nComparisons can be chained arbitrarily, e.g., "x < y <= z" is\nequivalent to "x < y and y <= z", except that "y" is evaluated only\nonce (but in both cases "z" is not evaluated at all when "x < y" is\nfound to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then "a op1 b op2 c ... y\nopN z" is equivalent to "a op1 b and b op2 c and ... y opN z", except\nthat each expression is evaluated at most once.\n\nNote that "a op1 b op2 c" doesn\'t imply any kind of comparison between\n*a* and *c*, so that, e.g., "x < y > z" is perfectly legal (though\nperhaps not pretty).\n\nThe operators "<", ">", "==", ">=", "<=", and "!=" compare the values\nof two objects. The objects need not have the same type. If both are\nnumbers, they are converted to a common type. Otherwise, the "==" and\n"!=" operators *always* consider objects of different types to be\nunequal, while the "<", ">", ">=" and "<=" operators raise a\n"TypeError" when comparing objects of different types that do not\nimplement these operators for the given pair of types. You can\ncontrol comparison behavior of objects of non-built-in types by\ndefining rich comparison methods like "__gt__()", described in section\n*Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values "float(\'NaN\')" and "Decimal(\'NaN\')" are special. The\n are identical to themselves, "x is x" but are not equal to\n themselves, "x != x". Additionally, comparing any value to a\n not-a-number value will return "False". For example, both "3 <\n float(\'NaN\')" and "float(\'NaN\') < 3" will return "False".\n\n* Bytes objects are compared lexicographically using the numeric\n values of their elements.\n\n* Strings are compared lexicographically using the numeric\n equivalents (the result of the built-in function "ord()") of their\n characters. [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison\n of corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, "[1,2,x] <= [1,2,y]" has the same\n value as "x <= y". If the corresponding element does not exist, the\n shorter sequence is ordered first (for example, "[1,2] < [1,2,3]").\n\n* Mappings (dictionaries) compare equal if and only if they have the\n same "(key, value)" pairs. Order comparisons "(\'<\', \'<=\', \'>=\',\n \'>\')" raise "TypeError".\n\n* Sets and frozensets define comparison operators to mean subset and\n superset tests. Those relations do not define total orderings (the\n two sets "{1,2}" and {2,3} are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering.\n For example, "min()", "max()", and "sorted()" produce undefined\n results given a list of sets as inputs.\n\n* Most other objects of built-in types compare unequal unless they\n are the same object; the choice whether one object is considered\n smaller or larger than another one is made arbitrarily but\n consistently within one execution of a program.\n\nComparison of objects of differing types depends on whether either of\nthe types provide explicit support for the comparison. Most numeric\ntypes can be compared with one another. When cross-type comparison is\nnot supported, the comparison method returns "NotImplemented".\n\nThe operators "in" and "not in" test for membership. "x in s"\nevaluates to true if *x* is a member of *s*, and false otherwise. "x\nnot in s" returns the negation of "x in s". All built-in sequences\nand set types support this as well as dictionary, for which "in" tests\nwhether the dictionary has a given key. For container types such as\nlist, tuple, set, frozenset, dict, or collections.deque, the\nexpression "x in y" is equivalent to "any(x is e or x == e for e in\ny)".\n\nFor the string and bytes types, "x in y" is true if and only if *x* is\na substring of *y*. An equivalent test is "y.find(x) != -1". Empty\nstrings are always considered to be a substring of any other string,\nso """ in "abc"" will return "True".\n\nFor user-defined classes which define the "__contains__()" method, "x\nin y" is true if and only if "y.__contains__(x)" is true.\n\nFor user-defined classes which do not define "__contains__()" but do\ndefine "__iter__()", "x in y" is true if some value "z" with "x == z"\nis produced while iterating over "y". If an exception is raised\nduring the iteration, it is as if "in" raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n"__getitem__()", "x in y" is true if and only if there is a non-\nnegative integer index *i* such that "x == y[i]", and all lower\ninteger indices do not raise "IndexError" exception. (If any other\nexception is raised, it is as if "in" raised that exception).\n\nThe operator "not in" is defined to have the inverse true value of\n"in".\n\nThe operators "is" and "is not" test for object identity: "x is y" is\ntrue if and only if *x* and *y* are the same object. "x is not y"\nyields the inverse truth value. [4]\n', + 'comparisons': u'\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like "a < b < c" have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: "True" or "False".\n\nComparisons can be chained arbitrarily, e.g., "x < y <= z" is\nequivalent to "x < y and y <= z", except that "y" is evaluated only\nonce (but in both cases "z" is not evaluated at all when "x < y" is\nfound to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then "a op1 b op2 c ... y\nopN z" is equivalent to "a op1 b and b op2 c and ... y opN z", except\nthat each expression is evaluated at most once.\n\nNote that "a op1 b op2 c" doesn\'t imply any kind of comparison between\n*a* and *c*, so that, e.g., "x < y > z" is perfectly legal (though\nperhaps not pretty).\n\n\nValue comparisons\n=================\n\nThe operators "<", ">", "==", ">=", "<=", and "!=" compare the values\nof two objects. The objects do not need to have the same type.\n\nChapter *Objects, values and types* states that objects have a value\n(in addition to type and identity). The value of an object is a\nrather abstract notion in Python: For example, there is no canonical\naccess method for an object\'s value. Also, there is no requirement\nthat the value of an object should be constructed in a particular way,\ne.g. comprised of all its data attributes. Comparison operators\nimplement a particular notion of what the value of an object is. One\ncan think of them as defining the value of an object indirectly, by\nmeans of their comparison implementation.\n\nBecause all types are (direct or indirect) subtypes of "object", they\ninherit the default comparison behavior from "object". Types can\ncustomize their comparison behavior by implementing *rich comparison\nmethods* like "__lt__()", described in *Basic customization*.\n\nThe default behavior for equality comparison ("==" and "!=") is based\non the identity of the objects. Hence, equality comparison of\ninstances with the same identity results in equality, and equality\ncomparison of instances with different identities results in\ninequality. A motivation for this default behavior is the desire that\nall objects should be reflexive (i.e. "x is y" implies "x == y").\n\nA default order comparison ("<", ">", "<=", and ">=") is not provided;\nan attempt raises "TypeError". A motivation for this default behavior\nis the lack of a similar invariant as for equality.\n\nThe behavior of the default equality comparison, that instances with\ndifferent identities are always unequal, may be in contrast to what\ntypes will need that have a sensible definition of object value and\nvalue-based equality. Such types will need to customize their\ncomparison behavior, and in fact, a number of built-in types have done\nthat.\n\nThe following list describes the comparison behavior of the most\nimportant built-in types.\n\n* Numbers of built-in numeric types (*Numeric Types --- int, float,\n complex*) and of the standard library types "fractions.Fraction" and\n "decimal.Decimal" can be compared within and across their types,\n with the restriction that complex numbers do not support order\n comparison. Within the limits of the types involved, they compare\n mathematically (algorithmically) correct without loss of precision.\n\n The not-a-number values "float(\'NaN\')" and "Decimal(\'NaN\')" are\n special. They are identical to themselves ("x is x" is true) but\n are not equal to themselves ("x == x" is false). Additionally,\n comparing any number to a not-a-number value will return "False".\n For example, both "3 < float(\'NaN\')" and "float(\'NaN\') < 3" will\n return "False".\n\n* Binary sequences (instances of "bytes" or "bytearray") can be\n compared within and across their types. They compare\n lexicographically using the numeric values of their elements.\n\n* Strings (instances of "str") compare lexicographically using the\n numerical Unicode code points (the result of the built-in function\n "ord()") of their characters. [3]\n\n Strings and binary sequences cannot be directly compared.\n\n* Sequences (instances of "tuple", "list", or "range") can be\n compared only within each of their types, with the restriction that\n ranges do not support order comparison. Equality comparison across\n these types results in unequality, and ordering comparison across\n these types raises "TypeError".\n\n Sequences compare lexicographically using comparison of\n corresponding elements, whereby reflexivity of the elements is\n enforced.\n\n In enforcing reflexivity of elements, the comparison of collections\n assumes that for a collection element "x", "x == x" is always true.\n Based on that assumption, element identity is compared first, and\n element comparison is performed only for distinct elements. This\n approach yields the same result as a strict element comparison\n would, if the compared elements are reflexive. For non-reflexive\n elements, the result is different than for strict element\n comparison, and may be surprising: The non-reflexive not-a-number\n values for example result in the following comparison behavior when\n used in a list:\n\n >>> nan = float(\'NaN\')\n >>> nan is nan\n True\n >>> nan == nan\n False <-- the defined non-reflexive behavior of NaN\n >>> [nan] == [nan]\n True <-- list enforces reflexivity and tests identity first\n\n Lexicographical comparison between built-in collections works as\n follows:\n\n * For two collections to compare equal, they must be of the same\n type, have the same length, and each pair of corresponding\n elements must compare equal (for example, "[1,2] == (1,2)" is\n false because the type is not the same).\n\n * Collections that support order comparison are ordered the same\n as their first unequal elements (for example, "[1,2,x] <= [1,2,y]"\n has the same value as "x <= y"). If a corresponding element does\n not exist, the shorter collection is ordered first (for example,\n "[1,2] < [1,2,3]" is true).\n\n* Mappings (instances of "dict") compare equal if and only if they\n have equal *(key, value)* pairs. Equality comparison of the keys and\n elements enforces reflexivity.\n\n Order comparisons ("<", ">", "<=", and ">=") raise "TypeError".\n\n* Sets (instances of "set" or "frozenset") can be compared within\n and across their types.\n\n They define order comparison operators to mean subset and superset\n tests. Those relations do not define total orderings (for example,\n the two sets "{1,2}" and "{2,3}" are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering\n (for example, "min()", "max()", and "sorted()" produce undefined\n results given a list of sets as inputs).\n\n Comparison of sets enforces reflexivity of its elements.\n\n* Most other built-in types have no comparison methods implemented,\n so they inherit the default comparison behavior.\n\nUser-defined classes that customize their comparison behavior should\nfollow some consistency rules, if possible:\n\n* Equality comparison should be reflexive. In other words, identical\n objects should compare equal:\n\n "x is y" implies "x == y"\n\n* Comparison should be symmetric. In other words, the following\n expressions should have the same result:\n\n "x == y" and "y == x"\n\n "x != y" and "y != x"\n\n "x < y" and "y > x"\n\n "x <= y" and "y >= x"\n\n* Comparison should be transitive. The following (non-exhaustive)\n examples illustrate that:\n\n "x > y and y > z" implies "x > z"\n\n "x < y and y <= z" implies "x < z"\n\n* Inverse comparison should result in the boolean negation. In other\n words, the following expressions should have the same result:\n\n "x == y" and "not x != y"\n\n "x < y" and "not x >= y" (for total ordering)\n\n "x > y" and "not x <= y" (for total ordering)\n\n The last two expressions apply to totally ordered collections (e.g.\n to sequences, but not to sets or mappings). See also the\n "total_ordering()" decorator.\n\nPython does not enforce these consistency rules. In fact, the\nnot-a-number values are an example for not following these rules.\n\n\nMembership test operations\n==========================\n\nThe operators "in" and "not in" test for membership. "x in s"\nevaluates to true if *x* is a member of *s*, and false otherwise. "x\nnot in s" returns the negation of "x in s". All built-in sequences\nand set types support this as well as dictionary, for which "in" tests\nwhether the dictionary has a given key. For container types such as\nlist, tuple, set, frozenset, dict, or collections.deque, the\nexpression "x in y" is equivalent to "any(x is e or x == e for e in\ny)".\n\nFor the string and bytes types, "x in y" is true if and only if *x* is\na substring of *y*. An equivalent test is "y.find(x) != -1". Empty\nstrings are always considered to be a substring of any other string,\nso """ in "abc"" will return "True".\n\nFor user-defined classes which define the "__contains__()" method, "x\nin y" is true if and only if "y.__contains__(x)" is true.\n\nFor user-defined classes which do not define "__contains__()" but do\ndefine "__iter__()", "x in y" is true if some value "z" with "x == z"\nis produced while iterating over "y". If an exception is raised\nduring the iteration, it is as if "in" raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n"__getitem__()", "x in y" is true if and only if there is a non-\nnegative integer index *i* such that "x == y[i]", and all lower\ninteger indices do not raise "IndexError" exception. (If any other\nexception is raised, it is as if "in" raised that exception).\n\nThe operator "not in" is defined to have the inverse true value of\n"in".\n\n\nIdentity comparisons\n====================\n\nThe operators "is" and "is not" test for object identity: "x is y" is\ntrue if and only if *x* and *y* are the same object. "x is not y"\nyields the inverse truth value. [4]\n', 'compound': u'\nCompound statements\n*******************\n\nCompound statements contain (groups of) other statements; they affect\nor control the execution of those other statements in some way. In\ngeneral, compound statements span multiple lines, although in simple\nincarnations a whole compound statement may be contained in one line.\n\nThe "if", "while" and "for" statements implement traditional control\nflow constructs. "try" specifies exception handlers and/or cleanup\ncode for a group of statements, while the "with" statement allows the\nexecution of initialization and finalization code around a block of\ncode. Function and class definitions are also syntactically compound\nstatements.\n\nA compound statement consists of one or more \'clauses.\' A clause\nconsists of a header and a \'suite.\' The clause headers of a\nparticular compound statement are all at the same indentation level.\nEach clause header begins with a uniquely identifying keyword and ends\nwith a colon. A suite is a group of statements controlled by a\nclause. A suite can be one or more semicolon-separated simple\nstatements on the same line as the header, following the header\'s\ncolon, or it can be one or more indented statements on subsequent\nlines. Only the latter form of a suite can contain nested compound\nstatements; the following is illegal, mostly because it wouldn\'t be\nclear to which "if" clause a following "else" clause would belong:\n\n if test1: if test2: print(x)\n\nAlso note that the semicolon binds tighter than the colon in this\ncontext, so that in the following example, either all or none of the\n"print()" calls are executed:\n\n if x < y < z: print(x); print(y); print(z)\n\nSummarizing:\n\n compound_stmt ::= if_stmt\n | while_stmt\n | for_stmt\n | try_stmt\n | with_stmt\n | funcdef\n | classdef\n suite ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT\n statement ::= stmt_list NEWLINE | compound_stmt\n stmt_list ::= simple_stmt (";" simple_stmt)* [";"]\n\nNote that statements always end in a "NEWLINE" possibly followed by a\n"DEDENT". Also note that optional continuation clauses always begin\nwith a keyword that cannot start a statement, thus there are no\nambiguities (the \'dangling "else"\' problem is solved in Python by\nrequiring nested "if" statements to be indented).\n\nThe formatting of the grammar rules in the following sections places\neach clause on a separate line for clarity.\n\n\nThe "if" statement\n==================\n\nThe "if" statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the "if" statement is executed or evaluated).\nIf all expressions are false, the suite of the "else" clause, if\npresent, is executed.\n\n\nThe "while" statement\n=====================\n\nThe "while" statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the "else" clause, if present, is executed\nand the loop terminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and goes back\nto testing the expression.\n\n\nThe "for" statement\n===================\n\nThe "for" statement is used to iterate over the elements of a sequence\n(such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n"expression_list". The suite is then executed once for each item\nprovided by the iterator, in the order returned by the iterator. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted. When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a "StopIteration" exception),\nthe suite in the "else" clause, if present, is executed, and the loop\nterminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and continues\nwith the next item, or with the "else" clause if there is no next\nitem.\n\nThe for-loop makes assignments to the variables(s) in the target list.\nThis overwrites all previous assignments to those variables including\nthose made in the suite of the for-loop:\n\n for i in range(10):\n print(i)\n i = 5 # this will not affect the for-loop\n # because i will be overwritten with the next\n # index in the range\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, they will not have been assigned to at\nall by the loop. Hint: the built-in function "range()" returns an\niterator of integers suitable to emulate the effect of Pascal\'s "for i\n:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".\n\nNote: There is a subtlety when the sequence is being modified by the\n loop (this can only occur for mutable sequences, i.e. lists). An\n internal counter is used to keep track of which item is used next,\n and this is incremented on each iteration. When this counter has\n reached the length of the sequence the loop terminates. This means\n that if the suite deletes the current (or a previous) item from the\n sequence, the next item will be skipped (since it gets the index of\n the current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n\n\nThe "try" statement\n===================\n\nThe "try" statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" identifier]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe "except" clause(s) specify one or more exception handlers. When no\nexception occurs in the "try" clause, no exception handler is\nexecuted. When an exception occurs in the "try" suite, a search for an\nexception handler is started. This search inspects the except clauses\nin turn until one is found that matches the exception. An expression-\nless except clause, if present, must be last; it matches any\nexception. For an except clause with an expression, that expression\nis evaluated, and the clause matches the exception if the resulting\nobject is "compatible" with the exception. An object is compatible\nwith an exception if it is the class or a base class of the exception\nobject or a tuple containing an item compatible with the exception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire "try" statement raised\nthe exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the "as" keyword in that except clause, if\npresent, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using "as target", it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause. Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the "sys" module and can be accessed via\n"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the\nexception class, the exception instance and a traceback object (see\nsection *The standard type hierarchy*) identifying the point in the\nprogram where the exception occurred. "sys.exc_info()" values are\nrestored to their previous values (before the call) when returning\nfrom a function that handled an exception.\n\nThe optional "else" clause is executed if and when control flows off\nthe end of the "try" clause. [2] Exceptions in the "else" clause are\nnot handled by the preceding "except" clauses.\n\nIf "finally" is present, it specifies a \'cleanup\' handler. The "try"\nclause is executed, including any "except" and "else" clauses. If an\nexception occurs in any of the clauses and is not handled, the\nexception is temporarily saved. The "finally" clause is executed. If\nthere is a saved exception it is re-raised at the end of the "finally"\nclause. If the "finally" clause raises another exception, the saved\nexception is set as the context of the new exception. If the "finally"\nclause executes a "return" or "break" statement, the saved exception\nis discarded:\n\n >>> def f():\n ... try:\n ... 1/0\n ... finally:\n ... return 42\n ...\n >>> f()\n 42\n\nThe exception information is not available to the program during\nexecution of the "finally" clause.\n\nWhen a "return", "break" or "continue" statement is executed in the\n"try" suite of a "try"..."finally" statement, the "finally" clause is\nalso executed \'on the way out.\' A "continue" statement is illegal in\nthe "finally" clause. (The reason is a problem with the current\nimplementation --- this restriction may be lifted in the future).\n\nThe return value of a function is determined by the last "return"\nstatement executed. Since the "finally" clause always executes, a\n"return" statement executed in the "finally" clause will always be the\nlast one executed:\n\n >>> def foo():\n ... try:\n ... return \'try\'\n ... finally:\n ... return \'finally\'\n ...\n >>> foo()\n \'finally\'\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the "raise" statement to\ngenerate exceptions may be found in section *The raise statement*.\n\n\nThe "with" statement\n====================\n\nThe "with" statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common "try"..."except"..."finally"\nusage patterns to be encapsulated for convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the "with" statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the "with_item")\n is evaluated to obtain a context manager.\n\n2. The context manager\'s "__exit__()" is loaded for later use.\n\n3. The context manager\'s "__enter__()" method is invoked.\n\n4. If a target was included in the "with" statement, the return\n value from "__enter__()" is assigned to it.\n\n Note: The "with" statement guarantees that if the "__enter__()"\n method returns without an error, then "__exit__()" will always be\n called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s "__exit__()" method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to "__exit__()". Otherwise, three\n "None" arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the "__exit__()" method was false, the exception is reraised.\n If the return value was true, the exception is suppressed, and\n execution continues with the statement following the "with"\n statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from "__exit__()" is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple "with" statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also: **PEP 0343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n\n\nFunction definitions\n====================\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n funcdef ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n decorators ::= decorator+\n decorator ::= "@" dotted_name ["(" [parameter_list [","]] ")"] NEWLINE\n dotted_name ::= identifier ("." identifier)*\n parameter_list ::= (defparameter ",")*\n | "*" [parameter] ("," defparameter)* ["," "**" parameter]\n | "**" parameter\n | defparameter [","] )\n parameter ::= identifier [":" expression]\n defparameter ::= parameter ["=" expression]\n funcname ::= identifier\n\nA function definition is an executable statement. Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function). This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition. The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object. Multiple decorators are applied in\nnested fashion. For example, the following code\n\n @f1(arg)\n @f2\n def func(): pass\n\nis equivalent to\n\n def func(): pass\n func = f1(arg)(f2(func))\n\nWhen one or more *parameters* have the form *parameter* "="\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding *argument* may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted. If a parameter has a default value, all following\nparameters up until the ""*"" must also have a default value --- this\nis a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated from left to right when the\nfunction definition is executed.** This means that the expression is\nevaluated once, when the function is defined, and that the same "pre-\ncomputed" value is used for each call. This is especially important\nto understand when a default parameter is a mutable object, such as a\nlist or a dictionary: if the function modifies the object (e.g. by\nappending an item to a list), the default value is in effect modified.\nThis is generally not what was intended. A way around this is to use\n"None" as the default, and explicitly test for it in the body of the\nfunction, e.g.:\n\n def whats_on_the_telly(penguin=None):\n if penguin is None:\n penguin = []\n penguin.append("property of the zoo")\n return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values. If the form\n""*identifier"" is present, it is initialized to a tuple receiving any\nexcess positional parameters, defaulting to the empty tuple. If the\nform ""**identifier"" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after ""*"" or ""*identifier"" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "": expression"" following\nthe parameter name. Any parameter may have an annotation even those\nof the form "*identifier" or "**identifier". Functions may have\n"return" annotation of the form ""-> expression"" after the parameter\nlist. These annotations can be any valid Python expression and are\nevaluated when the function definition is executed. Annotations may\nbe evaluated in a different order than they appear in the source code.\nThe presence of annotations does not change the semantics of a\nfunction. The annotation values are available as values of a\ndictionary keyed by the parameters\' names in the "__annotations__"\nattribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions. This uses lambda\nexpressions, described in section *Lambdas*. Note that the lambda\nexpression is merely a shorthand for a simplified function definition;\na function defined in a ""def"" statement can be passed around or\nassigned to another name just like a function defined by a lambda\nexpression. The ""def"" form is actually more powerful since it\nallows the execution of multiple statements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects. A ""def""\nstatement executed inside a function definition defines a local\nfunction that can be returned or passed around. Free variables used\nin the nested function can access the local variables of the function\ncontaining the def. See section *Naming and binding* for details.\n\nSee also: **PEP 3107** - Function Annotations\n\n The original specification for function annotations.\n\n\nClass definitions\n=================\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [parameter_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing. Classes without an inheritance\nlist inherit, by default, from the base class "object"; hence,\n\n class Foo:\n pass\n\nis equivalent to\n\n class Foo(object):\n pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.) When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators. The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances. Instance attributes\ncan be set in a method with "self.name = value". Both class and\ninstance attributes are accessible through the notation ""self.name"",\nand an instance attribute hides a class attribute with the same name\nwhen accessed in this way. Class attributes can be used as defaults\nfor instance attributes, but using mutable values there can lead to\nunexpected results. *Descriptors* can be used to create instance\nvariables with different implementation details.\n\nSee also: **PEP 3115** - Metaclasses in Python 3 **PEP 3129** -\n Class Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack unless\n there is a "finally" clause which happens to raise another\n exception. That new exception causes the old one to be lost.\n\n[2] Currently, control "flows off the end" except in the case of\n an exception or the execution of a "return", "continue", or\n "break" statement.\n\n[3] A string literal appearing as the first statement in the\n function body is transformed into the function\'s "__doc__"\n attribute and therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s "__doc__" item and\n therefore the class\'s *docstring*.\n', 'context-managers': u'\nWith Statement Context Managers\n*******************************\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a "with" statement. The context manager\nhandles the entry into, and the exit from, the desired runtime context\nfor the execution of the block of code. Context managers are normally\ninvoked using the "with" statement (described in section *The with\nstatement*), but can also be used by directly invoking their methods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The "with"\n statement will bind this method\'s return value to the target(s)\n specified in the "as" clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be "None".\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that "__exit__()" methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also: **PEP 0343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n', 'continue': u'\nThe "continue" statement\n************************\n\n continue_stmt ::= "continue"\n\n"continue" may only occur syntactically nested in a "for" or "while"\nloop, but not nested in a function or class definition or "finally"\nclause within that loop. It continues with the next cycle of the\nnearest enclosing loop.\n\nWhen "continue" passes control out of a "try" statement with a\n"finally" clause, that "finally" clause is executed before really\nstarting the next loop cycle.\n', 'conversions': u'\nArithmetic conversions\n**********************\n\nWhen a description of an arithmetic operator below uses the phrase\n"the numeric arguments are converted to a common type," this means\nthat the operator implementation for built-in types works as follows:\n\n* If either argument is a complex number, the other is converted to\n complex;\n\n* otherwise, if either argument is a floating point number, the\n other is converted to floating point;\n\n* otherwise, both must be integers and no conversion is necessary.\n\nSome additional rules apply for certain operators (e.g., a string as a\nleft argument to the \'%\' operator). Extensions must define their own\nconversion behavior.\n', - 'customization': u'\nBasic customization\n*******************\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. "__new__()" is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of "__new__()" should be the new object instance (usually an\n instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s "__new__()" method using\n "super(currentclass, cls).__new__(cls[, ...])" with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If "__new__()" returns an instance of *cls*, then the new\n instance\'s "__init__()" method will be invoked like\n "__init__(self[, ...])", where *self* is the new instance and the\n remaining arguments are the same as were passed to "__new__()".\n\n If "__new__()" does not return an instance of *cls*, then the new\n instance\'s "__init__()" method will not be invoked.\n\n "__new__()" is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called after the instance has been created (by "__new__()"), but\n before it is returned to the caller. The arguments are those\n passed to the class constructor expression. If a base class has an\n "__init__()" method, the derived class\'s "__init__()" method, if\n any, must explicitly call it to ensure proper initialization of the\n base class part of the instance; for example:\n "BaseClass.__init__(self, [args...])".\n\n Because "__new__()" and "__init__()" work together in constructing\n objects ("__new__()" to create it, and "__init__()" to customise\n it), no non-"None" value may be returned by "__init__()"; doing so\n will cause a "TypeError" to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a "__del__()" method, the\n derived class\'s "__del__()" method, if any, must explicitly call it\n to ensure proper deletion of the base class part of the instance.\n Note that it is possible (though not recommended!) for the\n "__del__()" method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n "__del__()" methods are called for objects that still exist when\n the interpreter exits.\n\n Note: "del x" doesn\'t directly call "x.__del__()" --- the former\n decrements the reference count for "x" by one, and the latter is\n only called when "x"\'s reference count reaches zero. Some common\n situations that may prevent the reference count of an object from\n going to zero include: circular references between objects (e.g.,\n a doubly-linked list or a tree data structure with parent and\n child pointers); a reference to the object on the stack frame of\n a function that caught an exception (the traceback stored in\n "sys.exc_info()[2]" keeps the stack frame alive); or a reference\n to the object on the stack frame that raised an unhandled\n exception in interactive mode (the traceback stored in\n "sys.last_traceback" keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the second can be resolved by freeing the reference to the\n traceback object when it is no longer useful, and the third can\n be resolved by storing "None" in "sys.last_traceback". Circular\n references which are garbage are detected and cleaned up when the\n cyclic garbage collector is enabled (it\'s on by default). Refer\n to the documentation for the "gc" module for more information\n about this topic.\n\n Warning: Due to the precarious circumstances under which\n "__del__()" methods are invoked, exceptions that occur during\n their execution are ignored, and a warning is printed to\n "sys.stderr" instead. Also, when "__del__()" is invoked in\n response to a module being deleted (e.g., when execution of the\n program is done), other globals referenced by the "__del__()"\n method may already have been deleted or in the process of being\n torn down (e.g. the import machinery shutting down). For this\n reason, "__del__()" methods should do the absolute minimum needed\n to maintain external invariants. Starting with version 1.5,\n Python guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the "__del__()" method is called.\n\nobject.__repr__(self)\n\n Called by the "repr()" built-in function to compute the "official"\n string representation of an object. If at all possible, this\n should look like a valid Python expression that could be used to\n recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n "<...some useful description...>" should be returned. The return\n value must be a string object. If a class defines "__repr__()" but\n not "__str__()", then "__repr__()" is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by "str(object)" and the built-in functions "format()" and\n "print()" to compute the "informal" or nicely printable string\n representation of an object. The return value must be a *string*\n object.\n\n This method differs from "object.__repr__()" in that there is no\n expectation that "__str__()" return a valid Python expression: a\n more convenient or concise representation can be used.\n\n The default implementation defined by the built-in type "object"\n calls "object.__repr__()".\n\nobject.__bytes__(self)\n\n Called by "bytes()" to compute a byte-string representation of an\n object. This should return a "bytes" object.\n\nobject.__format__(self, format_spec)\n\n Called by the "format()" built-in function (and by extension, the\n "str.format()" method of class "str") to produce a "formatted"\n string representation of an object. The "format_spec" argument is a\n string that contains a description of the formatting options\n desired. The interpretation of the "format_spec" argument is up to\n the type implementing "__format__()", however most classes will\n either delegate formatting to one of the built-in types, or use a\n similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\n Changed in version 3.4: The __format__ method of "object" itself\n raises a "TypeError" if passed any non-empty string.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: "xy" calls\n "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n\n A rich comparison method may return the singleton "NotImplemented"\n if it does not implement the operation for a given pair of\n arguments. By convention, "False" and "True" are returned for a\n successful comparison. However, these methods can return any value,\n so if the comparison operator is used in a Boolean context (e.g.,\n in the condition of an "if" statement), Python will call "bool()"\n on the value to determine if the result is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of "x==y" does not imply that "x!=y" is false.\n Accordingly, when defining "__eq__()", one should also define\n "__ne__()" so that the operators will behave as expected. See the\n paragraph on "__hash__()" for some important notes on creating\n *hashable* objects which support custom comparison operations and\n are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, "__lt__()" and "__gt__()" are each other\'s\n reflection, "__le__()" and "__ge__()" are each other\'s reflection,\n and "__eq__()" and "__ne__()" are their own reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see "functools.total_ordering()".\n\nobject.__hash__(self)\n\n Called by built-in function "hash()" and for operations on members\n of hashed collections including "set", "frozenset", and "dict".\n "__hash__()" should return an integer. The only required property\n is that objects which compare equal have the same hash value; it is\n advised to somehow mix together (e.g. using exclusive or) the hash\n values for the components of the object that also play a part in\n comparison of objects.\n\n Note: "hash()" truncates the value returned from an object\'s\n custom "__hash__()" method to the size of a "Py_ssize_t". This\n is typically 8 bytes on 64-bit builds and 4 bytes on 32-bit\n builds. If an object\'s "__hash__()" must interoperate on builds\n of different bit sizes, be sure to check the width on all\n supported builds. An easy way to do this is with "python -c\n "import sys; print(sys.hash_info.width)""\n\n If a class does not define an "__eq__()" method it should not\n define a "__hash__()" operation either; if it defines "__eq__()"\n but not "__hash__()", its instances will not be usable as items in\n hashable collections. If a class defines mutable objects and\n implements an "__eq__()" method, it should not implement\n "__hash__()", since the implementation of hashable collections\n requires that a key\'s hash value is immutable (if the object\'s hash\n value changes, it will be in the wrong hash bucket).\n\n User-defined classes have "__eq__()" and "__hash__()" methods by\n default; with them, all objects compare unequal (except with\n themselves) and "x.__hash__()" returns an appropriate value such\n that "x == y" implies both that "x is y" and "hash(x) == hash(y)".\n\n A class that overrides "__eq__()" and does not define "__hash__()"\n will have its "__hash__()" implicitly set to "None". When the\n "__hash__()" method of a class is "None", instances of the class\n will raise an appropriate "TypeError" when a program attempts to\n retrieve their hash value, and will also be correctly identified as\n unhashable when checking "isinstance(obj, collections.Hashable").\n\n If a class that overrides "__eq__()" needs to retain the\n implementation of "__hash__()" from a parent class, the interpreter\n must be told this explicitly by setting "__hash__ =\n .__hash__".\n\n If a class that does not override "__eq__()" wishes to suppress\n hash support, it should include "__hash__ = None" in the class\n definition. A class which defines its own "__hash__()" that\n explicitly raises a "TypeError" would be incorrectly identified as\n hashable by an "isinstance(obj, collections.Hashable)" call.\n\n Note: By default, the "__hash__()" values of str, bytes and\n datetime objects are "salted" with an unpredictable random value.\n Although they remain constant within an individual Python\n process, they are not predictable between repeated invocations of\n Python.This is intended to provide protection against a denial-\n of-service caused by carefully-chosen inputs that exploit the\n worst case performance of a dict insertion, O(n^2) complexity.\n See http://www.ocert.org/advisories/ocert-2011-003.html for\n details.Changing hash values affects the iteration order of\n dicts, sets and other mappings. Python has never made guarantees\n about this ordering (and it typically varies between 32-bit and\n 64-bit builds).See also "PYTHONHASHSEED".\n\n Changed in version 3.3: Hash randomization is enabled by default.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n "bool()"; should return "False" or "True". When this method is not\n defined, "__len__()" is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither "__len__()" nor "__bool__()", all its instances are\n considered true.\n', - 'debugger': u'\n"pdb" --- The Python Debugger\n*****************************\n\n**Source code:** Lib/pdb.py\n\n======================================================================\n\nThe module "pdb" defines an interactive source code debugger for\nPython programs. It supports setting (conditional) breakpoints and\nsingle stepping at the source line level, inspection of stack frames,\nsource code listing, and evaluation of arbitrary Python code in the\ncontext of any stack frame. It also supports post-mortem debugging\nand can be called under program control.\n\nThe debugger is extensible -- it is actually defined as the class\n"Pdb". This is currently undocumented but easily understood by reading\nthe source. The extension interface uses the modules "bdb" and "cmd".\n\nThe debugger\'s prompt is "(Pdb)". Typical usage to run a program under\ncontrol of the debugger is:\n\n >>> import pdb\n >>> import mymodule\n >>> pdb.run(\'mymodule.test()\')\n > (0)?()\n (Pdb) continue\n > (1)?()\n (Pdb) continue\n NameError: \'spam\'\n > (1)?()\n (Pdb)\n\nChanged in version 3.3: Tab-completion via the "readline" module is\navailable for commands and command arguments, e.g. the current global\nand local names are offered as arguments of the "p" command.\n\n"pdb.py" can also be invoked as a script to debug other scripts. For\nexample:\n\n python3 -m pdb myscript.py\n\nWhen invoked as a script, pdb will automatically enter post-mortem\ndebugging if the program being debugged exits abnormally. After post-\nmortem debugging (or after normal exit of the program), pdb will\nrestart the program. Automatic restarting preserves pdb\'s state (such\nas breakpoints) and in most cases is more useful than quitting the\ndebugger upon program\'s exit.\n\nNew in version 3.2: "pdb.py" now accepts a "-c" option that executes\ncommands as if given in a ".pdbrc" file, see *Debugger Commands*.\n\nThe typical usage to break into the debugger from a running program is\nto insert\n\n import pdb; pdb.set_trace()\n\nat the location you want to break into the debugger. You can then\nstep through the code following this statement, and continue running\nwithout the debugger using the "continue" command.\n\nThe typical usage to inspect a crashed program is:\n\n >>> import pdb\n >>> import mymodule\n >>> mymodule.test()\n Traceback (most recent call last):\n File "", line 1, in ?\n File "./mymodule.py", line 4, in test\n test2()\n File "./mymodule.py", line 3, in test2\n print(spam)\n NameError: spam\n >>> pdb.pm()\n > ./mymodule.py(3)test2()\n -> print(spam)\n (Pdb)\n\nThe module defines the following functions; each enters the debugger\nin a slightly different way:\n\npdb.run(statement, globals=None, locals=None)\n\n Execute the *statement* (given as a string or a code object) under\n debugger control. The debugger prompt appears before any code is\n executed; you can set breakpoints and type "continue", or you can\n step through the statement using "step" or "next" (all these\n commands are explained below). The optional *globals* and *locals*\n arguments specify the environment in which the code is executed; by\n default the dictionary of the module "__main__" is used. (See the\n explanation of the built-in "exec()" or "eval()" functions.)\n\npdb.runeval(expression, globals=None, locals=None)\n\n Evaluate the *expression* (given as a string or a code object)\n under debugger control. When "runeval()" returns, it returns the\n value of the expression. Otherwise this function is similar to\n "run()".\n\npdb.runcall(function, *args, **kwds)\n\n Call the *function* (a function or method object, not a string)\n with the given arguments. When "runcall()" returns, it returns\n whatever the function call returned. The debugger prompt appears\n as soon as the function is entered.\n\npdb.set_trace()\n\n Enter the debugger at the calling stack frame. This is useful to\n hard-code a breakpoint at a given point in a program, even if the\n code is not otherwise being debugged (e.g. when an assertion\n fails).\n\npdb.post_mortem(traceback=None)\n\n Enter post-mortem debugging of the given *traceback* object. If no\n *traceback* is given, it uses the one of the exception that is\n currently being handled (an exception must be being handled if the\n default is to be used).\n\npdb.pm()\n\n Enter post-mortem debugging of the traceback found in\n "sys.last_traceback".\n\nThe "run*" functions and "set_trace()" are aliases for instantiating\nthe "Pdb" class and calling the method of the same name. If you want\nto access further features, you have to do this yourself:\n\nclass class pdb.Pdb(completekey=\'tab\', stdin=None, stdout=None, skip=None, nosigint=False)\n\n "Pdb" is the debugger class.\n\n The *completekey*, *stdin* and *stdout* arguments are passed to the\n underlying "cmd.Cmd" class; see the description there.\n\n The *skip* argument, if given, must be an iterable of glob-style\n module name patterns. The debugger will not step into frames that\n originate in a module that matches one of these patterns. [1]\n\n By default, Pdb sets a handler for the SIGINT signal (which is sent\n when the user presses Ctrl-C on the console) when you give a\n "continue" command. This allows you to break into the debugger\n again by pressing Ctrl-C. If you want Pdb not to touch the SIGINT\n handler, set *nosigint* tot true.\n\n Example call to enable tracing with *skip*:\n\n import pdb; pdb.Pdb(skip=[\'django.*\']).set_trace()\n\n New in version 3.1: The *skip* argument.\n\n New in version 3.2: The *nosigint* argument. Previously, a SIGINT\n handler was never set by Pdb.\n\n run(statement, globals=None, locals=None)\n runeval(expression, globals=None, locals=None)\n runcall(function, *args, **kwds)\n set_trace()\n\n See the documentation for the functions explained above.\n\n\nDebugger Commands\n=================\n\nThe commands recognized by the debugger are listed below. Most\ncommands can be abbreviated to one or two letters as indicated; e.g.\n"h(elp)" means that either "h" or "help" can be used to enter the help\ncommand (but not "he" or "hel", nor "H" or "Help" or "HELP").\nArguments to commands must be separated by whitespace (spaces or\ntabs). Optional arguments are enclosed in square brackets ("[]") in\nthe command syntax; the square brackets must not be typed.\nAlternatives in the command syntax are separated by a vertical bar\n("|").\n\nEntering a blank line repeats the last command entered. Exception: if\nthe last command was a "list" command, the next 11 lines are listed.\n\nCommands that the debugger doesn\'t recognize are assumed to be Python\nstatements and are executed in the context of the program being\ndebugged. Python statements can also be prefixed with an exclamation\npoint ("!"). This is a powerful way to inspect the program being\ndebugged; it is even possible to change a variable or call a function.\nWhen an exception occurs in such a statement, the exception name is\nprinted but the debugger\'s state is not changed.\n\nThe debugger supports *aliases*. Aliases can have parameters which\nallows one a certain level of adaptability to the context under\nexamination.\n\nMultiple commands may be entered on a single line, separated by ";;".\n(A single ";" is not used as it is the separator for multiple commands\nin a line that is passed to the Python parser.) No intelligence is\napplied to separating the commands; the input is split at the first\n";;" pair, even if it is in the middle of a quoted string.\n\nIf a file ".pdbrc" exists in the user\'s home directory or in the\ncurrent directory, it is read in and executed as if it had been typed\nat the debugger prompt. This is particularly useful for aliases. If\nboth files exist, the one in the home directory is read first and\naliases defined there can be overridden by the local file.\n\nChanged in version 3.2: ".pdbrc" can now contain commands that\ncontinue debugging, such as "continue" or "next". Previously, these\ncommands had no effect.\n\nh(elp) [command]\n\n Without argument, print the list of available commands. With a\n *command* as argument, print help about that command. "help pdb"\n displays the full documentation (the docstring of the "pdb"\n module). Since the *command* argument must be an identifier, "help\n exec" must be entered to get help on the "!" command.\n\nw(here)\n\n Print a stack trace, with the most recent frame at the bottom. An\n arrow indicates the current frame, which determines the context of\n most commands.\n\nd(own) [count]\n\n Move the current frame *count* (default one) levels down in the\n stack trace (to a newer frame).\n\nu(p) [count]\n\n Move the current frame *count* (default one) levels up in the stack\n trace (to an older frame).\n\nb(reak) [([filename:]lineno | function) [, condition]]\n\n With a *lineno* argument, set a break there in the current file.\n With a *function* argument, set a break at the first executable\n statement within that function. The line number may be prefixed\n with a filename and a colon, to specify a breakpoint in another\n file (probably one that hasn\'t been loaded yet). The file is\n searched on "sys.path". Note that each breakpoint is assigned a\n number to which all the other breakpoint commands refer.\n\n If a second argument is present, it is an expression which must\n evaluate to true before the breakpoint is honored.\n\n Without argument, list all breaks, including for each breakpoint,\n the number of times that breakpoint has been hit, the current\n ignore count, and the associated condition if any.\n\ntbreak [([filename:]lineno | function) [, condition]]\n\n Temporary breakpoint, which is removed automatically when it is\n first hit. The arguments are the same as for "break".\n\ncl(ear) [filename:lineno | bpnumber [bpnumber ...]]\n\n With a *filename:lineno* argument, clear all the breakpoints at\n this line. With a space separated list of breakpoint numbers, clear\n those breakpoints. Without argument, clear all breaks (but first\n ask confirmation).\n\ndisable [bpnumber [bpnumber ...]]\n\n Disable the breakpoints given as a space separated list of\n breakpoint numbers. Disabling a breakpoint means it cannot cause\n the program to stop execution, but unlike clearing a breakpoint, it\n remains in the list of breakpoints and can be (re-)enabled.\n\nenable [bpnumber [bpnumber ...]]\n\n Enable the breakpoints specified.\n\nignore bpnumber [count]\n\n Set the ignore count for the given breakpoint number. If count is\n omitted, the ignore count is set to 0. A breakpoint becomes active\n when the ignore count is zero. When non-zero, the count is\n decremented each time the breakpoint is reached and the breakpoint\n is not disabled and any associated condition evaluates to true.\n\ncondition bpnumber [condition]\n\n Set a new *condition* for the breakpoint, an expression which must\n evaluate to true before the breakpoint is honored. If *condition*\n is absent, any existing condition is removed; i.e., the breakpoint\n is made unconditional.\n\ncommands [bpnumber]\n\n Specify a list of commands for breakpoint number *bpnumber*. The\n commands themselves appear on the following lines. Type a line\n containing just "end" to terminate the commands. An example:\n\n (Pdb) commands 1\n (com) p some_variable\n (com) end\n (Pdb)\n\n To remove all commands from a breakpoint, type commands and follow\n it immediately with "end"; that is, give no commands.\n\n With no *bpnumber* argument, commands refers to the last breakpoint\n set.\n\n You can use breakpoint commands to start your program up again.\n Simply use the continue command, or step, or any other command that\n resumes execution.\n\n Specifying any command resuming execution (currently continue,\n step, next, return, jump, quit and their abbreviations) terminates\n the command list (as if that command was immediately followed by\n end). This is because any time you resume execution (even with a\n simple next or step), you may encounter another breakpoint--which\n could have its own command list, leading to ambiguities about which\n list to execute.\n\n If you use the \'silent\' command in the command list, the usual\n message about stopping at a breakpoint is not printed. This may be\n desirable for breakpoints that are to print a specific message and\n then continue. If none of the other commands print anything, you\n see no sign that the breakpoint was reached.\n\ns(tep)\n\n Execute the current line, stop at the first possible occasion\n (either in a function that is called or on the next line in the\n current function).\n\nn(ext)\n\n Continue execution until the next line in the current function is\n reached or it returns. (The difference between "next" and "step"\n is that "step" stops inside a called function, while "next"\n executes called functions at (nearly) full speed, only stopping at\n the next line in the current function.)\n\nunt(il) [lineno]\n\n Without argument, continue execution until the line with a number\n greater than the current one is reached.\n\n With a line number, continue execution until a line with a number\n greater or equal to that is reached. In both cases, also stop when\n the current frame returns.\n\n Changed in version 3.2: Allow giving an explicit line number.\n\nr(eturn)\n\n Continue execution until the current function returns.\n\nc(ont(inue))\n\n Continue execution, only stop when a breakpoint is encountered.\n\nj(ump) lineno\n\n Set the next line that will be executed. Only available in the\n bottom-most frame. This lets you jump back and execute code again,\n or jump forward to skip code that you don\'t want to run.\n\n It should be noted that not all jumps are allowed -- for instance\n it is not possible to jump into the middle of a "for" loop or out\n of a "finally" clause.\n\nl(ist) [first[, last]]\n\n List source code for the current file. Without arguments, list 11\n lines around the current line or continue the previous listing.\n With "." as argument, list 11 lines around the current line. With\n one argument, list 11 lines around at that line. With two\n arguments, list the given range; if the second argument is less\n than the first, it is interpreted as a count.\n\n The current line in the current frame is indicated by "->". If an\n exception is being debugged, the line where the exception was\n originally raised or propagated is indicated by ">>", if it differs\n from the current line.\n\n New in version 3.2: The ">>" marker.\n\nll | longlist\n\n List all source code for the current function or frame.\n Interesting lines are marked as for "list".\n\n New in version 3.2.\n\na(rgs)\n\n Print the argument list of the current function.\n\np expression\n\n Evaluate the *expression* in the current context and print its\n value.\n\n Note: "print()" can also be used, but is not a debugger command\n --- this executes the Python "print()" function.\n\npp expression\n\n Like the "p" command, except the value of the expression is pretty-\n printed using the "pprint" module.\n\nwhatis expression\n\n Print the type of the *expression*.\n\nsource expression\n\n Try to get source code for the given object and display it.\n\n New in version 3.2.\n\ndisplay [expression]\n\n Display the value of the expression if it changed, each time\n execution stops in the current frame.\n\n Without expression, list all display expressions for the current\n frame.\n\n New in version 3.2.\n\nundisplay [expression]\n\n Do not display the expression any more in the current frame.\n Without expression, clear all display expressions for the current\n frame.\n\n New in version 3.2.\n\ninteract\n\n Start an interative interpreter (using the "code" module) whose\n global namespace contains all the (global and local) names found in\n the current scope.\n\n New in version 3.2.\n\nalias [name [command]]\n\n Create an alias called *name* that executes *command*. The command\n must *not* be enclosed in quotes. Replaceable parameters can be\n indicated by "%1", "%2", and so on, while "%*" is replaced by all\n the parameters. If no command is given, the current alias for\n *name* is shown. If no arguments are given, all aliases are listed.\n\n Aliases may be nested and can contain anything that can be legally\n typed at the pdb prompt. Note that internal pdb commands *can* be\n overridden by aliases. Such a command is then hidden until the\n alias is removed. Aliasing is recursively applied to the first\n word of the command line; all other words in the line are left\n alone.\n\n As an example, here are two useful aliases (especially when placed\n in the ".pdbrc" file):\n\n # Print instance variables (usage "pi classInst")\n alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])\n # Print instance variables in self\n alias ps pi self\n\nunalias name\n\n Delete the specified alias.\n\n! statement\n\n Execute the (one-line) *statement* in the context of the current\n stack frame. The exclamation point can be omitted unless the first\n word of the statement resembles a debugger command. To set a\n global variable, you can prefix the assignment command with a\n "global" statement on the same line, e.g.:\n\n (Pdb) global list_options; list_options = [\'-l\']\n (Pdb)\n\nrun [args ...]\nrestart [args ...]\n\n Restart the debugged Python program. If an argument is supplied,\n it is split with "shlex" and the result is used as the new\n "sys.argv". History, breakpoints, actions and debugger options are\n preserved. "restart" is an alias for "run".\n\nq(uit)\n\n Quit from the debugger. The program being executed is aborted.\n\n-[ Footnotes ]-\n\n[1] Whether a frame is considered to originate in a certain module\n is determined by the "__name__" in the frame globals.\n', + 'customization': u'\nBasic customization\n*******************\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. "__new__()" is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of "__new__()" should be the new object instance (usually an\n instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s "__new__()" method using\n "super(currentclass, cls).__new__(cls[, ...])" with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If "__new__()" returns an instance of *cls*, then the new\n instance\'s "__init__()" method will be invoked like\n "__init__(self[, ...])", where *self* is the new instance and the\n remaining arguments are the same as were passed to "__new__()".\n\n If "__new__()" does not return an instance of *cls*, then the new\n instance\'s "__init__()" method will not be invoked.\n\n "__new__()" is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called after the instance has been created (by "__new__()"), but\n before it is returned to the caller. The arguments are those\n passed to the class constructor expression. If a base class has an\n "__init__()" method, the derived class\'s "__init__()" method, if\n any, must explicitly call it to ensure proper initialization of the\n base class part of the instance; for example:\n "BaseClass.__init__(self, [args...])".\n\n Because "__new__()" and "__init__()" work together in constructing\n objects ("__new__()" to create it, and "__init__()" to customise\n it), no non-"None" value may be returned by "__init__()"; doing so\n will cause a "TypeError" to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a "__del__()" method, the\n derived class\'s "__del__()" method, if any, must explicitly call it\n to ensure proper deletion of the base class part of the instance.\n Note that it is possible (though not recommended!) for the\n "__del__()" method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n "__del__()" methods are called for objects that still exist when\n the interpreter exits.\n\n Note: "del x" doesn\'t directly call "x.__del__()" --- the former\n decrements the reference count for "x" by one, and the latter is\n only called when "x"\'s reference count reaches zero. Some common\n situations that may prevent the reference count of an object from\n going to zero include: circular references between objects (e.g.,\n a doubly-linked list or a tree data structure with parent and\n child pointers); a reference to the object on the stack frame of\n a function that caught an exception (the traceback stored in\n "sys.exc_info()[2]" keeps the stack frame alive); or a reference\n to the object on the stack frame that raised an unhandled\n exception in interactive mode (the traceback stored in\n "sys.last_traceback" keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the second can be resolved by freeing the reference to the\n traceback object when it is no longer useful, and the third can\n be resolved by storing "None" in "sys.last_traceback". Circular\n references which are garbage are detected and cleaned up when the\n cyclic garbage collector is enabled (it\'s on by default). Refer\n to the documentation for the "gc" module for more information\n about this topic.\n\n Warning: Due to the precarious circumstances under which\n "__del__()" methods are invoked, exceptions that occur during\n their execution are ignored, and a warning is printed to\n "sys.stderr" instead. Also, when "__del__()" is invoked in\n response to a module being deleted (e.g., when execution of the\n program is done), other globals referenced by the "__del__()"\n method may already have been deleted or in the process of being\n torn down (e.g. the import machinery shutting down). For this\n reason, "__del__()" methods should do the absolute minimum needed\n to maintain external invariants. Starting with version 1.5,\n Python guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the "__del__()" method is called.\n\nobject.__repr__(self)\n\n Called by the "repr()" built-in function to compute the "official"\n string representation of an object. If at all possible, this\n should look like a valid Python expression that could be used to\n recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n "<...some useful description...>" should be returned. The return\n value must be a string object. If a class defines "__repr__()" but\n not "__str__()", then "__repr__()" is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by "str(object)" and the built-in functions "format()" and\n "print()" to compute the "informal" or nicely printable string\n representation of an object. The return value must be a *string*\n object.\n\n This method differs from "object.__repr__()" in that there is no\n expectation that "__str__()" return a valid Python expression: a\n more convenient or concise representation can be used.\n\n The default implementation defined by the built-in type "object"\n calls "object.__repr__()".\n\nobject.__bytes__(self)\n\n Called by "bytes()" to compute a byte-string representation of an\n object. This should return a "bytes" object.\n\nobject.__format__(self, format_spec)\n\n Called by the "format()" built-in function (and by extension, the\n "str.format()" method of class "str") to produce a "formatted"\n string representation of an object. The "format_spec" argument is a\n string that contains a description of the formatting options\n desired. The interpretation of the "format_spec" argument is up to\n the type implementing "__format__()", however most classes will\n either delegate formatting to one of the built-in types, or use a\n similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\n Changed in version 3.4: The __format__ method of "object" itself\n raises a "TypeError" if passed any non-empty string.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: "xy" calls\n "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n\n A rich comparison method may return the singleton "NotImplemented"\n if it does not implement the operation for a given pair of\n arguments. By convention, "False" and "True" are returned for a\n successful comparison. However, these methods can return any value,\n so if the comparison operator is used in a Boolean context (e.g.,\n in the condition of an "if" statement), Python will call "bool()"\n on the value to determine if the result is true or false.\n\n By default, "__ne__()" delegates to "__eq__()" and inverts the\n result unless it is "NotImplemented". There are no other implied\n relationships among the comparison operators, for example, the\n truth of "(x.__hash__".\n\n If a class that does not override "__eq__()" wishes to suppress\n hash support, it should include "__hash__ = None" in the class\n definition. A class which defines its own "__hash__()" that\n explicitly raises a "TypeError" would be incorrectly identified as\n hashable by an "isinstance(obj, collections.Hashable)" call.\n\n Note: By default, the "__hash__()" values of str, bytes and\n datetime objects are "salted" with an unpredictable random value.\n Although they remain constant within an individual Python\n process, they are not predictable between repeated invocations of\n Python.This is intended to provide protection against a denial-\n of-service caused by carefully-chosen inputs that exploit the\n worst case performance of a dict insertion, O(n^2) complexity.\n See http://www.ocert.org/advisories/ocert-2011-003.html for\n details.Changing hash values affects the iteration order of\n dicts, sets and other mappings. Python has never made guarantees\n about this ordering (and it typically varies between 32-bit and\n 64-bit builds).See also "PYTHONHASHSEED".\n\n Changed in version 3.3: Hash randomization is enabled by default.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n "bool()"; should return "False" or "True". When this method is not\n defined, "__len__()" is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither "__len__()" nor "__bool__()", all its instances are\n considered true.\n', + 'debugger': u'\n"pdb" --- The Python Debugger\n*****************************\n\n**Source code:** Lib/pdb.py\n\n======================================================================\n\nThe module "pdb" defines an interactive source code debugger for\nPython programs. It supports setting (conditional) breakpoints and\nsingle stepping at the source line level, inspection of stack frames,\nsource code listing, and evaluation of arbitrary Python code in the\ncontext of any stack frame. It also supports post-mortem debugging\nand can be called under program control.\n\nThe debugger is extensible -- it is actually defined as the class\n"Pdb". This is currently undocumented but easily understood by reading\nthe source. The extension interface uses the modules "bdb" and "cmd".\n\nThe debugger\'s prompt is "(Pdb)". Typical usage to run a program under\ncontrol of the debugger is:\n\n >>> import pdb\n >>> import mymodule\n >>> pdb.run(\'mymodule.test()\')\n > (0)?()\n (Pdb) continue\n > (1)?()\n (Pdb) continue\n NameError: \'spam\'\n > (1)?()\n (Pdb)\n\nChanged in version 3.3: Tab-completion via the "readline" module is\navailable for commands and command arguments, e.g. the current global\nand local names are offered as arguments of the "p" command.\n\n"pdb.py" can also be invoked as a script to debug other scripts. For\nexample:\n\n python3 -m pdb myscript.py\n\nWhen invoked as a script, pdb will automatically enter post-mortem\ndebugging if the program being debugged exits abnormally. After post-\nmortem debugging (or after normal exit of the program), pdb will\nrestart the program. Automatic restarting preserves pdb\'s state (such\nas breakpoints) and in most cases is more useful than quitting the\ndebugger upon program\'s exit.\n\nNew in version 3.2: "pdb.py" now accepts a "-c" option that executes\ncommands as if given in a ".pdbrc" file, see *Debugger Commands*.\n\nThe typical usage to break into the debugger from a running program is\nto insert\n\n import pdb; pdb.set_trace()\n\nat the location you want to break into the debugger. You can then\nstep through the code following this statement, and continue running\nwithout the debugger using the "continue" command.\n\nThe typical usage to inspect a crashed program is:\n\n >>> import pdb\n >>> import mymodule\n >>> mymodule.test()\n Traceback (most recent call last):\n File "", line 1, in ?\n File "./mymodule.py", line 4, in test\n test2()\n File "./mymodule.py", line 3, in test2\n print(spam)\n NameError: spam\n >>> pdb.pm()\n > ./mymodule.py(3)test2()\n -> print(spam)\n (Pdb)\n\nThe module defines the following functions; each enters the debugger\nin a slightly different way:\n\npdb.run(statement, globals=None, locals=None)\n\n Execute the *statement* (given as a string or a code object) under\n debugger control. The debugger prompt appears before any code is\n executed; you can set breakpoints and type "continue", or you can\n step through the statement using "step" or "next" (all these\n commands are explained below). The optional *globals* and *locals*\n arguments specify the environment in which the code is executed; by\n default the dictionary of the module "__main__" is used. (See the\n explanation of the built-in "exec()" or "eval()" functions.)\n\npdb.runeval(expression, globals=None, locals=None)\n\n Evaluate the *expression* (given as a string or a code object)\n under debugger control. When "runeval()" returns, it returns the\n value of the expression. Otherwise this function is similar to\n "run()".\n\npdb.runcall(function, *args, **kwds)\n\n Call the *function* (a function or method object, not a string)\n with the given arguments. When "runcall()" returns, it returns\n whatever the function call returned. The debugger prompt appears\n as soon as the function is entered.\n\npdb.set_trace()\n\n Enter the debugger at the calling stack frame. This is useful to\n hard-code a breakpoint at a given point in a program, even if the\n code is not otherwise being debugged (e.g. when an assertion\n fails).\n\npdb.post_mortem(traceback=None)\n\n Enter post-mortem debugging of the given *traceback* object. If no\n *traceback* is given, it uses the one of the exception that is\n currently being handled (an exception must be being handled if the\n default is to be used).\n\npdb.pm()\n\n Enter post-mortem debugging of the traceback found in\n "sys.last_traceback".\n\nThe "run*" functions and "set_trace()" are aliases for instantiating\nthe "Pdb" class and calling the method of the same name. If you want\nto access further features, you have to do this yourself:\n\nclass class pdb.Pdb(completekey=\'tab\', stdin=None, stdout=None, skip=None, nosigint=False)\n\n "Pdb" is the debugger class.\n\n The *completekey*, *stdin* and *stdout* arguments are passed to the\n underlying "cmd.Cmd" class; see the description there.\n\n The *skip* argument, if given, must be an iterable of glob-style\n module name patterns. The debugger will not step into frames that\n originate in a module that matches one of these patterns. [1]\n\n By default, Pdb sets a handler for the SIGINT signal (which is sent\n when the user presses "Ctrl-C" on the console) when you give a\n "continue" command. This allows you to break into the debugger\n again by pressing "Ctrl-C". If you want Pdb not to touch the\n SIGINT handler, set *nosigint* tot true.\n\n Example call to enable tracing with *skip*:\n\n import pdb; pdb.Pdb(skip=[\'django.*\']).set_trace()\n\n New in version 3.1: The *skip* argument.\n\n New in version 3.2: The *nosigint* argument. Previously, a SIGINT\n handler was never set by Pdb.\n\n run(statement, globals=None, locals=None)\n runeval(expression, globals=None, locals=None)\n runcall(function, *args, **kwds)\n set_trace()\n\n See the documentation for the functions explained above.\n\n\nDebugger Commands\n=================\n\nThe commands recognized by the debugger are listed below. Most\ncommands can be abbreviated to one or two letters as indicated; e.g.\n"h(elp)" means that either "h" or "help" can be used to enter the help\ncommand (but not "he" or "hel", nor "H" or "Help" or "HELP").\nArguments to commands must be separated by whitespace (spaces or\ntabs). Optional arguments are enclosed in square brackets ("[]") in\nthe command syntax; the square brackets must not be typed.\nAlternatives in the command syntax are separated by a vertical bar\n("|").\n\nEntering a blank line repeats the last command entered. Exception: if\nthe last command was a "list" command, the next 11 lines are listed.\n\nCommands that the debugger doesn\'t recognize are assumed to be Python\nstatements and are executed in the context of the program being\ndebugged. Python statements can also be prefixed with an exclamation\npoint ("!"). This is a powerful way to inspect the program being\ndebugged; it is even possible to change a variable or call a function.\nWhen an exception occurs in such a statement, the exception name is\nprinted but the debugger\'s state is not changed.\n\nThe debugger supports *aliases*. Aliases can have parameters which\nallows one a certain level of adaptability to the context under\nexamination.\n\nMultiple commands may be entered on a single line, separated by ";;".\n(A single ";" is not used as it is the separator for multiple commands\nin a line that is passed to the Python parser.) No intelligence is\napplied to separating the commands; the input is split at the first\n";;" pair, even if it is in the middle of a quoted string.\n\nIf a file ".pdbrc" exists in the user\'s home directory or in the\ncurrent directory, it is read in and executed as if it had been typed\nat the debugger prompt. This is particularly useful for aliases. If\nboth files exist, the one in the home directory is read first and\naliases defined there can be overridden by the local file.\n\nChanged in version 3.2: ".pdbrc" can now contain commands that\ncontinue debugging, such as "continue" or "next". Previously, these\ncommands had no effect.\n\nh(elp) [command]\n\n Without argument, print the list of available commands. With a\n *command* as argument, print help about that command. "help pdb"\n displays the full documentation (the docstring of the "pdb"\n module). Since the *command* argument must be an identifier, "help\n exec" must be entered to get help on the "!" command.\n\nw(here)\n\n Print a stack trace, with the most recent frame at the bottom. An\n arrow indicates the current frame, which determines the context of\n most commands.\n\nd(own) [count]\n\n Move the current frame *count* (default one) levels down in the\n stack trace (to a newer frame).\n\nu(p) [count]\n\n Move the current frame *count* (default one) levels up in the stack\n trace (to an older frame).\n\nb(reak) [([filename:]lineno | function) [, condition]]\n\n With a *lineno* argument, set a break there in the current file.\n With a *function* argument, set a break at the first executable\n statement within that function. The line number may be prefixed\n with a filename and a colon, to specify a breakpoint in another\n file (probably one that hasn\'t been loaded yet). The file is\n searched on "sys.path". Note that each breakpoint is assigned a\n number to which all the other breakpoint commands refer.\n\n If a second argument is present, it is an expression which must\n evaluate to true before the breakpoint is honored.\n\n Without argument, list all breaks, including for each breakpoint,\n the number of times that breakpoint has been hit, the current\n ignore count, and the associated condition if any.\n\ntbreak [([filename:]lineno | function) [, condition]]\n\n Temporary breakpoint, which is removed automatically when it is\n first hit. The arguments are the same as for "break".\n\ncl(ear) [filename:lineno | bpnumber [bpnumber ...]]\n\n With a *filename:lineno* argument, clear all the breakpoints at\n this line. With a space separated list of breakpoint numbers, clear\n those breakpoints. Without argument, clear all breaks (but first\n ask confirmation).\n\ndisable [bpnumber [bpnumber ...]]\n\n Disable the breakpoints given as a space separated list of\n breakpoint numbers. Disabling a breakpoint means it cannot cause\n the program to stop execution, but unlike clearing a breakpoint, it\n remains in the list of breakpoints and can be (re-)enabled.\n\nenable [bpnumber [bpnumber ...]]\n\n Enable the breakpoints specified.\n\nignore bpnumber [count]\n\n Set the ignore count for the given breakpoint number. If count is\n omitted, the ignore count is set to 0. A breakpoint becomes active\n when the ignore count is zero. When non-zero, the count is\n decremented each time the breakpoint is reached and the breakpoint\n is not disabled and any associated condition evaluates to true.\n\ncondition bpnumber [condition]\n\n Set a new *condition* for the breakpoint, an expression which must\n evaluate to true before the breakpoint is honored. If *condition*\n is absent, any existing condition is removed; i.e., the breakpoint\n is made unconditional.\n\ncommands [bpnumber]\n\n Specify a list of commands for breakpoint number *bpnumber*. The\n commands themselves appear on the following lines. Type a line\n containing just "end" to terminate the commands. An example:\n\n (Pdb) commands 1\n (com) p some_variable\n (com) end\n (Pdb)\n\n To remove all commands from a breakpoint, type commands and follow\n it immediately with "end"; that is, give no commands.\n\n With no *bpnumber* argument, commands refers to the last breakpoint\n set.\n\n You can use breakpoint commands to start your program up again.\n Simply use the continue command, or step, or any other command that\n resumes execution.\n\n Specifying any command resuming execution (currently continue,\n step, next, return, jump, quit and their abbreviations) terminates\n the command list (as if that command was immediately followed by\n end). This is because any time you resume execution (even with a\n simple next or step), you may encounter another breakpoint--which\n could have its own command list, leading to ambiguities about which\n list to execute.\n\n If you use the \'silent\' command in the command list, the usual\n message about stopping at a breakpoint is not printed. This may be\n desirable for breakpoints that are to print a specific message and\n then continue. If none of the other commands print anything, you\n see no sign that the breakpoint was reached.\n\ns(tep)\n\n Execute the current line, stop at the first possible occasion\n (either in a function that is called or on the next line in the\n current function).\n\nn(ext)\n\n Continue execution until the next line in the current function is\n reached or it returns. (The difference between "next" and "step"\n is that "step" stops inside a called function, while "next"\n executes called functions at (nearly) full speed, only stopping at\n the next line in the current function.)\n\nunt(il) [lineno]\n\n Without argument, continue execution until the line with a number\n greater than the current one is reached.\n\n With a line number, continue execution until a line with a number\n greater or equal to that is reached. In both cases, also stop when\n the current frame returns.\n\n Changed in version 3.2: Allow giving an explicit line number.\n\nr(eturn)\n\n Continue execution until the current function returns.\n\nc(ont(inue))\n\n Continue execution, only stop when a breakpoint is encountered.\n\nj(ump) lineno\n\n Set the next line that will be executed. Only available in the\n bottom-most frame. This lets you jump back and execute code again,\n or jump forward to skip code that you don\'t want to run.\n\n It should be noted that not all jumps are allowed -- for instance\n it is not possible to jump into the middle of a "for" loop or out\n of a "finally" clause.\n\nl(ist) [first[, last]]\n\n List source code for the current file. Without arguments, list 11\n lines around the current line or continue the previous listing.\n With "." as argument, list 11 lines around the current line. With\n one argument, list 11 lines around at that line. With two\n arguments, list the given range; if the second argument is less\n than the first, it is interpreted as a count.\n\n The current line in the current frame is indicated by "->". If an\n exception is being debugged, the line where the exception was\n originally raised or propagated is indicated by ">>", if it differs\n from the current line.\n\n New in version 3.2: The ">>" marker.\n\nll | longlist\n\n List all source code for the current function or frame.\n Interesting lines are marked as for "list".\n\n New in version 3.2.\n\na(rgs)\n\n Print the argument list of the current function.\n\np expression\n\n Evaluate the *expression* in the current context and print its\n value.\n\n Note: "print()" can also be used, but is not a debugger command\n --- this executes the Python "print()" function.\n\npp expression\n\n Like the "p" command, except the value of the expression is pretty-\n printed using the "pprint" module.\n\nwhatis expression\n\n Print the type of the *expression*.\n\nsource expression\n\n Try to get source code for the given object and display it.\n\n New in version 3.2.\n\ndisplay [expression]\n\n Display the value of the expression if it changed, each time\n execution stops in the current frame.\n\n Without expression, list all display expressions for the current\n frame.\n\n New in version 3.2.\n\nundisplay [expression]\n\n Do not display the expression any more in the current frame.\n Without expression, clear all display expressions for the current\n frame.\n\n New in version 3.2.\n\ninteract\n\n Start an interative interpreter (using the "code" module) whose\n global namespace contains all the (global and local) names found in\n the current scope.\n\n New in version 3.2.\n\nalias [name [command]]\n\n Create an alias called *name* that executes *command*. The command\n must *not* be enclosed in quotes. Replaceable parameters can be\n indicated by "%1", "%2", and so on, while "%*" is replaced by all\n the parameters. If no command is given, the current alias for\n *name* is shown. If no arguments are given, all aliases are listed.\n\n Aliases may be nested and can contain anything that can be legally\n typed at the pdb prompt. Note that internal pdb commands *can* be\n overridden by aliases. Such a command is then hidden until the\n alias is removed. Aliasing is recursively applied to the first\n word of the command line; all other words in the line are left\n alone.\n\n As an example, here are two useful aliases (especially when placed\n in the ".pdbrc" file):\n\n # Print instance variables (usage "pi classInst")\n alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])\n # Print instance variables in self\n alias ps pi self\n\nunalias name\n\n Delete the specified alias.\n\n! statement\n\n Execute the (one-line) *statement* in the context of the current\n stack frame. The exclamation point can be omitted unless the first\n word of the statement resembles a debugger command. To set a\n global variable, you can prefix the assignment command with a\n "global" statement on the same line, e.g.:\n\n (Pdb) global list_options; list_options = [\'-l\']\n (Pdb)\n\nrun [args ...]\nrestart [args ...]\n\n Restart the debugged Python program. If an argument is supplied,\n it is split with "shlex" and the result is used as the new\n "sys.argv". History, breakpoints, actions and debugger options are\n preserved. "restart" is an alias for "run".\n\nq(uit)\n\n Quit from the debugger. The program being executed is aborted.\n\n-[ Footnotes ]-\n\n[1] Whether a frame is considered to originate in a certain module\n is determined by the "__name__" in the frame globals.\n', 'del': u'\nThe "del" statement\n*******************\n\n del_stmt ::= "del" target_list\n\nDeletion is recursively defined very similar to the way assignment is\ndefined. Rather than spelling it out in full details, here are some\nhints.\n\nDeletion of a target list recursively deletes each target, from left\nto right.\n\nDeletion of a name removes the binding of that name from the local or\nglobal namespace, depending on whether the name occurs in a "global"\nstatement in the same code block. If the name is unbound, a\n"NameError" exception will be raised.\n\nDeletion of attribute references, subscriptions and slicings is passed\nto the primary object involved; deletion of a slicing is in general\nequivalent to assignment of an empty slice of the right type (but even\nthis is determined by the sliced object).\n\nChanged in version 3.2: Previously it was illegal to delete a name\nfrom the local namespace if it occurs as a free variable in a nested\nblock.\n', 'dict': u'\nDictionary displays\n*******************\n\nA dictionary display is a possibly empty series of key/datum pairs\nenclosed in curly braces:\n\n dict_display ::= "{" [key_datum_list | dict_comprehension] "}"\n key_datum_list ::= key_datum ("," key_datum)* [","]\n key_datum ::= expression ":" expression\n dict_comprehension ::= expression ":" expression comp_for\n\nA dictionary display yields a new dictionary object.\n\nIf a comma-separated sequence of key/datum pairs is given, they are\nevaluated from left to right to define the entries of the dictionary:\neach key object is used as a key into the dictionary to store the\ncorresponding datum. This means that you can specify the same key\nmultiple times in the key/datum list, and the final dictionary\'s value\nfor that key will be the last one given.\n\nA dict comprehension, in contrast to list and set comprehensions,\nneeds two expressions separated with a colon followed by the usual\n"for" and "if" clauses. When the comprehension is run, the resulting\nkey and value elements are inserted in the new dictionary in the order\nthey are produced.\n\nRestrictions on the types of the key values are listed earlier in\nsection *The standard type hierarchy*. (To summarize, the key type\nshould be *hashable*, which excludes all mutable objects.) Clashes\nbetween duplicate keys are not detected; the last datum (textually\nrightmost in the display) stored for a given key value prevails.\n', - 'dynamic-features': u'\nInteraction with dynamic features\n*********************************\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- "import *" --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a "SyntaxError".\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n', + 'dynamic-features': u'\nInteraction with dynamic features\n*********************************\n\nName resolution of free variables occurs at runtime, not at compile\ntime. This means that the following code will print 42:\n\n i = 10\n def f():\n print(i)\n i = 42\n f()\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n', 'else': u'\nThe "if" statement\n******************\n\nThe "if" statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the "if" statement is executed or evaluated).\nIf all expressions are false, the suite of the "else" clause, if\npresent, is executed.\n', 'exceptions': u'\nExceptions\n**********\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the "raise" statement. Exception\nhandlers are specified with the "try" ... "except" statement. The\n"finally" clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n"SystemExit".\n\nExceptions are identified by class instances. The "except" clause is\nselected depending on the class of the instance: it must reference the\nclass of the instance or a base class thereof. The instance can be\nreceived by the handler and can carry additional information about the\nexceptional condition.\n\nNote: Exception messages are not part of the Python API. Their\n contents may change from one version of Python to the next without\n warning and should not be relied on by code which will run under\n multiple versions of the interpreter.\n\nSee also the description of the "try" statement in section *The try\nstatement* and "raise" statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by\n these operations is not available at the time the module is\n compiled.\n', - 'execmodel': u'\nExecution model\n***************\n\n\nNaming and binding\n==================\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\nas a command line argument to the interpreter) is a code block. A\nscript command (a command specified on the interpreter command line\nwith the \'**-c**\' option) is a code block. The string argument passed\nto the built-in functions "eval()" and "exec()" is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block\'s execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes comprehensions and generator\nexpressions since they are implemented using a function scope. This\nmeans that the following will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as "nonlocal". If a name is bound at the module\nlevel, it is a global variable. (The variables of the module code\nblock are local and global.) If a variable is used in a code block\nbut not defined there, it is a *free variable*.\n\nWhen a name is not found at all, a "NameError" exception is raised.\nIf the name refers to a local variable that has not been bound, an\n"UnboundLocalError" exception is raised. "UnboundLocalError" is a\nsubclass of "NameError".\n\nThe following constructs bind names: formal parameters to functions,\n"import" statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, "for" loop header, or after\n"as" in a "with" statement or "except" clause. The "import" statement\nof the form "from ... import *" binds all names defined in the\nimported module, except those beginning with an underscore. This form\nmay only be used at the module level.\n\nA target occurring in a "del" statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the "global" statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module "builtins". The global namespace is searched first. If\nthe name is not found there, the builtins namespace is searched. The\n"global" statement must precede all uses of the name.\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name "__builtins__" in its global\nnamespace; this should be a dictionary or a module (in the latter case\nthe module\'s dictionary is used). By default, when in the "__main__"\nmodule, "__builtins__" is the built-in module "builtins"; when in any\nother module, "__builtins__" is an alias for the dictionary of the\n"builtins" module itself. "__builtins__" can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n"__builtins__"; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should "import"\nthe "builtins" module and modify its attributes appropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n"__main__".\n\nThe "global" statement has the same scope as a name binding operation\nin the same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n---------------------------------\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- "import *" --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a "SyntaxError".\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n\n\nExceptions\n==========\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the "raise" statement. Exception\nhandlers are specified with the "try" ... "except" statement. The\n"finally" clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n"SystemExit".\n\nExceptions are identified by class instances. The "except" clause is\nselected depending on the class of the instance: it must reference the\nclass of the instance or a base class thereof. The instance can be\nreceived by the handler and can carry additional information about the\nexceptional condition.\n\nNote: Exception messages are not part of the Python API. Their\n contents may change from one version of Python to the next without\n warning and should not be relied on by code which will run under\n multiple versions of the interpreter.\n\nSee also the description of the "try" statement in section *The try\nstatement* and "raise" statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by\n these operations is not available at the time the module is\n compiled.\n', + 'execmodel': u'\nExecution model\n***************\n\n\nStructure of a program\n======================\n\nA Python program is constructed from code blocks. A *block* is a piece\nof Python program text that is executed as a unit. The following are\nblocks: a module, a function body, and a class definition. Each\ncommand typed interactively is a block. A script file (a file given\nas standard input to the interpreter or specified as a command line\nargument to the interpreter) is a code block. A script command (a\ncommand specified on the interpreter command line with the \'**-c**\'\noption) is a code block. The string argument passed to the built-in\nfunctions "eval()" and "exec()" is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block\'s execution has\ncompleted.\n\n\nNaming and binding\n==================\n\n\nBinding of names\n----------------\n\n*Names* refer to objects. Names are introduced by name binding\noperations.\n\nThe following constructs bind names: formal parameters to functions,\n"import" statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, "for" loop header, or after\n"as" in a "with" statement or "except" clause. The "import" statement\nof the form "from ... import *" binds all names defined in the\nimported module, except those beginning with an underscore. This form\nmay only be used at the module level.\n\nA target occurring in a "del" statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as "nonlocal" or "global". If a name is bound at the\nmodule level, it is a global variable. (The variables of the module\ncode block are local and global.) If a variable is used in a code\nblock but not defined there, it is a *free variable*.\n\nEach occurrence of a name in the program text refers to the *binding*\nof that name established by the following name resolution rules.\n\n\nResolution of names\n-------------------\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name.\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nWhen a name is not found at all, a "NameError" exception is raised. If\nthe current scope is a function scope, and the name refers to a local\nvariable that has not yet been bound to a value at the point where the\nname is used, an "UnboundLocalError" exception is raised.\n"UnboundLocalError" is a subclass of "NameError".\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the "global" statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module "builtins". The global namespace is searched first. If\nthe name is not found there, the builtins namespace is searched. The\n"global" statement must precede all uses of the name.\n\nThe "global" statement has the same scope as a name binding operation\nin the same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nThe "nonlocal" statement causes corresponding names to refer to\npreviously bound variables in the nearest enclosing function scope.\n"SyntaxError" is raised at compile time if the given name does not\nexist in any enclosing function scope.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n"__main__".\n\nClass definition blocks and arguments to "exec()" and "eval()" are\nspecial in the context of name resolution. A class definition is an\nexecutable statement that may use and define names. These references\nfollow the normal rules for name resolution with an exception that\nunbound local variables are looked up in the global namespace. The\nnamespace of the class definition becomes the attribute dictionary of\nthe class. The scope of names defined in a class block is limited to\nthe class block; it does not extend to the code blocks of methods --\nthis includes comprehensions and generator expressions since they are\nimplemented using a function scope. This means that the following\nwill fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\n\nBuiltins and restricted execution\n---------------------------------\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name "__builtins__" in its global\nnamespace; this should be a dictionary or a module (in the latter case\nthe module\'s dictionary is used). By default, when in the "__main__"\nmodule, "__builtins__" is the built-in module "builtins"; when in any\nother module, "__builtins__" is an alias for the dictionary of the\n"builtins" module itself. "__builtins__" can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n"__builtins__"; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should "import"\nthe "builtins" module and modify its attributes appropriately.\n\n\nInteraction with dynamic features\n---------------------------------\n\nName resolution of free variables occurs at runtime, not at compile\ntime. This means that the following code will print 42:\n\n i = 10\n def f():\n print(i)\n i = 42\n f()\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n\n\nExceptions\n==========\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the "raise" statement. Exception\nhandlers are specified with the "try" ... "except" statement. The\n"finally" clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n"SystemExit".\n\nExceptions are identified by class instances. The "except" clause is\nselected depending on the class of the instance: it must reference the\nclass of the instance or a base class thereof. The instance can be\nreceived by the handler and can carry additional information about the\nexceptional condition.\n\nNote: Exception messages are not part of the Python API. Their\n contents may change from one version of Python to the next without\n warning and should not be relied on by code which will run under\n multiple versions of the interpreter.\n\nSee also the description of the "try" statement in section *The try\nstatement* and "raise" statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by\n these operations is not available at the time the module is\n compiled.\n', 'exprlists': u'\nExpression lists\n****************\n\n expression_list ::= expression ( "," expression )* [","]\n\nAn expression list containing at least one comma yields a tuple. The\nlength of the tuple is the number of expressions in the list. The\nexpressions are evaluated from left to right.\n\nThe trailing comma is required only to create a single tuple (a.k.a. a\n*singleton*); it is optional in all other cases. A single expression\nwithout a trailing comma doesn\'t create a tuple, but rather yields the\nvalue of that expression. (To create an empty tuple, use an empty pair\nof parentheses: "()".)\n', 'floating': u'\nFloating point literals\n***********************\n\nFloating point literals are described by the following lexical\ndefinitions:\n\n floatnumber ::= pointfloat | exponentfloat\n pointfloat ::= [intpart] fraction | intpart "."\n exponentfloat ::= (intpart | pointfloat) exponent\n intpart ::= digit+\n fraction ::= "." digit+\n exponent ::= ("e" | "E") ["+" | "-"] digit+\n\nNote that the integer and exponent parts are always interpreted using\nradix 10. For example, "077e010" is legal, and denotes the same number\nas "77e10". The allowed range of floating point literals is\nimplementation-dependent. Some examples of floating point literals:\n\n 3.14 10. .001 1e100 3.14e-10 0e0\n\nNote that numeric literals do not include a sign; a phrase like "-1"\nis actually an expression composed of the unary operator "-" and the\nliteral "1".\n', 'for': u'\nThe "for" statement\n*******************\n\nThe "for" statement is used to iterate over the elements of a sequence\n(such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n"expression_list". The suite is then executed once for each item\nprovided by the iterator, in the order returned by the iterator. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted. When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a "StopIteration" exception),\nthe suite in the "else" clause, if present, is executed, and the loop\nterminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and continues\nwith the next item, or with the "else" clause if there is no next\nitem.\n\nThe for-loop makes assignments to the variables(s) in the target list.\nThis overwrites all previous assignments to those variables including\nthose made in the suite of the for-loop:\n\n for i in range(10):\n print(i)\n i = 5 # this will not affect the for-loop\n # because i will be overwritten with the next\n # index in the range\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, they will not have been assigned to at\nall by the loop. Hint: the built-in function "range()" returns an\niterator of integers suitable to emulate the effect of Pascal\'s "for i\n:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".\n\nNote: There is a subtlety when the sequence is being modified by the\n loop (this can only occur for mutable sequences, i.e. lists). An\n internal counter is used to keep track of which item is used next,\n and this is incremented on each iteration. When this counter has\n reached the length of the sequence the loop terminates. This means\n that if the suite deletes the current (or a previous) item from the\n sequence, the next item will be skipped (since it gets the index of\n the current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n', @@ -42,16 +42,16 @@ 'if': u'\nThe "if" statement\n******************\n\nThe "if" statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the "if" statement is executed or evaluated).\nIf all expressions are false, the suite of the "else" clause, if\npresent, is executed.\n', 'imaginary': u'\nImaginary literals\n******************\n\nImaginary literals are described by the following lexical definitions:\n\n imagnumber ::= (floatnumber | intpart) ("j" | "J")\n\nAn imaginary literal yields a complex number with a real part of 0.0.\nComplex numbers are represented as a pair of floating point numbers\nand have the same restrictions on their range. To create a complex\nnumber with a nonzero real part, add a floating point number to it,\ne.g., "(3+4j)". Some examples of imaginary literals:\n\n 3.14j 10.j 10j .001j 1e100j 3.14e-10j\n', 'import': u'\nThe "import" statement\n**********************\n\n import_stmt ::= "import" module ["as" name] ( "," module ["as" name] )*\n | "from" relative_module "import" identifier ["as" name]\n ( "," identifier ["as" name] )*\n | "from" relative_module "import" "(" identifier ["as" name]\n ( "," identifier ["as" name] )* [","] ")"\n | "from" module "import" "*"\n module ::= (identifier ".")* identifier\n relative_module ::= "."* module | "."+\n name ::= identifier\n\nThe basic import statement (no "from" clause) is executed in two\nsteps:\n\n1. find a module, loading and initializing it if necessary\n\n2. define a name or names in the local namespace for the scope\n where the "import" statement occurs.\n\nWhen the statement contains multiple clauses (separated by commas) the\ntwo steps are carried out separately for each clause, just as though\nthe clauses had been separated out into individiual import statements.\n\nThe details of the first step, finding and loading modules are\ndescribed in greater detail in the section on the *import system*,\nwhich also describes the various types of packages and modules that\ncan be imported, as well as all the hooks that can be used to\ncustomize the import system. Note that failures in this step may\nindicate either that the module could not be located, *or* that an\nerror occurred while initializing the module, which includes execution\nof the module\'s code.\n\nIf the requested module is retrieved successfully, it will be made\navailable in the local namespace in one of three ways:\n\n* If the module name is followed by "as", then the name following\n "as" is bound directly to the imported module.\n\n* If no other name is specified, and the module being imported is a\n top level module, the module\'s name is bound in the local namespace\n as a reference to the imported module\n\n* If the module being imported is *not* a top level module, then the\n name of the top level package that contains the module is bound in\n the local namespace as a reference to the top level package. The\n imported module must be accessed using its full qualified name\n rather than directly\n\nThe "from" form uses a slightly more complex process:\n\n1. find the module specified in the "from" clause, loading and\n initializing it if necessary;\n\n2. for each of the identifiers specified in the "import" clauses:\n\n 1. check if the imported module has an attribute by that name\n\n 2. if not, attempt to import a submodule with that name and then\n check the imported module again for that attribute\n\n 3. if the attribute is not found, "ImportError" is raised.\n\n 4. otherwise, a reference to that value is stored in the local\n namespace, using the name in the "as" clause if it is present,\n otherwise using the attribute name\n\nExamples:\n\n import foo # foo imported and bound locally\n import foo.bar.baz # foo.bar.baz imported, foo bound locally\n import foo.bar.baz as fbb # foo.bar.baz imported and bound as fbb\n from foo.bar import baz # foo.bar.baz imported and bound as baz\n from foo import attr # foo imported and foo.attr bound as attr\n\nIf the list of identifiers is replaced by a star ("\'*\'"), all public\nnames defined in the module are bound in the local namespace for the\nscope where the "import" statement occurs.\n\nThe *public names* defined by a module are determined by checking the\nmodule\'s namespace for a variable named "__all__"; if defined, it must\nbe a sequence of strings which are names defined or imported by that\nmodule. The names given in "__all__" are all considered public and\nare required to exist. If "__all__" is not defined, the set of public\nnames includes all names found in the module\'s namespace which do not\nbegin with an underscore character ("\'_\'"). "__all__" should contain\nthe entire public API. It is intended to avoid accidentally exporting\nitems that are not part of the API (such as library modules which were\nimported and used within the module).\n\nThe wild card form of import --- "from module import *" --- is only\nallowed at the module level. Attempting to use it in class or\nfunction definitions will raise a "SyntaxError".\n\nWhen specifying what module to import you do not have to specify the\nabsolute name of the module. When a module or package is contained\nwithin another package it is possible to make a relative import within\nthe same top package without having to mention the package name. By\nusing leading dots in the specified module or package after "from" you\ncan specify how high to traverse up the current package hierarchy\nwithout specifying exact names. One leading dot means the current\npackage where the module making the import exists. Two dots means up\none package level. Three dots is up two levels, etc. So if you execute\n"from . import mod" from a module in the "pkg" package then you will\nend up importing "pkg.mod". If you execute "from ..subpkg2 import mod"\nfrom within "pkg.subpkg1" you will import "pkg.subpkg2.mod". The\nspecification for relative imports is contained within **PEP 328**.\n\n"importlib.import_module()" is provided to support applications that\ndetermine dynamically the modules to be loaded.\n\n\nFuture statements\n=================\n\nA *future statement* is a directive to the compiler that a particular\nmodule should be compiled using syntax or semantics that will be\navailable in a specified future release of Python where the feature\nbecomes standard.\n\nThe future statement is intended to ease migration to future versions\nof Python that introduce incompatible changes to the language. It\nallows use of the new features on a per-module basis before the\nrelease in which the feature becomes standard.\n\n future_statement ::= "from" "__future__" "import" feature ["as" name]\n ("," feature ["as" name])*\n | "from" "__future__" "import" "(" feature ["as" name]\n ("," feature ["as" name])* [","] ")"\n feature ::= identifier\n name ::= identifier\n\nA future statement must appear near the top of the module. The only\nlines that can appear before a future statement are:\n\n* the module docstring (if any),\n\n* comments,\n\n* blank lines, and\n\n* other future statements.\n\nThe features recognized by Python 3.0 are "absolute_import",\n"division", "generators", "unicode_literals", "print_function",\n"nested_scopes" and "with_statement". They are all redundant because\nthey are always enabled, and only kept for backwards compatibility.\n\nA future statement is recognized and treated specially at compile\ntime: Changes to the semantics of core constructs are often\nimplemented by generating different code. It may even be the case\nthat a new feature introduces new incompatible syntax (such as a new\nreserved word), in which case the compiler may need to parse the\nmodule differently. Such decisions cannot be pushed off until\nruntime.\n\nFor any given release, the compiler knows which feature names have\nbeen defined, and raises a compile-time error if a future statement\ncontains a feature not known to it.\n\nThe direct runtime semantics are the same as for any import statement:\nthere is a standard module "__future__", described later, and it will\nbe imported in the usual way at the time the future statement is\nexecuted.\n\nThe interesting runtime semantics depend on the specific feature\nenabled by the future statement.\n\nNote that there is nothing special about the statement:\n\n import __future__ [as name]\n\nThat is not a future statement; it\'s an ordinary import statement with\nno special semantics or syntax restrictions.\n\nCode compiled by calls to the built-in functions "exec()" and\n"compile()" that occur in a module "M" containing a future statement\nwill, by default, use the new syntax or semantics associated with the\nfuture statement. This can be controlled by optional arguments to\n"compile()" --- see the documentation of that function for details.\n\nA future statement typed at an interactive interpreter prompt will\ntake effect for the rest of the interpreter session. If an\ninterpreter is started with the *-i* option, is passed a script name\nto execute, and the script includes a future statement, it will be in\neffect in the interactive session started after the script is\nexecuted.\n\nSee also: **PEP 236** - Back to the __future__\n\n The original proposal for the __future__ mechanism.\n', - 'in': u'\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like "a < b < c" have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: "True" or "False".\n\nComparisons can be chained arbitrarily, e.g., "x < y <= z" is\nequivalent to "x < y and y <= z", except that "y" is evaluated only\nonce (but in both cases "z" is not evaluated at all when "x < y" is\nfound to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then "a op1 b op2 c ... y\nopN z" is equivalent to "a op1 b and b op2 c and ... y opN z", except\nthat each expression is evaluated at most once.\n\nNote that "a op1 b op2 c" doesn\'t imply any kind of comparison between\n*a* and *c*, so that, e.g., "x < y > z" is perfectly legal (though\nperhaps not pretty).\n\nThe operators "<", ">", "==", ">=", "<=", and "!=" compare the values\nof two objects. The objects need not have the same type. If both are\nnumbers, they are converted to a common type. Otherwise, the "==" and\n"!=" operators *always* consider objects of different types to be\nunequal, while the "<", ">", ">=" and "<=" operators raise a\n"TypeError" when comparing objects of different types that do not\nimplement these operators for the given pair of types. You can\ncontrol comparison behavior of objects of non-built-in types by\ndefining rich comparison methods like "__gt__()", described in section\n*Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values "float(\'NaN\')" and "Decimal(\'NaN\')" are special. The\n are identical to themselves, "x is x" but are not equal to\n themselves, "x != x". Additionally, comparing any value to a\n not-a-number value will return "False". For example, both "3 <\n float(\'NaN\')" and "float(\'NaN\') < 3" will return "False".\n\n* Bytes objects are compared lexicographically using the numeric\n values of their elements.\n\n* Strings are compared lexicographically using the numeric\n equivalents (the result of the built-in function "ord()") of their\n characters. [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison\n of corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, "[1,2,x] <= [1,2,y]" has the same\n value as "x <= y". If the corresponding element does not exist, the\n shorter sequence is ordered first (for example, "[1,2] < [1,2,3]").\n\n* Mappings (dictionaries) compare equal if and only if they have the\n same "(key, value)" pairs. Order comparisons "(\'<\', \'<=\', \'>=\',\n \'>\')" raise "TypeError".\n\n* Sets and frozensets define comparison operators to mean subset and\n superset tests. Those relations do not define total orderings (the\n two sets "{1,2}" and {2,3} are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering.\n For example, "min()", "max()", and "sorted()" produce undefined\n results given a list of sets as inputs.\n\n* Most other objects of built-in types compare unequal unless they\n are the same object; the choice whether one object is considered\n smaller or larger than another one is made arbitrarily but\n consistently within one execution of a program.\n\nComparison of objects of differing types depends on whether either of\nthe types provide explicit support for the comparison. Most numeric\ntypes can be compared with one another. When cross-type comparison is\nnot supported, the comparison method returns "NotImplemented".\n\nThe operators "in" and "not in" test for membership. "x in s"\nevaluates to true if *x* is a member of *s*, and false otherwise. "x\nnot in s" returns the negation of "x in s". All built-in sequences\nand set types support this as well as dictionary, for which "in" tests\nwhether the dictionary has a given key. For container types such as\nlist, tuple, set, frozenset, dict, or collections.deque, the\nexpression "x in y" is equivalent to "any(x is e or x == e for e in\ny)".\n\nFor the string and bytes types, "x in y" is true if and only if *x* is\na substring of *y*. An equivalent test is "y.find(x) != -1". Empty\nstrings are always considered to be a substring of any other string,\nso """ in "abc"" will return "True".\n\nFor user-defined classes which define the "__contains__()" method, "x\nin y" is true if and only if "y.__contains__(x)" is true.\n\nFor user-defined classes which do not define "__contains__()" but do\ndefine "__iter__()", "x in y" is true if some value "z" with "x == z"\nis produced while iterating over "y". If an exception is raised\nduring the iteration, it is as if "in" raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n"__getitem__()", "x in y" is true if and only if there is a non-\nnegative integer index *i* such that "x == y[i]", and all lower\ninteger indices do not raise "IndexError" exception. (If any other\nexception is raised, it is as if "in" raised that exception).\n\nThe operator "not in" is defined to have the inverse true value of\n"in".\n\nThe operators "is" and "is not" test for object identity: "x is y" is\ntrue if and only if *x* and *y* are the same object. "x is not y"\nyields the inverse truth value. [4]\n', - 'integers': u'\nInteger literals\n****************\n\nInteger literals are described by the following lexical definitions:\n\n integer ::= decimalinteger | octinteger | hexinteger | bininteger\n decimalinteger ::= nonzerodigit digit* | "0"+\n nonzerodigit ::= "1"..."9"\n digit ::= "0"..."9"\n octinteger ::= "0" ("o" | "O") octdigit+\n hexinteger ::= "0" ("x" | "X") hexdigit+\n bininteger ::= "0" ("b" | "B") bindigit+\n octdigit ::= "0"..."7"\n hexdigit ::= digit | "a"..."f" | "A"..."F"\n bindigit ::= "0" | "1"\n\nThere is no limit for the length of integer literals apart from what\ncan be stored in available memory.\n\nNote that leading zeros in a non-zero decimal number are not allowed.\nThis is for disambiguation with C-style octal literals, which Python\nused before version 3.0.\n\nSome examples of integer literals:\n\n 7 2147483647 0o177 0b100110111\n 3 79228162514264337593543950336 0o377 0x100000000\n 79228162514264337593543950336 0xdeadbeef\n', + 'in': u'\nMembership test operations\n**************************\n\nThe operators "in" and "not in" test for membership. "x in s"\nevaluates to true if *x* is a member of *s*, and false otherwise. "x\nnot in s" returns the negation of "x in s". All built-in sequences\nand set types support this as well as dictionary, for which "in" tests\nwhether the dictionary has a given key. For container types such as\nlist, tuple, set, frozenset, dict, or collections.deque, the\nexpression "x in y" is equivalent to "any(x is e or x == e for e in\ny)".\n\nFor the string and bytes types, "x in y" is true if and only if *x* is\na substring of *y*. An equivalent test is "y.find(x) != -1". Empty\nstrings are always considered to be a substring of any other string,\nso """ in "abc"" will return "True".\n\nFor user-defined classes which define the "__contains__()" method, "x\nin y" is true if and only if "y.__contains__(x)" is true.\n\nFor user-defined classes which do not define "__contains__()" but do\ndefine "__iter__()", "x in y" is true if some value "z" with "x == z"\nis produced while iterating over "y". If an exception is raised\nduring the iteration, it is as if "in" raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n"__getitem__()", "x in y" is true if and only if there is a non-\nnegative integer index *i* such that "x == y[i]", and all lower\ninteger indices do not raise "IndexError" exception. (If any other\nexception is raised, it is as if "in" raised that exception).\n\nThe operator "not in" is defined to have the inverse true value of\n"in".\n', + 'integers': u'\nInteger literals\n****************\n\nInteger literals are described by the following lexical definitions:\n\n integer ::= decimalinteger | octinteger | hexinteger | bininteger\n decimalinteger ::= nonzerodigit digit* | "0"+\n nonzerodigit ::= "1"..."9"\n digit ::= "0"..."9"\n octinteger ::= "0" ("o" | "O") octdigit+\n hexinteger ::= "0" ("x" | "X") hexdigit+\n bininteger ::= "0" ("b" | "B") bindigit+\n octdigit ::= "0"..."7"\n hexdigit ::= digit | "a"..."f" | "A"..."F"\n bindigit ::= "0" | "1"\n\nThere is no limit for the length of integer literals apart from what\ncan be stored in available memory.\n\nNote that leading zeros in a non-zero decimal number are not allowed.\nThis is for disambiguation with C-style octal literals, which Python\nused before version 3.0.\n\nSome examples of integer literals:\n\n 7 2147483647 0o177 0b100110111\n 3 79228162514264337593543950336 0o377 0xdeadbeef\n', 'lambda': u'\nLambdas\n*******\n\n lambda_expr ::= "lambda" [parameter_list]: expression\n lambda_expr_nocond ::= "lambda" [parameter_list]: expression_nocond\n\nLambda expressions (sometimes called lambda forms) are used to create\nanonymous functions. The expression "lambda arguments: expression"\nyields a function object. The unnamed object behaves like a function\nobject defined with\n\n def (arguments):\n return expression\n\nSee section *Function definitions* for the syntax of parameter lists.\nNote that functions created with lambda expressions cannot contain\nstatements or annotations.\n', 'lists': u'\nList displays\n*************\n\nA list display is a possibly empty series of expressions enclosed in\nsquare brackets:\n\n list_display ::= "[" [expression_list | comprehension] "]"\n\nA list display yields a new list object, the contents being specified\nby either a list of expressions or a comprehension. When a comma-\nseparated list of expressions is supplied, its elements are evaluated\nfrom left to right and placed into the list object in that order.\nWhen a comprehension is supplied, the list is constructed from the\nelements resulting from the comprehension.\n', - 'naming': u'\nNaming and binding\n******************\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\nas a command line argument to the interpreter) is a code block. A\nscript command (a command specified on the interpreter command line\nwith the \'**-c**\' option) is a code block. The string argument passed\nto the built-in functions "eval()" and "exec()" is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block\'s execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes comprehensions and generator\nexpressions since they are implemented using a function scope. This\nmeans that the following will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as "nonlocal". If a name is bound at the module\nlevel, it is a global variable. (The variables of the module code\nblock are local and global.) If a variable is used in a code block\nbut not defined there, it is a *free variable*.\n\nWhen a name is not found at all, a "NameError" exception is raised.\nIf the name refers to a local variable that has not been bound, an\n"UnboundLocalError" exception is raised. "UnboundLocalError" is a\nsubclass of "NameError".\n\nThe following constructs bind names: formal parameters to functions,\n"import" statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, "for" loop header, or after\n"as" in a "with" statement or "except" clause. The "import" statement\nof the form "from ... import *" binds all names defined in the\nimported module, except those beginning with an underscore. This form\nmay only be used at the module level.\n\nA target occurring in a "del" statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the "global" statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module "builtins". The global namespace is searched first. If\nthe name is not found there, the builtins namespace is searched. The\n"global" statement must precede all uses of the name.\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name "__builtins__" in its global\nnamespace; this should be a dictionary or a module (in the latter case\nthe module\'s dictionary is used). By default, when in the "__main__"\nmodule, "__builtins__" is the built-in module "builtins"; when in any\nother module, "__builtins__" is an alias for the dictionary of the\n"builtins" module itself. "__builtins__" can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n"__builtins__"; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should "import"\nthe "builtins" module and modify its attributes appropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n"__main__".\n\nThe "global" statement has the same scope as a name binding operation\nin the same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n=================================\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- "import *" --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a "SyntaxError".\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n', + 'naming': u'\nNaming and binding\n******************\n\n\nBinding of names\n================\n\n*Names* refer to objects. Names are introduced by name binding\noperations.\n\nThe following constructs bind names: formal parameters to functions,\n"import" statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, "for" loop header, or after\n"as" in a "with" statement or "except" clause. The "import" statement\nof the form "from ... import *" binds all names defined in the\nimported module, except those beginning with an underscore. This form\nmay only be used at the module level.\n\nA target occurring in a "del" statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as "nonlocal" or "global". If a name is bound at the\nmodule level, it is a global variable. (The variables of the module\ncode block are local and global.) If a variable is used in a code\nblock but not defined there, it is a *free variable*.\n\nEach occurrence of a name in the program text refers to the *binding*\nof that name established by the following name resolution rules.\n\n\nResolution of names\n===================\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name.\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nWhen a name is not found at all, a "NameError" exception is raised. If\nthe current scope is a function scope, and the name refers to a local\nvariable that has not yet been bound to a value at the point where the\nname is used, an "UnboundLocalError" exception is raised.\n"UnboundLocalError" is a subclass of "NameError".\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the "global" statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module "builtins". The global namespace is searched first. If\nthe name is not found there, the builtins namespace is searched. The\n"global" statement must precede all uses of the name.\n\nThe "global" statement has the same scope as a name binding operation\nin the same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nThe "nonlocal" statement causes corresponding names to refer to\npreviously bound variables in the nearest enclosing function scope.\n"SyntaxError" is raised at compile time if the given name does not\nexist in any enclosing function scope.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n"__main__".\n\nClass definition blocks and arguments to "exec()" and "eval()" are\nspecial in the context of name resolution. A class definition is an\nexecutable statement that may use and define names. These references\nfollow the normal rules for name resolution with an exception that\nunbound local variables are looked up in the global namespace. The\nnamespace of the class definition becomes the attribute dictionary of\nthe class. The scope of names defined in a class block is limited to\nthe class block; it does not extend to the code blocks of methods --\nthis includes comprehensions and generator expressions since they are\nimplemented using a function scope. This means that the following\nwill fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\n\nBuiltins and restricted execution\n=================================\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name "__builtins__" in its global\nnamespace; this should be a dictionary or a module (in the latter case\nthe module\'s dictionary is used). By default, when in the "__main__"\nmodule, "__builtins__" is the built-in module "builtins"; when in any\nother module, "__builtins__" is an alias for the dictionary of the\n"builtins" module itself. "__builtins__" can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n"__builtins__"; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should "import"\nthe "builtins" module and modify its attributes appropriately.\n\n\nInteraction with dynamic features\n=================================\n\nName resolution of free variables occurs at runtime, not at compile\ntime. This means that the following code will print 42:\n\n i = 10\n def f():\n print(i)\n i = 42\n f()\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n', 'nonlocal': u'\nThe "nonlocal" statement\n************************\n\n nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*\n\nThe "nonlocal" statement causes the listed identifiers to refer to\npreviously bound variables in the nearest enclosing scope excluding\nglobals. This is important because the default behavior for binding is\nto search the local namespace first. The statement allows\nencapsulated code to rebind variables outside of the local scope\nbesides the global (module) scope.\n\nNames listed in a "nonlocal" statement, unlike those listed in a\n"global" statement, must refer to pre-existing bindings in an\nenclosing scope (the scope in which a new binding should be created\ncannot be determined unambiguously).\n\nNames listed in a "nonlocal" statement must not collide with pre-\nexisting bindings in the local scope.\n\nSee also: **PEP 3104** - Access to Names in Outer Scopes\n\n The specification for the "nonlocal" statement.\n', 'numbers': u'\nNumeric literals\n****************\n\nThere are three types of numeric literals: integers, floating point\nnumbers, and imaginary numbers. There are no complex literals\n(complex numbers can be formed by adding a real number and an\nimaginary number).\n\nNote that numeric literals do not include a sign; a phrase like "-1"\nis actually an expression composed of the unary operator \'"-"\' and the\nliteral "1".\n', 'numeric-types': u'\nEmulating numeric types\n***********************\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|"). For instance, to evaluate the\n expression "x + y", where *x* is an instance of a class that has an\n "__add__()" method, "x.__add__(y)" is called. The "__divmod__()"\n method should be the equivalent to using "__floordiv__()" and\n "__mod__()"; it should not be related to "__truediv__()". Note\n that "__pow__()" should be defined to accept an optional third\n argument if the ternary version of the built-in "pow()" function is\n to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return "NotImplemented".\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|") with reflected (swapped) operands.\n These functions are only called if the left operand does not\n support the corresponding operation and the operands are of\n different types. [2] For instance, to evaluate the expression "x -\n y", where *y* is an instance of a class that has an "__rsub__()"\n method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns\n *NotImplemented*.\n\n Note that ternary "pow()" will not try calling "__rpow__()" (the\n coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left\n operand\'s type and that subclass provides the reflected method\n for the operation, this method will be called before the left\n operand\'s non-reflected method. This behavior allows subclasses\n to override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments ("+=", "-=", "*=", "/=", "//=", "%=", "**=", "<<=",\n ">>=", "&=", "^=", "|="). These methods should attempt to do the\n operation in-place (modifying *self*) and return the result (which\n could be, but does not have to be, *self*). If a specific method\n is not defined, the augmented assignment falls back to the normal\n methods. For instance, if *x* is an instance of a class with an\n "__iadd__()" method, "x += y" is equivalent to "x = x.__iadd__(y)"\n . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are considered, as\n with the evaluation of "x + y". In certain situations, augmented\n assignment can result in unexpected errors (see *Why does\n a_tuple[i] += [\'item\'] raise an exception when the addition\n works?*), but this behavior is in fact part of the data model.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations ("-", "+",\n "abs()" and "~").\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions "complex()", "int()",\n "float()" and "round()". Should return a value of the appropriate\n type.\n\nobject.__index__(self)\n\n Called to implement "operator.index()", and whenever Python needs\n to losslessly convert the numeric object to an integer object (such\n as in slicing, or in the built-in "bin()", "hex()" and "oct()"\n functions). Presence of this method indicates that the numeric\n object is an integer type. Must return an integer.\n\n Note: In order to have a coherent integer type class, when\n "__index__()" is defined "__int__()" should also be defined, and\n both should return the same value.\n', 'objects': u'\nObjects, values and types\n*************************\n\n*Objects* are Python\'s abstraction for data. All data in a Python\nprogram is represented by objects or by relations between objects. (In\na sense, and in conformance to Von Neumann\'s model of a "stored\nprogram computer," code is also represented by objects.)\n\nEvery object has an identity, a type and a value. An object\'s\n*identity* never changes once it has been created; you may think of it\nas the object\'s address in memory. The \'"is"\' operator compares the\nidentity of two objects; the "id()" function returns an integer\nrepresenting its identity.\n\n**CPython implementation detail:** For CPython, "id(x)" is the memory\naddress where "x" is stored.\n\nAn object\'s type determines the operations that the object supports\n(e.g., "does it have a length?") and also defines the possible values\nfor objects of that type. The "type()" function returns an object\'s\ntype (which is an object itself). Like its identity, an object\'s\n*type* is also unchangeable. [1]\n\nThe *value* of some objects can change. Objects whose value can\nchange are said to be *mutable*; objects whose value is unchangeable\nonce they are created are called *immutable*. (The value of an\nimmutable container object that contains a reference to a mutable\nobject can change when the latter\'s value is changed; however the\ncontainer is still considered immutable, because the collection of\nobjects it contains cannot be changed. So, immutability is not\nstrictly the same as having an unchangeable value, it is more subtle.)\nAn object\'s mutability is determined by its type; for instance,\nnumbers, strings and tuples are immutable, while dictionaries and\nlists are mutable.\n\nObjects are never explicitly destroyed; however, when they become\nunreachable they may be garbage-collected. An implementation is\nallowed to postpone garbage collection or omit it altogether --- it is\na matter of implementation quality how garbage collection is\nimplemented, as long as no objects are collected that are still\nreachable.\n\n**CPython implementation detail:** CPython currently uses a reference-\ncounting scheme with (optional) delayed detection of cyclically linked\ngarbage, which collects most objects as soon as they become\nunreachable, but is not guaranteed to collect garbage containing\ncircular references. See the documentation of the "gc" module for\ninformation on controlling the collection of cyclic garbage. Other\nimplementations act differently and CPython may change. Do not depend\non immediate finalization of objects when they become unreachable (so\nyou should always close files explicitly).\n\nNote that the use of the implementation\'s tracing or debugging\nfacilities may keep objects alive that would normally be collectable.\nAlso note that catching an exception with a \'"try"..."except"\'\nstatement may keep objects alive.\n\nSome objects contain references to "external" resources such as open\nfiles or windows. It is understood that these resources are freed\nwhen the object is garbage-collected, but since garbage collection is\nnot guaranteed to happen, such objects also provide an explicit way to\nrelease the external resource, usually a "close()" method. Programs\nare strongly recommended to explicitly close such objects. The\n\'"try"..."finally"\' statement and the \'"with"\' statement provide\nconvenient ways to do this.\n\nSome objects contain references to other objects; these are called\n*containers*. Examples of containers are tuples, lists and\ndictionaries. The references are part of a container\'s value. In\nmost cases, when we talk about the value of a container, we imply the\nvalues, not the identities of the contained objects; however, when we\ntalk about the mutability of a container, only the identities of the\nimmediately contained objects are implied. So, if an immutable\ncontainer (like a tuple) contains a reference to a mutable object, its\nvalue changes if that mutable object is changed.\n\nTypes affect almost all aspects of object behavior. Even the\nimportance of object identity is affected in some sense: for immutable\ntypes, operations that compute new values may actually return a\nreference to any existing object with the same type and value, while\nfor mutable objects this is not allowed. E.g., after "a = 1; b = 1",\n"a" and "b" may or may not refer to the same object with the value\none, depending on the implementation, but after "c = []; d = []", "c"\nand "d" are guaranteed to refer to two different, unique, newly\ncreated empty lists. (Note that "c = d = []" assigns the same object\nto both "c" and "d".)\n', - 'operator-summary': u'\nOperator precedence\n*******************\n\nThe following table summarizes the operator precedence in Python, from\nlowest precedence (least binding) to highest precedence (most\nbinding). Operators in the same box have the same precedence. Unless\nthe syntax is explicitly given, operators are binary. Operators in\nthe same box group left to right (except for exponentiation, which\ngroups from right to left).\n\nNote that comparisons, membership tests, and identity tests, all have\nthe same precedence and have a left-to-right chaining feature as\ndescribed in the *Comparisons* section.\n\n+-------------------------------------------------+---------------------------------------+\n| Operator | Description |\n+=================================================+=======================================+\n| "lambda" | Lambda expression |\n+-------------------------------------------------+---------------------------------------+\n| "if" -- "else" | Conditional expression |\n+-------------------------------------------------+---------------------------------------+\n| "or" | Boolean OR |\n+-------------------------------------------------+---------------------------------------+\n| "and" | Boolean AND |\n+-------------------------------------------------+---------------------------------------+\n| "not" "x" | Boolean NOT |\n+-------------------------------------------------+---------------------------------------+\n| "in", "not in", "is", "is not", "<", "<=", ">", | Comparisons, including membership |\n| ">=", "!=", "==" | tests and identity tests |\n+-------------------------------------------------+---------------------------------------+\n| "|" | Bitwise OR |\n+-------------------------------------------------+---------------------------------------+\n| "^" | Bitwise XOR |\n+-------------------------------------------------+---------------------------------------+\n| "&" | Bitwise AND |\n+-------------------------------------------------+---------------------------------------+\n| "<<", ">>" | Shifts |\n+-------------------------------------------------+---------------------------------------+\n| "+", "-" | Addition and subtraction |\n+-------------------------------------------------+---------------------------------------+\n| "*", "/", "//", "%" | Multiplication, division, remainder |\n| | [5] |\n+-------------------------------------------------+---------------------------------------+\n| "+x", "-x", "~x" | Positive, negative, bitwise NOT |\n+-------------------------------------------------+---------------------------------------+\n| "**" | Exponentiation [6] |\n+-------------------------------------------------+---------------------------------------+\n| "x[index]", "x[index:index]", | Subscription, slicing, call, |\n| "x(arguments...)", "x.attribute" | attribute reference |\n+-------------------------------------------------+---------------------------------------+\n| "(expressions...)", "[expressions...]", "{key: | Binding or tuple display, list |\n| value...}", "{expressions...}" | display, dictionary display, set |\n| | display |\n+-------------------------------------------------+---------------------------------------+\n\n-[ Footnotes ]-\n\n[1] While "abs(x%y) < abs(y)" is true mathematically, for floats\n it may not be true numerically due to roundoff. For example, and\n assuming a platform on which a Python float is an IEEE 754 double-\n precision number, in order that "-1e-100 % 1e100" have the same\n sign as "1e100", the computed result is "-1e-100 + 1e100", which\n is numerically exactly equal to "1e100". The function\n "math.fmod()" returns a result whose sign matches the sign of the\n first argument instead, and so returns "-1e-100" in this case.\n Which approach is more appropriate depends on the application.\n\n[2] If x is very close to an exact integer multiple of y, it\'s\n possible for "x//y" to be one larger than "(x-x%y)//y" due to\n rounding. In such cases, Python returns the latter result, in\n order to preserve that "divmod(x,y)[0] * y + x % y" be very close\n to "x".\n\n[3] While comparisons between strings make sense at the byte\n level, they may be counter-intuitive to users. For example, the\n strings ""\\u00C7"" and ""\\u0327\\u0043"" compare differently, even\n though they both represent the same unicode character (LATIN\n CAPITAL LETTER C WITH CEDILLA). To compare strings in a human\n recognizable way, compare using "unicodedata.normalize()".\n\n[4] Due to automatic garbage-collection, free lists, and the\n dynamic nature of descriptors, you may notice seemingly unusual\n behaviour in certain uses of the "is" operator, like those\n involving comparisons between instance methods, or constants.\n Check their documentation for more info.\n\n[5] The "%" operator is also used for string formatting; the same\n precedence applies.\n\n[6] The power operator "**" binds less tightly than an arithmetic\n or bitwise unary operator on its right, that is, "2**-1" is "0.5".\n', + 'operator-summary': u'\nOperator precedence\n*******************\n\nThe following table summarizes the operator precedence in Python, from\nlowest precedence (least binding) to highest precedence (most\nbinding). Operators in the same box have the same precedence. Unless\nthe syntax is explicitly given, operators are binary. Operators in\nthe same box group left to right (except for exponentiation, which\ngroups from right to left).\n\nNote that comparisons, membership tests, and identity tests, all have\nthe same precedence and have a left-to-right chaining feature as\ndescribed in the *Comparisons* section.\n\n+-------------------------------------------------+---------------------------------------+\n| Operator | Description |\n+=================================================+=======================================+\n| "lambda" | Lambda expression |\n+-------------------------------------------------+---------------------------------------+\n| "if" -- "else" | Conditional expression |\n+-------------------------------------------------+---------------------------------------+\n| "or" | Boolean OR |\n+-------------------------------------------------+---------------------------------------+\n| "and" | Boolean AND |\n+-------------------------------------------------+---------------------------------------+\n| "not" "x" | Boolean NOT |\n+-------------------------------------------------+---------------------------------------+\n| "in", "not in", "is", "is not", "<", "<=", ">", | Comparisons, including membership |\n| ">=", "!=", "==" | tests and identity tests |\n+-------------------------------------------------+---------------------------------------+\n| "|" | Bitwise OR |\n+-------------------------------------------------+---------------------------------------+\n| "^" | Bitwise XOR |\n+-------------------------------------------------+---------------------------------------+\n| "&" | Bitwise AND |\n+-------------------------------------------------+---------------------------------------+\n| "<<", ">>" | Shifts |\n+-------------------------------------------------+---------------------------------------+\n| "+", "-" | Addition and subtraction |\n+-------------------------------------------------+---------------------------------------+\n| "*", "/", "//", "%" | Multiplication, division, remainder |\n| | [5] |\n+-------------------------------------------------+---------------------------------------+\n| "+x", "-x", "~x" | Positive, negative, bitwise NOT |\n+-------------------------------------------------+---------------------------------------+\n| "**" | Exponentiation [6] |\n+-------------------------------------------------+---------------------------------------+\n| "x[index]", "x[index:index]", | Subscription, slicing, call, |\n| "x(arguments...)", "x.attribute" | attribute reference |\n+-------------------------------------------------+---------------------------------------+\n| "(expressions...)", "[expressions...]", "{key: | Binding or tuple display, list |\n| value...}", "{expressions...}" | display, dictionary display, set |\n| | display |\n+-------------------------------------------------+---------------------------------------+\n\n-[ Footnotes ]-\n\n[1] While "abs(x%y) < abs(y)" is true mathematically, for floats\n it may not be true numerically due to roundoff. For example, and\n assuming a platform on which a Python float is an IEEE 754 double-\n precision number, in order that "-1e-100 % 1e100" have the same\n sign as "1e100", the computed result is "-1e-100 + 1e100", which\n is numerically exactly equal to "1e100". The function\n "math.fmod()" returns a result whose sign matches the sign of the\n first argument instead, and so returns "-1e-100" in this case.\n Which approach is more appropriate depends on the application.\n\n[2] If x is very close to an exact integer multiple of y, it\'s\n possible for "x//y" to be one larger than "(x-x%y)//y" due to\n rounding. In such cases, Python returns the latter result, in\n order to preserve that "divmod(x,y)[0] * y + x % y" be very close\n to "x".\n\n[3] The Unicode standard distinguishes between *code points* (e.g.\n U+0041) and *abstract characters* (e.g. "LATIN CAPITAL LETTER A").\n While most abstract characters in Unicode are only represented\n using one code point, there is a number of abstract characters\n that can in addition be represented using a sequence of more than\n one code point. For example, the abstract character "LATIN\n CAPITAL LETTER C WITH CEDILLA" can be represented as a single\n *precomposed character* at code position U+00C7, or as a sequence\n of a *base character* at code position U+0043 (LATIN CAPITAL\n LETTER C), followed by a *combining character* at code position\n U+0327 (COMBINING CEDILLA).\n\n The comparison operators on strings compare at the level of\n Unicode code points. This may be counter-intuitive to humans. For\n example, ""\\u00C7" == "\\u0043\\u0327"" is "False", even though both\n strings represent the same abstract character "LATIN CAPITAL\n LETTER C WITH CEDILLA".\n\n To compare strings at the level of abstract characters (that is,\n in a way intuitive to humans), use "unicodedata.normalize()".\n\n[4] Due to automatic garbage-collection, free lists, and the\n dynamic nature of descriptors, you may notice seemingly unusual\n behaviour in certain uses of the "is" operator, like those\n involving comparisons between instance methods, or constants.\n Check their documentation for more info.\n\n[5] The "%" operator is also used for string formatting; the same\n precedence applies.\n\n[6] The power operator "**" binds less tightly than an arithmetic\n or bitwise unary operator on its right, that is, "2**-1" is "0.5".\n', 'pass': u'\nThe "pass" statement\n********************\n\n pass_stmt ::= "pass"\n\n"pass" is a null operation --- when it is executed, nothing happens.\nIt is useful as a placeholder when a statement is required\nsyntactically, but no code needs to be executed, for example:\n\n def f(arg): pass # a function that does nothing (yet)\n\n class C: pass # a class with no methods (yet)\n', 'power': u'\nThe power operator\n******************\n\nThe power operator binds more tightly than unary operators on its\nleft; it binds less tightly than unary operators on its right. The\nsyntax is:\n\n power ::= primary ["**" u_expr]\n\nThus, in an unparenthesized sequence of power and unary operators, the\noperators are evaluated from right to left (this does not constrain\nthe evaluation order for the operands): "-1**2" results in "-1".\n\nThe power operator has the same semantics as the built-in "pow()"\nfunction, when called with two arguments: it yields its left argument\nraised to the power of its right argument. The numeric arguments are\nfirst converted to a common type, and the result is of that type.\n\nFor int operands, the result has the same type as the operands unless\nthe second argument is negative; in that case, all arguments are\nconverted to float and a float result is delivered. For example,\n"10**2" returns "100", but "10**-2" returns "0.01".\n\nRaising "0.0" to a negative power results in a "ZeroDivisionError".\nRaising a negative number to a fractional power results in a "complex"\nnumber. (In earlier versions it raised a "ValueError".)\n', 'raise': u'\nThe "raise" statement\n*********************\n\n raise_stmt ::= "raise" [expression ["from" expression]]\n\nIf no expressions are present, "raise" re-raises the last exception\nthat was active in the current scope. If no exception is active in\nthe current scope, a "RuntimeError" exception is raised indicating\nthat this is an error.\n\nOtherwise, "raise" evaluates the first expression as the exception\nobject. It must be either a subclass or an instance of\n"BaseException". If it is a class, the exception instance will be\nobtained when needed by instantiating the class with no arguments.\n\nThe *type* of the exception is the exception instance\'s class, the\n*value* is the instance itself.\n\nA traceback object is normally created automatically when an exception\nis raised and attached to it as the "__traceback__" attribute, which\nis writable. You can create an exception and set your own traceback in\none step using the "with_traceback()" exception method (which returns\nthe same exception instance, with its traceback set to its argument),\nlike so:\n\n raise Exception("foo occurred").with_traceback(tracebackobj)\n\nThe "from" clause is used for exception chaining: if given, the second\n*expression* must be another exception class or instance, which will\nthen be attached to the raised exception as the "__cause__" attribute\n(which is writable). If the raised exception is not handled, both\nexceptions will be printed:\n\n >>> try:\n ... print(1 / 0)\n ... except Exception as exc:\n ... raise RuntimeError("Something bad happened") from exc\n ...\n Traceback (most recent call last):\n File "", line 2, in \n ZeroDivisionError: int division or modulo by zero\n\n The above exception was the direct cause of the following exception:\n\n Traceback (most recent call last):\n File "", line 4, in \n RuntimeError: Something bad happened\n\nA similar mechanism works implicitly if an exception is raised inside\nan exception handler or a "finally" clause: the previous exception is\nthen attached as the new exception\'s "__context__" attribute:\n\n >>> try:\n ... print(1 / 0)\n ... except:\n ... raise RuntimeError("Something bad happened")\n ...\n Traceback (most recent call last):\n File "", line 2, in \n ZeroDivisionError: int division or modulo by zero\n\n During handling of the above exception, another exception occurred:\n\n Traceback (most recent call last):\n File "", line 4, in \n RuntimeError: Something bad happened\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information about handling exceptions is in section\n*The try statement*.\n', @@ -60,19 +60,19 @@ 'shifting': u'\nShifting operations\n*******************\n\nThe shifting operations have lower priority than the arithmetic\noperations:\n\n shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr\n\nThese operators accept integers as arguments. They shift the first\nargument to the left or right by the number of bits given by the\nsecond argument.\n\nA right shift by *n* bits is defined as floor division by "pow(2,n)".\nA left shift by *n* bits is defined as multiplication with "pow(2,n)".\n\nNote: In the current implementation, the right-hand operand is\n required to be at most "sys.maxsize". If the right-hand operand is\n larger than "sys.maxsize" an "OverflowError" exception is raised.\n', 'slicings': u'\nSlicings\n********\n\nA slicing selects a range of items in a sequence object (e.g., a\nstring, tuple or list). Slicings may be used as expressions or as\ntargets in assignment or "del" statements. The syntax for a slicing:\n\n slicing ::= primary "[" slice_list "]"\n slice_list ::= slice_item ("," slice_item)* [","]\n slice_item ::= expression | proper_slice\n proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" [stride] ]\n lower_bound ::= expression\n upper_bound ::= expression\n stride ::= expression\n\nThere is ambiguity in the formal syntax here: anything that looks like\nan expression list also looks like a slice list, so any subscription\ncan be interpreted as a slicing. Rather than further complicating the\nsyntax, this is disambiguated by defining that in this case the\ninterpretation as a subscription takes priority over the\ninterpretation as a slicing (this is the case if the slice list\ncontains no proper slice).\n\nThe semantics for a slicing are as follows. The primary is indexed\n(using the same "__getitem__()" method as normal subscription) with a\nkey that is constructed from the slice list, as follows. If the slice\nlist contains at least one comma, the key is a tuple containing the\nconversion of the slice items; otherwise, the conversion of the lone\nslice item is the key. The conversion of a slice item that is an\nexpression is that expression. The conversion of a proper slice is a\nslice object (see section *The standard type hierarchy*) whose\n"start", "stop" and "step" attributes are the values of the\nexpressions given as lower bound, upper bound and stride,\nrespectively, substituting "None" for missing expressions.\n', 'specialattrs': u'\nSpecial Attributes\n******************\n\nThe implementation adds a few special read-only attributes to several\nobject types, where they are relevant. Some of these are not reported\nby the "dir()" built-in function.\n\nobject.__dict__\n\n A dictionary or other mapping object used to store an object\'s\n (writable) attributes.\n\ninstance.__class__\n\n The class to which a class instance belongs.\n\nclass.__bases__\n\n The tuple of base classes of a class object.\n\nclass.__name__\n\n The name of the class or type.\n\nclass.__qualname__\n\n The *qualified name* of the class or type.\n\n New in version 3.3.\n\nclass.__mro__\n\n This attribute is a tuple of classes that are considered when\n looking for base classes during method resolution.\n\nclass.mro()\n\n This method can be overridden by a metaclass to customize the\n method resolution order for its instances. It is called at class\n instantiation, and its result is stored in "__mro__".\n\nclass.__subclasses__()\n\n Each class keeps a list of weak references to its immediate\n subclasses. This method returns a list of all those references\n still alive. Example:\n\n >>> int.__subclasses__()\n []\n\n-[ Footnotes ]-\n\n[1] Additional information on these special methods may be found\n in the Python Reference Manual (*Basic customization*).\n\n[2] As a consequence, the list "[1, 2]" is considered equal to\n "[1.0, 2.0]", and similarly for tuples.\n\n[3] They must have since the parser can\'t tell the type of the\n operands.\n\n[4] Cased characters are those with general category property\n being one of "Lu" (Letter, uppercase), "Ll" (Letter, lowercase),\n or "Lt" (Letter, titlecase).\n\n[5] To format only a tuple you should therefore provide a\n singleton tuple whose only element is the tuple to be formatted.\n', - 'specialnames': u'\nSpecial method names\n********************\n\nA class can implement certain operations that are invoked by special\nsyntax (such as arithmetic operations or subscripting and slicing) by\ndefining methods with special names. This is Python\'s approach to\n*operator overloading*, allowing classes to define their own behavior\nwith respect to language operators. For instance, if a class defines\na method named "__getitem__()", and "x" is an instance of this class,\nthen "x[i]" is roughly equivalent to "type(x).__getitem__(x, i)".\nExcept where mentioned, attempts to execute an operation raise an\nexception when no appropriate method is defined (typically\n"AttributeError" or "TypeError").\n\nWhen implementing a class that emulates any built-in type, it is\nimportant that the emulation only be implemented to the degree that it\nmakes sense for the object being modelled. For example, some\nsequences may work well with retrieval of individual elements, but\nextracting a slice may not make sense. (One example of this is the\n"NodeList" interface in the W3C\'s Document Object Model.)\n\n\nBasic customization\n===================\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. "__new__()" is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of "__new__()" should be the new object instance (usually an\n instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s "__new__()" method using\n "super(currentclass, cls).__new__(cls[, ...])" with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If "__new__()" returns an instance of *cls*, then the new\n instance\'s "__init__()" method will be invoked like\n "__init__(self[, ...])", where *self* is the new instance and the\n remaining arguments are the same as were passed to "__new__()".\n\n If "__new__()" does not return an instance of *cls*, then the new\n instance\'s "__init__()" method will not be invoked.\n\n "__new__()" is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called after the instance has been created (by "__new__()"), but\n before it is returned to the caller. The arguments are those\n passed to the class constructor expression. If a base class has an\n "__init__()" method, the derived class\'s "__init__()" method, if\n any, must explicitly call it to ensure proper initialization of the\n base class part of the instance; for example:\n "BaseClass.__init__(self, [args...])".\n\n Because "__new__()" and "__init__()" work together in constructing\n objects ("__new__()" to create it, and "__init__()" to customise\n it), no non-"None" value may be returned by "__init__()"; doing so\n will cause a "TypeError" to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a "__del__()" method, the\n derived class\'s "__del__()" method, if any, must explicitly call it\n to ensure proper deletion of the base class part of the instance.\n Note that it is possible (though not recommended!) for the\n "__del__()" method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n "__del__()" methods are called for objects that still exist when\n the interpreter exits.\n\n Note: "del x" doesn\'t directly call "x.__del__()" --- the former\n decrements the reference count for "x" by one, and the latter is\n only called when "x"\'s reference count reaches zero. Some common\n situations that may prevent the reference count of an object from\n going to zero include: circular references between objects (e.g.,\n a doubly-linked list or a tree data structure with parent and\n child pointers); a reference to the object on the stack frame of\n a function that caught an exception (the traceback stored in\n "sys.exc_info()[2]" keeps the stack frame alive); or a reference\n to the object on the stack frame that raised an unhandled\n exception in interactive mode (the traceback stored in\n "sys.last_traceback" keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the second can be resolved by freeing the reference to the\n traceback object when it is no longer useful, and the third can\n be resolved by storing "None" in "sys.last_traceback". Circular\n references which are garbage are detected and cleaned up when the\n cyclic garbage collector is enabled (it\'s on by default). Refer\n to the documentation for the "gc" module for more information\n about this topic.\n\n Warning: Due to the precarious circumstances under which\n "__del__()" methods are invoked, exceptions that occur during\n their execution are ignored, and a warning is printed to\n "sys.stderr" instead. Also, when "__del__()" is invoked in\n response to a module being deleted (e.g., when execution of the\n program is done), other globals referenced by the "__del__()"\n method may already have been deleted or in the process of being\n torn down (e.g. the import machinery shutting down). For this\n reason, "__del__()" methods should do the absolute minimum needed\n to maintain external invariants. Starting with version 1.5,\n Python guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the "__del__()" method is called.\n\nobject.__repr__(self)\n\n Called by the "repr()" built-in function to compute the "official"\n string representation of an object. If at all possible, this\n should look like a valid Python expression that could be used to\n recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n "<...some useful description...>" should be returned. The return\n value must be a string object. If a class defines "__repr__()" but\n not "__str__()", then "__repr__()" is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by "str(object)" and the built-in functions "format()" and\n "print()" to compute the "informal" or nicely printable string\n representation of an object. The return value must be a *string*\n object.\n\n This method differs from "object.__repr__()" in that there is no\n expectation that "__str__()" return a valid Python expression: a\n more convenient or concise representation can be used.\n\n The default implementation defined by the built-in type "object"\n calls "object.__repr__()".\n\nobject.__bytes__(self)\n\n Called by "bytes()" to compute a byte-string representation of an\n object. This should return a "bytes" object.\n\nobject.__format__(self, format_spec)\n\n Called by the "format()" built-in function (and by extension, the\n "str.format()" method of class "str") to produce a "formatted"\n string representation of an object. The "format_spec" argument is a\n string that contains a description of the formatting options\n desired. The interpretation of the "format_spec" argument is up to\n the type implementing "__format__()", however most classes will\n either delegate formatting to one of the built-in types, or use a\n similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\n Changed in version 3.4: The __format__ method of "object" itself\n raises a "TypeError" if passed any non-empty string.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: "xy" calls\n "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n\n A rich comparison method may return the singleton "NotImplemented"\n if it does not implement the operation for a given pair of\n arguments. By convention, "False" and "True" are returned for a\n successful comparison. However, these methods can return any value,\n so if the comparison operator is used in a Boolean context (e.g.,\n in the condition of an "if" statement), Python will call "bool()"\n on the value to determine if the result is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of "x==y" does not imply that "x!=y" is false.\n Accordingly, when defining "__eq__()", one should also define\n "__ne__()" so that the operators will behave as expected. See the\n paragraph on "__hash__()" for some important notes on creating\n *hashable* objects which support custom comparison operations and\n are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, "__lt__()" and "__gt__()" are each other\'s\n reflection, "__le__()" and "__ge__()" are each other\'s reflection,\n and "__eq__()" and "__ne__()" are their own reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see "functools.total_ordering()".\n\nobject.__hash__(self)\n\n Called by built-in function "hash()" and for operations on members\n of hashed collections including "set", "frozenset", and "dict".\n "__hash__()" should return an integer. The only required property\n is that objects which compare equal have the same hash value; it is\n advised to somehow mix together (e.g. using exclusive or) the hash\n values for the components of the object that also play a part in\n comparison of objects.\n\n Note: "hash()" truncates the value returned from an object\'s\n custom "__hash__()" method to the size of a "Py_ssize_t". This\n is typically 8 bytes on 64-bit builds and 4 bytes on 32-bit\n builds. If an object\'s "__hash__()" must interoperate on builds\n of different bit sizes, be sure to check the width on all\n supported builds. An easy way to do this is with "python -c\n "import sys; print(sys.hash_info.width)""\n\n If a class does not define an "__eq__()" method it should not\n define a "__hash__()" operation either; if it defines "__eq__()"\n but not "__hash__()", its instances will not be usable as items in\n hashable collections. If a class defines mutable objects and\n implements an "__eq__()" method, it should not implement\n "__hash__()", since the implementation of hashable collections\n requires that a key\'s hash value is immutable (if the object\'s hash\n value changes, it will be in the wrong hash bucket).\n\n User-defined classes have "__eq__()" and "__hash__()" methods by\n default; with them, all objects compare unequal (except with\n themselves) and "x.__hash__()" returns an appropriate value such\n that "x == y" implies both that "x is y" and "hash(x) == hash(y)".\n\n A class that overrides "__eq__()" and does not define "__hash__()"\n will have its "__hash__()" implicitly set to "None". When the\n "__hash__()" method of a class is "None", instances of the class\n will raise an appropriate "TypeError" when a program attempts to\n retrieve their hash value, and will also be correctly identified as\n unhashable when checking "isinstance(obj, collections.Hashable").\n\n If a class that overrides "__eq__()" needs to retain the\n implementation of "__hash__()" from a parent class, the interpreter\n must be told this explicitly by setting "__hash__ =\n .__hash__".\n\n If a class that does not override "__eq__()" wishes to suppress\n hash support, it should include "__hash__ = None" in the class\n definition. A class which defines its own "__hash__()" that\n explicitly raises a "TypeError" would be incorrectly identified as\n hashable by an "isinstance(obj, collections.Hashable)" call.\n\n Note: By default, the "__hash__()" values of str, bytes and\n datetime objects are "salted" with an unpredictable random value.\n Although they remain constant within an individual Python\n process, they are not predictable between repeated invocations of\n Python.This is intended to provide protection against a denial-\n of-service caused by carefully-chosen inputs that exploit the\n worst case performance of a dict insertion, O(n^2) complexity.\n See http://www.ocert.org/advisories/ocert-2011-003.html for\n details.Changing hash values affects the iteration order of\n dicts, sets and other mappings. Python has never made guarantees\n about this ordering (and it typically varies between 32-bit and\n 64-bit builds).See also "PYTHONHASHSEED".\n\n Changed in version 3.3: Hash randomization is enabled by default.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n "bool()"; should return "False" or "True". When this method is not\n defined, "__len__()" is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither "__len__()" nor "__bool__()", all its instances are\n considered true.\n\n\nCustomizing attribute access\n============================\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of "x.name") for\nclass instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for "self"). "name" is the attribute name. This\n method should return the (computed) attribute value or raise an\n "AttributeError" exception.\n\n Note that if the attribute is found through the normal mechanism,\n "__getattr__()" is not called. (This is an intentional asymmetry\n between "__getattr__()" and "__setattr__()".) This is done both for\n efficiency reasons and because otherwise "__getattr__()" would have\n no way to access other attributes of the instance. Note that at\n least for instance variables, you can fake total control by not\n inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n "__getattribute__()" method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines "__getattr__()",\n the latter will not be called unless "__getattribute__()" either\n calls it explicitly or raises an "AttributeError". This method\n should return the (computed) attribute value or raise an\n "AttributeError" exception. In order to avoid infinite recursion in\n this method, its implementation should always call the base class\n method with the same name to access any attributes it needs, for\n example, "object.__getattribute__(self, name)".\n\n Note: This method may still be bypassed when looking up special\n methods as the result of implicit invocation via language syntax\n or built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If "__setattr__()" wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n "object.__setattr__(self, name, value)".\n\nobject.__delattr__(self, name)\n\n Like "__setattr__()" but for attribute deletion instead of\n assignment. This should only be implemented if "del obj.name" is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when "dir()" is called on the object. A sequence must be\n returned. "dir()" converts the returned sequence to a list and\n sorts it.\n\n\nImplementing Descriptors\n------------------------\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in an\n*owner* class (the descriptor must be in either the owner\'s class\ndictionary or in the class dictionary for one of its parents). In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' "__dict__".\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or "None" when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an "AttributeError"\n exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\nThe attribute "__objclass__" is interpreted by the "inspect" module as\nspecifying the class where this object was defined (setting this\nappropriately can assist in runtime introspection of dynamic class\nattributes). For callables, it may indicate that an instance of the\ngiven type (or a subclass) is expected or required as the first\npositional argument (for example, CPython sets this attribute for\nunbound methods that are implemented in C).\n\n\nInvoking Descriptors\n--------------------\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: "__get__()", "__set__()", and\n"__delete__()". If any of those methods are defined for an object, it\nis said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, "a.x" has a\nlookup chain starting with "a.__dict__[\'x\']", then\n"type(a).__dict__[\'x\']", and continuing through the base classes of\n"type(a)" excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, "a.x". How\nthe arguments are assembled depends on "a":\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: "x.__get__(a)".\n\nInstance Binding\n If binding to an object instance, "a.x" is transformed into the\n call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n\nClass Binding\n If binding to a class, "A.x" is transformed into the call:\n "A.__dict__[\'x\'].__get__(None, A)".\n\nSuper Binding\n If "a" is an instance of "super", then the binding "super(B,\n obj).m()" searches "obj.__class__.__mro__" for the base class "A"\n immediately preceding "B" and then invokes the descriptor with the\n call: "A.__dict__[\'m\'].__get__(obj, obj.__class__)".\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of "__get__()", "__set__()" and "__delete__()". If it\ndoes not define "__get__()", then accessing the attribute will return\nthe descriptor object itself unless there is a value in the object\'s\ninstance dictionary. If the descriptor defines "__set__()" and/or\n"__delete__()", it is a data descriptor; if it defines neither, it is\na non-data descriptor. Normally, data descriptors define both\n"__get__()" and "__set__()", while non-data descriptors have just the\n"__get__()" method. Data descriptors with "__set__()" and "__get__()"\ndefined always override a redefinition in an instance dictionary. In\ncontrast, non-data descriptors can be overridden by instances.\n\nPython methods (including "staticmethod()" and "classmethod()") are\nimplemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe "property()" function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n---------\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. *__slots__*\n reserves space for the declared variables and prevents the\n automatic creation of *__dict__* and *__weakref__* for each\n instance.\n\n\nNotes on using *__slots__*\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises "AttributeError". If\n dynamic assignment of new variables is desired, then add\n "\'__dict__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes\n defining *__slots__* do not support weak references to its\n instances. If weak reference support is needed, then add\n "\'__weakref__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the\n instance variable defined by the base class slot is inaccessible\n (except by retrieving its descriptor directly from the base class).\n This renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as "int", "bytes" and "tuple".\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings\n may also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n\n\nCustomizing class creation\n==========================\n\nBy default, classes are constructed using "type()". The class body is\nexecuted in a new namespace and the class name is bound locally to the\nresult of "type(name, bases, namespace)".\n\nThe class creation process can be customised by passing the\n"metaclass" keyword argument in the class definition line, or by\ninheriting from an existing class that included such an argument. In\nthe following example, both "MyClass" and "MySubclass" are instances\nof "Meta":\n\n class Meta(type):\n pass\n\n class MyClass(metaclass=Meta):\n pass\n\n class MySubclass(MyClass):\n pass\n\nAny other keyword arguments that are specified in the class definition\nare passed through to all metaclass operations described below.\n\nWhen a class definition is executed, the following steps occur:\n\n* the appropriate metaclass is determined\n\n* the class namespace is prepared\n\n* the class body is executed\n\n* the class object is created\n\n\nDetermining the appropriate metaclass\n-------------------------------------\n\nThe appropriate metaclass for a class definition is determined as\nfollows:\n\n* if no bases and no explicit metaclass are given, then "type()" is\n used\n\n* if an explicit metaclass is given and it is *not* an instance of\n "type()", then it is used directly as the metaclass\n\n* if an instance of "type()" is given as the explicit metaclass, or\n bases are defined, then the most derived metaclass is used\n\nThe most derived metaclass is selected from the explicitly specified\nmetaclass (if any) and the metaclasses (i.e. "type(cls)") of all\nspecified base classes. The most derived metaclass is one which is a\nsubtype of *all* of these candidate metaclasses. If none of the\ncandidate metaclasses meets that criterion, then the class definition\nwill fail with "TypeError".\n\n\nPreparing the class namespace\n-----------------------------\n\nOnce the appropriate metaclass has been identified, then the class\nnamespace is prepared. If the metaclass has a "__prepare__" attribute,\nit is called as "namespace = metaclass.__prepare__(name, bases,\n**kwds)" (where the additional keyword arguments, if any, come from\nthe class definition).\n\nIf the metaclass has no "__prepare__" attribute, then the class\nnamespace is initialised as an empty "dict()" instance.\n\nSee also: **PEP 3115** - Metaclasses in Python 3000\n\n Introduced the "__prepare__" namespace hook\n\n\nExecuting the class body\n------------------------\n\nThe class body is executed (approximately) as "exec(body, globals(),\nnamespace)". The key difference from a normal call to "exec()" is that\nlexical scoping allows the class body (including any methods) to\nreference names from the current and outer scopes when the class\ndefinition occurs inside a function.\n\nHowever, even when the class definition occurs inside the function,\nmethods defined inside the class still cannot see names defined at the\nclass scope. Class variables must be accessed through the first\nparameter of instance or class methods, and cannot be accessed at all\nfrom static methods.\n\n\nCreating the class object\n-------------------------\n\nOnce the class namespace has been populated by executing the class\nbody, the class object is created by calling "metaclass(name, bases,\nnamespace, **kwds)" (the additional keywords passed here are the same\nas those passed to "__prepare__").\n\nThis class object is the one that will be referenced by the zero-\nargument form of "super()". "__class__" is an implicit closure\nreference created by the compiler if any methods in a class body refer\nto either "__class__" or "super". This allows the zero argument form\nof "super()" to correctly identify the class being defined based on\nlexical scoping, while the class or instance that was used to make the\ncurrent call is identified based on the first argument passed to the\nmethod.\n\nAfter the class object is created, it is passed to the class\ndecorators included in the class definition (if any) and the resulting\nobject is bound in the local namespace as the defined class.\n\nSee also: **PEP 3135** - New super\n\n Describes the implicit "__class__" closure reference\n\n\nMetaclass example\n-----------------\n\nThe potential uses for metaclasses are boundless. Some ideas that have\nbeen explored include logging, interface checking, automatic\ndelegation, automatic property creation, proxies, frameworks, and\nautomatic resource locking/synchronization.\n\nHere is an example of a metaclass that uses an\n"collections.OrderedDict" to remember the order that class variables\nare defined:\n\n class OrderedClass(type):\n\n @classmethod\n def __prepare__(metacls, name, bases, **kwds):\n return collections.OrderedDict()\n\n def __new__(cls, name, bases, namespace, **kwds):\n result = type.__new__(cls, name, bases, dict(namespace))\n result.members = tuple(namespace)\n return result\n\n class A(metaclass=OrderedClass):\n def one(self): pass\n def two(self): pass\n def three(self): pass\n def four(self): pass\n\n >>> A.members\n (\'__module__\', \'one\', \'two\', \'three\', \'four\')\n\nWhen the class definition for *A* gets executed, the process begins\nwith calling the metaclass\'s "__prepare__()" method which returns an\nempty "collections.OrderedDict". That mapping records the methods and\nattributes of *A* as they are defined within the body of the class\nstatement. Once those definitions are executed, the ordered dictionary\nis fully populated and the metaclass\'s "__new__()" method gets\ninvoked. That method builds the new type and it saves the ordered\ndictionary keys in an attribute called "members".\n\n\nCustomizing instance and subclass checks\n========================================\n\nThe following methods are used to override the default behavior of the\n"isinstance()" and "issubclass()" built-in functions.\n\nIn particular, the metaclass "abc.ABCMeta" implements these methods in\norder to allow the addition of Abstract Base Classes (ABCs) as\n"virtual base classes" to any class or type (including built-in\ntypes), including other ABCs.\n\nclass.__instancecheck__(self, instance)\n\n Return true if *instance* should be considered a (direct or\n indirect) instance of *class*. If defined, called to implement\n "isinstance(instance, class)".\n\nclass.__subclasscheck__(self, subclass)\n\n Return true if *subclass* should be considered a (direct or\n indirect) subclass of *class*. If defined, called to implement\n "issubclass(subclass, class)".\n\nNote that these methods are looked up on the type (metaclass) of a\nclass. They cannot be defined as class methods in the actual class.\nThis is consistent with the lookup of special methods that are called\non instances, only in this case the instance is itself a class.\n\nSee also: **PEP 3119** - Introducing Abstract Base Classes\n\n Includes the specification for customizing "isinstance()" and\n "issubclass()" behavior through "__instancecheck__()" and\n "__subclasscheck__()", with motivation for this functionality in\n the context of adding Abstract Base Classes (see the "abc"\n module) to the language.\n\n\nEmulating callable objects\n==========================\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, "x(arg1, arg2, ...)" is a shorthand for\n "x.__call__(arg1, arg2, ...)".\n\n\nEmulating container types\n=========================\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which "0 <= k < N" where\n*N* is the length of the sequence, or slice objects, which define a\nrange of items. It is also recommended that mappings provide the\nmethods "keys()", "values()", "items()", "get()", "clear()",\n"setdefault()", "pop()", "popitem()", "copy()", and "update()"\nbehaving similar to those for Python\'s standard dictionary objects.\nThe "collections" module provides a "MutableMapping" abstract base\nclass to help create those methods from a base set of "__getitem__()",\n"__setitem__()", "__delitem__()", and "keys()". Mutable sequences\nshould provide methods "append()", "count()", "index()", "extend()",\n"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python\nstandard list objects. Finally, sequence types should implement\naddition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods "__add__()", "__radd__()",\n"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described\nbelow; they should not define other numerical operators. It is\nrecommended that both mappings and sequences implement the\n"__contains__()" method to allow efficient use of the "in" operator;\nfor mappings, "in" should search the mapping\'s keys; for sequences, it\nshould search through the values. It is further recommended that both\nmappings and sequences implement the "__iter__()" method to allow\nefficient iteration through the container; for mappings, "__iter__()"\nshould be the same as "keys()"; for sequences, it should iterate\nthrough the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function "len()". Should return\n the length of the object, an integer ">=" 0. Also, an object that\n doesn\'t define a "__bool__()" method and whose "__len__()" method\n returns zero is considered to be false in a Boolean context.\n\nobject.__length_hint__(self)\n\n Called to implement "operator.length_hint()". Should return an\n estimated length for the object (which may be greater or less than\n the actual length). The length must be an integer ">=" 0. This\n method is purely an optimization and is never required for\n correctness.\n\n New in version 3.4.\n\nNote: Slicing is done exclusively with the following three methods.\n A call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with "None".\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of "self[key]". For sequence types,\n the accepted keys should be integers and slice objects. Note that\n the special interpretation of negative indexes (if the class wishes\n to emulate a sequence type) is up to the "__getitem__()" method. If\n *key* is of an inappropriate type, "TypeError" may be raised; if of\n a value outside the set of indexes for the sequence (after any\n special interpretation of negative values), "IndexError" should be\n raised. For mapping types, if *key* is missing (not in the\n container), "KeyError" should be raised.\n\n Note: "for" loops expect that an "IndexError" will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__missing__(self, key)\n\n Called by "dict"."__getitem__()" to implement "self[key]" for dict\n subclasses when key is not in the dictionary.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the "__getitem__()" method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the "__getitem__()" method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the "reversed()" built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the "__reversed__()" method is not provided, the "reversed()"\n built-in will fall back to using the sequence protocol ("__len__()"\n and "__getitem__()"). Objects that support the sequence protocol\n should only provide "__reversed__()" if they can provide an\n implementation that is more efficient than the one provided by\n "reversed()".\n\nThe membership test operators ("in" and "not in") are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don\'t define "__contains__()", the membership test\n first tries iteration via "__iter__()", then the old sequence\n iteration protocol via "__getitem__()", see *this section in the\n language reference*.\n\n\nEmulating numeric types\n=======================\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|"). For instance, to evaluate the\n expression "x + y", where *x* is an instance of a class that has an\n "__add__()" method, "x.__add__(y)" is called. The "__divmod__()"\n method should be the equivalent to using "__floordiv__()" and\n "__mod__()"; it should not be related to "__truediv__()". Note\n that "__pow__()" should be defined to accept an optional third\n argument if the ternary version of the built-in "pow()" function is\n to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return "NotImplemented".\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|") with reflected (swapped) operands.\n These functions are only called if the left operand does not\n support the corresponding operation and the operands are of\n different types. [2] For instance, to evaluate the expression "x -\n y", where *y* is an instance of a class that has an "__rsub__()"\n method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns\n *NotImplemented*.\n\n Note that ternary "pow()" will not try calling "__rpow__()" (the\n coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left\n operand\'s type and that subclass provides the reflected method\n for the operation, this method will be called before the left\n operand\'s non-reflected method. This behavior allows subclasses\n to override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments ("+=", "-=", "*=", "/=", "//=", "%=", "**=", "<<=",\n ">>=", "&=", "^=", "|="). These methods should attempt to do the\n operation in-place (modifying *self*) and return the result (which\n could be, but does not have to be, *self*). If a specific method\n is not defined, the augmented assignment falls back to the normal\n methods. For instance, if *x* is an instance of a class with an\n "__iadd__()" method, "x += y" is equivalent to "x = x.__iadd__(y)"\n . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are considered, as\n with the evaluation of "x + y". In certain situations, augmented\n assignment can result in unexpected errors (see *Why does\n a_tuple[i] += [\'item\'] raise an exception when the addition\n works?*), but this behavior is in fact part of the data model.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations ("-", "+",\n "abs()" and "~").\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions "complex()", "int()",\n "float()" and "round()". Should return a value of the appropriate\n type.\n\nobject.__index__(self)\n\n Called to implement "operator.index()", and whenever Python needs\n to losslessly convert the numeric object to an integer object (such\n as in slicing, or in the built-in "bin()", "hex()" and "oct()"\n functions). Presence of this method indicates that the numeric\n object is an integer type. Must return an integer.\n\n Note: In order to have a coherent integer type class, when\n "__index__()" is defined "__int__()" should also be defined, and\n both should return the same value.\n\n\nWith Statement Context Managers\n===============================\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a "with" statement. The context manager\nhandles the entry into, and the exit from, the desired runtime context\nfor the execution of the block of code. Context managers are normally\ninvoked using the "with" statement (described in section *The with\nstatement*), but can also be used by directly invoking their methods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The "with"\n statement will bind this method\'s return value to the target(s)\n specified in the "as" clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be "None".\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that "__exit__()" methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also: **PEP 0343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n\n\nSpecial method lookup\n=====================\n\nFor custom classes, implicit invocations of special methods are only\nguaranteed to work correctly if defined on an object\'s type, not in\nthe object\'s instance dictionary. That behaviour is the reason why\nthe following code raises an exception:\n\n >>> class C:\n ... pass\n ...\n >>> c = C()\n >>> c.__len__ = lambda: 5\n >>> len(c)\n Traceback (most recent call last):\n File "", line 1, in \n TypeError: object of type \'C\' has no len()\n\nThe rationale behind this behaviour lies with a number of special\nmethods such as "__hash__()" and "__repr__()" that are implemented by\nall objects, including type objects. If the implicit lookup of these\nmethods used the conventional lookup process, they would fail when\ninvoked on the type object itself:\n\n >>> 1 .__hash__() == hash(1)\n True\n >>> int.__hash__() == hash(int)\n Traceback (most recent call last):\n File "", line 1, in \n TypeError: descriptor \'__hash__\' of \'int\' object needs an argument\n\nIncorrectly attempting to invoke an unbound method of a class in this\nway is sometimes referred to as \'metaclass confusion\', and is avoided\nby bypassing the instance when looking up special methods:\n\n >>> type(1).__hash__(1) == hash(1)\n True\n >>> type(int).__hash__(int) == hash(int)\n True\n\nIn addition to bypassing any instance attributes in the interest of\ncorrectness, implicit special method lookup generally also bypasses\nthe "__getattribute__()" method even of the object\'s metaclass:\n\n >>> class Meta(type):\n ... def __getattribute__(*args):\n ... print("Metaclass getattribute invoked")\n ... return type.__getattribute__(*args)\n ...\n >>> class C(object, metaclass=Meta):\n ... def __len__(self):\n ... return 10\n ... def __getattribute__(*args):\n ... print("Class getattribute invoked")\n ... return object.__getattribute__(*args)\n ...\n >>> c = C()\n >>> c.__len__() # Explicit lookup via instance\n Class getattribute invoked\n 10\n >>> type(c).__len__(c) # Explicit lookup via type\n Metaclass getattribute invoked\n 10\n >>> len(c) # Implicit lookup\n 10\n\nBypassing the "__getattribute__()" machinery in this fashion provides\nsignificant scope for speed optimisations within the interpreter, at\nthe cost of some flexibility in the handling of special methods (the\nspecial method *must* be set on the class object itself in order to be\nconsistently invoked by the interpreter).\n\n-[ Footnotes ]-\n\n[1] It *is* possible in some cases to change an object\'s type,\n under certain controlled conditions. It generally isn\'t a good\n idea though, since it can lead to some very strange behaviour if\n it is handled incorrectly.\n\n[2] For operands of the same type, it is assumed that if the non-\n reflected method (such as "__add__()") fails the operation is not\n supported, which is why the reflected method is not called.\n', - 'string-methods': u'\nString Methods\n**************\n\nStrings implement all of the *common* sequence operations, along with\nthe additional methods described below.\n\nStrings also support two styles of string formatting, one providing a\nlarge degree of flexibility and customization (see "str.format()",\n*Format String Syntax* and *String Formatting*) and the other based on\nC "printf" style formatting that handles a narrower range of types and\nis slightly harder to use correctly, but is often faster for the cases\nit can handle (*printf-style String Formatting*).\n\nThe *Text Processing Services* section of the standard library covers\na number of other modules that provide various text related utilities\n(including regular expression support in the "re" module).\n\nstr.capitalize()\n\n Return a copy of the string with its first character capitalized\n and the rest lowercased.\n\nstr.casefold()\n\n Return a casefolded copy of the string. Casefolded strings may be\n used for caseless matching.\n\n Casefolding is similar to lowercasing but more aggressive because\n it is intended to remove all case distinctions in a string. For\n example, the German lowercase letter "\'\xdf\'" is equivalent to ""ss"".\n Since it is already lowercase, "lower()" would do nothing to "\'\xdf\'";\n "casefold()" converts it to ""ss"".\n\n The casefolding algorithm is described in section 3.13 of the\n Unicode Standard.\n\n New in version 3.3.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is an ASCII space). The\n original string is returned if *width* is less than or equal to\n "len(s)".\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n Return an encoded version of the string as a bytes object. Default\n encoding is "\'utf-8\'". *errors* may be given to set a different\n error handling scheme. The default for *errors* is "\'strict\'",\n meaning that encoding errors raise a "UnicodeError". Other possible\n values are "\'ignore\'", "\'replace\'", "\'xmlcharrefreplace\'",\n "\'backslashreplace\'" and any other name registered via\n "codecs.register_error()", see section *Error Handlers*. For a list\n of possible encodings, see section *Standard Encodings*.\n\n Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n Return "True" if the string ends with the specified *suffix*,\n otherwise return "False". *suffix* can also be a tuple of suffixes\n to look for. With optional *start*, test beginning at that\n position. With optional *end*, stop comparing at that position.\n\nstr.expandtabs(tabsize=8)\n\n Return a copy of the string where all tab characters are replaced\n by one or more spaces, depending on the current column and the\n given tab size. Tab positions occur every *tabsize* characters\n (default is 8, giving tab positions at columns 0, 8, 16 and so on).\n To expand the string, the current column is set to zero and the\n string is examined character by character. If the character is a\n tab ("\\t"), one or more space characters are inserted in the result\n until the current column is equal to the next tab position. (The\n tab character itself is not copied.) If the character is a newline\n ("\\n") or return ("\\r"), it is copied and the current column is\n reset to zero. Any other character is copied unchanged and the\n current column is incremented by one regardless of how the\n character is represented when printed.\n\n >>> \'01\\t012\\t0123\\t01234\'.expandtabs()\n \'01 012 0123 01234\'\n >>> \'01\\t012\\t0123\\t01234\'.expandtabs(4)\n \'01 012 0123 01234\'\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the slice "s[start:end]".\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return "-1" if *sub* is not found.\n\n Note: The "find()" method should be used only if you need to know\n the position of *sub*. To check if *sub* is a substring or not,\n use the "in" operator:\n\n >>> \'Py\' in \'Python\'\n True\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The string on which this\n method is called can contain literal text or replacement fields\n delimited by braces "{}". Each replacement field contains either\n the numeric index of a positional argument, or the name of a\n keyword argument. Returns a copy of the string where each\n replacement field is replaced with the string value of the\n corresponding argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n Similar to "str.format(**mapping)", except that "mapping" is used\n directly and not copied to a "dict". This is useful if for example\n "mapping" is a dict subclass:\n\n >>> class Default(dict):\n ... def __missing__(self, key):\n ... return key\n ...\n >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n \'Guido was born in country\'\n\n New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n Like "find()", but raise "ValueError" when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise. A character "c"\n is alphanumeric if one of the following returns "True":\n "c.isalpha()", "c.isdecimal()", "c.isdigit()", or "c.isnumeric()".\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise. Alphabetic\n characters are those characters defined in the Unicode character\n database as "Letter", i.e., those with general category property\n being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is\n different from the "Alphabetic" property defined in the Unicode\n Standard.\n\nstr.isdecimal()\n\n Return true if all characters in the string are decimal characters\n and there is at least one character, false otherwise. Decimal\n characters are those from general category "Nd". This category\n includes digit characters, and all characters that can be used to\n form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise. Digits include decimal\n characters and digits that need special handling, such as the\n compatibility superscript digits. Formally, a digit is a character\n that has the property value Numeric_Type=Digit or\n Numeric_Type=Decimal.\n\nstr.isidentifier()\n\n Return true if the string is a valid identifier according to the\n language definition, section *Identifiers and keywords*.\n\n Use "keyword.iskeyword()" to test for reserved identifiers such as\n "def" and "class".\n\nstr.islower()\n\n Return true if all cased characters [4] in the string are lowercase\n and there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n Return true if all characters in the string are numeric characters,\n and there is at least one character, false otherwise. Numeric\n characters include digit characters, and all characters that have\n the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n ONE FIFTH. Formally, numeric characters are those with the\n property value Numeric_Type=Digit, Numeric_Type=Decimal or\n Numeric_Type=Numeric.\n\nstr.isprintable()\n\n Return true if all characters in the string are printable or the\n string is empty, false otherwise. Nonprintable characters are\n those characters defined in the Unicode character database as\n "Other" or "Separator", excepting the ASCII space (0x20) which is\n considered printable. (Note that printable characters in this\n context are those which should not be escaped when "repr()" is\n invoked on a string. It has no bearing on the handling of strings\n written to "sys.stdout" or "sys.stderr".)\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise. Whitespace\n characters are those characters defined in the Unicode character\n database as "Other" or "Separator" and those with bidirectional\n property being one of "WS", "B", or "S".\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\nstr.isupper()\n\n Return true if all cased characters [4] in the string are uppercase\n and there is at least one cased character, false otherwise.\n\nstr.join(iterable)\n\n Return a string which is the concatenation of the strings in the\n *iterable* *iterable*. A "TypeError" will be raised if there are\n any non-string values in *iterable*, including "bytes" objects.\n The separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is an ASCII\n space). The original string is returned if *width* is less than or\n equal to "len(s)".\n\nstr.lower()\n\n Return a copy of the string with all the cased characters [4]\n converted to lowercase.\n\n The lowercasing algorithm used is described in section 3.13 of the\n Unicode Standard.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or "None", the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n This static method returns a translation table usable for\n "str.translate()".\n\n If there is only one argument, it must be a dictionary mapping\n Unicode ordinals (integers) or characters (strings of length 1) to\n Unicode ordinals, strings (of arbitrary lengths) or None.\n Character keys will then be converted to ordinals.\n\n If there are two arguments, they must be strings of equal length,\n and in the resulting dictionary, each character in x will be mapped\n to the character at the same position in y. If there is a third\n argument, it must be a string, whose characters will be mapped to\n None in the result.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within "s[start:end]".\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return "-1" on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like "rfind()" but raises "ValueError" when the substring *sub* is\n not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is an ASCII\n space). The original string is returned if *width* is less than or\n equal to "len(s)".\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\nstr.rsplit(sep=None, maxsplit=-1)\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n "None", any whitespace string is a separator. Except for splitting\n from the right, "rsplit()" behaves like "split()" which is\n described in detail below.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or "None", the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\nstr.split(sep=None, maxsplit=-1)\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most "maxsplit+1"\n elements). If *maxsplit* is not specified or "-1", then there is\n no limit on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n "\'1,,2\'.split(\',\')" returns "[\'1\', \'\', \'2\']"). The *sep* argument\n may consist of multiple characters (for example,\n "\'1<>2<>3\'.split(\'<>\')" returns "[\'1\', \'2\', \'3\']"). Splitting an\n empty string with a specified separator returns "[\'\']".\n\n For example:\n\n >>> \'1,2,3\'.split(\',\')\n [\'1\', \'2\', \'3\']\n >>> \'1,2,3\'.split(\',\', maxsplit=1)\n [\'1\', \'2,3\']\n >>> \'1,2,,3,\'.split(\',\')\n [\'1\', \'2\', \'\', \'3\', \'\']\n\n If *sep* is not specified or is "None", a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a "None" separator returns "[]".\n\n For example:\n\n >>> \'1 2 3\'.split()\n [\'1\', \'2\', \'3\']\n >>> \'1 2 3\'.split(maxsplit=1)\n [\'1\', \'2 3\']\n >>> \' 1 2 3 \'.split()\n [\'1\', \'2\', \'3\']\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. This method uses the *universal newlines* approach to\n splitting lines. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\n For example:\n\n >>> \'ab c\\n\\nde fg\\rkl\\r\\n\'.splitlines()\n [\'ab c\', \'\', \'de fg\', \'kl\']\n >>> \'ab c\\n\\nde fg\\rkl\\r\\n\'.splitlines(keepends=True)\n [\'ab c\\n\', \'\\n\', \'de fg\\r\', \'kl\\r\\n\']\n\n Unlike "split()" when a delimiter string *sep* is given, this\n method returns an empty list for the empty string, and a terminal\n line break does not result in an extra line:\n\n >>> "".splitlines()\n []\n >>> "One line\\n".splitlines()\n [\'One line\']\n\n For comparison, "split(\'\\n\')" gives:\n\n >>> \'\'.split(\'\\n\')\n [\'\']\n >>> \'Two lines\\n\'.split(\'\\n\')\n [\'Two lines\', \'\']\n\nstr.startswith(prefix[, start[, end]])\n\n Return "True" if string starts with the *prefix*, otherwise return\n "False". *prefix* can also be a tuple of prefixes to look for.\n With optional *start*, test string beginning at that position.\n With optional *end*, stop comparing string at that position.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or "None", the *chars*\n argument defaults to removing whitespace. The *chars* argument is\n not a prefix or suffix; rather, all combinations of its values are\n stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa. Note that it is not necessarily true that\n "s.swapcase().swapcase() == s".\n\nstr.title()\n\n Return a titlecased version of the string where words start with an\n uppercase character and the remaining characters are lowercase.\n\n For example:\n\n >>> \'Hello world\'.title()\n \'Hello World\'\n\n The algorithm uses a simple language-independent definition of a\n word as groups of consecutive letters. The definition works in\n many contexts but it means that apostrophes in contractions and\n possessives form word boundaries, which may not be the desired\n result:\n\n >>> "they\'re bill\'s friends from the UK".title()\n "They\'Re Bill\'S Friends From The Uk"\n\n A workaround for apostrophes can be constructed using regular\n expressions:\n\n >>> import re\n >>> def titlecase(s):\n ... return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n ... lambda mo: mo.group(0)[0].upper() +\n ... mo.group(0)[1:].lower(),\n ... s)\n ...\n >>> titlecase("they\'re bill\'s friends.")\n "They\'re Bill\'s Friends."\n\nstr.translate(map)\n\n Return a copy of the *s* where all characters have been mapped\n through the *map* which must be a dictionary of Unicode ordinals\n (integers) to Unicode ordinals, strings or "None". Unmapped\n characters are left untouched. Characters mapped to "None" are\n deleted.\n\n You can use "str.maketrans()" to create a translation map from\n character-to-character mappings in different formats.\n\n Note: An even more flexible approach is to create a custom\n character mapping codec using the "codecs" module (see\n "encodings.cp1251" for an example).\n\nstr.upper()\n\n Return a copy of the string with all the cased characters [4]\n converted to uppercase. Note that "str.upper().isupper()" might be\n "False" if "s" contains uncased characters or if the Unicode\n category of the resulting character(s) is not "Lu" (Letter,\n uppercase), but e.g. "Lt" (Letter, titlecase).\n\n The uppercasing algorithm used is described in section 3.13 of the\n Unicode Standard.\n\nstr.zfill(width)\n\n Return a copy of the string left filled with ASCII "\'0\'" digits to\n make a string of length *width*. A leading sign prefix ("\'+\'"/"\'-\'"\n is handled by inserting the padding *after* the sign character\n rather than before. The original string is returned if *width* is\n less than or equal to "len(s)".\n\n For example:\n\n >>> "42".zfill(5)\n \'00042\'\n >>> "-42".zfill(5)\n \'-0042\'\n', + 'specialnames': u'\nSpecial method names\n********************\n\nA class can implement certain operations that are invoked by special\nsyntax (such as arithmetic operations or subscripting and slicing) by\ndefining methods with special names. This is Python\'s approach to\n*operator overloading*, allowing classes to define their own behavior\nwith respect to language operators. For instance, if a class defines\na method named "__getitem__()", and "x" is an instance of this class,\nthen "x[i]" is roughly equivalent to "type(x).__getitem__(x, i)".\nExcept where mentioned, attempts to execute an operation raise an\nexception when no appropriate method is defined (typically\n"AttributeError" or "TypeError").\n\nWhen implementing a class that emulates any built-in type, it is\nimportant that the emulation only be implemented to the degree that it\nmakes sense for the object being modelled. For example, some\nsequences may work well with retrieval of individual elements, but\nextracting a slice may not make sense. (One example of this is the\n"NodeList" interface in the W3C\'s Document Object Model.)\n\n\nBasic customization\n===================\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. "__new__()" is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of "__new__()" should be the new object instance (usually an\n instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s "__new__()" method using\n "super(currentclass, cls).__new__(cls[, ...])" with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If "__new__()" returns an instance of *cls*, then the new\n instance\'s "__init__()" method will be invoked like\n "__init__(self[, ...])", where *self* is the new instance and the\n remaining arguments are the same as were passed to "__new__()".\n\n If "__new__()" does not return an instance of *cls*, then the new\n instance\'s "__init__()" method will not be invoked.\n\n "__new__()" is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called after the instance has been created (by "__new__()"), but\n before it is returned to the caller. The arguments are those\n passed to the class constructor expression. If a base class has an\n "__init__()" method, the derived class\'s "__init__()" method, if\n any, must explicitly call it to ensure proper initialization of the\n base class part of the instance; for example:\n "BaseClass.__init__(self, [args...])".\n\n Because "__new__()" and "__init__()" work together in constructing\n objects ("__new__()" to create it, and "__init__()" to customise\n it), no non-"None" value may be returned by "__init__()"; doing so\n will cause a "TypeError" to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a "__del__()" method, the\n derived class\'s "__del__()" method, if any, must explicitly call it\n to ensure proper deletion of the base class part of the instance.\n Note that it is possible (though not recommended!) for the\n "__del__()" method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n "__del__()" methods are called for objects that still exist when\n the interpreter exits.\n\n Note: "del x" doesn\'t directly call "x.__del__()" --- the former\n decrements the reference count for "x" by one, and the latter is\n only called when "x"\'s reference count reaches zero. Some common\n situations that may prevent the reference count of an object from\n going to zero include: circular references between objects (e.g.,\n a doubly-linked list or a tree data structure with parent and\n child pointers); a reference to the object on the stack frame of\n a function that caught an exception (the traceback stored in\n "sys.exc_info()[2]" keeps the stack frame alive); or a reference\n to the object on the stack frame that raised an unhandled\n exception in interactive mode (the traceback stored in\n "sys.last_traceback" keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the second can be resolved by freeing the reference to the\n traceback object when it is no longer useful, and the third can\n be resolved by storing "None" in "sys.last_traceback". Circular\n references which are garbage are detected and cleaned up when the\n cyclic garbage collector is enabled (it\'s on by default). Refer\n to the documentation for the "gc" module for more information\n about this topic.\n\n Warning: Due to the precarious circumstances under which\n "__del__()" methods are invoked, exceptions that occur during\n their execution are ignored, and a warning is printed to\n "sys.stderr" instead. Also, when "__del__()" is invoked in\n response to a module being deleted (e.g., when execution of the\n program is done), other globals referenced by the "__del__()"\n method may already have been deleted or in the process of being\n torn down (e.g. the import machinery shutting down). For this\n reason, "__del__()" methods should do the absolute minimum needed\n to maintain external invariants. Starting with version 1.5,\n Python guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the "__del__()" method is called.\n\nobject.__repr__(self)\n\n Called by the "repr()" built-in function to compute the "official"\n string representation of an object. If at all possible, this\n should look like a valid Python expression that could be used to\n recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n "<...some useful description...>" should be returned. The return\n value must be a string object. If a class defines "__repr__()" but\n not "__str__()", then "__repr__()" is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by "str(object)" and the built-in functions "format()" and\n "print()" to compute the "informal" or nicely printable string\n representation of an object. The return value must be a *string*\n object.\n\n This method differs from "object.__repr__()" in that there is no\n expectation that "__str__()" return a valid Python expression: a\n more convenient or concise representation can be used.\n\n The default implementation defined by the built-in type "object"\n calls "object.__repr__()".\n\nobject.__bytes__(self)\n\n Called by "bytes()" to compute a byte-string representation of an\n object. This should return a "bytes" object.\n\nobject.__format__(self, format_spec)\n\n Called by the "format()" built-in function (and by extension, the\n "str.format()" method of class "str") to produce a "formatted"\n string representation of an object. The "format_spec" argument is a\n string that contains a description of the formatting options\n desired. The interpretation of the "format_spec" argument is up to\n the type implementing "__format__()", however most classes will\n either delegate formatting to one of the built-in types, or use a\n similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\n Changed in version 3.4: The __format__ method of "object" itself\n raises a "TypeError" if passed any non-empty string.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: "xy" calls\n "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n\n A rich comparison method may return the singleton "NotImplemented"\n if it does not implement the operation for a given pair of\n arguments. By convention, "False" and "True" are returned for a\n successful comparison. However, these methods can return any value,\n so if the comparison operator is used in a Boolean context (e.g.,\n in the condition of an "if" statement), Python will call "bool()"\n on the value to determine if the result is true or false.\n\n By default, "__ne__()" delegates to "__eq__()" and inverts the\n result unless it is "NotImplemented". There are no other implied\n relationships among the comparison operators, for example, the\n truth of "(x.__hash__".\n\n If a class that does not override "__eq__()" wishes to suppress\n hash support, it should include "__hash__ = None" in the class\n definition. A class which defines its own "__hash__()" that\n explicitly raises a "TypeError" would be incorrectly identified as\n hashable by an "isinstance(obj, collections.Hashable)" call.\n\n Note: By default, the "__hash__()" values of str, bytes and\n datetime objects are "salted" with an unpredictable random value.\n Although they remain constant within an individual Python\n process, they are not predictable between repeated invocations of\n Python.This is intended to provide protection against a denial-\n of-service caused by carefully-chosen inputs that exploit the\n worst case performance of a dict insertion, O(n^2) complexity.\n See http://www.ocert.org/advisories/ocert-2011-003.html for\n details.Changing hash values affects the iteration order of\n dicts, sets and other mappings. Python has never made guarantees\n about this ordering (and it typically varies between 32-bit and\n 64-bit builds).See also "PYTHONHASHSEED".\n\n Changed in version 3.3: Hash randomization is enabled by default.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n "bool()"; should return "False" or "True". When this method is not\n defined, "__len__()" is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither "__len__()" nor "__bool__()", all its instances are\n considered true.\n\n\nCustomizing attribute access\n============================\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of "x.name") for\nclass instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for "self"). "name" is the attribute name. This\n method should return the (computed) attribute value or raise an\n "AttributeError" exception.\n\n Note that if the attribute is found through the normal mechanism,\n "__getattr__()" is not called. (This is an intentional asymmetry\n between "__getattr__()" and "__setattr__()".) This is done both for\n efficiency reasons and because otherwise "__getattr__()" would have\n no way to access other attributes of the instance. Note that at\n least for instance variables, you can fake total control by not\n inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n "__getattribute__()" method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines "__getattr__()",\n the latter will not be called unless "__getattribute__()" either\n calls it explicitly or raises an "AttributeError". This method\n should return the (computed) attribute value or raise an\n "AttributeError" exception. In order to avoid infinite recursion in\n this method, its implementation should always call the base class\n method with the same name to access any attributes it needs, for\n example, "object.__getattribute__(self, name)".\n\n Note: This method may still be bypassed when looking up special\n methods as the result of implicit invocation via language syntax\n or built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If "__setattr__()" wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n "object.__setattr__(self, name, value)".\n\nobject.__delattr__(self, name)\n\n Like "__setattr__()" but for attribute deletion instead of\n assignment. This should only be implemented if "del obj.name" is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when "dir()" is called on the object. A sequence must be\n returned. "dir()" converts the returned sequence to a list and\n sorts it.\n\n\nImplementing Descriptors\n------------------------\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in an\n*owner* class (the descriptor must be in either the owner\'s class\ndictionary or in the class dictionary for one of its parents). In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' "__dict__".\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or "None" when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an "AttributeError"\n exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\nThe attribute "__objclass__" is interpreted by the "inspect" module as\nspecifying the class where this object was defined (setting this\nappropriately can assist in runtime introspection of dynamic class\nattributes). For callables, it may indicate that an instance of the\ngiven type (or a subclass) is expected or required as the first\npositional argument (for example, CPython sets this attribute for\nunbound methods that are implemented in C).\n\n\nInvoking Descriptors\n--------------------\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: "__get__()", "__set__()", and\n"__delete__()". If any of those methods are defined for an object, it\nis said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, "a.x" has a\nlookup chain starting with "a.__dict__[\'x\']", then\n"type(a).__dict__[\'x\']", and continuing through the base classes of\n"type(a)" excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, "a.x". How\nthe arguments are assembled depends on "a":\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: "x.__get__(a)".\n\nInstance Binding\n If binding to an object instance, "a.x" is transformed into the\n call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n\nClass Binding\n If binding to a class, "A.x" is transformed into the call:\n "A.__dict__[\'x\'].__get__(None, A)".\n\nSuper Binding\n If "a" is an instance of "super", then the binding "super(B,\n obj).m()" searches "obj.__class__.__mro__" for the base class "A"\n immediately preceding "B" and then invokes the descriptor with the\n call: "A.__dict__[\'m\'].__get__(obj, obj.__class__)".\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of "__get__()", "__set__()" and "__delete__()". If it\ndoes not define "__get__()", then accessing the attribute will return\nthe descriptor object itself unless there is a value in the object\'s\ninstance dictionary. If the descriptor defines "__set__()" and/or\n"__delete__()", it is a data descriptor; if it defines neither, it is\na non-data descriptor. Normally, data descriptors define both\n"__get__()" and "__set__()", while non-data descriptors have just the\n"__get__()" method. Data descriptors with "__set__()" and "__get__()"\ndefined always override a redefinition in an instance dictionary. In\ncontrast, non-data descriptors can be overridden by instances.\n\nPython methods (including "staticmethod()" and "classmethod()") are\nimplemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe "property()" function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n---------\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. *__slots__*\n reserves space for the declared variables and prevents the\n automatic creation of *__dict__* and *__weakref__* for each\n instance.\n\n\nNotes on using *__slots__*\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises "AttributeError". If\n dynamic assignment of new variables is desired, then add\n "\'__dict__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes\n defining *__slots__* do not support weak references to its\n instances. If weak reference support is needed, then add\n "\'__weakref__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the\n instance variable defined by the base class slot is inaccessible\n (except by retrieving its descriptor directly from the base class).\n This renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as "int", "bytes" and "tuple".\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings\n may also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n\n\nCustomizing class creation\n==========================\n\nBy default, classes are constructed using "type()". The class body is\nexecuted in a new namespace and the class name is bound locally to the\nresult of "type(name, bases, namespace)".\n\nThe class creation process can be customised by passing the\n"metaclass" keyword argument in the class definition line, or by\ninheriting from an existing class that included such an argument. In\nthe following example, both "MyClass" and "MySubclass" are instances\nof "Meta":\n\n class Meta(type):\n pass\n\n class MyClass(metaclass=Meta):\n pass\n\n class MySubclass(MyClass):\n pass\n\nAny other keyword arguments that are specified in the class definition\nare passed through to all metaclass operations described below.\n\nWhen a class definition is executed, the following steps occur:\n\n* the appropriate metaclass is determined\n\n* the class namespace is prepared\n\n* the class body is executed\n\n* the class object is created\n\n\nDetermining the appropriate metaclass\n-------------------------------------\n\nThe appropriate metaclass for a class definition is determined as\nfollows:\n\n* if no bases and no explicit metaclass are given, then "type()" is\n used\n\n* if an explicit metaclass is given and it is *not* an instance of\n "type()", then it is used directly as the metaclass\n\n* if an instance of "type()" is given as the explicit metaclass, or\n bases are defined, then the most derived metaclass is used\n\nThe most derived metaclass is selected from the explicitly specified\nmetaclass (if any) and the metaclasses (i.e. "type(cls)") of all\nspecified base classes. The most derived metaclass is one which is a\nsubtype of *all* of these candidate metaclasses. If none of the\ncandidate metaclasses meets that criterion, then the class definition\nwill fail with "TypeError".\n\n\nPreparing the class namespace\n-----------------------------\n\nOnce the appropriate metaclass has been identified, then the class\nnamespace is prepared. If the metaclass has a "__prepare__" attribute,\nit is called as "namespace = metaclass.__prepare__(name, bases,\n**kwds)" (where the additional keyword arguments, if any, come from\nthe class definition).\n\nIf the metaclass has no "__prepare__" attribute, then the class\nnamespace is initialised as an empty "dict()" instance.\n\nSee also: **PEP 3115** - Metaclasses in Python 3000\n\n Introduced the "__prepare__" namespace hook\n\n\nExecuting the class body\n------------------------\n\nThe class body is executed (approximately) as "exec(body, globals(),\nnamespace)". The key difference from a normal call to "exec()" is that\nlexical scoping allows the class body (including any methods) to\nreference names from the current and outer scopes when the class\ndefinition occurs inside a function.\n\nHowever, even when the class definition occurs inside the function,\nmethods defined inside the class still cannot see names defined at the\nclass scope. Class variables must be accessed through the first\nparameter of instance or class methods, and cannot be accessed at all\nfrom static methods.\n\n\nCreating the class object\n-------------------------\n\nOnce the class namespace has been populated by executing the class\nbody, the class object is created by calling "metaclass(name, bases,\nnamespace, **kwds)" (the additional keywords passed here are the same\nas those passed to "__prepare__").\n\nThis class object is the one that will be referenced by the zero-\nargument form of "super()". "__class__" is an implicit closure\nreference created by the compiler if any methods in a class body refer\nto either "__class__" or "super". This allows the zero argument form\nof "super()" to correctly identify the class being defined based on\nlexical scoping, while the class or instance that was used to make the\ncurrent call is identified based on the first argument passed to the\nmethod.\n\nAfter the class object is created, it is passed to the class\ndecorators included in the class definition (if any) and the resulting\nobject is bound in the local namespace as the defined class.\n\nSee also: **PEP 3135** - New super\n\n Describes the implicit "__class__" closure reference\n\n\nMetaclass example\n-----------------\n\nThe potential uses for metaclasses are boundless. Some ideas that have\nbeen explored include logging, interface checking, automatic\ndelegation, automatic property creation, proxies, frameworks, and\nautomatic resource locking/synchronization.\n\nHere is an example of a metaclass that uses an\n"collections.OrderedDict" to remember the order that class variables\nare defined:\n\n class OrderedClass(type):\n\n @classmethod\n def __prepare__(metacls, name, bases, **kwds):\n return collections.OrderedDict()\n\n def __new__(cls, name, bases, namespace, **kwds):\n result = type.__new__(cls, name, bases, dict(namespace))\n result.members = tuple(namespace)\n return result\n\n class A(metaclass=OrderedClass):\n def one(self): pass\n def two(self): pass\n def three(self): pass\n def four(self): pass\n\n >>> A.members\n (\'__module__\', \'one\', \'two\', \'three\', \'four\')\n\nWhen the class definition for *A* gets executed, the process begins\nwith calling the metaclass\'s "__prepare__()" method which returns an\nempty "collections.OrderedDict". That mapping records the methods and\nattributes of *A* as they are defined within the body of the class\nstatement. Once those definitions are executed, the ordered dictionary\nis fully populated and the metaclass\'s "__new__()" method gets\ninvoked. That method builds the new type and it saves the ordered\ndictionary keys in an attribute called "members".\n\n\nCustomizing instance and subclass checks\n========================================\n\nThe following methods are used to override the default behavior of the\n"isinstance()" and "issubclass()" built-in functions.\n\nIn particular, the metaclass "abc.ABCMeta" implements these methods in\norder to allow the addition of Abstract Base Classes (ABCs) as\n"virtual base classes" to any class or type (including built-in\ntypes), including other ABCs.\n\nclass.__instancecheck__(self, instance)\n\n Return true if *instance* should be considered a (direct or\n indirect) instance of *class*. If defined, called to implement\n "isinstance(instance, class)".\n\nclass.__subclasscheck__(self, subclass)\n\n Return true if *subclass* should be considered a (direct or\n indirect) subclass of *class*. If defined, called to implement\n "issubclass(subclass, class)".\n\nNote that these methods are looked up on the type (metaclass) of a\nclass. They cannot be defined as class methods in the actual class.\nThis is consistent with the lookup of special methods that are called\non instances, only in this case the instance is itself a class.\n\nSee also: **PEP 3119** - Introducing Abstract Base Classes\n\n Includes the specification for customizing "isinstance()" and\n "issubclass()" behavior through "__instancecheck__()" and\n "__subclasscheck__()", with motivation for this functionality in\n the context of adding Abstract Base Classes (see the "abc"\n module) to the language.\n\n\nEmulating callable objects\n==========================\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, "x(arg1, arg2, ...)" is a shorthand for\n "x.__call__(arg1, arg2, ...)".\n\n\nEmulating container types\n=========================\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which "0 <= k < N" where\n*N* is the length of the sequence, or slice objects, which define a\nrange of items. It is also recommended that mappings provide the\nmethods "keys()", "values()", "items()", "get()", "clear()",\n"setdefault()", "pop()", "popitem()", "copy()", and "update()"\nbehaving similar to those for Python\'s standard dictionary objects.\nThe "collections" module provides a "MutableMapping" abstract base\nclass to help create those methods from a base set of "__getitem__()",\n"__setitem__()", "__delitem__()", and "keys()". Mutable sequences\nshould provide methods "append()", "count()", "index()", "extend()",\n"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python\nstandard list objects. Finally, sequence types should implement\naddition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods "__add__()", "__radd__()",\n"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described\nbelow; they should not define other numerical operators. It is\nrecommended that both mappings and sequences implement the\n"__contains__()" method to allow efficient use of the "in" operator;\nfor mappings, "in" should search the mapping\'s keys; for sequences, it\nshould search through the values. It is further recommended that both\nmappings and sequences implement the "__iter__()" method to allow\nefficient iteration through the container; for mappings, "__iter__()"\nshould be the same as "keys()"; for sequences, it should iterate\nthrough the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function "len()". Should return\n the length of the object, an integer ">=" 0. Also, an object that\n doesn\'t define a "__bool__()" method and whose "__len__()" method\n returns zero is considered to be false in a Boolean context.\n\nobject.__length_hint__(self)\n\n Called to implement "operator.length_hint()". Should return an\n estimated length for the object (which may be greater or less than\n the actual length). The length must be an integer ">=" 0. This\n method is purely an optimization and is never required for\n correctness.\n\n New in version 3.4.\n\nNote: Slicing is done exclusively with the following three methods.\n A call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with "None".\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of "self[key]". For sequence types,\n the accepted keys should be integers and slice objects. Note that\n the special interpretation of negative indexes (if the class wishes\n to emulate a sequence type) is up to the "__getitem__()" method. If\n *key* is of an inappropriate type, "TypeError" may be raised; if of\n a value outside the set of indexes for the sequence (after any\n special interpretation of negative values), "IndexError" should be\n raised. For mapping types, if *key* is missing (not in the\n container), "KeyError" should be raised.\n\n Note: "for" loops expect that an "IndexError" will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__missing__(self, key)\n\n Called by "dict"."__getitem__()" to implement "self[key]" for dict\n subclasses when key is not in the dictionary.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the "__getitem__()" method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the "__getitem__()" method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the "reversed()" built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the "__reversed__()" method is not provided, the "reversed()"\n built-in will fall back to using the sequence protocol ("__len__()"\n and "__getitem__()"). Objects that support the sequence protocol\n should only provide "__reversed__()" if they can provide an\n implementation that is more efficient than the one provided by\n "reversed()".\n\nThe membership test operators ("in" and "not in") are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don\'t define "__contains__()", the membership test\n first tries iteration via "__iter__()", then the old sequence\n iteration protocol via "__getitem__()", see *this section in the\n language reference*.\n\n\nEmulating numeric types\n=======================\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|"). For instance, to evaluate the\n expression "x + y", where *x* is an instance of a class that has an\n "__add__()" method, "x.__add__(y)" is called. The "__divmod__()"\n method should be the equivalent to using "__floordiv__()" and\n "__mod__()"; it should not be related to "__truediv__()". Note\n that "__pow__()" should be defined to accept an optional third\n argument if the ternary version of the built-in "pow()" function is\n to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return "NotImplemented".\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "/", "//", "%", "divmod()", "pow()",\n "**", "<<", ">>", "&", "^", "|") with reflected (swapped) operands.\n These functions are only called if the left operand does not\n support the corresponding operation and the operands are of\n different types. [2] For instance, to evaluate the expression "x -\n y", where *y* is an instance of a class that has an "__rsub__()"\n method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns\n *NotImplemented*.\n\n Note that ternary "pow()" will not try calling "__rpow__()" (the\n coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left\n operand\'s type and that subclass provides the reflected method\n for the operation, this method will be called before the left\n operand\'s non-reflected method. This behavior allows subclasses\n to override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments ("+=", "-=", "*=", "/=", "//=", "%=", "**=", "<<=",\n ">>=", "&=", "^=", "|="). These methods should attempt to do the\n operation in-place (modifying *self*) and return the result (which\n could be, but does not have to be, *self*). If a specific method\n is not defined, the augmented assignment falls back to the normal\n methods. For instance, if *x* is an instance of a class with an\n "__iadd__()" method, "x += y" is equivalent to "x = x.__iadd__(y)"\n . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are considered, as\n with the evaluation of "x + y". In certain situations, augmented\n assignment can result in unexpected errors (see *Why does\n a_tuple[i] += [\'item\'] raise an exception when the addition\n works?*), but this behavior is in fact part of the data model.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations ("-", "+",\n "abs()" and "~").\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions "complex()", "int()",\n "float()" and "round()". Should return a value of the appropriate\n type.\n\nobject.__index__(self)\n\n Called to implement "operator.index()", and whenever Python needs\n to losslessly convert the numeric object to an integer object (such\n as in slicing, or in the built-in "bin()", "hex()" and "oct()"\n functions). Presence of this method indicates that the numeric\n object is an integer type. Must return an integer.\n\n Note: In order to have a coherent integer type class, when\n "__index__()" is defined "__int__()" should also be defined, and\n both should return the same value.\n\n\nWith Statement Context Managers\n===============================\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a "with" statement. The context manager\nhandles the entry into, and the exit from, the desired runtime context\nfor the execution of the block of code. Context managers are normally\ninvoked using the "with" statement (described in section *The with\nstatement*), but can also be used by directly invoking their methods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The "with"\n statement will bind this method\'s return value to the target(s)\n specified in the "as" clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be "None".\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that "__exit__()" methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also: **PEP 0343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n\n\nSpecial method lookup\n=====================\n\nFor custom classes, implicit invocations of special methods are only\nguaranteed to work correctly if defined on an object\'s type, not in\nthe object\'s instance dictionary. That behaviour is the reason why\nthe following code raises an exception:\n\n >>> class C:\n ... pass\n ...\n >>> c = C()\n >>> c.__len__ = lambda: 5\n >>> len(c)\n Traceback (most recent call last):\n File "", line 1, in \n TypeError: object of type \'C\' has no len()\n\nThe rationale behind this behaviour lies with a number of special\nmethods such as "__hash__()" and "__repr__()" that are implemented by\nall objects, including type objects. If the implicit lookup of these\nmethods used the conventional lookup process, they would fail when\ninvoked on the type object itself:\n\n >>> 1 .__hash__() == hash(1)\n True\n >>> int.__hash__() == hash(int)\n Traceback (most recent call last):\n File "", line 1, in \n TypeError: descriptor \'__hash__\' of \'int\' object needs an argument\n\nIncorrectly attempting to invoke an unbound method of a class in this\nway is sometimes referred to as \'metaclass confusion\', and is avoided\nby bypassing the instance when looking up special methods:\n\n >>> type(1).__hash__(1) == hash(1)\n True\n >>> type(int).__hash__(int) == hash(int)\n True\n\nIn addition to bypassing any instance attributes in the interest of\ncorrectness, implicit special method lookup generally also bypasses\nthe "__getattribute__()" method even of the object\'s metaclass:\n\n >>> class Meta(type):\n ... def __getattribute__(*args):\n ... print("Metaclass getattribute invoked")\n ... return type.__getattribute__(*args)\n ...\n >>> class C(object, metaclass=Meta):\n ... def __len__(self):\n ... return 10\n ... def __getattribute__(*args):\n ... print("Class getattribute invoked")\n ... return object.__getattribute__(*args)\n ...\n >>> c = C()\n >>> c.__len__() # Explicit lookup via instance\n Class getattribute invoked\n 10\n >>> type(c).__len__(c) # Explicit lookup via type\n Metaclass getattribute invoked\n 10\n >>> len(c) # Implicit lookup\n 10\n\nBypassing the "__getattribute__()" machinery in this fashion provides\nsignificant scope for speed optimisations within the interpreter, at\nthe cost of some flexibility in the handling of special methods (the\nspecial method *must* be set on the class object itself in order to be\nconsistently invoked by the interpreter).\n\n-[ Footnotes ]-\n\n[1] It *is* possible in some cases to change an object\'s type,\n under certain controlled conditions. It generally isn\'t a good\n idea though, since it can lead to some very strange behaviour if\n it is handled incorrectly.\n\n[2] For operands of the same type, it is assumed that if the non-\n reflected method (such as "__add__()") fails the operation is not\n supported, which is why the reflected method is not called.\n', + 'string-methods': u'\nString Methods\n**************\n\nStrings implement all of the *common* sequence operations, along with\nthe additional methods described below.\n\nStrings also support two styles of string formatting, one providing a\nlarge degree of flexibility and customization (see "str.format()",\n*Format String Syntax* and *String Formatting*) and the other based on\nC "printf" style formatting that handles a narrower range of types and\nis slightly harder to use correctly, but is often faster for the cases\nit can handle (*printf-style String Formatting*).\n\nThe *Text Processing Services* section of the standard library covers\na number of other modules that provide various text related utilities\n(including regular expression support in the "re" module).\n\nstr.capitalize()\n\n Return a copy of the string with its first character capitalized\n and the rest lowercased.\n\nstr.casefold()\n\n Return a casefolded copy of the string. Casefolded strings may be\n used for caseless matching.\n\n Casefolding is similar to lowercasing but more aggressive because\n it is intended to remove all case distinctions in a string. For\n example, the German lowercase letter "\'\xdf\'" is equivalent to ""ss"".\n Since it is already lowercase, "lower()" would do nothing to "\'\xdf\'";\n "casefold()" converts it to ""ss"".\n\n The casefolding algorithm is described in section 3.13 of the\n Unicode Standard.\n\n New in version 3.3.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is an ASCII space). The\n original string is returned if *width* is less than or equal to\n "len(s)".\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n Return an encoded version of the string as a bytes object. Default\n encoding is "\'utf-8\'". *errors* may be given to set a different\n error handling scheme. The default for *errors* is "\'strict\'",\n meaning that encoding errors raise a "UnicodeError". Other possible\n values are "\'ignore\'", "\'replace\'", "\'xmlcharrefreplace\'",\n "\'backslashreplace\'" and any other name registered via\n "codecs.register_error()", see section *Error Handlers*. For a list\n of possible encodings, see section *Standard Encodings*.\n\n Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n Return "True" if the string ends with the specified *suffix*,\n otherwise return "False". *suffix* can also be a tuple of suffixes\n to look for. With optional *start*, test beginning at that\n position. With optional *end*, stop comparing at that position.\n\nstr.expandtabs(tabsize=8)\n\n Return a copy of the string where all tab characters are replaced\n by one or more spaces, depending on the current column and the\n given tab size. Tab positions occur every *tabsize* characters\n (default is 8, giving tab positions at columns 0, 8, 16 and so on).\n To expand the string, the current column is set to zero and the\n string is examined character by character. If the character is a\n tab ("\\t"), one or more space characters are inserted in the result\n until the current column is equal to the next tab position. (The\n tab character itself is not copied.) If the character is a newline\n ("\\n") or return ("\\r"), it is copied and the current column is\n reset to zero. Any other character is copied unchanged and the\n current column is incremented by one regardless of how the\n character is represented when printed.\n\n >>> \'01\\t012\\t0123\\t01234\'.expandtabs()\n \'01 012 0123 01234\'\n >>> \'01\\t012\\t0123\\t01234\'.expandtabs(4)\n \'01 012 0123 01234\'\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the slice "s[start:end]".\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return "-1" if *sub* is not found.\n\n Note: The "find()" method should be used only if you need to know\n the position of *sub*. To check if *sub* is a substring or not,\n use the "in" operator:\n\n >>> \'Py\' in \'Python\'\n True\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The string on which this\n method is called can contain literal text or replacement fields\n delimited by braces "{}". Each replacement field contains either\n the numeric index of a positional argument, or the name of a\n keyword argument. Returns a copy of the string where each\n replacement field is replaced with the string value of the\n corresponding argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n Similar to "str.format(**mapping)", except that "mapping" is used\n directly and not copied to a "dict". This is useful if for example\n "mapping" is a dict subclass:\n\n >>> class Default(dict):\n ... def __missing__(self, key):\n ... return key\n ...\n >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n \'Guido was born in country\'\n\n New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n Like "find()", but raise "ValueError" when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise. A character "c"\n is alphanumeric if one of the following returns "True":\n "c.isalpha()", "c.isdecimal()", "c.isdigit()", or "c.isnumeric()".\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise. Alphabetic\n characters are those characters defined in the Unicode character\n database as "Letter", i.e., those with general category property\n being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is\n different from the "Alphabetic" property defined in the Unicode\n Standard.\n\nstr.isdecimal()\n\n Return true if all characters in the string are decimal characters\n and there is at least one character, false otherwise. Decimal\n characters are those from general category "Nd". This category\n includes digit characters, and all characters that can be used to\n form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise. Digits include decimal\n characters and digits that need special handling, such as the\n compatibility superscript digits. Formally, a digit is a character\n that has the property value Numeric_Type=Digit or\n Numeric_Type=Decimal.\n\nstr.isidentifier()\n\n Return true if the string is a valid identifier according to the\n language definition, section *Identifiers and keywords*.\n\n Use "keyword.iskeyword()" to test for reserved identifiers such as\n "def" and "class".\n\nstr.islower()\n\n Return true if all cased characters [4] in the string are lowercase\n and there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n Return true if all characters in the string are numeric characters,\n and there is at least one character, false otherwise. Numeric\n characters include digit characters, and all characters that have\n the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n ONE FIFTH. Formally, numeric characters are those with the\n property value Numeric_Type=Digit, Numeric_Type=Decimal or\n Numeric_Type=Numeric.\n\nstr.isprintable()\n\n Return true if all characters in the string are printable or the\n string is empty, false otherwise. Nonprintable characters are\n those characters defined in the Unicode character database as\n "Other" or "Separator", excepting the ASCII space (0x20) which is\n considered printable. (Note that printable characters in this\n context are those which should not be escaped when "repr()" is\n invoked on a string. It has no bearing on the handling of strings\n written to "sys.stdout" or "sys.stderr".)\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise. Whitespace\n characters are those characters defined in the Unicode character\n database as "Other" or "Separator" and those with bidirectional\n property being one of "WS", "B", or "S".\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\nstr.isupper()\n\n Return true if all cased characters [4] in the string are uppercase\n and there is at least one cased character, false otherwise.\n\nstr.join(iterable)\n\n Return a string which is the concatenation of the strings in the\n *iterable* *iterable*. A "TypeError" will be raised if there are\n any non-string values in *iterable*, including "bytes" objects.\n The separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is an ASCII\n space). The original string is returned if *width* is less than or\n equal to "len(s)".\n\nstr.lower()\n\n Return a copy of the string with all the cased characters [4]\n converted to lowercase.\n\n The lowercasing algorithm used is described in section 3.13 of the\n Unicode Standard.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or "None", the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n This static method returns a translation table usable for\n "str.translate()".\n\n If there is only one argument, it must be a dictionary mapping\n Unicode ordinals (integers) or characters (strings of length 1) to\n Unicode ordinals, strings (of arbitrary lengths) or None.\n Character keys will then be converted to ordinals.\n\n If there are two arguments, they must be strings of equal length,\n and in the resulting dictionary, each character in x will be mapped\n to the character at the same position in y. If there is a third\n argument, it must be a string, whose characters will be mapped to\n None in the result.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within "s[start:end]".\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return "-1" on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like "rfind()" but raises "ValueError" when the substring *sub* is\n not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is an ASCII\n space). The original string is returned if *width* is less than or\n equal to "len(s)".\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\nstr.rsplit(sep=None, maxsplit=-1)\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n "None", any whitespace string is a separator. Except for splitting\n from the right, "rsplit()" behaves like "split()" which is\n described in detail below.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or "None", the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\nstr.split(sep=None, maxsplit=-1)\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most "maxsplit+1"\n elements). If *maxsplit* is not specified or "-1", then there is\n no limit on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n "\'1,,2\'.split(\',\')" returns "[\'1\', \'\', \'2\']"). The *sep* argument\n may consist of multiple characters (for example,\n "\'1<>2<>3\'.split(\'<>\')" returns "[\'1\', \'2\', \'3\']"). Splitting an\n empty string with a specified separator returns "[\'\']".\n\n For example:\n\n >>> \'1,2,3\'.split(\',\')\n [\'1\', \'2\', \'3\']\n >>> \'1,2,3\'.split(\',\', maxsplit=1)\n [\'1\', \'2,3\']\n >>> \'1,2,,3,\'.split(\',\')\n [\'1\', \'2\', \'\', \'3\', \'\']\n\n If *sep* is not specified or is "None", a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a "None" separator returns "[]".\n\n For example:\n\n >>> \'1 2 3\'.split()\n [\'1\', \'2\', \'3\']\n >>> \'1 2 3\'.split(maxsplit=1)\n [\'1\', \'2 3\']\n >>> \' 1 2 3 \'.split()\n [\'1\', \'2\', \'3\']\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\n This method splits on the following line boundaries. In\n particular, the boundaries are a superset of *universal newlines*.\n\n +-------------------------+-------------------------------+\n | Representation | Description |\n +=========================+===============================+\n | "\\n" | Line Feed |\n +-------------------------+-------------------------------+\n | "\\r" | Carriage Return |\n +-------------------------+-------------------------------+\n | "\\r\\n" | Carriage Return + Line Feed |\n +-------------------------+-------------------------------+\n | "\\v" or "\\x0b" | Line Tabulation |\n +-------------------------+-------------------------------+\n | "\\f" or "\\x0c" | Form Feed |\n +-------------------------+-------------------------------+\n | "\\x1c" | File Separator |\n +-------------------------+-------------------------------+\n | "\\x1d" | Group Separator |\n +-------------------------+-------------------------------+\n | "\\x1e" | Record Separator |\n +-------------------------+-------------------------------+\n | "\\x85" | Next Line (C1 Control Code) |\n +-------------------------+-------------------------------+\n | "\\u2028" | Line Separator |\n +-------------------------+-------------------------------+\n | "\\u2029" | Paragraph Separator |\n +-------------------------+-------------------------------+\n\n Changed in version 3.2: "\\v" and "\\f" added to list of line\n boundaries.\n\n For example:\n\n >>> \'ab c\\n\\nde fg\\rkl\\r\\n\'.splitlines()\n [\'ab c\', \'\', \'de fg\', \'kl\']\n >>> \'ab c\\n\\nde fg\\rkl\\r\\n\'.splitlines(keepends=True)\n [\'ab c\\n\', \'\\n\', \'de fg\\r\', \'kl\\r\\n\']\n\n Unlike "split()" when a delimiter string *sep* is given, this\n method returns an empty list for the empty string, and a terminal\n line break does not result in an extra line:\n\n >>> "".splitlines()\n []\n >>> "One line\\n".splitlines()\n [\'One line\']\n\n For comparison, "split(\'\\n\')" gives:\n\n >>> \'\'.split(\'\\n\')\n [\'\']\n >>> \'Two lines\\n\'.split(\'\\n\')\n [\'Two lines\', \'\']\n\nstr.startswith(prefix[, start[, end]])\n\n Return "True" if string starts with the *prefix*, otherwise return\n "False". *prefix* can also be a tuple of prefixes to look for.\n With optional *start*, test string beginning at that position.\n With optional *end*, stop comparing string at that position.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or "None", the *chars*\n argument defaults to removing whitespace. The *chars* argument is\n not a prefix or suffix; rather, all combinations of its values are\n stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa. Note that it is not necessarily true that\n "s.swapcase().swapcase() == s".\n\nstr.title()\n\n Return a titlecased version of the string where words start with an\n uppercase character and the remaining characters are lowercase.\n\n For example:\n\n >>> \'Hello world\'.title()\n \'Hello World\'\n\n The algorithm uses a simple language-independent definition of a\n word as groups of consecutive letters. The definition works in\n many contexts but it means that apostrophes in contractions and\n possessives form word boundaries, which may not be the desired\n result:\n\n >>> "they\'re bill\'s friends from the UK".title()\n "They\'Re Bill\'S Friends From The Uk"\n\n A workaround for apostrophes can be constructed using regular\n expressions:\n\n >>> import re\n >>> def titlecase(s):\n ... return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n ... lambda mo: mo.group(0)[0].upper() +\n ... mo.group(0)[1:].lower(),\n ... s)\n ...\n >>> titlecase("they\'re bill\'s friends.")\n "They\'re Bill\'s Friends."\n\nstr.translate(table)\n\n Return a copy of the string in which each character has been mapped\n through the given translation table. The table must be an object\n that implements indexing via "__getitem__()", typically a *mapping*\n or *sequence*. When indexed by a Unicode ordinal (an integer), the\n table object can do any of the following: return a Unicode ordinal\n or a string, to map the character to one or more other characters;\n return "None", to delete the character from the return string; or\n raise a "LookupError" exception, to map the character to itself.\n\n You can use "str.maketrans()" to create a translation map from\n character-to-character mappings in different formats.\n\n See also the "codecs" module for a more flexible approach to custom\n character mappings.\n\nstr.upper()\n\n Return a copy of the string with all the cased characters [4]\n converted to uppercase. Note that "str.upper().isupper()" might be\n "False" if "s" contains uncased characters or if the Unicode\n category of the resulting character(s) is not "Lu" (Letter,\n uppercase), but e.g. "Lt" (Letter, titlecase).\n\n The uppercasing algorithm used is described in section 3.13 of the\n Unicode Standard.\n\nstr.zfill(width)\n\n Return a copy of the string left filled with ASCII "\'0\'" digits to\n make a string of length *width*. A leading sign prefix\n ("\'+\'"/"\'-\'") is handled by inserting the padding *after* the sign\n character rather than before. The original string is returned if\n *width* is less than or equal to "len(s)".\n\n For example:\n\n >>> "42".zfill(5)\n \'00042\'\n >>> "-42".zfill(5)\n \'-0042\'\n', 'strings': u'\nString and Bytes literals\n*************************\n\nString literals are described by the following lexical definitions:\n\n stringliteral ::= [stringprefix](shortstring | longstring)\n stringprefix ::= "r" | "u" | "R" | "U"\n shortstring ::= "\'" shortstringitem* "\'" | \'"\' shortstringitem* \'"\'\n longstring ::= "\'\'\'" longstringitem* "\'\'\'" | \'"""\' longstringitem* \'"""\'\n shortstringitem ::= shortstringchar | stringescapeseq\n longstringitem ::= longstringchar | stringescapeseq\n shortstringchar ::= \n longstringchar ::= \n stringescapeseq ::= "\\" \n\n bytesliteral ::= bytesprefix(shortbytes | longbytes)\n bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB"\n shortbytes ::= "\'" shortbytesitem* "\'" | \'"\' shortbytesitem* \'"\'\n longbytes ::= "\'\'\'" longbytesitem* "\'\'\'" | \'"""\' longbytesitem* \'"""\'\n shortbytesitem ::= shortbyteschar | bytesescapeseq\n longbytesitem ::= longbyteschar | bytesescapeseq\n shortbyteschar ::= \n longbyteschar ::= \n bytesescapeseq ::= "\\" \n\nOne syntactic restriction not indicated by these productions is that\nwhitespace is not allowed between the "stringprefix" or "bytesprefix"\nand the rest of the literal. The source character set is defined by\nthe encoding declaration; it is UTF-8 if no encoding declaration is\ngiven in the source file; see section *Encoding declarations*.\n\nIn plain English: Both types of literals can be enclosed in matching\nsingle quotes ("\'") or double quotes ("""). They can also be enclosed\nin matching groups of three single or double quotes (these are\ngenerally referred to as *triple-quoted strings*). The backslash\n("\\") character is used to escape characters that otherwise have a\nspecial meaning, such as newline, backslash itself, or the quote\ncharacter.\n\nBytes literals are always prefixed with "\'b\'" or "\'B\'"; they produce\nan instance of the "bytes" type instead of the "str" type. They may\nonly contain ASCII characters; bytes with a numeric value of 128 or\ngreater must be expressed with escapes.\n\nAs of Python 3.3 it is possible again to prefix string literals with a\n"u" prefix to simplify maintenance of dual 2.x and 3.x codebases.\n\nBoth string and bytes literals may optionally be prefixed with a\nletter "\'r\'" or "\'R\'"; such strings are called *raw strings* and treat\nbackslashes as literal characters. As a result, in string literals,\n"\'\\U\'" and "\'\\u\'" escapes in raw strings are not treated specially.\nGiven that Python 2.x\'s raw unicode literals behave differently than\nPython 3.x\'s the "\'ur\'" syntax is not supported.\n\nNew in version 3.3: The "\'rb\'" prefix of raw bytes literals has been\nadded as a synonym of "\'br\'".\n\nNew in version 3.3: Support for the unicode legacy literal\n("u\'value\'") was reintroduced to simplify the maintenance of dual\nPython 2.x and 3.x codebases. See **PEP 414** for more information.\n\nIn triple-quoted literals, unescaped newlines and quotes are allowed\n(and are retained), except that three unescaped quotes in a row\nterminate the literal. (A "quote" is the character used to open the\nliteral, i.e. either "\'" or """.)\n\nUnless an "\'r\'" or "\'R\'" prefix is present, escape sequences in string\nand bytes literals are interpreted according to rules similar to those\nused by Standard C. The recognized escape sequences are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| "\\newline" | Backslash and newline ignored | |\n+-------------------+-----------------------------------+---------+\n| "\\\\" | Backslash ("\\") | |\n+-------------------+-----------------------------------+---------+\n| "\\\'" | Single quote ("\'") | |\n+-------------------+-----------------------------------+---------+\n| "\\"" | Double quote (""") | |\n+-------------------+-----------------------------------+---------+\n| "\\a" | ASCII Bell (BEL) | |\n+-------------------+-----------------------------------+---------+\n| "\\b" | ASCII Backspace (BS) | |\n+-------------------+-----------------------------------+---------+\n| "\\f" | ASCII Formfeed (FF) | |\n+-------------------+-----------------------------------+---------+\n| "\\n" | ASCII Linefeed (LF) | |\n+-------------------+-----------------------------------+---------+\n| "\\r" | ASCII Carriage Return (CR) | |\n+-------------------+-----------------------------------+---------+\n| "\\t" | ASCII Horizontal Tab (TAB) | |\n+-------------------+-----------------------------------+---------+\n| "\\v" | ASCII Vertical Tab (VT) | |\n+-------------------+-----------------------------------+---------+\n| "\\ooo" | Character with octal value *ooo* | (1,3) |\n+-------------------+-----------------------------------+---------+\n| "\\xhh" | Character with hex value *hh* | (2,3) |\n+-------------------+-----------------------------------+---------+\n\nEscape sequences only recognized in string literals are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| "\\N{name}" | Character named *name* in the | (4) |\n| | Unicode database | |\n+-------------------+-----------------------------------+---------+\n| "\\uxxxx" | Character with 16-bit hex value | (5) |\n| | *xxxx* | |\n+-------------------+-----------------------------------+---------+\n| "\\Uxxxxxxxx" | Character with 32-bit hex value | (6) |\n| | *xxxxxxxx* | |\n+-------------------+-----------------------------------+---------+\n\nNotes:\n\n1. As in Standard C, up to three octal digits are accepted.\n\n2. Unlike in Standard C, exactly two hex digits are required.\n\n3. In a bytes literal, hexadecimal and octal escapes denote the\n byte with the given value. In a string literal, these escapes\n denote a Unicode character with the given value.\n\n4. Changed in version 3.3: Support for name aliases [1] has been\n added.\n\n5. Individual code units which form parts of a surrogate pair can\n be encoded using this escape sequence. Exactly four hex digits are\n required.\n\n6. Any Unicode character can be encoded this way. Exactly eight\n hex digits are required.\n\nUnlike Standard C, all unrecognized escape sequences are left in the\nstring unchanged, i.e., *the backslash is left in the result*. (This\nbehavior is useful when debugging: if an escape sequence is mistyped,\nthe resulting output is more easily recognized as broken.) It is also\nimportant to note that the escape sequences only recognized in string\nliterals fall into the category of unrecognized escapes for bytes\nliterals.\n\nEven in a raw literal, quotes can be escaped with a backslash, but the\nbackslash remains in the result; for example, "r"\\""" is a valid\nstring literal consisting of two characters: a backslash and a double\nquote; "r"\\"" is not a valid string literal (even a raw string cannot\nend in an odd number of backslashes). Specifically, *a raw literal\ncannot end in a single backslash* (since the backslash would escape\nthe following quote character). Note also that a single backslash\nfollowed by a newline is interpreted as those two characters as part\nof the literal, *not* as a line continuation.\n', 'subscriptions': u'\nSubscriptions\n*************\n\nA subscription selects an item of a sequence (string, tuple or list)\nor mapping (dictionary) object:\n\n subscription ::= primary "[" expression_list "]"\n\nThe primary must evaluate to an object that supports subscription\n(lists or dictionaries for example). User-defined objects can support\nsubscription by defining a "__getitem__()" method.\n\nFor built-in objects, there are two types of objects that support\nsubscription:\n\nIf the primary is a mapping, the expression list must evaluate to an\nobject whose value is one of the keys of the mapping, and the\nsubscription selects the value in the mapping that corresponds to that\nkey. (The expression list is a tuple except if it has exactly one\nitem.)\n\nIf the primary is a sequence, the expression (list) must evaluate to\nan integer or a slice (as discussed in the following section).\n\nThe formal syntax makes no special provision for negative indices in\nsequences; however, built-in sequences all provide a "__getitem__()"\nmethod that interprets negative indices by adding the length of the\nsequence to the index (so that "x[-1]" selects the last item of "x").\nThe resulting value must be a nonnegative integer less than the number\nof items in the sequence, and the subscription selects the item whose\nindex is that value (counting from zero). Since the support for\nnegative indices and slicing occurs in the object\'s "__getitem__()"\nmethod, subclasses overriding this method will need to explicitly add\nthat support.\n\nA string\'s items are characters. A character is not a separate data\ntype but a string of exactly one character.\n', 'truth': u'\nTruth Value Testing\n*******************\n\nAny object can be tested for truth value, for use in an "if" or\n"while" condition or as operand of the Boolean operations below. The\nfollowing values are considered false:\n\n* "None"\n\n* "False"\n\n* zero of any numeric type, for example, "0", "0.0", "0j".\n\n* any empty sequence, for example, "\'\'", "()", "[]".\n\n* any empty mapping, for example, "{}".\n\n* instances of user-defined classes, if the class defines a\n "__bool__()" or "__len__()" method, when that method returns the\n integer zero or "bool" value "False". [1]\n\nAll other values are considered true --- so objects of many types are\nalways true.\n\nOperations and built-in functions that have a Boolean result always\nreturn "0" or "False" for false and "1" or "True" for true, unless\notherwise stated. (Important exception: the Boolean operations "or"\nand "and" always return one of their operands.)\n', 'try': u'\nThe "try" statement\n*******************\n\nThe "try" statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" identifier]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe "except" clause(s) specify one or more exception handlers. When no\nexception occurs in the "try" clause, no exception handler is\nexecuted. When an exception occurs in the "try" suite, a search for an\nexception handler is started. This search inspects the except clauses\nin turn until one is found that matches the exception. An expression-\nless except clause, if present, must be last; it matches any\nexception. For an except clause with an expression, that expression\nis evaluated, and the clause matches the exception if the resulting\nobject is "compatible" with the exception. An object is compatible\nwith an exception if it is the class or a base class of the exception\nobject or a tuple containing an item compatible with the exception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire "try" statement raised\nthe exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the "as" keyword in that except clause, if\npresent, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using "as target", it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause. Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the "sys" module and can be accessed via\n"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the\nexception class, the exception instance and a traceback object (see\nsection *The standard type hierarchy*) identifying the point in the\nprogram where the exception occurred. "sys.exc_info()" values are\nrestored to their previous values (before the call) when returning\nfrom a function that handled an exception.\n\nThe optional "else" clause is executed if and when control flows off\nthe end of the "try" clause. [2] Exceptions in the "else" clause are\nnot handled by the preceding "except" clauses.\n\nIf "finally" is present, it specifies a \'cleanup\' handler. The "try"\nclause is executed, including any "except" and "else" clauses. If an\nexception occurs in any of the clauses and is not handled, the\nexception is temporarily saved. The "finally" clause is executed. If\nthere is a saved exception it is re-raised at the end of the "finally"\nclause. If the "finally" clause raises another exception, the saved\nexception is set as the context of the new exception. If the "finally"\nclause executes a "return" or "break" statement, the saved exception\nis discarded:\n\n >>> def f():\n ... try:\n ... 1/0\n ... finally:\n ... return 42\n ...\n >>> f()\n 42\n\nThe exception information is not available to the program during\nexecution of the "finally" clause.\n\nWhen a "return", "break" or "continue" statement is executed in the\n"try" suite of a "try"..."finally" statement, the "finally" clause is\nalso executed \'on the way out.\' A "continue" statement is illegal in\nthe "finally" clause. (The reason is a problem with the current\nimplementation --- this restriction may be lifted in the future).\n\nThe return value of a function is determined by the last "return"\nstatement executed. Since the "finally" clause always executes, a\n"return" statement executed in the "finally" clause will always be the\nlast one executed:\n\n >>> def foo():\n ... try:\n ... return \'try\'\n ... finally:\n ... return \'finally\'\n ...\n >>> foo()\n \'finally\'\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the "raise" statement to\ngenerate exceptions may be found in section *The raise statement*.\n', 'types': u'\nThe standard type hierarchy\n***************************\n\nBelow is a list of the types that are built into Python. Extension\nmodules (written in C, Java, or other languages, depending on the\nimplementation) can define additional types. Future versions of\nPython may add types to the type hierarchy (e.g., rational numbers,\nefficiently stored arrays of integers, etc.), although such additions\nwill often be provided via the standard library instead.\n\nSome of the type descriptions below contain a paragraph listing\n\'special attributes.\' These are attributes that provide access to the\nimplementation and are not intended for general use. Their definition\nmay change in the future.\n\nNone\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name "None". It\n is used to signify the absence of a value in many situations, e.g.,\n it is returned from functions that don\'t explicitly return\n anything. Its truth value is false.\n\nNotImplemented\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name\n "NotImplemented". Numeric methods and rich comparison methods\n should return this value if they do not implement the operation for\n the operands provided. (The interpreter will then try the\n reflected operation, or some other fallback, depending on the\n operator.) Its truth value is true.\n\n See *Implementing the arithmetic operations* for more details.\n\nEllipsis\n This type has a single value. There is a single object with this\n value. This object is accessed through the literal "..." or the\n built-in name "Ellipsis". Its truth value is true.\n\n"numbers.Number"\n These are created by numeric literals and returned as results by\n arithmetic operators and arithmetic built-in functions. Numeric\n objects are immutable; once created their value never changes.\n Python numbers are of course strongly related to mathematical\n numbers, but subject to the limitations of numerical representation\n in computers.\n\n Python distinguishes between integers, floating point numbers, and\n complex numbers:\n\n "numbers.Integral"\n These represent elements from the mathematical set of integers\n (positive and negative).\n\n There are two types of integers:\n\n Integers ("int")\n\n These represent numbers in an unlimited range, subject to\n available (virtual) memory only. For the purpose of shift\n and mask operations, a binary representation is assumed, and\n negative numbers are represented in a variant of 2\'s\n complement which gives the illusion of an infinite string of\n sign bits extending to the left.\n\n Booleans ("bool")\n These represent the truth values False and True. The two\n objects representing the values "False" and "True" are the\n only Boolean objects. The Boolean type is a subtype of the\n integer type, and Boolean values behave like the values 0 and\n 1, respectively, in almost all contexts, the exception being\n that when converted to a string, the strings ""False"" or\n ""True"" are returned, respectively.\n\n The rules for integer representation are intended to give the\n most meaningful interpretation of shift and mask operations\n involving negative integers.\n\n "numbers.Real" ("float")\n These represent machine-level double precision floating point\n numbers. You are at the mercy of the underlying machine\n architecture (and C or Java implementation) for the accepted\n range and handling of overflow. Python does not support single-\n precision floating point numbers; the savings in processor and\n memory usage that are usually the reason for using these are\n dwarfed by the overhead of using objects in Python, so there is\n no reason to complicate the language with two kinds of floating\n point numbers.\n\n "numbers.Complex" ("complex")\n These represent complex numbers as a pair of machine-level\n double precision floating point numbers. The same caveats apply\n as for floating point numbers. The real and imaginary parts of a\n complex number "z" can be retrieved through the read-only\n attributes "z.real" and "z.imag".\n\nSequences\n These represent finite ordered sets indexed by non-negative\n numbers. The built-in function "len()" returns the number of items\n of a sequence. When the length of a sequence is *n*, the index set\n contains the numbers 0, 1, ..., *n*-1. Item *i* of sequence *a* is\n selected by "a[i]".\n\n Sequences also support slicing: "a[i:j]" selects all items with\n index *k* such that *i* "<=" *k* "<" *j*. When used as an\n expression, a slice is a sequence of the same type. This implies\n that the index set is renumbered so that it starts at 0.\n\n Some sequences also support "extended slicing" with a third "step"\n parameter: "a[i:j:k]" selects all items of *a* with index *x* where\n "x = i + n*k", *n* ">=" "0" and *i* "<=" *x* "<" *j*.\n\n Sequences are distinguished according to their mutability:\n\n Immutable sequences\n An object of an immutable sequence type cannot change once it is\n created. (If the object contains references to other objects,\n these other objects may be mutable and may be changed; however,\n the collection of objects directly referenced by an immutable\n object cannot change.)\n\n The following types are immutable sequences:\n\n Strings\n A string is a sequence of values that represent Unicode code\n points. All the code points in the range "U+0000 - U+10FFFF"\n can be represented in a string. Python doesn\'t have a "char"\n type; instead, every code point in the string is represented\n as a string object with length "1". The built-in function\n "ord()" converts a code point from its string form to an\n integer in the range "0 - 10FFFF"; "chr()" converts an\n integer in the range "0 - 10FFFF" to the corresponding length\n "1" string object. "str.encode()" can be used to convert a\n "str" to "bytes" using the given text encoding, and\n "bytes.decode()" can be used to achieve the opposite.\n\n Tuples\n The items of a tuple are arbitrary Python objects. Tuples of\n two or more items are formed by comma-separated lists of\n expressions. A tuple of one item (a \'singleton\') can be\n formed by affixing a comma to an expression (an expression by\n itself does not create a tuple, since parentheses must be\n usable for grouping of expressions). An empty tuple can be\n formed by an empty pair of parentheses.\n\n Bytes\n A bytes object is an immutable array. The items are 8-bit\n bytes, represented by integers in the range 0 <= x < 256.\n Bytes literals (like "b\'abc\'") and the built-in function\n "bytes()" can be used to construct bytes objects. Also,\n bytes objects can be decoded to strings via the "decode()"\n method.\n\n Mutable sequences\n Mutable sequences can be changed after they are created. The\n subscription and slicing notations can be used as the target of\n assignment and "del" (delete) statements.\n\n There are currently two intrinsic mutable sequence types:\n\n Lists\n The items of a list are arbitrary Python objects. Lists are\n formed by placing a comma-separated list of expressions in\n square brackets. (Note that there are no special cases needed\n to form lists of length 0 or 1.)\n\n Byte Arrays\n A bytearray object is a mutable array. They are created by\n the built-in "bytearray()" constructor. Aside from being\n mutable (and hence unhashable), byte arrays otherwise provide\n the same interface and functionality as immutable bytes\n objects.\n\n The extension module "array" provides an additional example of a\n mutable sequence type, as does the "collections" module.\n\nSet types\n These represent unordered, finite sets of unique, immutable\n objects. As such, they cannot be indexed by any subscript. However,\n they can be iterated over, and the built-in function "len()"\n returns the number of items in a set. Common uses for sets are fast\n membership testing, removing duplicates from a sequence, and\n computing mathematical operations such as intersection, union,\n difference, and symmetric difference.\n\n For set elements, the same immutability rules apply as for\n dictionary keys. Note that numeric types obey the normal rules for\n numeric comparison: if two numbers compare equal (e.g., "1" and\n "1.0"), only one of them can be contained in a set.\n\n There are currently two intrinsic set types:\n\n Sets\n These represent a mutable set. They are created by the built-in\n "set()" constructor and can be modified afterwards by several\n methods, such as "add()".\n\n Frozen sets\n These represent an immutable set. They are created by the\n built-in "frozenset()" constructor. As a frozenset is immutable\n and *hashable*, it can be used again as an element of another\n set, or as a dictionary key.\n\nMappings\n These represent finite sets of objects indexed by arbitrary index\n sets. The subscript notation "a[k]" selects the item indexed by "k"\n from the mapping "a"; this can be used in expressions and as the\n target of assignments or "del" statements. The built-in function\n "len()" returns the number of items in a mapping.\n\n There is currently a single intrinsic mapping type:\n\n Dictionaries\n These represent finite sets of objects indexed by nearly\n arbitrary values. The only types of values not acceptable as\n keys are values containing lists or dictionaries or other\n mutable types that are compared by value rather than by object\n identity, the reason being that the efficient implementation of\n dictionaries requires a key\'s hash value to remain constant.\n Numeric types used for keys obey the normal rules for numeric\n comparison: if two numbers compare equal (e.g., "1" and "1.0")\n then they can be used interchangeably to index the same\n dictionary entry.\n\n Dictionaries are mutable; they can be created by the "{...}"\n notation (see section *Dictionary displays*).\n\n The extension modules "dbm.ndbm" and "dbm.gnu" provide\n additional examples of mapping types, as does the "collections"\n module.\n\nCallable types\n These are the types to which the function call operation (see\n section *Calls*) can be applied:\n\n User-defined functions\n A user-defined function object is created by a function\n definition (see section *Function definitions*). It should be\n called with an argument list containing the same number of items\n as the function\'s formal parameter list.\n\n Special attributes:\n\n +---------------------------+---------------------------------+-------------+\n | Attribute | Meaning | |\n +===========================+=================================+=============+\n | "__doc__" | The function\'s documentation | Writable |\n | | string, or "None" if | |\n | | unavailable; not inherited by | |\n | | subclasses | |\n +---------------------------+---------------------------------+-------------+\n | "__name__" | The function\'s name | Writable |\n +---------------------------+---------------------------------+-------------+\n | "__qualname__" | The function\'s *qualified name* | Writable |\n | | New in version 3.3. | |\n +---------------------------+---------------------------------+-------------+\n | "__module__" | The name of the module the | Writable |\n | | function was defined in, or | |\n | | "None" if unavailable. | |\n +---------------------------+---------------------------------+-------------+\n | "__defaults__" | A tuple containing default | Writable |\n | | argument values for those | |\n | | arguments that have defaults, | |\n | | or "None" if no arguments have | |\n | | a default value | |\n +---------------------------+---------------------------------+-------------+\n | "__code__" | The code object representing | Writable |\n | | the compiled function body. | |\n +---------------------------+---------------------------------+-------------+\n | "__globals__" | A reference to the dictionary | Read-only |\n | | that holds the function\'s | |\n | | global variables --- the global | |\n | | namespace of the module in | |\n | | which the function was defined. | |\n +---------------------------+---------------------------------+-------------+\n | "__dict__" | The namespace supporting | Writable |\n | | arbitrary function attributes. | |\n +---------------------------+---------------------------------+-------------+\n | "__closure__" | "None" or a tuple of cells that | Read-only |\n | | contain bindings for the | |\n | | function\'s free variables. | |\n +---------------------------+---------------------------------+-------------+\n | "__annotations__" | A dict containing annotations | Writable |\n | | of parameters. The keys of the | |\n | | dict are the parameter names, | |\n | | and "\'return\'" for the return | |\n | | annotation, if provided. | |\n +---------------------------+---------------------------------+-------------+\n | "__kwdefaults__" | A dict containing defaults for | Writable |\n | | keyword-only parameters. | |\n +---------------------------+---------------------------------+-------------+\n\n Most of the attributes labelled "Writable" check the type of the\n assigned value.\n\n Function objects also support getting and setting arbitrary\n attributes, which can be used, for example, to attach metadata\n to functions. Regular attribute dot-notation is used to get and\n set such attributes. *Note that the current implementation only\n supports function attributes on user-defined functions. Function\n attributes on built-in functions may be supported in the\n future.*\n\n Additional information about a function\'s definition can be\n retrieved from its code object; see the description of internal\n types below.\n\n Instance methods\n An instance method object combines a class, a class instance and\n any callable object (normally a user-defined function).\n\n Special read-only attributes: "__self__" is the class instance\n object, "__func__" is the function object; "__doc__" is the\n method\'s documentation (same as "__func__.__doc__"); "__name__"\n is the method name (same as "__func__.__name__"); "__module__"\n is the name of the module the method was defined in, or "None"\n if unavailable.\n\n Methods also support accessing (but not setting) the arbitrary\n function attributes on the underlying function object.\n\n User-defined method objects may be created when getting an\n attribute of a class (perhaps via an instance of that class), if\n that attribute is a user-defined function object or a class\n method object.\n\n When an instance method object is created by retrieving a user-\n defined function object from a class via one of its instances,\n its "__self__" attribute is the instance, and the method object\n is said to be bound. The new method\'s "__func__" attribute is\n the original function object.\n\n When a user-defined method object is created by retrieving\n another method object from a class or instance, the behaviour is\n the same as for a function object, except that the "__func__"\n attribute of the new instance is not the original method object\n but its "__func__" attribute.\n\n When an instance method object is created by retrieving a class\n method object from a class or instance, its "__self__" attribute\n is the class itself, and its "__func__" attribute is the\n function object underlying the class method.\n\n When an instance method object is called, the underlying\n function ("__func__") is called, inserting the class instance\n ("__self__") in front of the argument list. For instance, when\n "C" is a class which contains a definition for a function "f()",\n and "x" is an instance of "C", calling "x.f(1)" is equivalent to\n calling "C.f(x, 1)".\n\n When an instance method object is derived from a class method\n object, the "class instance" stored in "__self__" will actually\n be the class itself, so that calling either "x.f(1)" or "C.f(1)"\n is equivalent to calling "f(C,1)" where "f" is the underlying\n function.\n\n Note that the transformation from function object to instance\n method object happens each time the attribute is retrieved from\n the instance. In some cases, a fruitful optimization is to\n assign the attribute to a local variable and call that local\n variable. Also notice that this transformation only happens for\n user-defined functions; other callable objects (and all non-\n callable objects) are retrieved without transformation. It is\n also important to note that user-defined functions which are\n attributes of a class instance are not converted to bound\n methods; this *only* happens when the function is an attribute\n of the class.\n\n Generator functions\n A function or method which uses the "yield" statement (see\n section *The yield statement*) is called a *generator function*.\n Such a function, when called, always returns an iterator object\n which can be used to execute the body of the function: calling\n the iterator\'s "iterator.__next__()" method will cause the\n function to execute until it provides a value using the "yield"\n statement. When the function executes a "return" statement or\n falls off the end, a "StopIteration" exception is raised and the\n iterator will have reached the end of the set of values to be\n returned.\n\n Built-in functions\n A built-in function object is a wrapper around a C function.\n Examples of built-in functions are "len()" and "math.sin()"\n ("math" is a standard built-in module). The number and type of\n the arguments are determined by the C function. Special read-\n only attributes: "__doc__" is the function\'s documentation\n string, or "None" if unavailable; "__name__" is the function\'s\n name; "__self__" is set to "None" (but see the next item);\n "__module__" is the name of the module the function was defined\n in or "None" if unavailable.\n\n Built-in methods\n This is really a different disguise of a built-in function, this\n time containing an object passed to the C function as an\n implicit extra argument. An example of a built-in method is\n "alist.append()", assuming *alist* is a list object. In this\n case, the special read-only attribute "__self__" is set to the\n object denoted by *alist*.\n\n Classes\n Classes are callable. These objects normally act as factories\n for new instances of themselves, but variations are possible for\n class types that override "__new__()". The arguments of the\n call are passed to "__new__()" and, in the typical case, to\n "__init__()" to initialize the new instance.\n\n Class Instances\n Instances of arbitrary classes can be made callable by defining\n a "__call__()" method in their class.\n\nModules\n Modules are a basic organizational unit of Python code, and are\n created by the *import system* as invoked either by the "import"\n statement (see "import"), or by calling functions such as\n "importlib.import_module()" and built-in "__import__()". A module\n object has a namespace implemented by a dictionary object (this is\n the dictionary referenced by the "__globals__" attribute of\n functions defined in the module). Attribute references are\n translated to lookups in this dictionary, e.g., "m.x" is equivalent\n to "m.__dict__["x"]". A module object does not contain the code\n object used to initialize the module (since it isn\'t needed once\n the initialization is done).\n\n Attribute assignment updates the module\'s namespace dictionary,\n e.g., "m.x = 1" is equivalent to "m.__dict__["x"] = 1".\n\n Special read-only attribute: "__dict__" is the module\'s namespace\n as a dictionary object.\n\n **CPython implementation detail:** Because of the way CPython\n clears module dictionaries, the module dictionary will be cleared\n when the module falls out of scope even if the dictionary still has\n live references. To avoid this, copy the dictionary or keep the\n module around while using its dictionary directly.\n\n Predefined (writable) attributes: "__name__" is the module\'s name;\n "__doc__" is the module\'s documentation string, or "None" if\n unavailable; "__file__" is the pathname of the file from which the\n module was loaded, if it was loaded from a file. The "__file__"\n attribute may be missing for certain types of modules, such as C\n modules that are statically linked into the interpreter; for\n extension modules loaded dynamically from a shared library, it is\n the pathname of the shared library file.\n\nCustom classes\n Custom class types are typically created by class definitions (see\n section *Class definitions*). A class has a namespace implemented\n by a dictionary object. Class attribute references are translated\n to lookups in this dictionary, e.g., "C.x" is translated to\n "C.__dict__["x"]" (although there are a number of hooks which allow\n for other means of locating attributes). When the attribute name is\n not found there, the attribute search continues in the base\n classes. This search of the base classes uses the C3 method\n resolution order which behaves correctly even in the presence of\n \'diamond\' inheritance structures where there are multiple\n inheritance paths leading back to a common ancestor. Additional\n details on the C3 MRO used by Python can be found in the\n documentation accompanying the 2.3 release at\n https://www.python.org/download/releases/2.3/mro/.\n\n When a class attribute reference (for class "C", say) would yield a\n class method object, it is transformed into an instance method\n object whose "__self__" attributes is "C". When it would yield a\n static method object, it is transformed into the object wrapped by\n the static method object. See section *Implementing Descriptors*\n for another way in which attributes retrieved from a class may\n differ from those actually contained in its "__dict__".\n\n Class attribute assignments update the class\'s dictionary, never\n the dictionary of a base class.\n\n A class object can be called (see above) to yield a class instance\n (see below).\n\n Special attributes: "__name__" is the class name; "__module__" is\n the module name in which the class was defined; "__dict__" is the\n dictionary containing the class\'s namespace; "__bases__" is a tuple\n (possibly empty or a singleton) containing the base classes, in the\n order of their occurrence in the base class list; "__doc__" is the\n class\'s documentation string, or None if undefined.\n\nClass instances\n A class instance is created by calling a class object (see above).\n A class instance has a namespace implemented as a dictionary which\n is the first place in which attribute references are searched.\n When an attribute is not found there, and the instance\'s class has\n an attribute by that name, the search continues with the class\n attributes. If a class attribute is found that is a user-defined\n function object, it is transformed into an instance method object\n whose "__self__" attribute is the instance. Static method and\n class method objects are also transformed; see above under\n "Classes". See section *Implementing Descriptors* for another way\n in which attributes of a class retrieved via its instances may\n differ from the objects actually stored in the class\'s "__dict__".\n If no class attribute is found, and the object\'s class has a\n "__getattr__()" method, that is called to satisfy the lookup.\n\n Attribute assignments and deletions update the instance\'s\n dictionary, never a class\'s dictionary. If the class has a\n "__setattr__()" or "__delattr__()" method, this is called instead\n of updating the instance dictionary directly.\n\n Class instances can pretend to be numbers, sequences, or mappings\n if they have methods with certain special names. See section\n *Special method names*.\n\n Special attributes: "__dict__" is the attribute dictionary;\n "__class__" is the instance\'s class.\n\nI/O objects (also known as file objects)\n A *file object* represents an open file. Various shortcuts are\n available to create file objects: the "open()" built-in function,\n and also "os.popen()", "os.fdopen()", and the "makefile()" method\n of socket objects (and perhaps by other functions or methods\n provided by extension modules).\n\n The objects "sys.stdin", "sys.stdout" and "sys.stderr" are\n initialized to file objects corresponding to the interpreter\'s\n standard input, output and error streams; they are all open in text\n mode and therefore follow the interface defined by the\n "io.TextIOBase" abstract class.\n\nInternal types\n A few types used internally by the interpreter are exposed to the\n user. Their definitions may change with future versions of the\n interpreter, but they are mentioned here for completeness.\n\n Code objects\n Code objects represent *byte-compiled* executable Python code,\n or *bytecode*. The difference between a code object and a\n function object is that the function object contains an explicit\n reference to the function\'s globals (the module in which it was\n defined), while a code object contains no context; also the\n default argument values are stored in the function object, not\n in the code object (because they represent values calculated at\n run-time). Unlike function objects, code objects are immutable\n and contain no references (directly or indirectly) to mutable\n objects.\n\n Special read-only attributes: "co_name" gives the function name;\n "co_argcount" is the number of positional arguments (including\n arguments with default values); "co_nlocals" is the number of\n local variables used by the function (including arguments);\n "co_varnames" is a tuple containing the names of the local\n variables (starting with the argument names); "co_cellvars" is a\n tuple containing the names of local variables that are\n referenced by nested functions; "co_freevars" is a tuple\n containing the names of free variables; "co_code" is a string\n representing the sequence of bytecode instructions; "co_consts"\n is a tuple containing the literals used by the bytecode;\n "co_names" is a tuple containing the names used by the bytecode;\n "co_filename" is the filename from which the code was compiled;\n "co_firstlineno" is the first line number of the function;\n "co_lnotab" is a string encoding the mapping from bytecode\n offsets to line numbers (for details see the source code of the\n interpreter); "co_stacksize" is the required stack size\n (including local variables); "co_flags" is an integer encoding a\n number of flags for the interpreter.\n\n The following flag bits are defined for "co_flags": bit "0x04"\n is set if the function uses the "*arguments" syntax to accept an\n arbitrary number of positional arguments; bit "0x08" is set if\n the function uses the "**keywords" syntax to accept arbitrary\n keyword arguments; bit "0x20" is set if the function is a\n generator.\n\n Future feature declarations ("from __future__ import division")\n also use bits in "co_flags" to indicate whether a code object\n was compiled with a particular feature enabled: bit "0x2000" is\n set if the function was compiled with future division enabled;\n bits "0x10" and "0x1000" were used in earlier versions of\n Python.\n\n Other bits in "co_flags" are reserved for internal use.\n\n If a code object represents a function, the first item in\n "co_consts" is the documentation string of the function, or\n "None" if undefined.\n\n Frame objects\n Frame objects represent execution frames. They may occur in\n traceback objects (see below).\n\n Special read-only attributes: "f_back" is to the previous stack\n frame (towards the caller), or "None" if this is the bottom\n stack frame; "f_code" is the code object being executed in this\n frame; "f_locals" is the dictionary used to look up local\n variables; "f_globals" is used for global variables;\n "f_builtins" is used for built-in (intrinsic) names; "f_lasti"\n gives the precise instruction (this is an index into the\n bytecode string of the code object).\n\n Special writable attributes: "f_trace", if not "None", is a\n function called at the start of each source code line (this is\n used by the debugger); "f_lineno" is the current line number of\n the frame --- writing to this from within a trace function jumps\n to the given line (only for the bottom-most frame). A debugger\n can implement a Jump command (aka Set Next Statement) by writing\n to f_lineno.\n\n Frame objects support one method:\n\n frame.clear()\n\n This method clears all references to local variables held by\n the frame. Also, if the frame belonged to a generator, the\n generator is finalized. This helps break reference cycles\n involving frame objects (for example when catching an\n exception and storing its traceback for later use).\n\n "RuntimeError" is raised if the frame is currently executing.\n\n New in version 3.4.\n\n Traceback objects\n Traceback objects represent a stack trace of an exception. A\n traceback object is created when an exception occurs. When the\n search for an exception handler unwinds the execution stack, at\n each unwound level a traceback object is inserted in front of\n the current traceback. When an exception handler is entered,\n the stack trace is made available to the program. (See section\n *The try statement*.) It is accessible as the third item of the\n tuple returned by "sys.exc_info()". When the program contains no\n suitable handler, the stack trace is written (nicely formatted)\n to the standard error stream; if the interpreter is interactive,\n it is also made available to the user as "sys.last_traceback".\n\n Special read-only attributes: "tb_next" is the next level in the\n stack trace (towards the frame where the exception occurred), or\n "None" if there is no next level; "tb_frame" points to the\n execution frame of the current level; "tb_lineno" gives the line\n number where the exception occurred; "tb_lasti" indicates the\n precise instruction. The line number and last instruction in\n the traceback may differ from the line number of its frame\n object if the exception occurred in a "try" statement with no\n matching except clause or with a finally clause.\n\n Slice objects\n Slice objects are used to represent slices for "__getitem__()"\n methods. They are also created by the built-in "slice()"\n function.\n\n Special read-only attributes: "start" is the lower bound; "stop"\n is the upper bound; "step" is the step value; each is "None" if\n omitted. These attributes can have any type.\n\n Slice objects support one method:\n\n slice.indices(self, length)\n\n This method takes a single integer argument *length* and\n computes information about the slice that the slice object\n would describe if applied to a sequence of *length* items.\n It returns a tuple of three integers; respectively these are\n the *start* and *stop* indices and the *step* or stride\n length of the slice. Missing or out-of-bounds indices are\n handled in a manner consistent with regular slices.\n\n Static method objects\n Static method objects provide a way of defeating the\n transformation of function objects to method objects described\n above. A static method object is a wrapper around any other\n object, usually a user-defined method object. When a static\n method object is retrieved from a class or a class instance, the\n object actually returned is the wrapped object, which is not\n subject to any further transformation. Static method objects are\n not themselves callable, although the objects they wrap usually\n are. Static method objects are created by the built-in\n "staticmethod()" constructor.\n\n Class method objects\n A class method object, like a static method object, is a wrapper\n around another object that alters the way in which that object\n is retrieved from classes and class instances. The behaviour of\n class method objects upon such retrieval is described above,\n under "User-defined methods". Class method objects are created\n by the built-in "classmethod()" constructor.\n', 'typesfunctions': u'\nFunctions\n*********\n\nFunction objects are created by function definitions. The only\noperation on a function object is to call it: "func(argument-list)".\n\nThere are really two flavors of function objects: built-in functions\nand user-defined functions. Both support the same operation (to call\nthe function), but the implementation is different, hence the\ndifferent object types.\n\nSee *Function definitions* for more information.\n', - 'typesmapping': u'\nMapping Types --- "dict"\n************************\n\nA *mapping* object maps *hashable* values to arbitrary objects.\nMappings are mutable objects. There is currently only one standard\nmapping type, the *dictionary*. (For other containers see the built-\nin "list", "set", and "tuple" classes, and the "collections" module.)\n\nA dictionary\'s keys are *almost* arbitrary values. Values that are\nnot *hashable*, that is, values containing lists, dictionaries or\nother mutable types (that are compared by value rather than by object\nidentity) may not be used as keys. Numeric types used for keys obey\nthe normal rules for numeric comparison: if two numbers compare equal\n(such as "1" and "1.0") then they can be used interchangeably to index\nthe same dictionary entry. (Note however, that since computers store\nfloating-point numbers as approximations it is usually unwise to use\nthem as dictionary keys.)\n\nDictionaries can be created by placing a comma-separated list of "key:\nvalue" pairs within braces, for example: "{\'jack\': 4098, \'sjoerd\':\n4127}" or "{4098: \'jack\', 4127: \'sjoerd\'}", or by the "dict"\nconstructor.\n\nclass class dict(**kwarg)\nclass class dict(mapping, **kwarg)\nclass class dict(iterable, **kwarg)\n\n Return a new dictionary initialized from an optional positional\n argument and a possibly empty set of keyword arguments.\n\n If no positional argument is given, an empty dictionary is created.\n If a positional argument is given and it is a mapping object, a\n dictionary is created with the same key-value pairs as the mapping\n object. Otherwise, the positional argument must be an *iterable*\n object. Each item in the iterable must itself be an iterable with\n exactly two objects. The first object of each item becomes a key\n in the new dictionary, and the second object the corresponding\n value. If a key occurs more than once, the last value for that key\n becomes the corresponding value in the new dictionary.\n\n If keyword arguments are given, the keyword arguments and their\n values are added to the dictionary created from the positional\n argument. If a key being added is already present, the value from\n the keyword argument replaces the value from the positional\n argument.\n\n To illustrate, the following examples all return a dictionary equal\n to "{"one": 1, "two": 2, "three": 3}":\n\n >>> a = dict(one=1, two=2, three=3)\n >>> b = {\'one\': 1, \'two\': 2, \'three\': 3}\n >>> c = dict(zip([\'one\', \'two\', \'three\'], [1, 2, 3]))\n >>> d = dict([(\'two\', 2), (\'one\', 1), (\'three\', 3)])\n >>> e = dict({\'three\': 3, \'one\': 1, \'two\': 2})\n >>> a == b == c == d == e\n True\n\n Providing keyword arguments as in the first example only works for\n keys that are valid Python identifiers. Otherwise, any valid keys\n can be used.\n\n These are the operations that dictionaries support (and therefore,\n custom mapping types should support too):\n\n len(d)\n\n Return the number of items in the dictionary *d*.\n\n d[key]\n\n Return the item of *d* with key *key*. Raises a "KeyError" if\n *key* is not in the map.\n\n If a subclass of dict defines a method "__missing__()" and *key*\n is not present, the "d[key]" operation calls that method with\n the key *key* as argument. The "d[key]" operation then returns\n or raises whatever is returned or raised by the\n "__missing__(key)" call. No other operations or methods invoke\n "__missing__()". If "__missing__()" is not defined, "KeyError"\n is raised. "__missing__()" must be a method; it cannot be an\n instance variable:\n\n >>> class Counter(dict):\n ... def __missing__(self, key):\n ... return 0\n >>> c = Counter()\n >>> c[\'red\']\n 0\n >>> c[\'red\'] += 1\n >>> c[\'red\']\n 1\n\n The example above shows part of the implementation of\n "collections.Counter". A different "__missing__" method is used\n by "collections.defaultdict".\n\n d[key] = value\n\n Set "d[key]" to *value*.\n\n del d[key]\n\n Remove "d[key]" from *d*. Raises a "KeyError" if *key* is not\n in the map.\n\n key in d\n\n Return "True" if *d* has a key *key*, else "False".\n\n key not in d\n\n Equivalent to "not key in d".\n\n iter(d)\n\n Return an iterator over the keys of the dictionary. This is a\n shortcut for "iter(d.keys())".\n\n clear()\n\n Remove all items from the dictionary.\n\n copy()\n\n Return a shallow copy of the dictionary.\n\n classmethod fromkeys(seq[, value])\n\n Create a new dictionary with keys from *seq* and values set to\n *value*.\n\n "fromkeys()" is a class method that returns a new dictionary.\n *value* defaults to "None".\n\n get(key[, default])\n\n Return the value for *key* if *key* is in the dictionary, else\n *default*. If *default* is not given, it defaults to "None", so\n that this method never raises a "KeyError".\n\n items()\n\n Return a new view of the dictionary\'s items ("(key, value)"\n pairs). See the *documentation of view objects*.\n\n keys()\n\n Return a new view of the dictionary\'s keys. See the\n *documentation of view objects*.\n\n pop(key[, default])\n\n If *key* is in the dictionary, remove it and return its value,\n else return *default*. If *default* is not given and *key* is\n not in the dictionary, a "KeyError" is raised.\n\n popitem()\n\n Remove and return an arbitrary "(key, value)" pair from the\n dictionary.\n\n "popitem()" is useful to destructively iterate over a\n dictionary, as often used in set algorithms. If the dictionary\n is empty, calling "popitem()" raises a "KeyError".\n\n setdefault(key[, default])\n\n If *key* is in the dictionary, return its value. If not, insert\n *key* with a value of *default* and return *default*. *default*\n defaults to "None".\n\n update([other])\n\n Update the dictionary with the key/value pairs from *other*,\n overwriting existing keys. Return "None".\n\n "update()" accepts either another dictionary object or an\n iterable of key/value pairs (as tuples or other iterables of\n length two). If keyword arguments are specified, the dictionary\n is then updated with those key/value pairs: "d.update(red=1,\n blue=2)".\n\n values()\n\n Return a new view of the dictionary\'s values. See the\n *documentation of view objects*.\n\nSee also: "types.MappingProxyType" can be used to create a read-only\n view of a "dict".\n\n\nDictionary view objects\n=======================\n\nThe objects returned by "dict.keys()", "dict.values()" and\n"dict.items()" are *view objects*. They provide a dynamic view on the\ndictionary\'s entries, which means that when the dictionary changes,\nthe view reflects these changes.\n\nDictionary views can be iterated over to yield their respective data,\nand support membership tests:\n\nlen(dictview)\n\n Return the number of entries in the dictionary.\n\niter(dictview)\n\n Return an iterator over the keys, values or items (represented as\n tuples of "(key, value)") in the dictionary.\n\n Keys and values are iterated over in an arbitrary order which is\n non-random, varies across Python implementations, and depends on\n the dictionary\'s history of insertions and deletions. If keys,\n values and items views are iterated over with no intervening\n modifications to the dictionary, the order of items will directly\n correspond. This allows the creation of "(value, key)" pairs using\n "zip()": "pairs = zip(d.values(), d.keys())". Another way to\n create the same list is "pairs = [(v, k) for (k, v) in d.items()]".\n\n Iterating views while adding or deleting entries in the dictionary\n may raise a "RuntimeError" or fail to iterate over all entries.\n\nx in dictview\n\n Return "True" if *x* is in the underlying dictionary\'s keys, values\n or items (in the latter case, *x* should be a "(key, value)"\n tuple).\n\nKeys views are set-like since their entries are unique and hashable.\nIf all values are hashable, so that "(key, value)" pairs are unique\nand hashable, then the items view is also set-like. (Values views are\nnot treated as set-like since the entries are generally not unique.)\nFor set-like views, all of the operations defined for the abstract\nbase class "collections.abc.Set" are available (for example, "==",\n"<", or "^").\n\nAn example of dictionary view usage:\n\n >>> dishes = {\'eggs\': 2, \'sausage\': 1, \'bacon\': 1, \'spam\': 500}\n >>> keys = dishes.keys()\n >>> values = dishes.values()\n\n >>> # iteration\n >>> n = 0\n >>> for val in values:\n ... n += val\n >>> print(n)\n 504\n\n >>> # keys and values are iterated over in the same order\n >>> list(keys)\n [\'eggs\', \'bacon\', \'sausage\', \'spam\']\n >>> list(values)\n [2, 1, 1, 500]\n\n >>> # view objects are dynamic and reflect dict changes\n >>> del dishes[\'eggs\']\n >>> del dishes[\'sausage\']\n >>> list(keys)\n [\'spam\', \'bacon\']\n\n >>> # set operations\n >>> keys & {\'eggs\', \'bacon\', \'salad\'}\n {\'bacon\'}\n >>> keys ^ {\'sausage\', \'juice\'}\n {\'juice\', \'sausage\', \'bacon\', \'spam\'}\n', + 'typesmapping': u'\nMapping Types --- "dict"\n************************\n\nA *mapping* object maps *hashable* values to arbitrary objects.\nMappings are mutable objects. There is currently only one standard\nmapping type, the *dictionary*. (For other containers see the built-\nin "list", "set", and "tuple" classes, and the "collections" module.)\n\nA dictionary\'s keys are *almost* arbitrary values. Values that are\nnot *hashable*, that is, values containing lists, dictionaries or\nother mutable types (that are compared by value rather than by object\nidentity) may not be used as keys. Numeric types used for keys obey\nthe normal rules for numeric comparison: if two numbers compare equal\n(such as "1" and "1.0") then they can be used interchangeably to index\nthe same dictionary entry. (Note however, that since computers store\nfloating-point numbers as approximations it is usually unwise to use\nthem as dictionary keys.)\n\nDictionaries can be created by placing a comma-separated list of "key:\nvalue" pairs within braces, for example: "{\'jack\': 4098, \'sjoerd\':\n4127}" or "{4098: \'jack\', 4127: \'sjoerd\'}", or by the "dict"\nconstructor.\n\nclass class dict(**kwarg)\nclass class dict(mapping, **kwarg)\nclass class dict(iterable, **kwarg)\n\n Return a new dictionary initialized from an optional positional\n argument and a possibly empty set of keyword arguments.\n\n If no positional argument is given, an empty dictionary is created.\n If a positional argument is given and it is a mapping object, a\n dictionary is created with the same key-value pairs as the mapping\n object. Otherwise, the positional argument must be an *iterable*\n object. Each item in the iterable must itself be an iterable with\n exactly two objects. The first object of each item becomes a key\n in the new dictionary, and the second object the corresponding\n value. If a key occurs more than once, the last value for that key\n becomes the corresponding value in the new dictionary.\n\n If keyword arguments are given, the keyword arguments and their\n values are added to the dictionary created from the positional\n argument. If a key being added is already present, the value from\n the keyword argument replaces the value from the positional\n argument.\n\n To illustrate, the following examples all return a dictionary equal\n to "{"one": 1, "two": 2, "three": 3}":\n\n >>> a = dict(one=1, two=2, three=3)\n >>> b = {\'one\': 1, \'two\': 2, \'three\': 3}\n >>> c = dict(zip([\'one\', \'two\', \'three\'], [1, 2, 3]))\n >>> d = dict([(\'two\', 2), (\'one\', 1), (\'three\', 3)])\n >>> e = dict({\'three\': 3, \'one\': 1, \'two\': 2})\n >>> a == b == c == d == e\n True\n\n Providing keyword arguments as in the first example only works for\n keys that are valid Python identifiers. Otherwise, any valid keys\n can be used.\n\n These are the operations that dictionaries support (and therefore,\n custom mapping types should support too):\n\n len(d)\n\n Return the number of items in the dictionary *d*.\n\n d[key]\n\n Return the item of *d* with key *key*. Raises a "KeyError" if\n *key* is not in the map.\n\n If a subclass of dict defines a method "__missing__()" and *key*\n is not present, the "d[key]" operation calls that method with\n the key *key* as argument. The "d[key]" operation then returns\n or raises whatever is returned or raised by the\n "__missing__(key)" call. No other operations or methods invoke\n "__missing__()". If "__missing__()" is not defined, "KeyError"\n is raised. "__missing__()" must be a method; it cannot be an\n instance variable:\n\n >>> class Counter(dict):\n ... def __missing__(self, key):\n ... return 0\n >>> c = Counter()\n >>> c[\'red\']\n 0\n >>> c[\'red\'] += 1\n >>> c[\'red\']\n 1\n\n The example above shows part of the implementation of\n "collections.Counter". A different "__missing__" method is used\n by "collections.defaultdict".\n\n d[key] = value\n\n Set "d[key]" to *value*.\n\n del d[key]\n\n Remove "d[key]" from *d*. Raises a "KeyError" if *key* is not\n in the map.\n\n key in d\n\n Return "True" if *d* has a key *key*, else "False".\n\n key not in d\n\n Equivalent to "not key in d".\n\n iter(d)\n\n Return an iterator over the keys of the dictionary. This is a\n shortcut for "iter(d.keys())".\n\n clear()\n\n Remove all items from the dictionary.\n\n copy()\n\n Return a shallow copy of the dictionary.\n\n classmethod fromkeys(seq[, value])\n\n Create a new dictionary with keys from *seq* and values set to\n *value*.\n\n "fromkeys()" is a class method that returns a new dictionary.\n *value* defaults to "None".\n\n get(key[, default])\n\n Return the value for *key* if *key* is in the dictionary, else\n *default*. If *default* is not given, it defaults to "None", so\n that this method never raises a "KeyError".\n\n items()\n\n Return a new view of the dictionary\'s items ("(key, value)"\n pairs). See the *documentation of view objects*.\n\n keys()\n\n Return a new view of the dictionary\'s keys. See the\n *documentation of view objects*.\n\n pop(key[, default])\n\n If *key* is in the dictionary, remove it and return its value,\n else return *default*. If *default* is not given and *key* is\n not in the dictionary, a "KeyError" is raised.\n\n popitem()\n\n Remove and return an arbitrary "(key, value)" pair from the\n dictionary.\n\n "popitem()" is useful to destructively iterate over a\n dictionary, as often used in set algorithms. If the dictionary\n is empty, calling "popitem()" raises a "KeyError".\n\n setdefault(key[, default])\n\n If *key* is in the dictionary, return its value. If not, insert\n *key* with a value of *default* and return *default*. *default*\n defaults to "None".\n\n update([other])\n\n Update the dictionary with the key/value pairs from *other*,\n overwriting existing keys. Return "None".\n\n "update()" accepts either another dictionary object or an\n iterable of key/value pairs (as tuples or other iterables of\n length two). If keyword arguments are specified, the dictionary\n is then updated with those key/value pairs: "d.update(red=1,\n blue=2)".\n\n values()\n\n Return a new view of the dictionary\'s values. See the\n *documentation of view objects*.\n\n Dictionaries compare equal if and only if they have the same "(key,\n value)" pairs. Order comparisons (\'<\', \'<=\', \'>=\', \'>\') raise\n "TypeError".\n\nSee also: "types.MappingProxyType" can be used to create a read-only\n view of a "dict".\n\n\nDictionary view objects\n=======================\n\nThe objects returned by "dict.keys()", "dict.values()" and\n"dict.items()" are *view objects*. They provide a dynamic view on the\ndictionary\'s entries, which means that when the dictionary changes,\nthe view reflects these changes.\n\nDictionary views can be iterated over to yield their respective data,\nand support membership tests:\n\nlen(dictview)\n\n Return the number of entries in the dictionary.\n\niter(dictview)\n\n Return an iterator over the keys, values or items (represented as\n tuples of "(key, value)") in the dictionary.\n\n Keys and values are iterated over in an arbitrary order which is\n non-random, varies across Python implementations, and depends on\n the dictionary\'s history of insertions and deletions. If keys,\n values and items views are iterated over with no intervening\n modifications to the dictionary, the order of items will directly\n correspond. This allows the creation of "(value, key)" pairs using\n "zip()": "pairs = zip(d.values(), d.keys())". Another way to\n create the same list is "pairs = [(v, k) for (k, v) in d.items()]".\n\n Iterating views while adding or deleting entries in the dictionary\n may raise a "RuntimeError" or fail to iterate over all entries.\n\nx in dictview\n\n Return "True" if *x* is in the underlying dictionary\'s keys, values\n or items (in the latter case, *x* should be a "(key, value)"\n tuple).\n\nKeys views are set-like since their entries are unique and hashable.\nIf all values are hashable, so that "(key, value)" pairs are unique\nand hashable, then the items view is also set-like. (Values views are\nnot treated as set-like since the entries are generally not unique.)\nFor set-like views, all of the operations defined for the abstract\nbase class "collections.abc.Set" are available (for example, "==",\n"<", or "^").\n\nAn example of dictionary view usage:\n\n >>> dishes = {\'eggs\': 2, \'sausage\': 1, \'bacon\': 1, \'spam\': 500}\n >>> keys = dishes.keys()\n >>> values = dishes.values()\n\n >>> # iteration\n >>> n = 0\n >>> for val in values:\n ... n += val\n >>> print(n)\n 504\n\n >>> # keys and values are iterated over in the same order\n >>> list(keys)\n [\'eggs\', \'bacon\', \'sausage\', \'spam\']\n >>> list(values)\n [2, 1, 1, 500]\n\n >>> # view objects are dynamic and reflect dict changes\n >>> del dishes[\'eggs\']\n >>> del dishes[\'sausage\']\n >>> list(keys)\n [\'spam\', \'bacon\']\n\n >>> # set operations\n >>> keys & {\'eggs\', \'bacon\', \'salad\'}\n {\'bacon\'}\n >>> keys ^ {\'sausage\', \'juice\'}\n {\'juice\', \'sausage\', \'bacon\', \'spam\'}\n', 'typesmethods': u'\nMethods\n*******\n\nMethods are functions that are called using the attribute notation.\nThere are two flavors: built-in methods (such as "append()" on lists)\nand class instance methods. Built-in methods are described with the\ntypes that support them.\n\nIf you access a method (a function defined in a class namespace)\nthrough an instance, you get a special object: a *bound method* (also\ncalled *instance method*) object. When called, it will add the "self"\nargument to the argument list. Bound methods have two special read-\nonly attributes: "m.__self__" is the object on which the method\noperates, and "m.__func__" is the function implementing the method.\nCalling "m(arg-1, arg-2, ..., arg-n)" is completely equivalent to\ncalling "m.__func__(m.__self__, arg-1, arg-2, ..., arg-n)".\n\nLike function objects, bound method objects support getting arbitrary\nattributes. However, since method attributes are actually stored on\nthe underlying function object ("meth.__func__"), setting method\nattributes on bound methods is disallowed. Attempting to set an\nattribute on a method results in an "AttributeError" being raised. In\norder to set a method attribute, you need to explicitly set it on the\nunderlying function object:\n\n >>> class C:\n ... def method(self):\n ... pass\n ...\n >>> c = C()\n >>> c.method.whoami = \'my name is method\' # can\'t set on the method\n Traceback (most recent call last):\n File "", line 1, in \n AttributeError: \'method\' object has no attribute \'whoami\'\n >>> c.method.__func__.whoami = \'my name is method\'\n >>> c.method.whoami\n \'my name is method\'\n\nSee *The standard type hierarchy* for more information.\n', 'typesmodules': u'\nModules\n*******\n\nThe only special operation on a module is attribute access: "m.name",\nwhere *m* is a module and *name* accesses a name defined in *m*\'s\nsymbol table. Module attributes can be assigned to. (Note that the\n"import" statement is not, strictly speaking, an operation on a module\nobject; "import foo" does not require a module object named *foo* to\nexist, rather it requires an (external) *definition* for a module\nnamed *foo* somewhere.)\n\nA special attribute of every module is "__dict__". This is the\ndictionary containing the module\'s symbol table. Modifying this\ndictionary will actually change the module\'s symbol table, but direct\nassignment to the "__dict__" attribute is not possible (you can write\n"m.__dict__[\'a\'] = 1", which defines "m.a" to be "1", but you can\'t\nwrite "m.__dict__ = {}"). Modifying "__dict__" directly is not\nrecommended.\n\nModules built into the interpreter are written like this: "". If loaded from a file, they are written as\n"".\n', - 'typesseq': u'\nSequence Types --- "list", "tuple", "range"\n*******************************************\n\nThere are three basic sequence types: lists, tuples, and range\nobjects. Additional sequence types tailored for processing of *binary\ndata* and *text strings* are described in dedicated sections.\n\n\nCommon Sequence Operations\n==========================\n\nThe operations in the following table are supported by most sequence\ntypes, both mutable and immutable. The "collections.abc.Sequence" ABC\nis provided to make it easier to correctly implement these operations\non custom sequence types.\n\nThis table lists the sequence operations sorted in ascending priority.\nIn the table, *s* and *t* are sequences of the same type, *n*, *i*,\n*j* and *k* are integers and *x* is an arbitrary object that meets any\ntype and value restrictions imposed by *s*.\n\nThe "in" and "not in" operations have the same priorities as the\ncomparison operations. The "+" (concatenation) and "*" (repetition)\noperations have the same priority as the corresponding numeric\noperations.\n\n+----------------------------+----------------------------------+------------+\n| Operation | Result | Notes |\n+============================+==================================+============+\n| "x in s" | "True" if an item of *s* is | (1) |\n| | equal to *x*, else "False" | |\n+----------------------------+----------------------------------+------------+\n| "x not in s" | "False" if an item of *s* is | (1) |\n| | equal to *x*, else "True" | |\n+----------------------------+----------------------------------+------------+\n| "s + t" | the concatenation of *s* and *t* | (6)(7) |\n+----------------------------+----------------------------------+------------+\n| "s * n" or "n * s" | *n* shallow copies of *s* | (2)(7) |\n| | concatenated | |\n+----------------------------+----------------------------------+------------+\n| "s[i]" | *i*th item of *s*, origin 0 | (3) |\n+----------------------------+----------------------------------+------------+\n| "s[i:j]" | slice of *s* from *i* to *j* | (3)(4) |\n+----------------------------+----------------------------------+------------+\n| "s[i:j:k]" | slice of *s* from *i* to *j* | (3)(5) |\n| | with step *k* | |\n+----------------------------+----------------------------------+------------+\n| "len(s)" | length of *s* | |\n+----------------------------+----------------------------------+------------+\n| "min(s)" | smallest item of *s* | |\n+----------------------------+----------------------------------+------------+\n| "max(s)" | largest item of *s* | |\n+----------------------------+----------------------------------+------------+\n| "s.index(x[, i[, j]])" | index of the first occurrence of | (8) |\n| | *x* in *s* (at or after index | |\n| | *i* and before index *j*) | |\n+----------------------------+----------------------------------+------------+\n| "s.count(x)" | total number of occurrences of | |\n| | *x* in *s* | |\n+----------------------------+----------------------------------+------------+\n\nSequences of the same type also support comparisons. In particular,\ntuples and lists are compared lexicographically by comparing\ncorresponding elements. This means that to compare equal, every\nelement must compare equal and the two sequences must be of the same\ntype and have the same length. (For full details see *Comparisons* in\nthe language reference.)\n\nNotes:\n\n1. While the "in" and "not in" operations are used only for simple\n containment testing in the general case, some specialised sequences\n (such as "str", "bytes" and "bytearray") also use them for\n subsequence testing:\n\n >>> "gg" in "eggs"\n True\n\n2. Values of *n* less than "0" are treated as "0" (which yields an\n empty sequence of the same type as *s*). Note also that the copies\n are shallow; nested structures are not copied. This often haunts\n new Python programmers; consider:\n\n >>> lists = [[]] * 3\n >>> lists\n [[], [], []]\n >>> lists[0].append(3)\n >>> lists\n [[3], [3], [3]]\n\n What has happened is that "[[]]" is a one-element list containing\n an empty list, so all three elements of "[[]] * 3" are (pointers\n to) this single empty list. Modifying any of the elements of\n "lists" modifies this single list. You can create a list of\n different lists this way:\n\n >>> lists = [[] for i in range(3)]\n >>> lists[0].append(3)\n >>> lists[1].append(5)\n >>> lists[2].append(7)\n >>> lists\n [[3], [5], [7]]\n\n3. If *i* or *j* is negative, the index is relative to the end of\n the string: "len(s) + i" or "len(s) + j" is substituted. But note\n that "-0" is still "0".\n\n4. The slice of *s* from *i* to *j* is defined as the sequence of\n items with index *k* such that "i <= k < j". If *i* or *j* is\n greater than "len(s)", use "len(s)". If *i* is omitted or "None",\n use "0". If *j* is omitted or "None", use "len(s)". If *i* is\n greater than or equal to *j*, the slice is empty.\n\n5. The slice of *s* from *i* to *j* with step *k* is defined as the\n sequence of items with index "x = i + n*k" such that "0 <= n <\n (j-i)/k". In other words, the indices are "i", "i+k", "i+2*k",\n "i+3*k" and so on, stopping when *j* is reached (but never\n including *j*). If *i* or *j* is greater than "len(s)", use\n "len(s)". If *i* or *j* are omitted or "None", they become "end"\n values (which end depends on the sign of *k*). Note, *k* cannot be\n zero. If *k* is "None", it is treated like "1".\n\n6. Concatenating immutable sequences always results in a new\n object. This means that building up a sequence by repeated\n concatenation will have a quadratic runtime cost in the total\n sequence length. To get a linear runtime cost, you must switch to\n one of the alternatives below:\n\n * if concatenating "str" objects, you can build a list and use\n "str.join()" at the end or else write to a "io.StringIO" instance\n and retrieve its value when complete\n\n * if concatenating "bytes" objects, you can similarly use\n "bytes.join()" or "io.BytesIO", or you can do in-place\n concatenation with a "bytearray" object. "bytearray" objects are\n mutable and have an efficient overallocation mechanism\n\n * if concatenating "tuple" objects, extend a "list" instead\n\n * for other types, investigate the relevant class documentation\n\n7. Some sequence types (such as "range") only support item\n sequences that follow specific patterns, and hence don\'t support\n sequence concatenation or repetition.\n\n8. "index" raises "ValueError" when *x* is not found in *s*. When\n supported, the additional arguments to the index method allow\n efficient searching of subsections of the sequence. Passing the\n extra arguments is roughly equivalent to using "s[i:j].index(x)",\n only without copying any data and with the returned index being\n relative to the start of the sequence rather than the start of the\n slice.\n\n\nImmutable Sequence Types\n========================\n\nThe only operation that immutable sequence types generally implement\nthat is not also implemented by mutable sequence types is support for\nthe "hash()" built-in.\n\nThis support allows immutable sequences, such as "tuple" instances, to\nbe used as "dict" keys and stored in "set" and "frozenset" instances.\n\nAttempting to hash an immutable sequence that contains unhashable\nvalues will result in "TypeError".\n\n\nMutable Sequence Types\n======================\n\nThe operations in the following table are defined on mutable sequence\ntypes. The "collections.abc.MutableSequence" ABC is provided to make\nit easier to correctly implement these operations on custom sequence\ntypes.\n\nIn the table *s* is an instance of a mutable sequence type, *t* is any\niterable object and *x* is an arbitrary object that meets any type and\nvalue restrictions imposed by *s* (for example, "bytearray" only\naccepts integers that meet the value restriction "0 <= x <= 255").\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| "s[i] = x" | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j] = t" | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j]" | same as "s[i:j] = []" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j:k] = t" | the elements of "s[i:j:k]" are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j:k]" | removes the elements of | |\n| | "s[i:j:k]" from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.append(x)" | appends *x* to the end of the | |\n| | sequence (same as | |\n| | "s[len(s):len(s)] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.clear()" | removes all items from "s" (same | (5) |\n| | as "del s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.copy()" | creates a shallow copy of "s" | (5) |\n| | (same as "s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.extend(t)" | extends *s* with the contents of | |\n| | *t* (same as "s[len(s):len(s)] = | |\n| | t") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.insert(i, x)" | inserts *x* into *s* at the | |\n| | index given by *i* (same as | |\n| | "s[i:i] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.pop([i])" | retrieves the item at *i* and | (2) |\n| | also removes it from *s* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.remove(x)" | remove the first item from *s* | (3) |\n| | where "s[i] == x" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.reverse()" | reverses the items of *s* in | (4) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The optional argument *i* defaults to "-1", so that by default\n the last item is removed and returned.\n\n3. "remove" raises "ValueError" when *x* is not found in *s*.\n\n4. The "reverse()" method modifies the sequence in place for\n economy of space when reversing a large sequence. To remind users\n that it operates by side effect, it does not return the reversed\n sequence.\n\n5. "clear()" and "copy()" are included for consistency with the\n interfaces of mutable containers that don\'t support slicing\n operations (such as "dict" and "set")\n\n New in version 3.3: "clear()" and "copy()" methods.\n\n\nLists\n=====\n\nLists are mutable sequences, typically used to store collections of\nhomogeneous items (where the precise degree of similarity will vary by\napplication).\n\nclass class list([iterable])\n\n Lists may be constructed in several ways:\n\n * Using a pair of square brackets to denote the empty list: "[]"\n\n * Using square brackets, separating items with commas: "[a]",\n "[a, b, c]"\n\n * Using a list comprehension: "[x for x in iterable]"\n\n * Using the type constructor: "list()" or "list(iterable)"\n\n The constructor builds a list whose items are the same and in the\n same order as *iterable*\'s items. *iterable* may be either a\n sequence, a container that supports iteration, or an iterator\n object. If *iterable* is already a list, a copy is made and\n returned, similar to "iterable[:]". For example, "list(\'abc\')"\n returns "[\'a\', \'b\', \'c\']" and "list( (1, 2, 3) )" returns "[1, 2,\n 3]". If no argument is given, the constructor creates a new empty\n list, "[]".\n\n Many other operations also produce lists, including the "sorted()"\n built-in.\n\n Lists implement all of the *common* and *mutable* sequence\n operations. Lists also provide the following additional method:\n\n sort(*, key=None, reverse=None)\n\n This method sorts the list in place, using only "<" comparisons\n between items. Exceptions are not suppressed - if any comparison\n operations fail, the entire sort operation will fail (and the\n list will likely be left in a partially modified state).\n\n "sort()" accepts two arguments that can only be passed by\n keyword (*keyword-only arguments*):\n\n *key* specifies a function of one argument that is used to\n extract a comparison key from each list element (for example,\n "key=str.lower"). The key corresponding to each item in the list\n is calculated once and then used for the entire sorting process.\n The default value of "None" means that list items are sorted\n directly without calculating a separate key value.\n\n The "functools.cmp_to_key()" utility is available to convert a\n 2.x style *cmp* function to a *key* function.\n\n *reverse* is a boolean value. If set to "True", then the list\n elements are sorted as if each comparison were reversed.\n\n This method modifies the sequence in place for economy of space\n when sorting a large sequence. To remind users that it operates\n by side effect, it does not return the sorted sequence (use\n "sorted()" to explicitly request a new sorted list instance).\n\n The "sort()" method is guaranteed to be stable. A sort is\n stable if it guarantees not to change the relative order of\n elements that compare equal --- this is helpful for sorting in\n multiple passes (for example, sort by department, then by salary\n grade).\n\n **CPython implementation detail:** While a list is being sorted,\n the effect of attempting to mutate, or even inspect, the list is\n undefined. The C implementation of Python makes the list appear\n empty for the duration, and raises "ValueError" if it can detect\n that the list has been mutated during a sort.\n\n\nTuples\n======\n\nTuples are immutable sequences, typically used to store collections of\nheterogeneous data (such as the 2-tuples produced by the "enumerate()"\nbuilt-in). Tuples are also used for cases where an immutable sequence\nof homogeneous data is needed (such as allowing storage in a "set" or\n"dict" instance).\n\nclass class tuple([iterable])\n\n Tuples may be constructed in a number of ways:\n\n * Using a pair of parentheses to denote the empty tuple: "()"\n\n * Using a trailing comma for a singleton tuple: "a," or "(a,)"\n\n * Separating items with commas: "a, b, c" or "(a, b, c)"\n\n * Using the "tuple()" built-in: "tuple()" or "tuple(iterable)"\n\n The constructor builds a tuple whose items are the same and in the\n same order as *iterable*\'s items. *iterable* may be either a\n sequence, a container that supports iteration, or an iterator\n object. If *iterable* is already a tuple, it is returned\n unchanged. For example, "tuple(\'abc\')" returns "(\'a\', \'b\', \'c\')"\n and "tuple( [1, 2, 3] )" returns "(1, 2, 3)". If no argument is\n given, the constructor creates a new empty tuple, "()".\n\n Note that it is actually the comma which makes a tuple, not the\n parentheses. The parentheses are optional, except in the empty\n tuple case, or when they are needed to avoid syntactic ambiguity.\n For example, "f(a, b, c)" is a function call with three arguments,\n while "f((a, b, c))" is a function call with a 3-tuple as the sole\n argument.\n\n Tuples implement all of the *common* sequence operations.\n\nFor heterogeneous collections of data where access by name is clearer\nthan access by index, "collections.namedtuple()" may be a more\nappropriate choice than a simple tuple object.\n\n\nRanges\n======\n\nThe "range" type represents an immutable sequence of numbers and is\ncommonly used for looping a specific number of times in "for" loops.\n\nclass class range(stop)\nclass class range(start, stop[, step])\n\n The arguments to the range constructor must be integers (either\n built-in "int" or any object that implements the "__index__"\n special method). If the *step* argument is omitted, it defaults to\n "1". If the *start* argument is omitted, it defaults to "0". If\n *step* is zero, "ValueError" is raised.\n\n For a positive *step*, the contents of a range "r" are determined\n by the formula "r[i] = start + step*i" where "i >= 0" and "r[i] <\n stop".\n\n For a negative *step*, the contents of the range are still\n determined by the formula "r[i] = start + step*i", but the\n constraints are "i >= 0" and "r[i] > stop".\n\n A range object will be empty if "r[0]" does not meet the value\n constraint. Ranges do support negative indices, but these are\n interpreted as indexing from the end of the sequence determined by\n the positive indices.\n\n Ranges containing absolute values larger than "sys.maxsize" are\n permitted but some features (such as "len()") may raise\n "OverflowError".\n\n Range examples:\n\n >>> list(range(10))\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n >>> list(range(1, 11))\n [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n >>> list(range(0, 30, 5))\n [0, 5, 10, 15, 20, 25]\n >>> list(range(0, 10, 3))\n [0, 3, 6, 9]\n >>> list(range(0, -10, -1))\n [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n >>> list(range(0))\n []\n >>> list(range(1, 0))\n []\n\n Ranges implement all of the *common* sequence operations except\n concatenation and repetition (due to the fact that range objects\n can only represent sequences that follow a strict pattern and\n repetition and concatenation will usually violate that pattern).\n\nThe advantage of the "range" type over a regular "list" or "tuple" is\nthat a "range" object will always take the same (small) amount of\nmemory, no matter the size of the range it represents (as it only\nstores the "start", "stop" and "step" values, calculating individual\nitems and subranges as needed).\n\nRange objects implement the "collections.abc.Sequence" ABC, and\nprovide features such as containment tests, element index lookup,\nslicing and support for negative indices (see *Sequence Types ---\nlist, tuple, range*):\n\n>>> r = range(0, 20, 2)\n>>> r\nrange(0, 20, 2)\n>>> 11 in r\nFalse\n>>> 10 in r\nTrue\n>>> r.index(10)\n5\n>>> r[5]\n10\n>>> r[:5]\nrange(0, 10, 2)\n>>> r[-1]\n18\n\nTesting range objects for equality with "==" and "!=" compares them as\nsequences. That is, two range objects are considered equal if they\nrepresent the same sequence of values. (Note that two range objects\nthat compare equal might have different "start", "stop" and "step"\nattributes, for example "range(0) == range(2, 1, 3)" or "range(0, 3,\n2) == range(0, 4, 2)".)\n\nChanged in version 3.2: Implement the Sequence ABC. Support slicing\nand negative indices. Test "int" objects for membership in constant\ntime instead of iterating through all items.\n\nChanged in version 3.3: Define \'==\' and \'!=\' to compare range objects\nbased on the sequence of values they define (instead of comparing\nbased on object identity).\n\nNew in version 3.3: The "start", "stop" and "step" attributes.\n', - 'typesseq-mutable': u'\nMutable Sequence Types\n**********************\n\nThe operations in the following table are defined on mutable sequence\ntypes. The "collections.abc.MutableSequence" ABC is provided to make\nit easier to correctly implement these operations on custom sequence\ntypes.\n\nIn the table *s* is an instance of a mutable sequence type, *t* is any\niterable object and *x* is an arbitrary object that meets any type and\nvalue restrictions imposed by *s* (for example, "bytearray" only\naccepts integers that meet the value restriction "0 <= x <= 255").\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| "s[i] = x" | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j] = t" | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j]" | same as "s[i:j] = []" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j:k] = t" | the elements of "s[i:j:k]" are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j:k]" | removes the elements of | |\n| | "s[i:j:k]" from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.append(x)" | appends *x* to the end of the | |\n| | sequence (same as | |\n| | "s[len(s):len(s)] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.clear()" | removes all items from "s" (same | (5) |\n| | as "del s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.copy()" | creates a shallow copy of "s" | (5) |\n| | (same as "s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.extend(t)" | extends *s* with the contents of | |\n| | *t* (same as "s[len(s):len(s)] = | |\n| | t") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.insert(i, x)" | inserts *x* into *s* at the | |\n| | index given by *i* (same as | |\n| | "s[i:i] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.pop([i])" | retrieves the item at *i* and | (2) |\n| | also removes it from *s* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.remove(x)" | remove the first item from *s* | (3) |\n| | where "s[i] == x" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.reverse()" | reverses the items of *s* in | (4) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The optional argument *i* defaults to "-1", so that by default\n the last item is removed and returned.\n\n3. "remove" raises "ValueError" when *x* is not found in *s*.\n\n4. The "reverse()" method modifies the sequence in place for\n economy of space when reversing a large sequence. To remind users\n that it operates by side effect, it does not return the reversed\n sequence.\n\n5. "clear()" and "copy()" are included for consistency with the\n interfaces of mutable containers that don\'t support slicing\n operations (such as "dict" and "set")\n\n New in version 3.3: "clear()" and "copy()" methods.\n', + 'typesseq': u'\nSequence Types --- "list", "tuple", "range"\n*******************************************\n\nThere are three basic sequence types: lists, tuples, and range\nobjects. Additional sequence types tailored for processing of *binary\ndata* and *text strings* are described in dedicated sections.\n\n\nCommon Sequence Operations\n==========================\n\nThe operations in the following table are supported by most sequence\ntypes, both mutable and immutable. The "collections.abc.Sequence" ABC\nis provided to make it easier to correctly implement these operations\non custom sequence types.\n\nThis table lists the sequence operations sorted in ascending priority.\nIn the table, *s* and *t* are sequences of the same type, *n*, *i*,\n*j* and *k* are integers and *x* is an arbitrary object that meets any\ntype and value restrictions imposed by *s*.\n\nThe "in" and "not in" operations have the same priorities as the\ncomparison operations. The "+" (concatenation) and "*" (repetition)\noperations have the same priority as the corresponding numeric\noperations.\n\n+----------------------------+----------------------------------+------------+\n| Operation | Result | Notes |\n+============================+==================================+============+\n| "x in s" | "True" if an item of *s* is | (1) |\n| | equal to *x*, else "False" | |\n+----------------------------+----------------------------------+------------+\n| "x not in s" | "False" if an item of *s* is | (1) |\n| | equal to *x*, else "True" | |\n+----------------------------+----------------------------------+------------+\n| "s + t" | the concatenation of *s* and *t* | (6)(7) |\n+----------------------------+----------------------------------+------------+\n| "s * n" or "n * s" | equivalent to adding *s* to | (2)(7) |\n| | itself *n* times | |\n+----------------------------+----------------------------------+------------+\n| "s[i]" | *i*th item of *s*, origin 0 | (3) |\n+----------------------------+----------------------------------+------------+\n| "s[i:j]" | slice of *s* from *i* to *j* | (3)(4) |\n+----------------------------+----------------------------------+------------+\n| "s[i:j:k]" | slice of *s* from *i* to *j* | (3)(5) |\n| | with step *k* | |\n+----------------------------+----------------------------------+------------+\n| "len(s)" | length of *s* | |\n+----------------------------+----------------------------------+------------+\n| "min(s)" | smallest item of *s* | |\n+----------------------------+----------------------------------+------------+\n| "max(s)" | largest item of *s* | |\n+----------------------------+----------------------------------+------------+\n| "s.index(x[, i[, j]])" | index of the first occurrence of | (8) |\n| | *x* in *s* (at or after index | |\n| | *i* and before index *j*) | |\n+----------------------------+----------------------------------+------------+\n| "s.count(x)" | total number of occurrences of | |\n| | *x* in *s* | |\n+----------------------------+----------------------------------+------------+\n\nSequences of the same type also support comparisons. In particular,\ntuples and lists are compared lexicographically by comparing\ncorresponding elements. This means that to compare equal, every\nelement must compare equal and the two sequences must be of the same\ntype and have the same length. (For full details see *Comparisons* in\nthe language reference.)\n\nNotes:\n\n1. While the "in" and "not in" operations are used only for simple\n containment testing in the general case, some specialised sequences\n (such as "str", "bytes" and "bytearray") also use them for\n subsequence testing:\n\n >>> "gg" in "eggs"\n True\n\n2. Values of *n* less than "0" are treated as "0" (which yields an\n empty sequence of the same type as *s*). Note that items in the\n sequence *s* are not copied; they are referenced multiple times.\n This often haunts new Python programmers; consider:\n\n >>> lists = [[]] * 3\n >>> lists\n [[], [], []]\n >>> lists[0].append(3)\n >>> lists\n [[3], [3], [3]]\n\n What has happened is that "[[]]" is a one-element list containing\n an empty list, so all three elements of "[[]] * 3" are references\n to this single empty list. Modifying any of the elements of\n "lists" modifies this single list. You can create a list of\n different lists this way:\n\n >>> lists = [[] for i in range(3)]\n >>> lists[0].append(3)\n >>> lists[1].append(5)\n >>> lists[2].append(7)\n >>> lists\n [[3], [5], [7]]\n\n Further explanation is available in the FAQ entry *How do I create\n a multidimensional list?*.\n\n3. If *i* or *j* is negative, the index is relative to the end of\n the string: "len(s) + i" or "len(s) + j" is substituted. But note\n that "-0" is still "0".\n\n4. The slice of *s* from *i* to *j* is defined as the sequence of\n items with index *k* such that "i <= k < j". If *i* or *j* is\n greater than "len(s)", use "len(s)". If *i* is omitted or "None",\n use "0". If *j* is omitted or "None", use "len(s)". If *i* is\n greater than or equal to *j*, the slice is empty.\n\n5. The slice of *s* from *i* to *j* with step *k* is defined as the\n sequence of items with index "x = i + n*k" such that "0 <= n <\n (j-i)/k". In other words, the indices are "i", "i+k", "i+2*k",\n "i+3*k" and so on, stopping when *j* is reached (but never\n including *j*). If *i* or *j* is greater than "len(s)", use\n "len(s)". If *i* or *j* are omitted or "None", they become "end"\n values (which end depends on the sign of *k*). Note, *k* cannot be\n zero. If *k* is "None", it is treated like "1".\n\n6. Concatenating immutable sequences always results in a new\n object. This means that building up a sequence by repeated\n concatenation will have a quadratic runtime cost in the total\n sequence length. To get a linear runtime cost, you must switch to\n one of the alternatives below:\n\n * if concatenating "str" objects, you can build a list and use\n "str.join()" at the end or else write to an "io.StringIO"\n instance and retrieve its value when complete\n\n * if concatenating "bytes" objects, you can similarly use\n "bytes.join()" or "io.BytesIO", or you can do in-place\n concatenation with a "bytearray" object. "bytearray" objects are\n mutable and have an efficient overallocation mechanism\n\n * if concatenating "tuple" objects, extend a "list" instead\n\n * for other types, investigate the relevant class documentation\n\n7. Some sequence types (such as "range") only support item\n sequences that follow specific patterns, and hence don\'t support\n sequence concatenation or repetition.\n\n8. "index" raises "ValueError" when *x* is not found in *s*. When\n supported, the additional arguments to the index method allow\n efficient searching of subsections of the sequence. Passing the\n extra arguments is roughly equivalent to using "s[i:j].index(x)",\n only without copying any data and with the returned index being\n relative to the start of the sequence rather than the start of the\n slice.\n\n\nImmutable Sequence Types\n========================\n\nThe only operation that immutable sequence types generally implement\nthat is not also implemented by mutable sequence types is support for\nthe "hash()" built-in.\n\nThis support allows immutable sequences, such as "tuple" instances, to\nbe used as "dict" keys and stored in "set" and "frozenset" instances.\n\nAttempting to hash an immutable sequence that contains unhashable\nvalues will result in "TypeError".\n\n\nMutable Sequence Types\n======================\n\nThe operations in the following table are defined on mutable sequence\ntypes. The "collections.abc.MutableSequence" ABC is provided to make\nit easier to correctly implement these operations on custom sequence\ntypes.\n\nIn the table *s* is an instance of a mutable sequence type, *t* is any\niterable object and *x* is an arbitrary object that meets any type and\nvalue restrictions imposed by *s* (for example, "bytearray" only\naccepts integers that meet the value restriction "0 <= x <= 255").\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| "s[i] = x" | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j] = t" | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j]" | same as "s[i:j] = []" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j:k] = t" | the elements of "s[i:j:k]" are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j:k]" | removes the elements of | |\n| | "s[i:j:k]" from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.append(x)" | appends *x* to the end of the | |\n| | sequence (same as | |\n| | "s[len(s):len(s)] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.clear()" | removes all items from "s" (same | (5) |\n| | as "del s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.copy()" | creates a shallow copy of "s" | (5) |\n| | (same as "s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.extend(t)" or "s += t" | extends *s* with the contents of | |\n| | *t* (for the most part the same | |\n| | as "s[len(s):len(s)] = t") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s *= n" | updates *s* with its contents | (6) |\n| | repeated *n* times | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.insert(i, x)" | inserts *x* into *s* at the | |\n| | index given by *i* (same as | |\n| | "s[i:i] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.pop([i])" | retrieves the item at *i* and | (2) |\n| | also removes it from *s* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.remove(x)" | remove the first item from *s* | (3) |\n| | where "s[i] == x" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.reverse()" | reverses the items of *s* in | (4) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The optional argument *i* defaults to "-1", so that by default\n the last item is removed and returned.\n\n3. "remove" raises "ValueError" when *x* is not found in *s*.\n\n4. The "reverse()" method modifies the sequence in place for\n economy of space when reversing a large sequence. To remind users\n that it operates by side effect, it does not return the reversed\n sequence.\n\n5. "clear()" and "copy()" are included for consistency with the\n interfaces of mutable containers that don\'t support slicing\n operations (such as "dict" and "set")\n\n New in version 3.3: "clear()" and "copy()" methods.\n\n6. The value *n* is an integer, or an object implementing\n "__index__()". Zero and negative values of *n* clear the sequence.\n Items in the sequence are not copied; they are referenced multiple\n times, as explained for "s * n" under *Common Sequence Operations*.\n\n\nLists\n=====\n\nLists are mutable sequences, typically used to store collections of\nhomogeneous items (where the precise degree of similarity will vary by\napplication).\n\nclass class list([iterable])\n\n Lists may be constructed in several ways:\n\n * Using a pair of square brackets to denote the empty list: "[]"\n\n * Using square brackets, separating items with commas: "[a]",\n "[a, b, c]"\n\n * Using a list comprehension: "[x for x in iterable]"\n\n * Using the type constructor: "list()" or "list(iterable)"\n\n The constructor builds a list whose items are the same and in the\n same order as *iterable*\'s items. *iterable* may be either a\n sequence, a container that supports iteration, or an iterator\n object. If *iterable* is already a list, a copy is made and\n returned, similar to "iterable[:]". For example, "list(\'abc\')"\n returns "[\'a\', \'b\', \'c\']" and "list( (1, 2, 3) )" returns "[1, 2,\n 3]". If no argument is given, the constructor creates a new empty\n list, "[]".\n\n Many other operations also produce lists, including the "sorted()"\n built-in.\n\n Lists implement all of the *common* and *mutable* sequence\n operations. Lists also provide the following additional method:\n\n sort(*, key=None, reverse=None)\n\n This method sorts the list in place, using only "<" comparisons\n between items. Exceptions are not suppressed - if any comparison\n operations fail, the entire sort operation will fail (and the\n list will likely be left in a partially modified state).\n\n "sort()" accepts two arguments that can only be passed by\n keyword (*keyword-only arguments*):\n\n *key* specifies a function of one argument that is used to\n extract a comparison key from each list element (for example,\n "key=str.lower"). The key corresponding to each item in the list\n is calculated once and then used for the entire sorting process.\n The default value of "None" means that list items are sorted\n directly without calculating a separate key value.\n\n The "functools.cmp_to_key()" utility is available to convert a\n 2.x style *cmp* function to a *key* function.\n\n *reverse* is a boolean value. If set to "True", then the list\n elements are sorted as if each comparison were reversed.\n\n This method modifies the sequence in place for economy of space\n when sorting a large sequence. To remind users that it operates\n by side effect, it does not return the sorted sequence (use\n "sorted()" to explicitly request a new sorted list instance).\n\n The "sort()" method is guaranteed to be stable. A sort is\n stable if it guarantees not to change the relative order of\n elements that compare equal --- this is helpful for sorting in\n multiple passes (for example, sort by department, then by salary\n grade).\n\n **CPython implementation detail:** While a list is being sorted,\n the effect of attempting to mutate, or even inspect, the list is\n undefined. The C implementation of Python makes the list appear\n empty for the duration, and raises "ValueError" if it can detect\n that the list has been mutated during a sort.\n\n\nTuples\n======\n\nTuples are immutable sequences, typically used to store collections of\nheterogeneous data (such as the 2-tuples produced by the "enumerate()"\nbuilt-in). Tuples are also used for cases where an immutable sequence\nof homogeneous data is needed (such as allowing storage in a "set" or\n"dict" instance).\n\nclass class tuple([iterable])\n\n Tuples may be constructed in a number of ways:\n\n * Using a pair of parentheses to denote the empty tuple: "()"\n\n * Using a trailing comma for a singleton tuple: "a," or "(a,)"\n\n * Separating items with commas: "a, b, c" or "(a, b, c)"\n\n * Using the "tuple()" built-in: "tuple()" or "tuple(iterable)"\n\n The constructor builds a tuple whose items are the same and in the\n same order as *iterable*\'s items. *iterable* may be either a\n sequence, a container that supports iteration, or an iterator\n object. If *iterable* is already a tuple, it is returned\n unchanged. For example, "tuple(\'abc\')" returns "(\'a\', \'b\', \'c\')"\n and "tuple( [1, 2, 3] )" returns "(1, 2, 3)". If no argument is\n given, the constructor creates a new empty tuple, "()".\n\n Note that it is actually the comma which makes a tuple, not the\n parentheses. The parentheses are optional, except in the empty\n tuple case, or when they are needed to avoid syntactic ambiguity.\n For example, "f(a, b, c)" is a function call with three arguments,\n while "f((a, b, c))" is a function call with a 3-tuple as the sole\n argument.\n\n Tuples implement all of the *common* sequence operations.\n\nFor heterogeneous collections of data where access by name is clearer\nthan access by index, "collections.namedtuple()" may be a more\nappropriate choice than a simple tuple object.\n\n\nRanges\n======\n\nThe "range" type represents an immutable sequence of numbers and is\ncommonly used for looping a specific number of times in "for" loops.\n\nclass class range(stop)\nclass class range(start, stop[, step])\n\n The arguments to the range constructor must be integers (either\n built-in "int" or any object that implements the "__index__"\n special method). If the *step* argument is omitted, it defaults to\n "1". If the *start* argument is omitted, it defaults to "0". If\n *step* is zero, "ValueError" is raised.\n\n For a positive *step*, the contents of a range "r" are determined\n by the formula "r[i] = start + step*i" where "i >= 0" and "r[i] <\n stop".\n\n For a negative *step*, the contents of the range are still\n determined by the formula "r[i] = start + step*i", but the\n constraints are "i >= 0" and "r[i] > stop".\n\n A range object will be empty if "r[0]" does not meet the value\n constraint. Ranges do support negative indices, but these are\n interpreted as indexing from the end of the sequence determined by\n the positive indices.\n\n Ranges containing absolute values larger than "sys.maxsize" are\n permitted but some features (such as "len()") may raise\n "OverflowError".\n\n Range examples:\n\n >>> list(range(10))\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n >>> list(range(1, 11))\n [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n >>> list(range(0, 30, 5))\n [0, 5, 10, 15, 20, 25]\n >>> list(range(0, 10, 3))\n [0, 3, 6, 9]\n >>> list(range(0, -10, -1))\n [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n >>> list(range(0))\n []\n >>> list(range(1, 0))\n []\n\n Ranges implement all of the *common* sequence operations except\n concatenation and repetition (due to the fact that range objects\n can only represent sequences that follow a strict pattern and\n repetition and concatenation will usually violate that pattern).\n\nThe advantage of the "range" type over a regular "list" or "tuple" is\nthat a "range" object will always take the same (small) amount of\nmemory, no matter the size of the range it represents (as it only\nstores the "start", "stop" and "step" values, calculating individual\nitems and subranges as needed).\n\nRange objects implement the "collections.abc.Sequence" ABC, and\nprovide features such as containment tests, element index lookup,\nslicing and support for negative indices (see *Sequence Types ---\nlist, tuple, range*):\n\n>>> r = range(0, 20, 2)\n>>> r\nrange(0, 20, 2)\n>>> 11 in r\nFalse\n>>> 10 in r\nTrue\n>>> r.index(10)\n5\n>>> r[5]\n10\n>>> r[:5]\nrange(0, 10, 2)\n>>> r[-1]\n18\n\nTesting range objects for equality with "==" and "!=" compares them as\nsequences. That is, two range objects are considered equal if they\nrepresent the same sequence of values. (Note that two range objects\nthat compare equal might have different "start", "stop" and "step"\nattributes, for example "range(0) == range(2, 1, 3)" or "range(0, 3,\n2) == range(0, 4, 2)".)\n\nChanged in version 3.2: Implement the Sequence ABC. Support slicing\nand negative indices. Test "int" objects for membership in constant\ntime instead of iterating through all items.\n\nChanged in version 3.3: Define \'==\' and \'!=\' to compare range objects\nbased on the sequence of values they define (instead of comparing\nbased on object identity).\n\nNew in version 3.3: The "start", "stop" and "step" attributes.\n', + 'typesseq-mutable': u'\nMutable Sequence Types\n**********************\n\nThe operations in the following table are defined on mutable sequence\ntypes. The "collections.abc.MutableSequence" ABC is provided to make\nit easier to correctly implement these operations on custom sequence\ntypes.\n\nIn the table *s* is an instance of a mutable sequence type, *t* is any\niterable object and *x* is an arbitrary object that meets any type and\nvalue restrictions imposed by *s* (for example, "bytearray" only\naccepts integers that meet the value restriction "0 <= x <= 255").\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| "s[i] = x" | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j] = t" | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j]" | same as "s[i:j] = []" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j:k] = t" | the elements of "s[i:j:k]" are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j:k]" | removes the elements of | |\n| | "s[i:j:k]" from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.append(x)" | appends *x* to the end of the | |\n| | sequence (same as | |\n| | "s[len(s):len(s)] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.clear()" | removes all items from "s" (same | (5) |\n| | as "del s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.copy()" | creates a shallow copy of "s" | (5) |\n| | (same as "s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.extend(t)" or "s += t" | extends *s* with the contents of | |\n| | *t* (for the most part the same | |\n| | as "s[len(s):len(s)] = t") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s *= n" | updates *s* with its contents | (6) |\n| | repeated *n* times | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.insert(i, x)" | inserts *x* into *s* at the | |\n| | index given by *i* (same as | |\n| | "s[i:i] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.pop([i])" | retrieves the item at *i* and | (2) |\n| | also removes it from *s* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.remove(x)" | remove the first item from *s* | (3) |\n| | where "s[i] == x" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.reverse()" | reverses the items of *s* in | (4) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The optional argument *i* defaults to "-1", so that by default\n the last item is removed and returned.\n\n3. "remove" raises "ValueError" when *x* is not found in *s*.\n\n4. The "reverse()" method modifies the sequence in place for\n economy of space when reversing a large sequence. To remind users\n that it operates by side effect, it does not return the reversed\n sequence.\n\n5. "clear()" and "copy()" are included for consistency with the\n interfaces of mutable containers that don\'t support slicing\n operations (such as "dict" and "set")\n\n New in version 3.3: "clear()" and "copy()" methods.\n\n6. The value *n* is an integer, or an object implementing\n "__index__()". Zero and negative values of *n* clear the sequence.\n Items in the sequence are not copied; they are referenced multiple\n times, as explained for "s * n" under *Common Sequence Operations*.\n', 'unary': u'\nUnary arithmetic and bitwise operations\n***************************************\n\nAll unary arithmetic and bitwise operations have the same priority:\n\n u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr\n\nThe unary "-" (minus) operator yields the negation of its numeric\nargument.\n\nThe unary "+" (plus) operator yields its numeric argument unchanged.\n\nThe unary "~" (invert) operator yields the bitwise inversion of its\ninteger argument. The bitwise inversion of "x" is defined as\n"-(x+1)". It only applies to integral numbers.\n\nIn all three cases, if the argument does not have the proper type, a\n"TypeError" exception is raised.\n', 'while': u'\nThe "while" statement\n*********************\n\nThe "while" statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the "else" clause, if present, is executed\nand the loop terminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and goes back\nto testing the expression.\n', 'with': u'\nThe "with" statement\n********************\n\nThe "with" statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common "try"..."except"..."finally"\nusage patterns to be encapsulated for convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the "with" statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the "with_item")\n is evaluated to obtain a context manager.\n\n2. The context manager\'s "__exit__()" is loaded for later use.\n\n3. The context manager\'s "__enter__()" method is invoked.\n\n4. If a target was included in the "with" statement, the return\n value from "__enter__()" is assigned to it.\n\n Note: The "with" statement guarantees that if the "__enter__()"\n method returns without an error, then "__exit__()" will always be\n called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s "__exit__()" method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to "__exit__()". Otherwise, three\n "None" arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the "__exit__()" method was false, the exception is reraised.\n If the return value was true, the exception is suppressed, and\n execution continues with the statement following the "with"\n statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from "__exit__()" is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple "with" statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also: **PEP 0343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n', diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -2,15 +2,28 @@ Python News +++++++++++ +What's New in Python 3.4.4? +=========================== + +Release date: 2015/12/20 + +Core and Builtins +----------------- + +Library +------- + + What's New in Python 3.4.4rc1? ============================== -Release date: tba +Release date: 2015/12/06 Core and Builtins ----------------- -- Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. +- Issue #25709: Fixed problem with in-place string concatenation and utf-8 + cache. - Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside __getattr__. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 01:19:55 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 07 Dec 2015 06:19:55 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Touched_up_release_schedules_?= =?utf-8?q?for_3=2E4_and_3=2E5=2E?= Message-ID: <20151207061955.29611.33418@psf.io> https://hg.python.org/peps/rev/17a43716ae25 changeset: 6138:17a43716ae25 user: Larry Hastings date: Sun Dec 06 22:19:52 2015 -0800 summary: Touched up release schedules for 3.4 and 3.5. files: pep-0429.txt | 13 ++++++++----- pep-0478.txt | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pep-0429.txt b/pep-0429.txt --- a/pep-0429.txt +++ b/pep-0429.txt @@ -50,32 +50,35 @@ (Beta 1 was also "feature freeze"--no new features beyond this point.) -3.4.1 schedule +3.4.1 -------------- - 3.4.1 candidate 1: May 5, 2014 - 3.4.1 final: May 18, 2014 -3.4.2 schedule +3.4.2 -------------- - 3.4.2 candidate 1: September 22, 2014 - 3.4.2 final: October 6, 2014 -3.4.3 schedule +3.4.3 -------------- - 3.4.3 candidate 1: February 8, 2015 - 3.4.3 final: February 25, 2015 -3.4.4 schedule (planned) +3.4.4 ------------------------ - 3.4.4 candidate 1: December 6, 2015 + + +Planned future releases: + - 3.4.4 final: December 20, 2015 - Features for 3.4 ================ diff --git a/pep-0478.txt b/pep-0478.txt --- a/pep-0478.txt +++ b/pep-0478.txt @@ -50,10 +50,10 @@ - 3.5.0 release candidate 3: September 7, 2015 - 3.5.0 final: September 13, 2015 - 3.5.1 release candidate 1: November 22, 2015 +- 3.5.1 final: December 6, 2015 -Planned future release dates: +.. Planned future release dates: -- 3.5.1 final: December 6, 2015 Features for 3.5 -- Repository URL: https://hg.python.org/peps From solipsis at pitrou.net Mon Dec 7 03:44:09 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 07 Dec 2015 08:44:09 +0000 Subject: [Python-checkins] Daily reference leaks (dd67c8c53aea): sum=22 Message-ID: <20151207084408.105489.91096@psf.io> results for dd67c8c53aea on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 test_pickle leaked [4, 4, 4] references, sum=12 test_pickle leaked [2, 2, 2] memory blocks, sum=6 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogiG1_sC', '--timeout', '7200'] From python-checkins at python.org Mon Dec 7 04:32:38 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 07 Dec 2015 09:32:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325761=3A_Fixed_re?= =?utf-8?q?ference_leak_added_in_previous_changeset_=285c670af0100f=29=2E?= Message-ID: <20151207093238.29981.58927@psf.io> https://hg.python.org/cpython/rev/001514146c21 changeset: 99500:001514146c21 user: Serhiy Storchaka date: Mon Dec 07 11:32:00 2015 +0200 summary: Issue #25761: Fixed reference leak added in previous changeset (5c670af0100f). files: Modules/_pickle.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Modules/_pickle.c b/Modules/_pickle.c --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -5152,6 +5152,7 @@ if ((j - i) % 2 != 0) { PickleState *st = _Pickle_GetGlobalState(); PyErr_SetString(st->UnpicklingError, "odd number of items for DICT"); + Py_DECREF(dict); return -1; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 06:21:10 2015 From: python-checkins at python.org (matthias.klose) Date: Mon, 07 Dec 2015 11:21:10 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy41?= Message-ID: <20151207112109.21227.79342@psf.io> https://hg.python.org/cpython/rev/c15ad9f317de changeset: 99503:c15ad9f317de parent: 99500:001514146c21 parent: 99502:e10e3fd31726 user: doko at ubuntu.com date: Mon Dec 07 12:21:01 2015 +0100 summary: merge 3.5 files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 06:21:10 2015 From: python-checkins at python.org (matthias.klose) Date: Mon, 07 Dec 2015 11:21:10 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Remove_x_permi?= =?utf-8?q?ssions_from_Lib/test/test=5Fscript=5Fhelper=2Epy?= Message-ID: <20151207112109.61841.79641@psf.io> https://hg.python.org/cpython/rev/6a3b444d89ce changeset: 99501:6a3b444d89ce branch: 3.4 parent: 99496:3b94245f9cf1 user: doko at ubuntu.com date: Mon Dec 07 12:19:49 2015 +0100 summary: Remove x permissions from Lib/test/test_script_helper.py files: Lib/test/test_script_helper.py | 0 1 files changed, 0 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_script_helper.py b/Lib/test/test_script_helper.py old mode 100755 new mode 100644 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 06:21:10 2015 From: python-checkins at python.org (matthias.klose) Date: Mon, 07 Dec 2015 11:21:10 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_merge_3=2E4?= Message-ID: <20151207112109.93624.19629@psf.io> https://hg.python.org/cpython/rev/e10e3fd31726 changeset: 99502:e10e3fd31726 branch: 3.5 parent: 99498:179cbf430ba7 parent: 99501:6a3b444d89ce user: doko at ubuntu.com date: Mon Dec 07 12:20:44 2015 +0100 summary: merge 3.4 files: -- Repository URL: https://hg.python.org/cpython From tjreedy at udel.edu Mon Dec 7 12:32:17 2015 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 07 Dec 2015 12:32:17 -0500 Subject: [Python-checkins] cpython (3.4): Remove x permissions from Lib/test/test_script_helper.py In-Reply-To: <20151207112109.61841.79641@psf.io> References: <20151207112109.61841.79641@psf.io> Message-ID: <5665C2A1.1090804@udel.edu> On 12/7/2015 6:21 AM, matthias.klose wrote: > https://hg.python.org/cpython/rev/6a3b444d89ce > changeset: 99501:6a3b444d89ce > branch: 3.4 3.4.4rc1 was just released. AFAIK, the only commits to 3.4 now should be either security patches for 3.4.5 or things you expect Larry to cherry pick into 3.4.4 final. Does this qualify for either? > parent: 99496:3b94245f9cf1 > user: doko at ubuntu.com > date: Mon Dec 07 12:19:49 2015 +0100 > summary: > Remove x permissions from Lib/test/test_script_helper.py > > files: > Lib/test/test_script_helper.py | 0 > 1 files changed, 0 insertions(+), 0 deletions(-) > > > diff --git a/Lib/test/test_script_helper.py b/Lib/test/test_script_helper.py > old mode 100755 > new mode 100644 From lp_benchmark_robot at intel.com Mon Dec 7 13:44:52 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 7 Dec 2015 18:44:52 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-07 Message-ID: <637eec81-6bb0-44f7-b2cf-4469b010e6e7@irsmsx105.ger.corp.intel.com> Results for project Python default, build date 2015-12-07 04:02:48 +0000 commit: dd67c8c53aea8d2613bb33ead3b1ee70f59743c6 revision date: 2015-12-07 00:31:11 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.42% 0.79% 9.99% 15.09% :-( pybench 0.17% -0.03% -2.15% 9.02% :-( regex_v8 2.62% -0.73% -4.40% 4.86% :-( nbody 0.07% -0.62% -3.78% 13.57% :-( json_dump_v2 0.27% -0.74% -2.34% 12.42% :-| normal_startup 0.78% 0.03% 0.24% 4.86% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Mon Dec 7 19:07:30 2015 From: python-checkins at python.org (martin.panter) Date: Tue, 08 Dec 2015 00:07:30 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325701=3A_Merge_set_and_delete_documentation_fro?= =?utf-8?q?m_3=2E5?= Message-ID: <20151208000730.5509.35952@psf.io> https://hg.python.org/cpython/rev/7bb7173cd97a changeset: 99505:7bb7173cd97a parent: 99503:c15ad9f317de parent: 99504:50711c80ff76 user: Martin Panter date: Tue Dec 08 00:05:06 2015 +0000 summary: Issue #25701: Merge set and delete documentation from 3.5 files: Doc/c-api/object.rst | 27 +++++++++++++++++++-------- Doc/c-api/sequence.rst | 6 +++++- Doc/c-api/typeobj.rst | 26 ++++++++++++++++---------- Include/abstract.h | 20 ++++++++++---------- 4 files changed, 50 insertions(+), 29 deletions(-) diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst --- a/Doc/c-api/object.rst +++ b/Doc/c-api/object.rst @@ -68,25 +68,35 @@ .. c:function:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v) Set the value of the attribute named *attr_name*, for object *o*, to the value - *v*. Returns ``-1`` on failure. This is the equivalent of the Python statement + *v*. Raise an exception and return ``-1`` on failure; + return ``0`` on success. This is the equivalent of the Python statement ``o.attr_name = v``. + If *v* is *NULL*, the attribute is deleted, however this feature is + deprecated in favour of using :c:func:`PyObject_DelAttr`. + .. c:function:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v) Set the value of the attribute named *attr_name*, for object *o*, to the value - *v*. Returns ``-1`` on failure. This is the equivalent of the Python statement + *v*. Raise an exception and return ``-1`` on failure; + return ``0`` on success. This is the equivalent of the Python statement ``o.attr_name = v``. + If *v* is *NULL*, the attribute is deleted, however this feature is + deprecated in favour of using :c:func:`PyObject_DelAttrString`. + .. c:function:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value) - Generic attribute setter function that is meant to be put into a type - object's ``tp_setattro`` slot. It looks for a data descriptor in the + Generic attribute setter and deleter function that is meant + to be put into a type object's :c:member:`~PyTypeObject.tp_setattro` + slot. It looks for a data descriptor in the dictionary of classes in the object's MRO, and if found it takes preference - over setting the attribute in the instance dictionary. Otherwise, the - attribute is set in the object's :attr:`~object.__dict__` (if present). - Otherwise, an :exc:`AttributeError` is raised and ``-1`` is returned. + over setting or deleting the attribute in the instance dictionary. Otherwise, the + attribute is set or deleted in the object's :attr:`~object.__dict__` (if present). + On success, ``0`` is returned, otherwise an :exc:`AttributeError` + is raised and ``-1`` is returned. .. c:function:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name) @@ -378,7 +388,8 @@ .. c:function:: int PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v) - Map the object *key* to the value *v*. Returns ``-1`` on failure. This is the + Map the object *key* to the value *v*. Raise an exception and + return ``-1`` on failure; return ``0`` on success. This is the equivalent of the Python statement ``o[key] = v``. diff --git a/Doc/c-api/sequence.rst b/Doc/c-api/sequence.rst --- a/Doc/c-api/sequence.rst +++ b/Doc/c-api/sequence.rst @@ -62,10 +62,14 @@ .. c:function:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v) - Assign object *v* to the *i*\ th element of *o*. Returns ``-1`` on failure. This + Assign object *v* to the *i*\ th element of *o*. Raise an exception + and return ``-1`` on failure; return ``0`` on success. This is the equivalent of the Python statement ``o[i] = v``. This function *does not* steal a reference to *v*. + If *v* is *NULL*, the element is deleted, however this feature is + deprecated in favour of using :c:func:`PySequence_DelItem`. + .. c:function:: int PySequence_DelItem(PyObject *o, Py_ssize_t i) diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -208,12 +208,13 @@ .. c:member:: setattrfunc PyTypeObject.tp_setattr - An optional pointer to the set-attribute-string function. + An optional pointer to the function for setting and deleting attributes. This field is deprecated. When it is defined, it should point to a function that acts the same as the :c:member:`~PyTypeObject.tp_setattro` function, but taking a C string instead of a Python string object to give the attribute name. The signature is - the same as for :c:func:`PyObject_SetAttrString`. + the same as for :c:func:`PyObject_SetAttrString`, but setting + *v* to *NULL* to delete an attribute must be supported. This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_setattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` from its base type when @@ -351,9 +352,10 @@ .. c:member:: setattrofunc PyTypeObject.tp_setattro - An optional pointer to the set-attribute function. + An optional pointer to the function for setting and deleting attributes. - The signature is the same as for :c:func:`PyObject_SetAttr`. It is usually + The signature is the same as for :c:func:`PyObject_SetAttr`, but setting + *v* to *NULL* to delete an attribute must be supported. It is usually convenient to set this field to :c:func:`PyObject_GenericSetAttr`, which implements the normal way of setting object attributes. @@ -724,7 +726,7 @@ typedef struct PyGetSetDef { char *name; /* attribute name */ getter get; /* C function to get the attribute */ - setter set; /* C function to set the attribute */ + setter set; /* C function to set or delete the attribute */ char *doc; /* optional doc string */ void *closure; /* optional additional data for getter and setter */ } PyGetSetDef; @@ -775,12 +777,14 @@ .. c:member:: descrsetfunc PyTypeObject.tp_descr_set - An optional pointer to a "descriptor set" function. + An optional pointer to a function for setting and deleting + a descriptor's value. The function signature is :: int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value); + The *value* argument is set to *NULL* to delete the value. This field is inherited by subtypes. .. XXX explain. @@ -1171,9 +1175,11 @@ .. c:member:: objobjargproc PyMappingMethods.mp_ass_subscript - This function is used by :c:func:`PyObject_SetItem` and has the same - signature. If this slot is *NULL*, the object does not support item - assignment. + This function is used by :c:func:`PyObject_SetItem` and + :c:func:`PyObject_DelItem`. It has the same signature as + :c:func:`PyObject_SetItem`, but *v* can also be set to *NULL* to delete + an item. If this slot is *NULL*, the object does not support item + assignment and deletion. .. _sequence-structs: @@ -1222,7 +1228,7 @@ This function is used by :c:func:`PySequence_SetItem` and has the same signature. This slot may be left to *NULL* if the object does not support - item assignment. + item assignment and deletion. .. c:member:: objobjproc PySequenceMethods.sq_contains diff --git a/Include/abstract.h b/Include/abstract.h --- a/Include/abstract.h +++ b/Include/abstract.h @@ -192,8 +192,8 @@ int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v); Set the value of the attribute named attr_name, for object o, - to the value, v. Returns -1 on failure. This is - the equivalent of the Python statement: o.attr_name=v. + to the value v. Raise an exception and return -1 on failure; return 0 on + success. This is the equivalent of the Python statement o.attr_name=v. */ @@ -202,8 +202,8 @@ int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v); Set the value of the attribute named attr_name, for object o, - to the value, v. Returns -1 on failure. This is - the equivalent of the Python statement: o.attr_name=v. + to the value v. Raise an exception and return -1 on failure; return 0 on + success. This is the equivalent of the Python statement o.attr_name=v. */ @@ -435,9 +435,9 @@ PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v); /* - Map the object, key, to the value, v. Returns - -1 on failure. This is the equivalent of the Python - statement: o[key]=v. + Map the object key to the value v. Raise an exception and return -1 + on failure; return 0 on success. This is the equivalent of the Python + statement o[key]=v. */ PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key); @@ -993,9 +993,9 @@ PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v); /* - Assign object v to the ith element of o. Returns - -1 on failure. This is the equivalent of the Python - statement: o[i]=v. + Assign object v to the ith element of o. Raise an exception and return + -1 on failure; return 0 on success. This is the equivalent of the + Python statement o[i]=v. */ PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 19:07:30 2015 From: python-checkins at python.org (martin.panter) Date: Tue, 08 Dec 2015 00:07:30 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NzAx?= =?utf-8?q?=3A_Document_C_API_functions_that_both_set_and_delete_objects?= Message-ID: <20151208000730.16232.44097@psf.io> https://hg.python.org/cpython/rev/50711c80ff76 changeset: 99504:50711c80ff76 branch: 3.5 parent: 99502:e10e3fd31726 user: Martin Panter date: Tue Dec 08 00:03:20 2015 +0000 summary: Issue #25701: Document C API functions that both set and delete objects Also document that the separate functions that delete objects are preferred; using PyObject_SetAttr(), _SetAttrString(), and PySequence_SetItem() to delete is deprecated. files: Doc/c-api/object.rst | 27 +++++++++++++++++++-------- Doc/c-api/sequence.rst | 6 +++++- Doc/c-api/typeobj.rst | 26 ++++++++++++++++---------- Include/abstract.h | 20 ++++++++++---------- 4 files changed, 50 insertions(+), 29 deletions(-) diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst --- a/Doc/c-api/object.rst +++ b/Doc/c-api/object.rst @@ -68,25 +68,35 @@ .. c:function:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v) Set the value of the attribute named *attr_name*, for object *o*, to the value - *v*. Returns ``-1`` on failure. This is the equivalent of the Python statement + *v*. Raise an exception and return ``-1`` on failure; + return ``0`` on success. This is the equivalent of the Python statement ``o.attr_name = v``. + If *v* is *NULL*, the attribute is deleted, however this feature is + deprecated in favour of using :c:func:`PyObject_DelAttr`. + .. c:function:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v) Set the value of the attribute named *attr_name*, for object *o*, to the value - *v*. Returns ``-1`` on failure. This is the equivalent of the Python statement + *v*. Raise an exception and return ``-1`` on failure; + return ``0`` on success. This is the equivalent of the Python statement ``o.attr_name = v``. + If *v* is *NULL*, the attribute is deleted, however this feature is + deprecated in favour of using :c:func:`PyObject_DelAttrString`. + .. c:function:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value) - Generic attribute setter function that is meant to be put into a type - object's ``tp_setattro`` slot. It looks for a data descriptor in the + Generic attribute setter and deleter function that is meant + to be put into a type object's :c:member:`~PyTypeObject.tp_setattro` + slot. It looks for a data descriptor in the dictionary of classes in the object's MRO, and if found it takes preference - over setting the attribute in the instance dictionary. Otherwise, the - attribute is set in the object's :attr:`~object.__dict__` (if present). - Otherwise, an :exc:`AttributeError` is raised and ``-1`` is returned. + over setting or deleting the attribute in the instance dictionary. Otherwise, the + attribute is set or deleted in the object's :attr:`~object.__dict__` (if present). + On success, ``0`` is returned, otherwise an :exc:`AttributeError` + is raised and ``-1`` is returned. .. c:function:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name) @@ -378,7 +388,8 @@ .. c:function:: int PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v) - Map the object *key* to the value *v*. Returns ``-1`` on failure. This is the + Map the object *key* to the value *v*. Raise an exception and + return ``-1`` on failure; return ``0`` on success. This is the equivalent of the Python statement ``o[key] = v``. diff --git a/Doc/c-api/sequence.rst b/Doc/c-api/sequence.rst --- a/Doc/c-api/sequence.rst +++ b/Doc/c-api/sequence.rst @@ -62,10 +62,14 @@ .. c:function:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v) - Assign object *v* to the *i*\ th element of *o*. Returns ``-1`` on failure. This + Assign object *v* to the *i*\ th element of *o*. Raise an exception + and return ``-1`` on failure; return ``0`` on success. This is the equivalent of the Python statement ``o[i] = v``. This function *does not* steal a reference to *v*. + If *v* is *NULL*, the element is deleted, however this feature is + deprecated in favour of using :c:func:`PySequence_DelItem`. + .. c:function:: int PySequence_DelItem(PyObject *o, Py_ssize_t i) diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -208,12 +208,13 @@ .. c:member:: setattrfunc PyTypeObject.tp_setattr - An optional pointer to the set-attribute-string function. + An optional pointer to the function for setting and deleting attributes. This field is deprecated. When it is defined, it should point to a function that acts the same as the :c:member:`~PyTypeObject.tp_setattro` function, but taking a C string instead of a Python string object to give the attribute name. The signature is - the same as for :c:func:`PyObject_SetAttrString`. + the same as for :c:func:`PyObject_SetAttrString`, but setting + *v* to *NULL* to delete an attribute must be supported. This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_setattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` from its base type when @@ -351,9 +352,10 @@ .. c:member:: setattrofunc PyTypeObject.tp_setattro - An optional pointer to the set-attribute function. + An optional pointer to the function for setting and deleting attributes. - The signature is the same as for :c:func:`PyObject_SetAttr`. It is usually + The signature is the same as for :c:func:`PyObject_SetAttr`, but setting + *v* to *NULL* to delete an attribute must be supported. It is usually convenient to set this field to :c:func:`PyObject_GenericSetAttr`, which implements the normal way of setting object attributes. @@ -724,7 +726,7 @@ typedef struct PyGetSetDef { char *name; /* attribute name */ getter get; /* C function to get the attribute */ - setter set; /* C function to set the attribute */ + setter set; /* C function to set or delete the attribute */ char *doc; /* optional doc string */ void *closure; /* optional additional data for getter and setter */ } PyGetSetDef; @@ -775,12 +777,14 @@ .. c:member:: descrsetfunc PyTypeObject.tp_descr_set - An optional pointer to a "descriptor set" function. + An optional pointer to a function for setting and deleting + a descriptor's value. The function signature is :: int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value); + The *value* argument is set to *NULL* to delete the value. This field is inherited by subtypes. .. XXX explain. @@ -1171,9 +1175,11 @@ .. c:member:: objobjargproc PyMappingMethods.mp_ass_subscript - This function is used by :c:func:`PyObject_SetItem` and has the same - signature. If this slot is *NULL*, the object does not support item - assignment. + This function is used by :c:func:`PyObject_SetItem` and + :c:func:`PyObject_DelItem`. It has the same signature as + :c:func:`PyObject_SetItem`, but *v* can also be set to *NULL* to delete + an item. If this slot is *NULL*, the object does not support item + assignment and deletion. .. _sequence-structs: @@ -1222,7 +1228,7 @@ This function is used by :c:func:`PySequence_SetItem` and has the same signature. This slot may be left to *NULL* if the object does not support - item assignment. + item assignment and deletion. .. c:member:: objobjproc PySequenceMethods.sq_contains diff --git a/Include/abstract.h b/Include/abstract.h --- a/Include/abstract.h +++ b/Include/abstract.h @@ -192,8 +192,8 @@ int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v); Set the value of the attribute named attr_name, for object o, - to the value, v. Returns -1 on failure. This is - the equivalent of the Python statement: o.attr_name=v. + to the value v. Raise an exception and return -1 on failure; return 0 on + success. This is the equivalent of the Python statement o.attr_name=v. */ @@ -202,8 +202,8 @@ int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v); Set the value of the attribute named attr_name, for object o, - to the value, v. Returns -1 on failure. This is - the equivalent of the Python statement: o.attr_name=v. + to the value v. Raise an exception and return -1 on failure; return 0 on + success. This is the equivalent of the Python statement o.attr_name=v. */ @@ -435,9 +435,9 @@ PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v); /* - Map the object, key, to the value, v. Returns - -1 on failure. This is the equivalent of the Python - statement: o[key]=v. + Map the object key to the value v. Raise an exception and return -1 + on failure; return 0 on success. This is the equivalent of the Python + statement o[key]=v. */ PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key); @@ -993,9 +993,9 @@ PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v); /* - Assign object v to the ith element of o. Returns - -1 on failure. This is the equivalent of the Python - statement: o[i]=v. + Assign object v to the ith element of o. Raise an exception and return + -1 on failure; return 0 on success. This is the equivalent of the + Python statement o[i]=v. */ PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 7 23:45:22 2015 From: python-checkins at python.org (raymond.hettinger) Date: Tue, 08 Dec 2015 04:45:22 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Only_update_the_arr_variab?= =?utf-8?q?le_when_PyObject=5FRichCompareBool=28=29_has_been_called=2E?= Message-ID: <20151208044522.11497.82974@psf.io> https://hg.python.org/cpython/rev/d6e27eafb4e1 changeset: 99506:d6e27eafb4e1 user: Raymond Hettinger date: Mon Dec 07 20:45:16 2015 -0800 summary: Only update the arr variable when PyObject_RichCompareBool() has been called. files: Modules/_heapqmodule.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -78,6 +78,7 @@ if (cmp < 0) return -1; childpos += ((unsigned)cmp ^ 1); /* increment when cmp==0 */ + arr = _PyList_ITEMS(heap); /* arr may have changed */ if (endpos != PyList_GET_SIZE(heap)) { PyErr_SetString(PyExc_RuntimeError, "list changed size during iteration"); @@ -85,7 +86,6 @@ } } /* Move the smaller child up. */ - arr = _PyList_ITEMS(heap); tmp1 = arr[childpos]; tmp2 = arr[pos]; arr[childpos] = tmp2; @@ -432,6 +432,7 @@ if (cmp < 0) return -1; childpos += ((unsigned)cmp ^ 1); /* increment when cmp==0 */ + arr = _PyList_ITEMS(heap); /* arr may have changed */ if (endpos != PyList_GET_SIZE(heap)) { PyErr_SetString(PyExc_RuntimeError, "list changed size during iteration"); @@ -439,7 +440,6 @@ } } /* Move the smaller child up. */ - arr = _PyList_ITEMS(heap); tmp1 = arr[childpos]; tmp2 = arr[pos]; arr[childpos] = tmp2; -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Tue Dec 8 03:42:05 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 08 Dec 2015 08:42:05 +0000 Subject: [Python-checkins] Daily reference leaks (d6e27eafb4e1): sum=4 Message-ID: <20151208084205.11499.29703@psf.io> results for d6e27eafb4e1 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogBXl2nM', '--timeout', '7200'] From python-checkins at python.org Tue Dec 8 03:44:04 2015 From: python-checkins at python.org (nick.coghlan) Date: Tue, 08 Dec 2015 08:44:04 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_493=3A_Clarify_scope_=26_?= =?utf-8?q?deemphasise_PEP_476_backport?= Message-ID: <20151208084403.73061.20670@psf.io> https://hg.python.org/peps/rev/17e0e36cbc19 changeset: 6139:17e0e36cbc19 user: Nick Coghlan date: Tue Dec 08 18:43:52 2015 +1000 summary: PEP 493: Clarify scope & deemphasise PEP 476 backport * Scope limitations now have their own section, rather than being part of the Rationale section * reordered backport sections so PEP 493 backport is discussed prior to the PEP 476 backport * made it explicit that the PEP 476 section is aimed at "*IF* you backport this feature, do it *this* way", so simply not implementing that section at all is entirely PEP compliant files: pep-0493.txt | 402 ++++++++++++++++++++------------------ 1 files changed, 207 insertions(+), 195 deletions(-) diff --git a/pep-0493.txt b/pep-0493.txt --- a/pep-0493.txt +++ b/pep-0493.txt @@ -76,17 +76,6 @@ recommendations to redistributors backporting these features to versions of Python prior to Python 2.7.9. -These designs are being proposed purely as tools for helping to manage the -transition to the new default certificate handling behaviour in the context -of Python 2.7. They are not being proposed as new features for Python 3, as -it is expected that the vast majority of client applications affected by this -problem without the ability to update the application itself will be Python 2 -applications. - -It would likely be desirable for a future version of Python 3 to allow default -certificate handling for secure protocols to be configurable on a per-protocol -basis, but that question is beyond the scope of this PEP. - Alternatives ------------ @@ -105,6 +94,21 @@ regardless of the formal status of the PEP +Scope Limitations +================= + +These changes are being proposed purely as tools for helping to manage the +transition to the new default certificate handling behaviour in the context +of Python 2.7. They are not being proposed as new features for Python 3, as +it is expected that the vast majority of client applications affected by this +problem without the ability to update the application itself will be Python 2 +applications. + +It would likely be desirable for a future version of Python 3 to allow the +default certificate handling for secure protocols to be configurable on a +per-protocol basis, but that question is beyond the scope of this PEP. + + Requirements for capability detection ===================================== @@ -124,6 +128,7 @@ migration process from the original Python 2.7 HTTPS handling to the new default behaviour. + Feature: Configuration API ========================== @@ -250,191 +255,13 @@ inside an activated Python virtual environment. -Backporting PEP 476 to earlier Python versions -============================================== - -Some redistributors, most notably Linux distributions, may choose to backport -the PEP 476 HTTPS verification changes to modified Python versions based on -earlier Python 2 maintenance releases. In these cases, a configuration -mechanism is needed that provides: - -* an opt-in model that allows the decision to enable HTTPS certificate - verification to be made independently of the decision to upgrade to the - Python version where the feature was first backported -* the ability for system administrators to set the default behaviour of Python - applications and scripts run directly in the system Python installation -* the ability for the redistributor to consider changing the default behaviour - of *new* installations at some point in the future without impacting existing - installations that have been explicitly configured to skip verifying HTTPS - certificates by default - -As it only affects backports to earlier releases of Python 2.7, this change is -not proposed for inclusion in upstream CPython, but rather is offered as -guidance to redistributors to reduce the likelihood of multiple mutually -incompatible approaches to backporting being adopted. - -This approach SHOULD NOT be used for any Python installation that advertises -itself as providing Python 2.7.9 or later, as most Python users will have the -reasonable expectation that all such environments will validate HTTPS -certificates by default. - - -Feature detection ------------------ - -The marker attribute on the ``ssl`` module related to this feature is:: - - _cert_verification_config = '' - -This not only makes it straightforward to detect the presence (or absence) of -the capability, it also makes it possible to programmatically determine the -relevant configuration file name. - - -Recommended modifications to the Python standard library --------------------------------------------------------- - -The recommended approach to backporting the PEP 476 modifications to an earlier -point release is to implement the following changes relative to the default -PEP 476 behaviour implemented in Python 2.7.9+: - -* modify the ``ssl`` module to read a system wide configuration file when the - module is first imported into a Python process -* define a platform default behaviour (either verifying or not verifying HTTPS - certificates) to be used if this configuration file is not present -* support selection between the following three modes of operation: - - * ensure HTTPS certificate verification is enabled - * ensure HTTPS certificate verification is disabled - * delegate the decision to the redistributor providing this Python version - -* set the ``ssl._create_default_https_context`` function to be an alias for - either ``ssl.create_default_context`` or ``ssl._create_unverified_context`` - based on the given configuration setting. - - -Recommended file location -------------------------- - -As the PEP authors are not aware of any vendors providing long-term support -releases targeting Windows, Mac OS X or \*BSD systems, this approach is -currently only specifically defined for Linux system Python installations. - -The recommended configuration file name on Linux systems is -``/etc/python/cert-verification.cfg``. - -The ``.cfg`` filename extension is recommended for consistency with the -``pyvenv.cfg`` used by the ``venv`` module in Python 3's standard library. - - -Recommended file format ------------------------ - -The configuration file should use a ConfigParser ini-style format with a -single section named ``[https]`` containing one required setting ``verify``. - -The suggested section name is taken from the "https" URL schema passed to -affected client APIs. - -Permitted values for ``verify`` are: - -* ``enable``: ensure HTTPS certificate verification is enabled by default -* ``disable``: ensure HTTPS certificate verification is disabled by default -* ``platform_default``: delegate the decision to the redistributor providing - this particular Python version - -If the ``[https]`` section or the ``verify`` setting are missing, or if the -``verify`` setting is set to an unknown value, it should be treated as if the -configuration file is not present. - - -Example implementation ----------------------- - -:: - - _cert_verification_config = '/etc/python/cert-verification.cfg' - - def _get_https_context_factory(): - # Check for a system-wide override of the default behaviour - context_factories = { - 'enable': create_default_context, - 'disable': _create_unverified_context, - 'platform_default': _create_unverified_context, # For now :) - } - import ConfigParser - config = ConfigParser.RawConfigParser() - config.read(_cert_verification_config) - try: - verify_mode = config.get('https', 'verify') - except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): - verify_mode = 'platform_default' - default_factory = context_factories.get('platform_default') - return context_factories.get(verify_mode, default_factory) - - _create_default_https_context = _get_https_context_factory() - - -Security Considerations ------------------------ - -The specific recommendations for this backporting case are designed to work for -privileged, security sensitive processes, even those being run in the following -locked down configuration: - -* run from a locked down administrator controlled directory rather than a normal - user directory (preventing ``sys.path[0]`` based privilege escalation attacks) -* run using the ``-E`` switch (preventing ``PYTHON*`` environment variable based - privilege escalation attacks) -* run using the ``-s`` switch (preventing user site directory based privilege - escalation attacks) -* run using the ``-S`` switch (preventing ``sitecustomize`` based privilege - escalation attacks) - -The intent is that the *only* reason HTTPS verification should be getting -turned off system wide when using this approach is because: - -* an end user is running a redistributor provided version of CPython rather - than running upstream CPython directly -* that redistributor has decided to provide a smoother migration path to - verifying HTTPS certificates by default than that being provided by the - upstream project -* either the redistributor or the local infrastructure administrator has - determined that it is appropriate to override the default upstream behaviour - (at least for the time being) - -Using an administrator controlled configuration file rather than an environment -variable has the essential feature of providing a smoother migration path, even -for applications being run with the ``-E`` switch. - -Interaction with Python virtual environments --------------------------------------------- - -This setting is scoped by the interpreter installation and affects all Python -processes using that interpreter, regardless of whether or not the interpreter -is being run inside an activated Python virtual environment. - -Origins of this recommendation ------------------------------- - -This recommendation is based on the backporting approach adopted for Red Hat -Enterprise Linux 7.2, as published in the original July 2015 draft of this PEP -and described in detail in `this KnowledgeBase article -`__. Red Hat's patches implementing -this backport for Python 2.7.5 can be found in the `CentOS git repository -`__. - - Backporting this PEP to earlier Python versions =============================================== -The configuration file based backport described above is designed to cover -backporting the PEP 476 changes to default certificate handling without the -additional configuration mechanisms defined in this PEP. - -If this PEP is accepted, then an additional backporting option becomes -available, which is to backport the per-process configuration mechanisms -defined in this PEP, without backporting the ability to change the default behaviour of the overall Python installation. +If this PEP is accepted, then commercial Python redistributors may choose to +backport the per-process configuration mechanisms defined in this PEP to base +versions older than Python 2.7.9, *without* also backporting PEP 476's change +to the default behaviour of the overall Python installation. Such a backport would differ from the mechanism proposed in this PEP solely in the default behaviour when ``PYTHONHTTPSVERIFY`` was not set at all: it would @@ -444,7 +271,6 @@ set to anything *other* than ``'0'``, then HTTPS certificate verification should be enabled. - Feature detection ----------------- @@ -506,12 +332,198 @@ inside an activated Python virtual environment. +Backporting PEP 476 to earlier Python versions +============================================== + +The backporting approach described above leaves the default HTTPS certificate +verification behaviour of a Python 2.7 installation unmodified: verifying +certificates still needs to be opted into on a per-connection or per-process +basis. + +To allow the default behaviour of the entire installation to be modified +without breaking backwards compatibility, Red Hat designed a configuration +mechanism for the system Python 2.7 installation in Red Hat Enterprise Linux +7.2+ that provides: + +* an opt-in model that allows the decision to enable HTTPS certificate + verification to be made independently of the decision to upgrade to the + operating system version where the feature was first backported +* the ability for system administrators to set the default behaviour of Python + applications and scripts run directly in the system Python installation +* the ability for the redistributor to consider changing the default behaviour + of *new* installations at some point in the future without impacting existing + installations that have been explicitly configured to skip verifying HTTPS + certificates by default + +As it only affects backports to earlier releases of Python 2.7, this change is +not proposed for inclusion in upstream CPython, but rather is offered as +a recommendation to other redistributors that choose to offer a similar feature +to their users. + +This PEP doesn't take a position on whether or not this particular change is a +good idea - rather, it suggests that *if* a redistributor chooses to go down +the path of making the default behaviour configurable in a version of Python +older than Python 2.7.9, then maintaining a consistent approach across +redistributors would be beneficial for users. + +However, this approach SHOULD NOT be used for any Python installation that +advertises itself as providing Python 2.7.9 or later, as most Python users +will have the reasonable expectation that all such environments will verify +HTTPS certificates by default. + + +Feature detection +----------------- + +The marker attribute on the ``ssl`` module related to this feature is:: + + _cert_verification_config = '' + +This not only makes it straightforward to detect the presence (or absence) of +the capability, it also makes it possible to programmatically determine the +relevant configuration file name. + + +Recommended modifications to the Python standard library +-------------------------------------------------------- + +The recommended approach to backporting the PEP 476 modifications to an earlier +point release is to implement the following changes relative to the default +PEP 476 behaviour implemented in Python 2.7.9+: + +* modify the ``ssl`` module to read a system wide configuration file when the + module is first imported into a Python process +* define a platform default behaviour (either verifying or not verifying HTTPS + certificates) to be used if this configuration file is not present +* support selection between the following three modes of operation: + + * ensure HTTPS certificate verification is enabled + * ensure HTTPS certificate verification is disabled + * delegate the decision to the redistributor providing this Python version + +* set the ``ssl._create_default_https_context`` function to be an alias for + either ``ssl.create_default_context`` or ``ssl._create_unverified_context`` + based on the given configuration setting. + + +Recommended file location +------------------------- + +As the PEP authors are not aware of any vendors providing long-term support +releases targeting Windows, Mac OS X or \*BSD systems, this approach is +currently only specifically defined for Linux system Python installations. + +The recommended configuration file name on Linux systems is +``/etc/python/cert-verification.cfg``. + +The ``.cfg`` filename extension is recommended for consistency with the +``pyvenv.cfg`` used by the ``venv`` module in Python 3's standard library. + + +Recommended file format +----------------------- + +The configuration file should use a ConfigParser ini-style format with a +single section named ``[https]`` containing one required setting ``verify``. + +The suggested section name is taken from the "https" URL schema passed to +affected client APIs. + +Permitted values for ``verify`` are: + +* ``enable``: ensure HTTPS certificate verification is enabled by default +* ``disable``: ensure HTTPS certificate verification is disabled by default +* ``platform_default``: delegate the decision to the redistributor providing + this particular Python version + +If the ``[https]`` section or the ``verify`` setting are missing, or if the +``verify`` setting is set to an unknown value, it should be treated as if the +configuration file is not present. + + +Example implementation +---------------------- + +:: + + _cert_verification_config = '/etc/python/cert-verification.cfg' + + def _get_https_context_factory(): + # Check for a system-wide override of the default behaviour + context_factories = { + 'enable': create_default_context, + 'disable': _create_unverified_context, + 'platform_default': _create_unverified_context, # For now :) + } + import ConfigParser + config = ConfigParser.RawConfigParser() + config.read(_cert_verification_config) + try: + verify_mode = config.get('https', 'verify') + except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): + verify_mode = 'platform_default' + default_factory = context_factories.get('platform_default') + return context_factories.get(verify_mode, default_factory) + + _create_default_https_context = _get_https_context_factory() + + +Security Considerations +----------------------- + +The specific recommendations for this backporting case are designed to work for +privileged, security sensitive processes, even those being run in the following +locked down configuration: + +* run from a locked down administrator controlled directory rather than a normal + user directory (preventing ``sys.path[0]`` based privilege escalation attacks) +* run using the ``-E`` switch (preventing ``PYTHON*`` environment variable based + privilege escalation attacks) +* run using the ``-s`` switch (preventing user site directory based privilege + escalation attacks) +* run using the ``-S`` switch (preventing ``sitecustomize`` based privilege + escalation attacks) + +The intent is that the *only* reason HTTPS verification should be getting +turned off installation wide when using this approach is because: + +* an end user is running a redistributor provided version of CPython rather + than running upstream CPython directly +* that redistributor has decided to provide a smoother migration path to + verifying HTTPS certificates by default than that being provided by the + upstream project +* either the redistributor or the local infrastructure administrator has + determined that it is appropriate to retaing the default pre-2.7.9 behaviour + (at least for the time being) + +Using an administrator controlled configuration file rather than an environment +variable has the essential feature of providing a smoother migration path, even +for applications being run with the ``-E`` switch. + +Interaction with Python virtual environments +-------------------------------------------- + +This setting is scoped by the interpreter installation and affects all Python +processes using that interpreter, regardless of whether or not the interpreter +is being run inside an activated Python virtual environment. + +Origins of this recommendation +------------------------------ + +This recommendation is based on the backporting approach adopted for Red Hat +Enterprise Linux 7.2, as published in the original July 2015 draft of this PEP +and described in detail in `this KnowledgeBase article +`__. Red Hat's patches implementing +this backport for Python 2.7.5 can be found in the `CentOS git repository +`__. + + Recommendation for combined feature backports ============================================= If a redistributor chooses to backport the environment variable based configuration setting from this PEP to a modified Python version that also -implements the configuration file based PEP 476 , then the environment +implements the configuration file based PEP 476 backport, then the environment variable should take precedence over the system-wide configuration setting. This allows the setting to be changed for a given user or application, regardless of the installation-wide default behaviour. -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Tue Dec 8 05:15:30 2015 From: python-checkins at python.org (berker.peksag) Date: Tue, 08 Dec 2015 10:15:30 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2321240=3A_Add_an_abstractmethod_directive_to_mar?= =?utf-8?q?k_abstract_methods_in_the?= Message-ID: <20151208101528.73041.22885@psf.io> https://hg.python.org/cpython/rev/84468e1aea61 changeset: 99508:84468e1aea61 parent: 99506:d6e27eafb4e1 parent: 99507:1d0d8b27a4e6 user: Berker Peksag date: Tue Dec 08 12:15:19 2015 +0200 summary: Issue #21240: Add an abstractmethod directive to mark abstract methods in the docs more explicitly files: Doc/library/importlib.rst | 12 ++++++------ Doc/library/numbers.rst | 2 +- Doc/library/selectors.rst | 8 ++++---- Doc/tools/extensions/pyspecific.py | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -230,7 +230,7 @@ .. deprecated:: 3.3 Use :class:`MetaPathFinder` or :class:`PathEntryFinder` instead. - .. method:: find_module(fullname, path=None) + .. abstractmethod:: find_module(fullname, path=None) An abstact method for finding a :term:`loader` for the specified module. Originally specified in :pep:`302`, this method was meant @@ -453,7 +453,7 @@ :pep:`302` protocol for loading arbitrary resources from the storage back-end. - .. method:: get_data(path) + .. abstractmethod:: get_data(path) An abstract method to return the bytes for the data located at *path*. Loaders that have a file-like storage back-end @@ -489,7 +489,7 @@ .. versionchanged:: 3.4 No longer abstract and a concrete implementation is provided. - .. method:: get_source(fullname) + .. abstractmethod:: get_source(fullname) An abstract method to return the source of a module. It is returned as a text string using :term:`universal newlines`, translating all @@ -546,7 +546,7 @@ when implemented, helps a module to be executed as a script. The ABC represents an optional :pep:`302` protocol. - .. method:: get_filename(fullname) + .. abstractmethod:: get_filename(fullname) An abstract method that is to return the value of :attr:`__file__` for the specified module. If no path is available, :exc:`ImportError` is @@ -586,11 +586,11 @@ .. deprecated:: 3.4 Use :meth:`Loader.exec_module` instead. - .. method:: get_filename(fullname) + .. abstractmethod:: get_filename(fullname) Returns :attr:`path`. - .. method:: get_data(path) + .. abstractmethod:: get_data(path) Reads *path* as a binary file and returns the bytes from it. diff --git a/Doc/library/numbers.rst b/Doc/library/numbers.rst --- a/Doc/library/numbers.rst +++ b/Doc/library/numbers.rst @@ -35,7 +35,7 @@ Abstract. Retrieves the imaginary component of this number. - .. method:: conjugate() + .. abstractmethod:: conjugate() Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate() == (1-3j)``. diff --git a/Doc/library/selectors.rst b/Doc/library/selectors.rst --- a/Doc/library/selectors.rst +++ b/Doc/library/selectors.rst @@ -99,7 +99,7 @@ :class:`BaseSelector` and its concrete implementations support the :term:`context manager` protocol. - .. method:: register(fileobj, events, data=None) + .. abstractmethod:: register(fileobj, events, data=None) Register a file object for selection, monitoring it for I/O events. @@ -112,7 +112,7 @@ :exc:`ValueError` in case of invalid event mask or file descriptor, or :exc:`KeyError` if the file object is already registered. - .. method:: unregister(fileobj) + .. abstractmethod:: unregister(fileobj) Unregister a file object from selection, removing it from monitoring. A file object shall be unregistered prior to being closed. @@ -136,7 +136,7 @@ :exc:`ValueError` in case of invalid event mask or file descriptor, or :exc:`KeyError` if the file object is not registered. - .. method:: select(timeout=None) + .. abstractmethod:: select(timeout=None) Wait until some registered file objects become ready, or the timeout expires. @@ -179,7 +179,7 @@ This returns the :class:`SelectorKey` instance associated to this file object, or raises :exc:`KeyError` if the file object is not registered. - .. method:: get_map() + .. abstractmethod:: get_map() Return a mapping of file objects to selector keys. diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -164,6 +164,19 @@ return PyClassmember.run(self) +class PyAbstractMethod(PyClassmember): + + def handle_signature(self, sig, signode): + ret = super(PyAbstractMethod, self).handle_signature(sig, signode) + signode.insert(0, addnodes.desc_annotation('abstractmethod ', + 'abstractmethod ')) + return ret + + def run(self): + self.name = 'py:method' + return PyClassmember.run(self) + + # Support for documenting version of removal in deprecations class DeprecatedRemoved(Directive): @@ -368,5 +381,6 @@ app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod) app.add_directive_to_domain('py', 'coroutinefunction', PyCoroutineFunction) app.add_directive_to_domain('py', 'coroutinemethod', PyCoroutineMethod) + app.add_directive_to_domain('py', 'abstractmethod', PyAbstractMethod) app.add_directive('miscnews', MiscNews) return {'version': '1.0', 'parallel_read_safe': True} -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 8 05:15:30 2015 From: python-checkins at python.org (berker.peksag) Date: Tue, 08 Dec 2015 10:15:30 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIxMjQw?= =?utf-8?q?=3A_Add_an_abstractmethod_directive_to_mark_abstract_methods_in?= =?utf-8?q?_the?= Message-ID: <20151208101528.98350.18375@psf.io> https://hg.python.org/cpython/rev/1d0d8b27a4e6 changeset: 99507:1d0d8b27a4e6 branch: 3.5 parent: 99504:50711c80ff76 user: Berker Peksag date: Tue Dec 08 12:14:50 2015 +0200 summary: Issue #21240: Add an abstractmethod directive to mark abstract methods in the docs more explicitly files: Doc/library/importlib.rst | 12 ++++++------ Doc/library/numbers.rst | 2 +- Doc/library/selectors.rst | 8 ++++---- Doc/tools/extensions/pyspecific.py | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -230,7 +230,7 @@ .. deprecated:: 3.3 Use :class:`MetaPathFinder` or :class:`PathEntryFinder` instead. - .. method:: find_module(fullname, path=None) + .. abstractmethod:: find_module(fullname, path=None) An abstact method for finding a :term:`loader` for the specified module. Originally specified in :pep:`302`, this method was meant @@ -453,7 +453,7 @@ :pep:`302` protocol for loading arbitrary resources from the storage back-end. - .. method:: get_data(path) + .. abstractmethod:: get_data(path) An abstract method to return the bytes for the data located at *path*. Loaders that have a file-like storage back-end @@ -489,7 +489,7 @@ .. versionchanged:: 3.4 No longer abstract and a concrete implementation is provided. - .. method:: get_source(fullname) + .. abstractmethod:: get_source(fullname) An abstract method to return the source of a module. It is returned as a text string using :term:`universal newlines`, translating all @@ -546,7 +546,7 @@ when implemented, helps a module to be executed as a script. The ABC represents an optional :pep:`302` protocol. - .. method:: get_filename(fullname) + .. abstractmethod:: get_filename(fullname) An abstract method that is to return the value of :attr:`__file__` for the specified module. If no path is available, :exc:`ImportError` is @@ -586,11 +586,11 @@ .. deprecated:: 3.4 Use :meth:`Loader.exec_module` instead. - .. method:: get_filename(fullname) + .. abstractmethod:: get_filename(fullname) Returns :attr:`path`. - .. method:: get_data(path) + .. abstractmethod:: get_data(path) Reads *path* as a binary file and returns the bytes from it. diff --git a/Doc/library/numbers.rst b/Doc/library/numbers.rst --- a/Doc/library/numbers.rst +++ b/Doc/library/numbers.rst @@ -35,7 +35,7 @@ Abstract. Retrieves the imaginary component of this number. - .. method:: conjugate() + .. abstractmethod:: conjugate() Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate() == (1-3j)``. diff --git a/Doc/library/selectors.rst b/Doc/library/selectors.rst --- a/Doc/library/selectors.rst +++ b/Doc/library/selectors.rst @@ -99,7 +99,7 @@ :class:`BaseSelector` and its concrete implementations support the :term:`context manager` protocol. - .. method:: register(fileobj, events, data=None) + .. abstractmethod:: register(fileobj, events, data=None) Register a file object for selection, monitoring it for I/O events. @@ -112,7 +112,7 @@ :exc:`ValueError` in case of invalid event mask or file descriptor, or :exc:`KeyError` if the file object is already registered. - .. method:: unregister(fileobj) + .. abstractmethod:: unregister(fileobj) Unregister a file object from selection, removing it from monitoring. A file object shall be unregistered prior to being closed. @@ -136,7 +136,7 @@ :exc:`ValueError` in case of invalid event mask or file descriptor, or :exc:`KeyError` if the file object is not registered. - .. method:: select(timeout=None) + .. abstractmethod:: select(timeout=None) Wait until some registered file objects become ready, or the timeout expires. @@ -179,7 +179,7 @@ This returns the :class:`SelectorKey` instance associated to this file object, or raises :exc:`KeyError` if the file object is not registered. - .. method:: get_map() + .. abstractmethod:: get_map() Return a mapping of file objects to selector keys. diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -164,6 +164,19 @@ return PyClassmember.run(self) +class PyAbstractMethod(PyClassmember): + + def handle_signature(self, sig, signode): + ret = super(PyAbstractMethod, self).handle_signature(sig, signode) + signode.insert(0, addnodes.desc_annotation('abstractmethod ', + 'abstractmethod ')) + return ret + + def run(self): + self.name = 'py:method' + return PyClassmember.run(self) + + # Support for documenting version of removal in deprecations class DeprecatedRemoved(Directive): @@ -368,5 +381,6 @@ app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod) app.add_directive_to_domain('py', 'coroutinefunction', PyCoroutineFunction) app.add_directive_to_domain('py', 'coroutinemethod', PyCoroutineMethod) + app.add_directive_to_domain('py', 'abstractmethod', PyAbstractMethod) app.add_directive('miscnews', MiscNews) return {'version': '1.0', 'parallel_read_safe': True} -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Tue Dec 8 10:00:17 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 8 Dec 2015 15:00:17 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-08 Message-ID: Results for project Python default, build date 2015-12-08 04:02:46 +0000 commit: 7bb7173cd97a06286ab1f018d0cd7a83735618e1 revision date: 2015-12-08 00:05:06 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.26% 0.32% 10.28% 14.11% :-( pybench 0.16% -0.01% -2.16% 9.09% :-( regex_v8 2.72% 0.56% -3.81% 4.52% :-( nbody 0.06% -0.09% -3.88% 10.72% :-( json_dump_v2 0.22% -0.04% -2.38% 11.93% :-| normal_startup 1.02% 0.25% 0.12% 4.29% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Tue Dec 8 10:00:55 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 8 Dec 2015 15:00:55 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-08 Message-ID: <40c984f1-ec0a-4158-8b45-90ec4603d9f7@irsmsx153.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python 2.7, build date 2015-12-08 08:52:14 +0000 commit: de9ef294a3efb0657ba0e5bee23ecb5ea66c3b67 revision date: 2015-12-06 21:51:53 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.13% -0.30% 2.29% 10.06% :-) pybench 0.15% -0.14% 5.99% 7.19% :-( regex_v8 1.22% 0.81% -2.92% 8.53% :-) nbody 0.11% 0.24% 7.81% 5.04% :-| json_dump_v2 0.22% -0.51% 1.84% 15.80% :-| normal_startup 1.91% 0.40% -1.67% 2.67% :-| ssbench 0.16% 0.82% 1.25% 1.42% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Tue Dec 8 22:20:57 2015 From: python-checkins at python.org (martin.panter) Date: Wed, 09 Dec 2015 03:20:57 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325820=3A_Merge_test=5Fgdb_fixes_from_3=2E5?= Message-ID: <20151209032056.16242.55283@psf.io> https://hg.python.org/cpython/rev/2e5fdb8a8874 changeset: 99510:2e5fdb8a8874 parent: 99508:84468e1aea61 parent: 99509:6902b2024d25 user: Martin Panter date: Wed Dec 09 02:05:03 2015 +0000 summary: Issue #25820: Merge test_gdb fixes from 3.5 files: Lib/test/test_gdb.py | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py --- a/Lib/test/test_gdb.py +++ b/Lib/test/test_gdb.py @@ -89,7 +89,6 @@ # Verify that "gdb" can load our custom hooks, as OS security settings may # disallow this without a customised .gdbinit. -cmd = ['--args', sys.executable] _, gdbpy_errors = run_gdb('--args', sys.executable) if "auto-loading has been declined" in gdbpy_errors: msg = "gdb security settings prevent use of custom hooks: " @@ -171,8 +170,7 @@ # print commands # Use "commands" to generate the arguments with which to invoke "gdb": - args = ["gdb", "--batch", "-nx"] - args += ['--eval-command=%s' % cmd for cmd in commands] + args = ['--eval-command=%s' % cmd for cmd in commands] args += ["--args", sys.executable] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 8 22:20:57 2015 From: python-checkins at python.org (martin.panter) Date: Wed, 09 Dec 2015 03:20:57 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODIw?= =?utf-8?q?=3A_Remove_unused_assignment_and_redundant_GDB_CLI_arguments?= Message-ID: <20151209032056.98344.56920@psf.io> https://hg.python.org/cpython/rev/6902b2024d25 changeset: 99509:6902b2024d25 branch: 3.5 parent: 99507:1d0d8b27a4e6 user: Martin Panter date: Tue Dec 08 21:54:42 2015 +0000 summary: Issue #25820: Remove unused assignment and redundant GDB CLI arguments These were added in revision b71cda2f48c6. files: Lib/test/test_gdb.py | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py --- a/Lib/test/test_gdb.py +++ b/Lib/test/test_gdb.py @@ -89,7 +89,6 @@ # Verify that "gdb" can load our custom hooks, as OS security settings may # disallow this without a customised .gdbinit. -cmd = ['--args', sys.executable] _, gdbpy_errors = run_gdb('--args', sys.executable) if "auto-loading has been declined" in gdbpy_errors: msg = "gdb security settings prevent use of custom hooks: " @@ -171,8 +170,7 @@ # print commands # Use "commands" to generate the arguments with which to invoke "gdb": - args = ["gdb", "--batch", "-nx"] - args += ['--eval-command=%s' % cmd for cmd in commands] + args = ['--eval-command=%s' % cmd for cmd in commands] args += ["--args", sys.executable] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 9 03:03:38 2015 From: python-checkins at python.org (zach.ware) Date: Wed, 09 Dec 2015 08:03:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Clarify_that_o?= =?utf-8?q?nly_*documentation*_bugs_should_go_to_docs=40python=2Eorg?= Message-ID: <20151209080337.1968.26994@psf.io> https://hg.python.org/cpython/rev/8459f530aaed changeset: 99511:8459f530aaed branch: 2.7 parent: 99481:de9ef294a3ef user: Zachary Ware date: Wed Dec 09 01:53:44 2015 -0600 summary: Clarify that only *documentation* bugs should go to docs at python.org files: Doc/bugs.rst | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Doc/bugs.rst b/Doc/bugs.rst --- a/Doc/bugs.rst +++ b/Doc/bugs.rst @@ -16,7 +16,8 @@ please submit a bug report on the :ref:`tracker `. If you have a suggestion how to fix it, include that as well. -If you're short on time, you can also email your bug report to docs at python.org. +If you're short on time, you can also email documentation bug reports to +docs at python.org (behavioral bugs can be sent to python-list at python.org). 'docs@' is a mailing list run by volunteers; your request will be noticed, though it may take a while to be processed. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 9 03:03:38 2015 From: python-checkins at python.org (zach.ware) Date: Wed, 09 Dec 2015 08:03:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Clarify_that_o?= =?utf-8?q?nly_*documentation*_bugs_should_go_to_docs=40python=2Eorg?= Message-ID: <20151209080338.98356.42344@psf.io> https://hg.python.org/cpython/rev/9e72d13d4b4d changeset: 99512:9e72d13d4b4d branch: 3.5 parent: 99509:6902b2024d25 user: Zachary Ware date: Wed Dec 09 01:53:44 2015 -0600 summary: Clarify that only *documentation* bugs should go to docs at python.org files: Doc/bugs.rst | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Doc/bugs.rst b/Doc/bugs.rst --- a/Doc/bugs.rst +++ b/Doc/bugs.rst @@ -16,7 +16,8 @@ please submit a bug report on the :ref:`tracker `. If you have a suggestion how to fix it, include that as well. -If you're short on time, you can also email your bug report to docs at python.org. +If you're short on time, you can also email documentation bug reports to +docs at python.org (behavioral bugs can be sent to python-list at python.org). 'docs@' is a mailing list run by volunteers; your request will be noticed, though it may take a while to be processed. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 9 03:03:38 2015 From: python-checkins at python.org (zach.ware) Date: Wed, 09 Dec 2015 08:03:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_with_3=2E5?= Message-ID: <20151209080338.16244.15128@psf.io> https://hg.python.org/cpython/rev/e587858aa63d changeset: 99513:e587858aa63d parent: 99510:2e5fdb8a8874 parent: 99512:9e72d13d4b4d user: Zachary Ware date: Wed Dec 09 02:03:18 2015 -0600 summary: Merge with 3.5 files: Doc/bugs.rst | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Doc/bugs.rst b/Doc/bugs.rst --- a/Doc/bugs.rst +++ b/Doc/bugs.rst @@ -16,7 +16,8 @@ please submit a bug report on the :ref:`tracker `. If you have a suggestion how to fix it, include that as well. -If you're short on time, you can also email your bug report to docs at python.org. +If you're short on time, you can also email documentation bug reports to +docs at python.org (behavioral bugs can be sent to python-list at python.org). 'docs@' is a mailing list run by volunteers; your request will be noticed, though it may take a while to be processed. -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Wed Dec 9 03:43:24 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 09 Dec 2015 08:43:24 +0000 Subject: [Python-checkins] Daily reference leaks (2e5fdb8a8874): sum=4 Message-ID: <20151209084324.26595.82504@psf.io> results for 2e5fdb8a8874 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogVTDvIi', '--timeout', '7200'] From python-checkins at python.org Wed Dec 9 04:28:07 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 09 Dec 2015 09:28:07 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fixed_possible?= =?utf-8?q?_leak_in_ElementTree=2EElement=2Eiter=28=29=2E?= Message-ID: <20151209092807.5513.73110@psf.io> https://hg.python.org/cpython/rev/6633f29771db changeset: 99514:6633f29771db branch: 3.5 parent: 99512:9e72d13d4b4d user: Serhiy Storchaka date: Wed Dec 09 11:27:07 2015 +0200 summary: Fixed possible leak in ElementTree.Element.iter(). files: Modules/_elementtree.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1373,6 +1373,17 @@ _elementtree_Element_iter_impl(ElementObject *self, PyObject *tag) /*[clinic end generated code: output=3f49f9a862941cc5 input=774d5b12e573aedd]*/ { + if (PyUnicode_Check(tag)) { + if (PyUnicode_READY(tag) < 0) + return NULL; + if (PyUnicode_GET_LENGTH(tag) == 1 && PyUnicode_READ_CHAR(tag, 0) == '*') + tag = Py_None; + } + else if (PyBytes_Check(tag)) { + if (PyBytes_GET_SIZE(tag) == 1 && *PyBytes_AS_STRING(tag) == '*') + tag = Py_None; + } + return create_elementiter(self, tag, 0); } @@ -2238,17 +2249,6 @@ if (!it) return NULL; - if (PyUnicode_Check(tag)) { - if (PyUnicode_READY(tag) < 0) - return NULL; - if (PyUnicode_GET_LENGTH(tag) == 1 && PyUnicode_READ_CHAR(tag, 0) == '*') - tag = Py_None; - } - else if (PyBytes_Check(tag)) { - if (PyBytes_GET_SIZE(tag) == 1 && *PyBytes_AS_STRING(tag) == '*') - tag = Py_None; - } - Py_INCREF(tag); it->sought_tag = tag; it->root_done = 0; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 9 04:28:08 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 09 Dec 2015 09:28:08 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Fixed_possible_leak_in_ElementTree=2EElement=2Eiter=28?= =?utf-8?b?KS4=?= Message-ID: <20151209092807.98362.80948@psf.io> https://hg.python.org/cpython/rev/bb8b75c6bfdf changeset: 99515:bb8b75c6bfdf parent: 99513:e587858aa63d parent: 99514:6633f29771db user: Serhiy Storchaka date: Wed Dec 09 11:27:34 2015 +0200 summary: Fixed possible leak in ElementTree.Element.iter(). files: Modules/_elementtree.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1373,6 +1373,17 @@ _elementtree_Element_iter_impl(ElementObject *self, PyObject *tag) /*[clinic end generated code: output=3f49f9a862941cc5 input=774d5b12e573aedd]*/ { + if (PyUnicode_Check(tag)) { + if (PyUnicode_READY(tag) < 0) + return NULL; + if (PyUnicode_GET_LENGTH(tag) == 1 && PyUnicode_READ_CHAR(tag, 0) == '*') + tag = Py_None; + } + else if (PyBytes_Check(tag)) { + if (PyBytes_GET_SIZE(tag) == 1 && *PyBytes_AS_STRING(tag) == '*') + tag = Py_None; + } + return create_elementiter(self, tag, 0); } @@ -2236,17 +2247,6 @@ if (!it) return NULL; - if (PyUnicode_Check(tag)) { - if (PyUnicode_READY(tag) < 0) - return NULL; - if (PyUnicode_GET_LENGTH(tag) == 1 && PyUnicode_READ_CHAR(tag, 0) == '*') - tag = Py_None; - } - else if (PyBytes_Check(tag)) { - if (PyBytes_GET_SIZE(tag) == 1 && *PyBytes_AS_STRING(tag) == '*') - tag = Py_None; - } - Py_INCREF(tag); it->sought_tag = tag; it->root_done = 0; -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Wed Dec 9 08:09:56 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 9 Dec 2015 13:09:56 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-09 Message-ID: <4964450b-eaeb-497f-b8b9-24aa4b3e4183@irsmsx104.ger.corp.intel.com> Results for project Python default, build date 2015-12-09 04:02:14 +0000 commit: 2e5fdb8a8874dd85cab9fd6f08639276395cfda3 revision date: 2015-12-09 02:05:03 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.21% 0.66% 10.87% 13.70% :-( pybench 0.18% 0.03% -2.12% 9.29% :-( regex_v8 2.74% 0.05% -3.76% 5.36% :-( nbody 0.05% 0.13% -3.75% 11.40% :-( json_dump_v2 0.23% 0.16% -2.22% 10.93% :-| normal_startup 0.86% -0.35% -0.09% 4.47% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Wed Dec 9 08:10:33 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 9 Dec 2015 13:10:33 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-09 Message-ID: No new revisions. Here are the previous results: Results for project Python 2.7, build date 2015-12-09 04:51:39 +0000 commit: de9ef294a3efb0657ba0e5bee23ecb5ea66c3b67 revision date: 2015-12-06 21:51:53 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.13% -0.30% 2.29% 10.06% :-) pybench 0.15% -0.14% 5.99% 7.19% :-( regex_v8 1.22% 0.81% -2.92% 8.53% :-) nbody 0.11% 0.24% 7.81% 5.04% :-| json_dump_v2 0.22% -0.51% 1.84% 15.80% :-| normal_startup 1.91% 0.40% -1.67% 2.67% :-| ssbench 0.16% 0.82% 1.25% 1.42% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Wed Dec 9 12:49:34 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 09 Dec 2015 17:49:34 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fixed_possible?= =?utf-8?q?_leaks_in_ElementTree_parser=2E?= Message-ID: <20151209174934.16224.63173@psf.io> https://hg.python.org/cpython/rev/002d8b981128 changeset: 99518:002d8b981128 branch: 2.7 parent: 99511:8459f530aaed user: Serhiy Storchaka date: Wed Dec 09 19:44:30 2015 +0200 summary: Fixed possible leaks in ElementTree parser. files: Modules/_elementtree.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2227,8 +2227,10 @@ /* attributes */ if (attrib_in[0]) { attrib = PyDict_New(); - if (!attrib) + if (!attrib) { + Py_DECREF(tag); return; + } while (attrib_in[0] && attrib_in[1]) { PyObject* key = makeuniversal(self, attrib_in[0]); PyObject* value = makestring(attrib_in[1], strlen(attrib_in[1])); @@ -2236,6 +2238,7 @@ Py_XDECREF(value); Py_XDECREF(key); Py_DECREF(attrib); + Py_DECREF(tag); return; } ok = PyDict_SetItem(attrib, key, value); @@ -2243,6 +2246,7 @@ Py_DECREF(key); if (ok < 0) { Py_DECREF(attrib); + Py_DECREF(tag); return; } attrib_in += 2; @@ -2260,8 +2264,10 @@ if (attrib == Py_None) { Py_DECREF(attrib); attrib = PyDict_New(); - if (!attrib) + if (!attrib) { + Py_DECREF(tag); return; + } } res = PyObject_CallFunction(self->handle_start, "OO", tag, attrib); } else -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 9 12:49:34 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 09 Dec 2015 17:49:34 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Fixed_possible_leaks_in_ElementTree_parser=2E?= Message-ID: <20151209174934.16250.55173@psf.io> https://hg.python.org/cpython/rev/5176e8a2e258 changeset: 99517:5176e8a2e258 parent: 99515:bb8b75c6bfdf parent: 99516:7cb05201f93b user: Serhiy Storchaka date: Wed Dec 09 19:45:07 2015 +0200 summary: Fixed possible leaks in ElementTree parser. files: Modules/_elementtree.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2934,8 +2934,10 @@ /* attributes */ if (attrib_in[0]) { attrib = PyDict_New(); - if (!attrib) + if (!attrib) { + Py_DECREF(tag); return; + } while (attrib_in[0] && attrib_in[1]) { PyObject* key = makeuniversal(self, attrib_in[0]); PyObject* value = PyUnicode_DecodeUTF8(attrib_in[1], strlen(attrib_in[1]), "strict"); @@ -2943,6 +2945,7 @@ Py_XDECREF(value); Py_XDECREF(key); Py_DECREF(attrib); + Py_DECREF(tag); return; } ok = PyDict_SetItem(attrib, key, value); @@ -2950,6 +2953,7 @@ Py_DECREF(key); if (ok < 0) { Py_DECREF(attrib); + Py_DECREF(tag); return; } attrib_in += 2; @@ -2957,8 +2961,10 @@ } else { /* Pass an empty dictionary on */ attrib = PyDict_New(); - if (!attrib) + if (!attrib) { + Py_DECREF(tag); return; + } } if (TreeBuilder_CheckExact(self->target)) { -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 9 12:49:34 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 09 Dec 2015 17:49:34 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fixed_possible?= =?utf-8?q?_leaks_in_ElementTree_parser=2E?= Message-ID: <20151209174934.98358.50959@psf.io> https://hg.python.org/cpython/rev/7cb05201f93b changeset: 99516:7cb05201f93b branch: 3.5 parent: 99514:6633f29771db user: Serhiy Storchaka date: Wed Dec 09 19:44:30 2015 +0200 summary: Fixed possible leaks in ElementTree parser. files: Modules/_elementtree.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2935,8 +2935,10 @@ /* attributes */ if (attrib_in[0]) { attrib = PyDict_New(); - if (!attrib) + if (!attrib) { + Py_DECREF(tag); return; + } while (attrib_in[0] && attrib_in[1]) { PyObject* key = makeuniversal(self, attrib_in[0]); PyObject* value = PyUnicode_DecodeUTF8(attrib_in[1], strlen(attrib_in[1]), "strict"); @@ -2944,6 +2946,7 @@ Py_XDECREF(value); Py_XDECREF(key); Py_DECREF(attrib); + Py_DECREF(tag); return; } ok = PyDict_SetItem(attrib, key, value); @@ -2951,6 +2954,7 @@ Py_DECREF(key); if (ok < 0) { Py_DECREF(attrib); + Py_DECREF(tag); return; } attrib_in += 2; @@ -2958,8 +2962,10 @@ } else { /* Pass an empty dictionary on */ attrib = PyDict_New(); - if (!attrib) + if (!attrib) { + Py_DECREF(tag); return; + } } if (TreeBuilder_CheckExact(self->target)) { -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 10 02:52:28 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 10 Dec 2015 07:52:28 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325638=3A_Optimize?= =?utf-8?q?d_ElementTree_parsing=3B_it_is_now_10=25_faster=2E?= Message-ID: <20151210075227.6040.56123@psf.io> https://hg.python.org/cpython/rev/1fe904420c20 changeset: 99519:1fe904420c20 parent: 99517:5176e8a2e258 user: Serhiy Storchaka date: Thu Dec 10 09:51:53 2015 +0200 summary: Issue #25638: Optimized ElementTree parsing; it is now 10% faster. files: Misc/NEWS | 1 + Modules/_elementtree.c | 29 ++++++++++++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -110,6 +110,7 @@ ------- - Issue #25638: Optimized ElementTree.iterparse(); it is now 2x faster. + Optimized ElementTree parsing; it is now 10% faster. - Issue #25761: Improved detecting errors in broken pickle data. diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2491,10 +2491,17 @@ self->data = NULL; } - if (self->element_factory && self->element_factory != Py_None) { + if (!self->element_factory || self->element_factory == Py_None) { + node = create_new_element(tag, attrib); + } else if (attrib == Py_None) { + attrib = PyDict_New(); + if (!attrib) + return NULL; node = PyObject_CallFunction(self->element_factory, "OO", tag, attrib); - } else { - node = create_new_element(tag, attrib); + Py_DECREF(attrib); + } + else { + node = PyObject_CallFunction(self->element_factory, "OO", tag, attrib); } if (!node) { return NULL; @@ -2959,12 +2966,8 @@ attrib_in += 2; } } else { - /* Pass an empty dictionary on */ - attrib = PyDict_New(); - if (!attrib) { - Py_DECREF(tag); - return; - } + Py_INCREF(Py_None); + attrib = Py_None; } if (TreeBuilder_CheckExact(self->target)) { @@ -2973,6 +2976,14 @@ tag, attrib); } else if (self->handle_start) { + if (attrib == Py_None) { + Py_DECREF(attrib); + attrib = PyDict_New(); + if (!attrib) { + Py_DECREF(tag); + return; + } + } res = PyObject_CallFunction(self->handle_start, "OO", tag, attrib); } else res = NULL; -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Thu Dec 10 03:41:12 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 10 Dec 2015 08:41:12 +0000 Subject: [Python-checkins] Daily reference leaks (5176e8a2e258): sum=4 Message-ID: <20151210084112.11511.8797@psf.io> results for 5176e8a2e258 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogy07zNf', '--timeout', '7200'] From lp_benchmark_robot at intel.com Thu Dec 10 09:31:47 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 10 Dec 2015 14:31:47 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-10 Message-ID: <48f05a2b-5d04-40b2-b02a-801f54ca652b@irsmsx106.ger.corp.intel.com> Results for project Python default, build date 2015-12-10 04:02:17 +0000 commit: 5176e8a2e2589b707e94020b86cbbb2831af4790 revision date: 2015-12-09 17:45:07 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.25% -0.46% 10.47% 14.50% :-( pybench 0.14% 0.04% -2.08% 9.26% :-( regex_v8 2.73% -0.10% -3.86% 4.87% :-( nbody 0.06% -0.00% -3.75% 13.69% :-( json_dump_v2 0.24% -0.05% -2.27% 11.22% :-| normal_startup 1.01% 0.04% -0.20% 4.68% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Thu Dec 10 09:33:28 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 10 Dec 2015 14:33:28 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-10 Message-ID: Results for project Python 2.7, build date 2015-12-10 04:49:23 +0000 commit: 002d8b981128cbee6fb9f1529a66c756ad24718b revision date: 2015-12-09 17:44:30 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-| django_v2 0.38% -1.07% 1.25% 11.43% :-) pybench 0.15% 0.16% 6.14% 7.18% :-( regex_v8 1.13% 0.38% -2.53% 7.93% :-) nbody 0.11% 0.07% 7.87% 4.81% :-| json_dump_v2 0.24% -0.08% 1.76% 15.65% :-| normal_startup 2.09% -0.20% -1.87% 2.56% :-| ssbench 0.61% -0.22% 1.03% 1.29% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Thu Dec 10 22:55:59 2015 From: python-checkins at python.org (martin.panter) Date: Fri, 11 Dec 2015 03:55:59 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2314285=3A_Merge_runpy_fix_from_3=2E5?= Message-ID: <20151211035559.16228.44292@psf.io> https://hg.python.org/cpython/rev/a526ebcfd31d changeset: 99521:a526ebcfd31d parent: 99519:1fe904420c20 parent: 99520:3202d143a194 user: Martin Panter date: Fri Dec 11 03:35:31 2015 +0000 summary: Issue #14285: Merge runpy fix from 3.5 files: Doc/library/runpy.rst | 3 +- Doc/using/cmdline.rst | 2 +- Lib/runpy.py | 22 ++++++++++++++++--- Lib/test/test_cmd_line_script.py | 1 + Lib/test/test_runpy.py | 9 ++++++++ 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Doc/library/runpy.rst b/Doc/library/runpy.rst --- a/Doc/library/runpy.rst +++ b/Doc/library/runpy.rst @@ -36,7 +36,8 @@ import mechanism (refer to :pep:`302` for details) and then executed in a fresh module namespace. - If the supplied module name refers to a package rather than a normal + The *mod_name* argument should be an absolute module name. + If the module name refers to a package rather than a normal module, then that package is imported and the ``__main__`` submodule within that package is then executed and the resulting module globals dictionary returned. diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -77,7 +77,7 @@ the :mod:`__main__` module. Since the argument is a *module* name, you must not give a file extension - (``.py``). The ``module-name`` should be a valid Python module name, but + (``.py``). The module name should be a valid absolute Python module name, but the implementation may not always enforce this (e.g. it may allow you to use a name that includes a hyphen). diff --git a/Lib/runpy.py b/Lib/runpy.py --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -100,6 +100,21 @@ # Helper to get the loader, code and filename for a module def _get_module_details(mod_name, error=ImportError): + if mod_name.startswith("."): + raise error("Relative module names not supported") + pkg_name, _, _ = mod_name.rpartition(".") + if pkg_name: + # Try importing the parent to avoid catching initialization errors + try: + __import__(pkg_name) + except ImportError as e: + # If the parent or higher ancestor package is missing, let the + # error be raised by find_spec() below and then be caught. But do + # not allow other errors to be caught. + if e.name is None or (e.name != pkg_name and + not pkg_name.startswith(e.name + ".")): + raise + try: spec = importlib.util.find_spec(mod_name) except (ImportError, AttributeError, TypeError, ValueError) as ex: @@ -107,17 +122,16 @@ # importlib, where the latter raises other errors for cases where # pkgutil previously raised ImportError msg = "Error while finding spec for {!r} ({}: {})" - raise error(msg.format(mod_name, type(ex), ex)) from ex + raise error(msg.format(mod_name, type(ex).__name__, ex)) from ex if spec is None: raise error("No module named %s" % mod_name) if spec.submodule_search_locations is not None: if mod_name == "__main__" or mod_name.endswith(".__main__"): raise error("Cannot use package as __main__ module") - __import__(mod_name) # Do not catch exceptions initializing package try: pkg_main_name = mod_name + ".__main__" - return _get_module_details(pkg_main_name) - except ImportError as e: + return _get_module_details(pkg_main_name, error) + except error as e: raise error(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name)) loader = spec.loader diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -433,6 +433,7 @@ ('importlib', br'No module named.*' br'is a package and cannot be directly executed'), ('importlib.nonexistant', br'No module named'), + ('.unittest', br'Relative module names not supported'), ) for name, regex in tests: with self.subTest(name): diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -197,8 +197,11 @@ self.expect_import_error("sys.imp.eric") self.expect_import_error("os.path.half") self.expect_import_error("a.bee") + # Relative names not allowed self.expect_import_error(".howard") self.expect_import_error("..eaten") + self.expect_import_error(".test_runpy") + self.expect_import_error(".unittest") # Package without __main__.py self.expect_import_error("multiprocessing") @@ -460,6 +463,12 @@ self.assertNotIn("finding spec", format(err)) else: self.fail("Nothing raised; expected {}".format(name)) + try: + run_module(mod_name + ".submodule") + except exception as err: + self.assertNotIn("finding spec", format(err)) + else: + self.fail("Nothing raised; expected {}".format(name)) def test_run_package_in_namespace_package(self): for depth in range(1, 4): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 10 22:55:58 2015 From: python-checkins at python.org (martin.panter) Date: Fri, 11 Dec 2015 03:55:58 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzE0Mjg1?= =?utf-8?q?=3A_Do_not_catch_exceptions_initializing_any_ancestor_package?= Message-ID: <20151211035558.30449.60637@psf.io> https://hg.python.org/cpython/rev/3202d143a194 changeset: 99520:3202d143a194 branch: 3.5 parent: 99516:7cb05201f93b user: Martin Panter date: Thu Dec 10 06:47:06 2015 +0000 summary: Issue #14285: Do not catch exceptions initializing any ancestor package The previous fix only handled the case of the parent package of __main__ failing to initialize. Also make the "Error while finding spec" formatting slightly more appealing, and document and test that the module name must be absolute. files: Doc/library/runpy.rst | 3 +- Doc/using/cmdline.rst | 2 +- Lib/runpy.py | 22 ++++++++++++++++--- Lib/test/test_cmd_line_script.py | 1 + Lib/test/test_runpy.py | 9 ++++++++ 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Doc/library/runpy.rst b/Doc/library/runpy.rst --- a/Doc/library/runpy.rst +++ b/Doc/library/runpy.rst @@ -36,7 +36,8 @@ import mechanism (refer to :pep:`302` for details) and then executed in a fresh module namespace. - If the supplied module name refers to a package rather than a normal + The *mod_name* argument should be an absolute module name. + If the module name refers to a package rather than a normal module, then that package is imported and the ``__main__`` submodule within that package is then executed and the resulting module globals dictionary returned. diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -77,7 +77,7 @@ the :mod:`__main__` module. Since the argument is a *module* name, you must not give a file extension - (``.py``). The ``module-name`` should be a valid Python module name, but + (``.py``). The module name should be a valid absolute Python module name, but the implementation may not always enforce this (e.g. it may allow you to use a name that includes a hyphen). diff --git a/Lib/runpy.py b/Lib/runpy.py --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -100,6 +100,21 @@ # Helper to get the loader, code and filename for a module def _get_module_details(mod_name, error=ImportError): + if mod_name.startswith("."): + raise error("Relative module names not supported") + pkg_name, _, _ = mod_name.rpartition(".") + if pkg_name: + # Try importing the parent to avoid catching initialization errors + try: + __import__(pkg_name) + except ImportError as e: + # If the parent or higher ancestor package is missing, let the + # error be raised by find_spec() below and then be caught. But do + # not allow other errors to be caught. + if e.name is None or (e.name != pkg_name and + not pkg_name.startswith(e.name + ".")): + raise + try: spec = importlib.util.find_spec(mod_name) except (ImportError, AttributeError, TypeError, ValueError) as ex: @@ -107,17 +122,16 @@ # importlib, where the latter raises other errors for cases where # pkgutil previously raised ImportError msg = "Error while finding spec for {!r} ({}: {})" - raise error(msg.format(mod_name, type(ex), ex)) from ex + raise error(msg.format(mod_name, type(ex).__name__, ex)) from ex if spec is None: raise error("No module named %s" % mod_name) if spec.submodule_search_locations is not None: if mod_name == "__main__" or mod_name.endswith(".__main__"): raise error("Cannot use package as __main__ module") - __import__(mod_name) # Do not catch exceptions initializing package try: pkg_main_name = mod_name + ".__main__" - return _get_module_details(pkg_main_name) - except ImportError as e: + return _get_module_details(pkg_main_name, error) + except error as e: raise error(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name)) loader = spec.loader diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -433,6 +433,7 @@ ('importlib', br'No module named.*' br'is a package and cannot be directly executed'), ('importlib.nonexistant', br'No module named'), + ('.unittest', br'Relative module names not supported'), ) for name, regex in tests: with self.subTest(name): diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -197,8 +197,11 @@ self.expect_import_error("sys.imp.eric") self.expect_import_error("os.path.half") self.expect_import_error("a.bee") + # Relative names not allowed self.expect_import_error(".howard") self.expect_import_error("..eaten") + self.expect_import_error(".test_runpy") + self.expect_import_error(".unittest") # Package without __main__.py self.expect_import_error("multiprocessing") @@ -460,6 +463,12 @@ self.assertNotIn("finding spec", format(err)) else: self.fail("Nothing raised; expected {}".format(name)) + try: + run_module(mod_name + ".submodule") + except exception as err: + self.assertNotIn("finding spec", format(err)) + else: + self.fail("Nothing raised; expected {}".format(name)) def test_run_package_in_namespace_package(self): for depth in range(1, 4): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 10 23:08:59 2015 From: python-checkins at python.org (larry.hastings) Date: Fri, 11 Dec 2015 04:08:59 +0000 Subject: [Python-checkins] =?utf-8?q?release=3A_add-to-pydotorg_now_handle?= =?utf-8?q?s_the_=2Eexe_installers_for_3=2E5+=2E?= Message-ID: <20151211040859.6036.96138@psf.io> https://hg.python.org/release/rev/8ac8ddf2c7d6 changeset: 103:8ac8ddf2c7d6 user: Larry Hastings date: Thu Dec 10 20:08:56 2015 -0800 summary: add-to-pydotorg now handles the .exe installers for 3.5+. It sets "download button" on three files right now: * .exe without "amd64" or "webinstall" for Windows * 10.6 for OS X * .xz for Linux files: add-to-pydotorg.py | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/add-to-pydotorg.py b/add-to-pydotorg.py --- a/add-to-pydotorg.py +++ b/add-to-pydotorg.py @@ -23,13 +23,13 @@ Georg Brandl, March 2014. """ +import hashlib +import json import os +from os import path import re import sys -import json import time -import hashlib -from os import path import requests @@ -117,7 +117,8 @@ download_button = 'tar.xz' in rfile or 'macosx10.6.dmg' in rfile or 'macosx10.6.pkg' in rfile or - ('.msi' in rfile and not 'amd64' in rfile), + (rfile.endswith(('.msi', '.exe')) + and not ('amd64' in rfile or 'webinstall' in rfile)), ) if os.path.exists(ftp_root + "%s/%s.asc" % (base_version(release), rfile)): d["gpg_signature_file"] = sigfile_for(base_version(release), rfile) -- Repository URL: https://hg.python.org/release From python-checkins at python.org Fri Dec 11 01:04:43 2015 From: python-checkins at python.org (martin.panter) Date: Fri, 11 Dec 2015 06:04:43 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NzY0?= =?utf-8?q?=3A_Skip_fork_failure_test_when_run_as_root?= Message-ID: <20151211060443.5491.76259@psf.io> https://hg.python.org/cpython/rev/fe844253cd44 changeset: 99523:fe844253cd44 branch: 3.5 user: Martin Panter date: Fri Dec 11 05:40:14 2015 +0000 summary: Issue #25764: Skip fork failure test when run as root files: Lib/test/test_subprocess.py | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1525,10 +1525,14 @@ [_, hard] = limits setrlimit(RLIMIT_NPROC, (0, hard)) self.addCleanup(setrlimit, RLIMIT_NPROC, limits) - # Forking should raise EAGAIN, translated to BlockingIOError - with self.assertRaises(BlockingIOError): + try: subprocess.call([sys.executable, '-c', ''], preexec_fn=lambda: None) + except BlockingIOError: + # Forking should raise EAGAIN, translated to BlockingIOError + pass + else: + self.skipTest('RLIMIT_NPROC had no effect; probably superuser') def test_args_string(self): # args is a string -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 11 01:04:43 2015 From: python-checkins at python.org (martin.panter) Date: Fri, 11 Dec 2015 06:04:43 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325764=3A_Merge_fix_for_root_user_from_3=2E5?= Message-ID: <20151211060443.11505.1332@psf.io> https://hg.python.org/cpython/rev/2f9541cab936 changeset: 99525:2f9541cab936 parent: 99524:360c1326d8d1 parent: 99523:fe844253cd44 user: Martin Panter date: Fri Dec 11 05:42:26 2015 +0000 summary: Issue #25764: Merge fix for root user from 3.5 files: Lib/test/test_subprocess.py | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1525,10 +1525,14 @@ [_, hard] = limits setrlimit(RLIMIT_NPROC, (0, hard)) self.addCleanup(setrlimit, RLIMIT_NPROC, limits) - # Forking should raise EAGAIN, translated to BlockingIOError - with self.assertRaises(BlockingIOError): + try: subprocess.call([sys.executable, '-c', ''], preexec_fn=lambda: None) + except BlockingIOError: + # Forking should raise EAGAIN, translated to BlockingIOError + pass + else: + self.skipTest('RLIMIT_NPROC had no effect; probably superuser') def test_args_string(self): # args is a string -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 11 01:04:43 2015 From: python-checkins at python.org (martin.panter) Date: Fri, 11 Dec 2015 06:04:43 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2322341=3A_Merge_CRC_doc_from_3=2E5?= Message-ID: <20151211060443.90211.96776@psf.io> https://hg.python.org/cpython/rev/360c1326d8d1 changeset: 99524:360c1326d8d1 parent: 99521:a526ebcfd31d parent: 99522:03c4ca1a34e2 user: Martin Panter date: Fri Dec 11 05:41:48 2015 +0000 summary: Issue #22341: Merge CRC doc from 3.5 files: Doc/library/binascii.rst | 23 ++++++++--------- Doc/library/zlib.rst | 37 +++++++++++---------------- Lib/gzip.py | 8 +++--- Lib/tarfile.py | 8 +----- Lib/test/test_zlib.py | 13 +++------ Lib/zipfile.py | 8 +++--- 6 files changed, 39 insertions(+), 58 deletions(-) diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst --- a/Doc/library/binascii.rst +++ b/Doc/library/binascii.rst @@ -115,15 +115,16 @@ possibly the last fragment). -.. function:: crc_hqx(data, crc) +.. function:: crc_hqx(data, value) - Compute the binhex4 crc value of *data*, starting with an initial *crc* and - returning the result. + Compute the binhex4 crc value of *data*, starting with *value* as the + initial crc, and return the result. -.. function:: crc32(data[, crc]) +.. function:: crc32(data[, value]) - Compute CRC-32, the 32-bit checksum of data, starting with an initial crc. This + Compute CRC-32, the 32-bit checksum of *data*, starting with an + initial CRC of *value*. The default initial CRC is zero. The algorithm is consistent with the ZIP file checksum. Since the algorithm is designed for use as a checksum algorithm, it is not suitable for use as a general hash algorithm. Use as follows:: @@ -131,15 +132,13 @@ print(binascii.crc32(b"hello world")) # Or, in two pieces: crc = binascii.crc32(b"hello") - crc = binascii.crc32(b" world", crc) & 0xffffffff + crc = binascii.crc32(b" world", crc) print('crc32 = {:#010x}'.format(crc)) -.. note:: - To generate the same numeric value across all Python versions and - platforms use crc32(data) & 0xffffffff. If you are only using - the checksum in packed binary format this is not necessary as the - return value is the correct 32bit binary representation - regardless of sign. + .. versionchanged:: 3.0 + The result is always unsigned. + To generate the same numeric value across all Python versions and + platforms, use ``crc32(data) & 0xffffffff``. .. function:: b2a_hex(data) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -31,22 +31,19 @@ .. function:: adler32(data[, value]) Computes an Adler-32 checksum of *data*. (An Adler-32 checksum is almost as - reliable as a CRC32 but can be computed much more quickly.) If *value* is - present, it is used as the starting value of the checksum; otherwise, a fixed - default value is used. This allows computing a running checksum over the + reliable as a CRC32 but can be computed much more quickly.) The result + is an unsigned 32-bit integer. If *value* is present, it is used as + the starting value of the checksum; otherwise, a default value of 1 + is used. Passing in *value* allows computing a running checksum over the concatenation of several inputs. The algorithm is not cryptographically strong, and should not be used for authentication or digital signatures. Since the algorithm is designed for use as a checksum algorithm, it is not suitable for use as a general hash algorithm. - Always returns an unsigned 32-bit integer. - -.. note:: - To generate the same numeric value across all Python versions and - platforms use adler32(data) & 0xffffffff. If you are only using - the checksum in packed binary format this is not necessary as the - return value is the correct 32bit binary representation - regardless of sign. + .. versionchanged:: 3.0 + Always returns an unsigned value. + To generate the same numeric value across all Python versions and + platforms, use ``adler32(data) & 0xffffffff``. .. function:: compress(data[, level]) @@ -97,23 +94,19 @@ single: Cyclic Redundancy Check single: checksum; Cyclic Redundancy Check - Computes a CRC (Cyclic Redundancy Check) checksum of *data*. If *value* is - present, it is used as the starting value of the checksum; otherwise, a fixed - default value is used. This allows computing a running checksum over the + Computes a CRC (Cyclic Redundancy Check) checksum of *data*. The + result is an unsigned 32-bit integer. If *value* is present, it is used + as the starting value of the checksum; otherwise, a default value of 0 + is used. Passing in *value* allows computing a running checksum over the concatenation of several inputs. The algorithm is not cryptographically strong, and should not be used for authentication or digital signatures. Since the algorithm is designed for use as a checksum algorithm, it is not suitable for use as a general hash algorithm. - Always returns an unsigned 32-bit integer. - - .. note:: - + .. versionchanged:: 3.0 + Always returns an unsigned value. To generate the same numeric value across all Python versions and - platforms, use ``crc32(data) & 0xffffffff``. If you are only using - the checksum in packed binary format this is not necessary as the - return value is the correct 32-bit binary representation - regardless of sign. + platforms, use ``crc32(data) & 0xffffffff``. .. function:: decompress(data[, wbits[, bufsize]]) diff --git a/Lib/gzip.py b/Lib/gzip.py --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -210,7 +210,7 @@ def _init_write(self, filename): self.name = filename - self.crc = zlib.crc32(b"") & 0xffffffff + self.crc = zlib.crc32(b"") self.size = 0 self.writebuf = [] self.bufsize = 0 @@ -261,7 +261,7 @@ if length > 0: self.fileobj.write(self.compress.compress(data)) self.size += length - self.crc = zlib.crc32(data, self.crc) & 0xffffffff + self.crc = zlib.crc32(data, self.crc) self.offset += length return length @@ -381,7 +381,7 @@ self._last_mtime = None def _init_read(self): - self._crc = zlib.crc32(b"") & 0xffffffff + self._crc = zlib.crc32(b"") self._stream_size = 0 # Decompressed size of unconcatenated stream def _read_exact(self, n): @@ -485,7 +485,7 @@ return uncompress def _add_read_data(self, data): - self._crc = zlib.crc32(data, self._crc) & 0xffffffff + self._crc = zlib.crc32(data, self._crc) self._stream_size = self._stream_size + len(data) def _read_eof(self): diff --git a/Lib/tarfile.py b/Lib/tarfile.py --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -459,13 +459,7 @@ self.fileobj.write(self.buf) self.buf = b"" if self.comptype == "gz": - # The native zlib crc is an unsigned 32-bit integer, but - # the Python wrapper implicitly casts that to a signed C - # long. So, on a 32-bit box self.crc may "look negative", - # while the same crc on a 64-bit box may "look positive". - # To avoid irksome warnings from the `struct` module, force - # it to look positive on all boxes. - self.fileobj.write(struct.pack(" https://hg.python.org/cpython/rev/03c4ca1a34e2 changeset: 99522:03c4ca1a34e2 branch: 3.5 parent: 99520:3202d143a194 user: Martin Panter date: Fri Dec 11 05:19:29 2015 +0000 summary: Issue #22341: Drop Python 2 workaround and document CRC initial value Also align the parameter naming in binascii to be consistent with zlib. files: Doc/library/binascii.rst | 23 ++++++++--------- Doc/library/zlib.rst | 37 +++++++++++---------------- Lib/gzip.py | 8 +++--- Lib/tarfile.py | 8 +----- Lib/test/test_zlib.py | 13 +++------ Lib/zipfile.py | 8 +++--- 6 files changed, 39 insertions(+), 58 deletions(-) diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst --- a/Doc/library/binascii.rst +++ b/Doc/library/binascii.rst @@ -110,15 +110,16 @@ possibly the last fragment). -.. function:: crc_hqx(data, crc) +.. function:: crc_hqx(data, value) - Compute the binhex4 crc value of *data*, starting with an initial *crc* and - returning the result. + Compute the binhex4 crc value of *data*, starting with *value* as the + initial crc, and return the result. -.. function:: crc32(data[, crc]) +.. function:: crc32(data[, value]) - Compute CRC-32, the 32-bit checksum of data, starting with an initial crc. This + Compute CRC-32, the 32-bit checksum of *data*, starting with an + initial CRC of *value*. The default initial CRC is zero. The algorithm is consistent with the ZIP file checksum. Since the algorithm is designed for use as a checksum algorithm, it is not suitable for use as a general hash algorithm. Use as follows:: @@ -126,15 +127,13 @@ print(binascii.crc32(b"hello world")) # Or, in two pieces: crc = binascii.crc32(b"hello") - crc = binascii.crc32(b" world", crc) & 0xffffffff + crc = binascii.crc32(b" world", crc) print('crc32 = {:#010x}'.format(crc)) -.. note:: - To generate the same numeric value across all Python versions and - platforms use crc32(data) & 0xffffffff. If you are only using - the checksum in packed binary format this is not necessary as the - return value is the correct 32bit binary representation - regardless of sign. + .. versionchanged:: 3.0 + The result is always unsigned. + To generate the same numeric value across all Python versions and + platforms, use ``crc32(data) & 0xffffffff``. .. function:: b2a_hex(data) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -31,22 +31,19 @@ .. function:: adler32(data[, value]) Computes an Adler-32 checksum of *data*. (An Adler-32 checksum is almost as - reliable as a CRC32 but can be computed much more quickly.) If *value* is - present, it is used as the starting value of the checksum; otherwise, a fixed - default value is used. This allows computing a running checksum over the + reliable as a CRC32 but can be computed much more quickly.) The result + is an unsigned 32-bit integer. If *value* is present, it is used as + the starting value of the checksum; otherwise, a default value of 1 + is used. Passing in *value* allows computing a running checksum over the concatenation of several inputs. The algorithm is not cryptographically strong, and should not be used for authentication or digital signatures. Since the algorithm is designed for use as a checksum algorithm, it is not suitable for use as a general hash algorithm. - Always returns an unsigned 32-bit integer. - -.. note:: - To generate the same numeric value across all Python versions and - platforms use adler32(data) & 0xffffffff. If you are only using - the checksum in packed binary format this is not necessary as the - return value is the correct 32bit binary representation - regardless of sign. + .. versionchanged:: 3.0 + Always returns an unsigned value. + To generate the same numeric value across all Python versions and + platforms, use ``adler32(data) & 0xffffffff``. .. function:: compress(data[, level]) @@ -97,23 +94,19 @@ single: Cyclic Redundancy Check single: checksum; Cyclic Redundancy Check - Computes a CRC (Cyclic Redundancy Check) checksum of *data*. If *value* is - present, it is used as the starting value of the checksum; otherwise, a fixed - default value is used. This allows computing a running checksum over the + Computes a CRC (Cyclic Redundancy Check) checksum of *data*. The + result is an unsigned 32-bit integer. If *value* is present, it is used + as the starting value of the checksum; otherwise, a default value of 0 + is used. Passing in *value* allows computing a running checksum over the concatenation of several inputs. The algorithm is not cryptographically strong, and should not be used for authentication or digital signatures. Since the algorithm is designed for use as a checksum algorithm, it is not suitable for use as a general hash algorithm. - Always returns an unsigned 32-bit integer. - - .. note:: - + .. versionchanged:: 3.0 + Always returns an unsigned value. To generate the same numeric value across all Python versions and - platforms, use ``crc32(data) & 0xffffffff``. If you are only using - the checksum in packed binary format this is not necessary as the - return value is the correct 32-bit binary representation - regardless of sign. + platforms, use ``crc32(data) & 0xffffffff``. .. function:: decompress(data[, wbits[, bufsize]]) diff --git a/Lib/gzip.py b/Lib/gzip.py --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -210,7 +210,7 @@ def _init_write(self, filename): self.name = filename - self.crc = zlib.crc32(b"") & 0xffffffff + self.crc = zlib.crc32(b"") self.size = 0 self.writebuf = [] self.bufsize = 0 @@ -261,7 +261,7 @@ if length > 0: self.fileobj.write(self.compress.compress(data)) self.size += length - self.crc = zlib.crc32(data, self.crc) & 0xffffffff + self.crc = zlib.crc32(data, self.crc) self.offset += length return length @@ -381,7 +381,7 @@ self._last_mtime = None def _init_read(self): - self._crc = zlib.crc32(b"") & 0xffffffff + self._crc = zlib.crc32(b"") self._stream_size = 0 # Decompressed size of unconcatenated stream def _read_exact(self, n): @@ -485,7 +485,7 @@ return uncompress def _add_read_data(self, data): - self._crc = zlib.crc32(data, self._crc) & 0xffffffff + self._crc = zlib.crc32(data, self._crc) self._stream_size = self._stream_size + len(data) def _read_eof(self): diff --git a/Lib/tarfile.py b/Lib/tarfile.py --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -459,13 +459,7 @@ self.fileobj.write(self.buf) self.buf = b"" if self.comptype == "gz": - # The native zlib crc is an unsigned 32-bit integer, but - # the Python wrapper implicitly casts that to a signed C - # long. So, on a 32-bit box self.crc may "look negative", - # while the same crc on a 64-bit box may "look positive". - # To avoid irksome warnings from the `struct` module, force - # it to look positive on all boxes. - self.fileobj.write(struct.pack(" results for a526ebcfd31d on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogG70WtO', '--timeout', '7200'] From python-checkins at python.org Fri Dec 11 11:33:26 2015 From: python-checkins at python.org (yury.selivanov) Date: Fri, 11 Dec 2015 16:33:26 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151211163325.5493.52093@psf.io> https://hg.python.org/cpython/rev/64be64bd7444 changeset: 99528:64be64bd7444 parent: 99525:2f9541cab936 parent: 99527:4cd2d977a980 user: Yury Selivanov date: Fri Dec 11 11:33:21 2015 -0500 summary: Merge 3.5 files: Lib/asyncio/streams.py | 3 +++ Lib/test/test_asyncio/test_streams.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -494,6 +494,9 @@ @coroutine def readexactly(self, n): + if n < 0: + raise ValueError('readexactly size can not be less than zero') + if self._exception is not None: raise self._exception diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -351,8 +351,8 @@ self.assertEqual(b'', data) self.assertEqual(self.DATA, stream._buffer) - data = self.loop.run_until_complete(stream.readexactly(-1)) - self.assertEqual(b'', data) + with self.assertRaisesRegexp(ValueError, 'less than zero'): + self.loop.run_until_complete(stream.readexactly(-1)) self.assertEqual(self.DATA, stream._buffer) def test_readexactly(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 11 11:33:26 2015 From: python-checkins at python.org (yury.selivanov) Date: Fri, 11 Dec 2015 16:33:26 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_3=2E4?= Message-ID: <20151211163325.73047.65313@psf.io> https://hg.python.org/cpython/rev/4cd2d977a980 changeset: 99527:4cd2d977a980 branch: 3.5 parent: 99523:fe844253cd44 parent: 99526:36cd67ed9d4a user: Yury Selivanov date: Fri Dec 11 11:33:08 2015 -0500 summary: Merge 3.4 files: Lib/asyncio/streams.py | 3 +++ Lib/test/test_asyncio/test_streams.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -494,6 +494,9 @@ @coroutine def readexactly(self, n): + if n < 0: + raise ValueError('readexactly size can not be less than zero') + if self._exception is not None: raise self._exception diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -351,8 +351,8 @@ self.assertEqual(b'', data) self.assertEqual(self.DATA, stream._buffer) - data = self.loop.run_until_complete(stream.readexactly(-1)) - self.assertEqual(b'', data) + with self.assertRaisesRegexp(ValueError, 'less than zero'): + self.loop.run_until_complete(stream.readexactly(-1)) self.assertEqual(self.DATA, stream._buffer) def test_readexactly(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 11 11:33:26 2015 From: python-checkins at python.org (yury.selivanov) Date: Fri, 11 Dec 2015 16:33:26 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogYXN5bmNpbzogU3lu?= =?utf-8?q?c_with_github?= Message-ID: <20151211163325.90209.72415@psf.io> https://hg.python.org/cpython/rev/36cd67ed9d4a changeset: 99526:36cd67ed9d4a branch: 3.4 parent: 99501:6a3b444d89ce user: Yury Selivanov date: Fri Dec 11 11:32:59 2015 -0500 summary: asyncio: Sync with github files: Lib/asyncio/streams.py | 3 +++ Lib/test/test_asyncio/test_streams.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -494,6 +494,9 @@ @coroutine def readexactly(self, n): + if n < 0: + raise ValueError('readexactly size can not be less than zero') + if self._exception is not None: raise self._exception diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -351,8 +351,8 @@ self.assertEqual(b'', data) self.assertEqual(self.DATA, stream._buffer) - data = self.loop.run_until_complete(stream.readexactly(-1)) - self.assertEqual(b'', data) + with self.assertRaisesRegexp(ValueError, 'less than zero'): + self.loop.run_until_complete(stream.readexactly(-1)) self.assertEqual(self.DATA, stream._buffer) def test_readexactly(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 11 11:34:39 2015 From: python-checkins at python.org (yury.selivanov) Date: Fri, 11 Dec 2015 16:34:39 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogYXN5bmNpbzogTWFr?= =?utf-8?q?e_Tasks_check_if_Futures_are_attached_to_the_same_event_loop?= Message-ID: <20151211163439.5487.8468@psf.io> https://hg.python.org/cpython/rev/646bf7f5f019 changeset: 99529:646bf7f5f019 branch: 3.4 parent: 99526:36cd67ed9d4a user: Yury Selivanov date: Fri Dec 11 11:33:59 2015 -0500 summary: asyncio: Make Tasks check if Futures are attached to the same event loop See https://github.com/python/asyncio/pull/303 for details files: Lib/asyncio/tasks.py | 8 +++++++- Lib/test/test_asyncio/test_tasks.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletions(-) diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -251,7 +251,13 @@ else: if isinstance(result, futures.Future): # Yielded Future must come from Future.__iter__(). - if result._blocking: + if result._loop is not self._loop: + self._loop.call_soon( + self._step, + RuntimeError( + 'Task {!r} got Future {!r} attached to a ' + 'different loop'.format(self, result))) + elif result._blocking: result._blocking = False result.add_done_callback(self._wakeup) self._fut_waiter = result diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -76,6 +76,21 @@ def setUp(self): self.loop = self.new_test_loop() + def test_other_loop_future(self): + other_loop = asyncio.new_event_loop() + fut = asyncio.Future(loop=other_loop) + + @asyncio.coroutine + def run(fut): + yield from fut + + try: + with self.assertRaisesRegex(RuntimeError, + r'Task .* got Future .* attached'): + self.loop.run_until_complete(run(fut)) + finally: + other_loop.close() + def test_task_class(self): @asyncio.coroutine def notmuch(): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 11 11:34:45 2015 From: python-checkins at python.org (yury.selivanov) Date: Fri, 11 Dec 2015 16:34:45 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151211163439.98344.70915@psf.io> https://hg.python.org/cpython/rev/f8c8441c6cfe changeset: 99531:f8c8441c6cfe parent: 99528:64be64bd7444 parent: 99530:e3e7fe5f802a user: Yury Selivanov date: Fri Dec 11 11:34:30 2015 -0500 summary: Merge 3.5 files: Lib/asyncio/tasks.py | 8 +++++++- Lib/test/test_asyncio/test_tasks.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletions(-) diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -251,7 +251,13 @@ else: if isinstance(result, futures.Future): # Yielded Future must come from Future.__iter__(). - if result._blocking: + if result._loop is not self._loop: + self._loop.call_soon( + self._step, + RuntimeError( + 'Task {!r} got Future {!r} attached to a ' + 'different loop'.format(self, result))) + elif result._blocking: result._blocking = False result.add_done_callback(self._wakeup) self._fut_waiter = result diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -76,6 +76,21 @@ def setUp(self): self.loop = self.new_test_loop() + def test_other_loop_future(self): + other_loop = asyncio.new_event_loop() + fut = asyncio.Future(loop=other_loop) + + @asyncio.coroutine + def run(fut): + yield from fut + + try: + with self.assertRaisesRegex(RuntimeError, + r'Task .* got Future .* attached'): + self.loop.run_until_complete(run(fut)) + finally: + other_loop.close() + def test_task_class(self): @asyncio.coroutine def notmuch(): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 11 11:34:50 2015 From: python-checkins at python.org (yury.selivanov) Date: Fri, 11 Dec 2015 16:34:50 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_3=2E4?= Message-ID: <20151211163439.5505.16178@psf.io> https://hg.python.org/cpython/rev/e3e7fe5f802a changeset: 99530:e3e7fe5f802a branch: 3.5 parent: 99527:4cd2d977a980 parent: 99529:646bf7f5f019 user: Yury Selivanov date: Fri Dec 11 11:34:11 2015 -0500 summary: Merge 3.4 files: Lib/asyncio/tasks.py | 8 +++++++- Lib/test/test_asyncio/test_tasks.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletions(-) diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -251,7 +251,13 @@ else: if isinstance(result, futures.Future): # Yielded Future must come from Future.__iter__(). - if result._blocking: + if result._loop is not self._loop: + self._loop.call_soon( + self._step, + RuntimeError( + 'Task {!r} got Future {!r} attached to a ' + 'different loop'.format(self, result))) + elif result._blocking: result._blocking = False result.add_done_callback(self._wakeup) self._fut_waiter = result diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -76,6 +76,21 @@ def setUp(self): self.loop = self.new_test_loop() + def test_other_loop_future(self): + other_loop = asyncio.new_event_loop() + fut = asyncio.Future(loop=other_loop) + + @asyncio.coroutine + def run(fut): + yield from fut + + try: + with self.assertRaisesRegex(RuntimeError, + r'Task .* got Future .* attached'): + self.loop.run_until_complete(run(fut)) + finally: + other_loop.close() + def test_task_class(self): @asyncio.coroutine def notmuch(): -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Fri Dec 11 12:08:54 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 11 Dec 2015 17:08:54 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-11 Message-ID: Results for project Python default, build date 2015-12-11 04:02:49 +0000 commit: a526ebcfd31de99e2d3cf837a50d27501beb8aec revision date: 2015-12-11 03:35:31 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.40% -0.30% 10.19% 15.56% :-( pybench 0.13% -0.10% -2.18% 9.41% :-( regex_v8 2.72% 0.09% -3.77% 4.91% :-( nbody 0.07% -0.05% -3.80% 11.68% :-( json_dump_v2 0.24% -0.89% -3.18% 11.00% :-| normal_startup 1.00% 0.20% 0.53% 4.61% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Fri Dec 11 12:11:31 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 11 Dec 2015 17:11:31 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-11 Message-ID: <90f335c0-d939-4cd7-8d7a-d0e280badc6a@irsmsx104.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python 2.7, build date 2015-12-11 04:52:42 +0000 commit: 002d8b981128cbee6fb9f1529a66c756ad24718b revision date: 2015-12-09 17:44:30 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-| django_v2 0.38% -1.07% 1.25% 11.43% :-) pybench 0.15% 0.16% 6.14% 7.18% :-( regex_v8 1.13% 0.38% -2.53% 7.93% :-) nbody 0.11% 0.07% 7.87% 4.81% :-| json_dump_v2 0.24% -0.08% 1.76% 15.65% :-| normal_startup 2.09% -0.20% -1.87% 2.56% :-| ssbench 0.61% -0.22% 1.03% 1.29% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Fri Dec 11 16:48:43 2015 From: python-checkins at python.org (berker.peksag) Date: Fri, 11 Dec 2015 21:48:43 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NzU1?= =?utf-8?q?=3A_Move_PropertyWritableDoc_into_the_test_case?= Message-ID: <20151211214843.5497.38668@psf.io> https://hg.python.org/cpython/rev/cc1aa0e88626 changeset: 99532:cc1aa0e88626 branch: 3.5 parent: 99530:e3e7fe5f802a user: Berker Peksag date: Fri Dec 11 23:48:13 2015 +0200 summary: Issue #25755: Move PropertyWritableDoc into the test case This fixes a test failure in refleak mode because test_property_decorator_doc_writable no longer modifies the class in module level. Initial patch by Nan Wu and Torsten Landschoff (from issue 25757) files: Lib/test/test_property.py | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -76,13 +76,6 @@ """new docstring""" return 8 -class PropertyWritableDoc(object): - - @property - def spam(self): - """Eggs""" - return "eggs" - class PropertyTests(unittest.TestCase): def test_property_decorator_baseclass(self): # see #1620 @@ -168,6 +161,13 @@ @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_property_decorator_doc_writable(self): + class PropertyWritableDoc(object): + + @property + def spam(self): + """Eggs""" + return "eggs" + sub = PropertyWritableDoc() self.assertEqual(sub.__class__.spam.__doc__, 'Eggs') sub.__class__.spam.__doc__ = 'Spam' -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 11 16:48:44 2015 From: python-checkins at python.org (berker.peksag) Date: Fri, 11 Dec 2015 21:48:44 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325755=3A_Move_PropertyWritableDoc_into_the_test?= =?utf-8?q?_case?= Message-ID: <20151211214843.90201.32409@psf.io> https://hg.python.org/cpython/rev/8f52c9d72d9f changeset: 99533:8f52c9d72d9f parent: 99531:f8c8441c6cfe parent: 99532:cc1aa0e88626 user: Berker Peksag date: Fri Dec 11 23:48:37 2015 +0200 summary: Issue #25755: Move PropertyWritableDoc into the test case This fixes a test failure in refleak mode because test_property_decorator_doc_writable no longer modifies the class in module level. Initial patch by Nan Wu and Torsten Landschoff (from issue 25757) files: Lib/test/test_property.py | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -76,13 +76,6 @@ """new docstring""" return 8 -class PropertyWritableDoc(object): - - @property - def spam(self): - """Eggs""" - return "eggs" - class PropertyTests(unittest.TestCase): def test_property_decorator_baseclass(self): # see #1620 @@ -168,6 +161,13 @@ @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_property_decorator_doc_writable(self): + class PropertyWritableDoc(object): + + @property + def spam(self): + """Eggs""" + return "eggs" + sub = PropertyWritableDoc() self.assertEqual(sub.__class__.spam.__doc__, 'Eggs') sub.__class__.spam.__doc__ = 'Spam' -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 12 02:31:23 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 12 Dec 2015 07:31:23 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODQ1?= =?utf-8?q?=3A_Drop_redundant_checks_leftover_from_int_to_long_conversion?= Message-ID: <20151212073123.5495.89972@psf.io> https://hg.python.org/cpython/rev/26859a7e385c changeset: 99535:26859a7e385c branch: 3.5 user: Martin Panter date: Sat Dec 12 06:57:13 2015 +0000 summary: Issue #25845: Drop redundant checks leftover from int to long conversion files: Modules/_ctypes/cfield.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1375,7 +1375,7 @@ Py_INCREF(value); return value; } - if (PyLong_Check(value) || PyLong_Check(value)) { + if (PyLong_Check(value)) { #if SIZEOF_VOID_P == SIZEOF_LONG_LONG *(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongLongMask(value); #else @@ -1491,7 +1491,7 @@ _RET(value); } - if (!PyLong_Check(value) && !PyLong_Check(value)) { + if (!PyLong_Check(value)) { PyErr_SetString(PyExc_TypeError, "cannot be converted to pointer"); return NULL; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 12 02:31:23 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 12 Dec 2015 07:31:23 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzE5Nzcx?= =?utf-8?q?=3A_Omit_irrelevant_message_if_package_could_not_be_initialized?= Message-ID: <20151212073123.98338.57409@psf.io> https://hg.python.org/cpython/rev/850cc65ceda4 changeset: 99536:850cc65ceda4 branch: 3.5 user: Martin Panter date: Sat Dec 12 06:58:55 2015 +0000 summary: Issue #19771: Omit irrelevant message if package could not be initialized files: Lib/runpy.py | 2 ++ Lib/test/test_cmd_line_script.py | 13 +++++++++++++ Misc/NEWS | 4 ++++ 3 files changed, 19 insertions(+), 0 deletions(-) diff --git a/Lib/runpy.py b/Lib/runpy.py --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -132,6 +132,8 @@ pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name, error) except error as e: + if mod_name not in sys.modules: + raise # No module loaded; being a package is irrelevant raise error(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name)) loader = spec.loader diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -442,6 +442,19 @@ self.assertRegex(err, regex) self.assertNotIn(b'Traceback', err) + def test_dash_m_bad_pyc(self): + with support.temp_dir() as script_dir, \ + support.change_cwd(path=script_dir): + os.mkdir('test_pkg') + # Create invalid *.pyc as empty file + with open('test_pkg/__init__.pyc', 'wb'): + pass + err = self.check_dash_m_failure('test_pkg') + self.assertRegex(err, br'Error while finding spec.*' + br'ImportError.*bad magic number') + self.assertNotIn(b'is a package', err) + self.assertNotIn(b'Traceback', err) + def test_dash_m_init_traceback(self): # These were wrapped in an ImportError and tracebacks were # suppressed; see Issue 14285 diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -41,6 +41,10 @@ "runpy" module now lets exceptions from package initialization pass back to the caller, rather than raising ImportError. +- Issue #19771: Also in runpy and the "-m" option, omit the irrelevant + message ". . . is a package and cannot be directly executed" if the package + could not even be initialized (e.g. due to a bad *.pyc file). + - Issue #25177: Fixed problem with the mean of very small and very large numbers. As a side effect, statistics.mean and statistics.variance should be significantly faster. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 12 02:31:23 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 12 Dec 2015 07:31:23 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODA5?= =?utf-8?q?=3A_Skip_testing_platform-dependent_French_thousands_separator?= Message-ID: <20151212073123.73035.88191@psf.io> https://hg.python.org/cpython/rev/4f24a6dc934b changeset: 99534:4f24a6dc934b branch: 3.5 parent: 99532:cc1aa0e88626 user: Martin Panter date: Sat Dec 12 06:53:34 2015 +0000 summary: Issue #25809: Skip testing platform-dependent French thousands separator files: Lib/test/test__locale.py | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py --- a/Lib/test/test__locale.py +++ b/Lib/test/test__locale.py @@ -67,7 +67,9 @@ known_numerics = { 'en_US': ('.', ','), 'de_DE' : (',', '.'), - 'fr_FR.UTF-8' : (',', ' '), + # The French thousands separator may be a breaking or non-breaking space + # depending on the platform, so do not test it + 'fr_FR' : (',', ''), 'ps_AF': ('\u066b', '\u066c'), } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 12 02:31:24 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 12 Dec 2015 07:31:24 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325845=3A_Merge_PyLong=5FCheck=28=29_cleanup_fro?= =?utf-8?q?m_3=2E5?= Message-ID: <20151212073123.26589.68176@psf.io> https://hg.python.org/cpython/rev/9be59ad8af80 changeset: 99538:9be59ad8af80 parent: 99537:7c5c03143923 parent: 99535:26859a7e385c user: Martin Panter date: Sat Dec 12 07:14:03 2015 +0000 summary: Issue #25845: Merge PyLong_Check() cleanup from 3.5 files: Modules/_ctypes/cfield.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1375,7 +1375,7 @@ Py_INCREF(value); return value; } - if (PyLong_Check(value) || PyLong_Check(value)) { + if (PyLong_Check(value)) { #if SIZEOF_VOID_P == SIZEOF_LONG_LONG *(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongLongMask(value); #else @@ -1491,7 +1491,7 @@ _RET(value); } - if (!PyLong_Check(value) && !PyLong_Check(value)) { + if (!PyLong_Check(value)) { PyErr_SetString(PyExc_TypeError, "cannot be converted to pointer"); return NULL; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 12 02:31:24 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 12 Dec 2015 07:31:24 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2319771=3A_Merge_runpy_error_adjustment_from_3=2E?= =?utf-8?q?5?= Message-ID: <20151212073123.11513.79414@psf.io> https://hg.python.org/cpython/rev/323c10701e5d changeset: 99539:323c10701e5d parent: 99538:9be59ad8af80 parent: 99536:850cc65ceda4 user: Martin Panter date: Sat Dec 12 07:16:33 2015 +0000 summary: Issue #19771: Merge runpy error adjustment from 3.5 files: Lib/runpy.py | 2 ++ Lib/test/test_cmd_line_script.py | 13 +++++++++++++ Misc/NEWS | 4 ++++ 3 files changed, 19 insertions(+), 0 deletions(-) diff --git a/Lib/runpy.py b/Lib/runpy.py --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -132,6 +132,8 @@ pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name, error) except error as e: + if mod_name not in sys.modules: + raise # No module loaded; being a package is irrelevant raise error(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name)) loader = spec.loader diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -442,6 +442,19 @@ self.assertRegex(err, regex) self.assertNotIn(b'Traceback', err) + def test_dash_m_bad_pyc(self): + with support.temp_dir() as script_dir, \ + support.change_cwd(path=script_dir): + os.mkdir('test_pkg') + # Create invalid *.pyc as empty file + with open('test_pkg/__init__.pyc', 'wb'): + pass + err = self.check_dash_m_failure('test_pkg') + self.assertRegex(err, br'Error while finding spec.*' + br'ImportError.*bad magic number') + self.assertNotIn(b'is a package', err) + self.assertNotIn(b'Traceback', err) + def test_dash_m_init_traceback(self): # These were wrapped in an ImportError and tracebacks were # suppressed; see Issue 14285 diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -136,6 +136,10 @@ "runpy" module now lets exceptions from package initialization pass back to the caller, rather than raising ImportError. +- Issue #19771: Also in runpy and the "-m" option, omit the irrelevant + message ". . . is a package and cannot be directly executed" if the package + could not even be initialized (e.g. due to a bad *.pyc file). + - Issue #25177: Fixed problem with the mean of very small and very large numbers. As a side effect, statistics.mean and statistics.variance should be significantly faster. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 12 02:31:23 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 12 Dec 2015 07:31:23 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325809=3A_Merge_French_locale_test_from_3=2E5?= Message-ID: <20151212073123.30461.16467@psf.io> https://hg.python.org/cpython/rev/7c5c03143923 changeset: 99537:7c5c03143923 parent: 99533:8f52c9d72d9f parent: 99534:4f24a6dc934b user: Martin Panter date: Sat Dec 12 07:13:10 2015 +0000 summary: Issue #25809: Merge French locale test from 3.5 files: Lib/test/test__locale.py | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py --- a/Lib/test/test__locale.py +++ b/Lib/test/test__locale.py @@ -67,7 +67,9 @@ known_numerics = { 'en_US': ('.', ','), 'de_DE' : (',', '.'), - 'fr_FR.UTF-8' : (',', ' '), + # The French thousands separator may be a breaking or non-breaking space + # depending on the platform, so do not test it + 'fr_FR' : (',', ''), 'ps_AF': ('\u066b', '\u066c'), } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 12 02:41:35 2015 From: python-checkins at python.org (martin.panter) Date: Sat, 12 Dec 2015 07:41:35 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1ODA5?= =?utf-8?q?=3A_Skip_testing_platform-dependent_French_thousands_separator?= Message-ID: <20151212074135.16254.9775@psf.io> https://hg.python.org/cpython/rev/903a2664d32d changeset: 99540:903a2664d32d branch: 2.7 parent: 99518:002d8b981128 user: Martin Panter date: Sat Dec 12 06:53:34 2015 +0000 summary: Issue #25809: Skip testing platform-dependent French thousands separator files: Lib/test/test__locale.py | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py --- a/Lib/test/test__locale.py +++ b/Lib/test/test__locale.py @@ -39,7 +39,9 @@ known_numerics = { 'en_US': ('.', ','), 'de_DE' : (',', '.'), - 'fr_FR.UTF-8' : (',', ' '), + # The French thousands separator may be a breaking or non-breaking space + # depending on the platform, so do not test it + 'fr_FR' : (',', ''), 'ps_AF.UTF-8' : ('\xd9\xab', '\xd9\xac'), } -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sat Dec 12 03:43:32 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 12 Dec 2015 08:43:32 +0000 Subject: [Python-checkins] Daily reference leaks (8f52c9d72d9f): sum=7 Message-ID: <20151212084332.25629.62434@psf.io> results for 8f52c9d72d9f on branch "default" -------------------------------------------- test_asyncio leaked [0, 3, 0] memory blocks, sum=3 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogo8P_Y3', '--timeout', '7200'] From python-checkins at python.org Sat Dec 12 20:02:26 2015 From: python-checkins at python.org (guido.van.rossum) Date: Sun, 13 Dec 2015 01:02:26 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Sync_asyncio_with_upstream_git_repo_=28conditional_impor?= =?utf-8?b?dCBpbiB0ZXN0X3BlcDQ5Mi5weSku?= Message-ID: <20151213010226.98340.69253@psf.io> https://hg.python.org/cpython/rev/93538e7d6ed8 changeset: 99542:93538e7d6ed8 parent: 99539:323c10701e5d parent: 99541:e911f05c945f user: Guido van Rossum date: Sat Dec 12 17:02:15 2015 -0800 summary: Sync asyncio with upstream git repo (conditional import in test_pep492.py). (Merge 3.5->3.6) files: Lib/test/test_asyncio/test_pep492.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py --- a/Lib/test/test_asyncio/test_pep492.py +++ b/Lib/test/test_asyncio/test_pep492.py @@ -4,7 +4,10 @@ import types import unittest -from test import support +try: + from test import support +except ImportError: + from asyncio import test_support as support from unittest import mock import asyncio -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 12 20:02:26 2015 From: python-checkins at python.org (guido.van.rossum) Date: Sun, 13 Dec 2015 01:02:26 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Sync_asyncio_w?= =?utf-8?q?ith_upstream_git_repo_=28conditional_import_in_test=5Fpep492=2E?= =?utf-8?q?py=29=2E?= Message-ID: <20151213010226.26589.52729@psf.io> https://hg.python.org/cpython/rev/e911f05c945f changeset: 99541:e911f05c945f branch: 3.5 parent: 99536:850cc65ceda4 user: Guido van Rossum date: Sat Dec 12 17:01:47 2015 -0800 summary: Sync asyncio with upstream git repo (conditional import in test_pep492.py). files: Lib/test/test_asyncio/test_pep492.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py --- a/Lib/test/test_asyncio/test_pep492.py +++ b/Lib/test/test_asyncio/test_pep492.py @@ -4,7 +4,10 @@ import types import unittest -from test import support +try: + from test import support +except ImportError: + from asyncio import test_support as support from unittest import mock import asyncio -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sun Dec 13 03:43:57 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 13 Dec 2015 08:43:57 +0000 Subject: [Python-checkins] Daily reference leaks (93538e7d6ed8): sum=4 Message-ID: <20151213084357.25647.30841@psf.io> results for 93538e7d6ed8 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogbugnvw', '--timeout', '7200'] From python-checkins at python.org Sun Dec 13 04:45:28 2015 From: python-checkins at python.org (vinay.sajip) Date: Sun, 13 Dec 2015 09:45:28 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Fixes_=2325844=3A_Corrected_=3D/=3D=3D_typo_potentially_leadin?= =?utf-8?q?g_to_crash_in_launcher=2E?= Message-ID: <20151213094528.30378.80289@psf.io> https://hg.python.org/cpython/rev/9552fcd303fd changeset: 99544:9552fcd303fd branch: 3.5 parent: 99541:e911f05c945f parent: 99543:5015440beec2 user: Vinay Sajip date: Sun Dec 13 09:44:15 2015 +0000 summary: Fixes #25844: Corrected =/== typo potentially leading to crash in launcher. files: PC/launcher.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -114,7 +114,7 @@ if (result >= BUFSIZE) { /* Large environment variable. Accept some leakage */ wchar_t *buf2 = (wchar_t*)malloc(sizeof(wchar_t) * (result+1)); - if (buf2 = NULL) { + if (buf2 == NULL) { error(RC_NO_MEMORY, L"Could not allocate environment buffer"); } GetEnvironmentVariableW(key, buf2, result); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 04:45:28 2015 From: python-checkins at python.org (vinay.sajip) Date: Sun, 13 Dec 2015 09:45:28 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogRml4ZXMgIzI1ODQ0?= =?utf-8?q?=3A_Corrected_=3D/=3D=3D_typo_potentially_leading_to_crash_in_l?= =?utf-8?q?auncher=2E?= Message-ID: <20151213094528.30370.51333@psf.io> https://hg.python.org/cpython/rev/5015440beec2 changeset: 99543:5015440beec2 branch: 3.4 parent: 99529:646bf7f5f019 user: Vinay Sajip date: Sun Dec 13 09:41:29 2015 +0000 summary: Fixes #25844: Corrected =/== typo potentially leading to crash in launcher. files: PC/launcher.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -114,7 +114,7 @@ if (result >= BUFSIZE) { /* Large environment variable. Accept some leakage */ wchar_t *buf2 = (wchar_t*)malloc(sizeof(wchar_t) * (result+1)); - if (buf2 = NULL) { + if (buf2 == NULL) { error(RC_NO_MEMORY, L"Could not allocate environment buffer"); } GetEnvironmentVariableW(key, buf2, result); @@ -1219,7 +1219,7 @@ * is no version specification. */ debug(L"searching PATH for python executable\n"); - cmd = find_on_path(L"python"); + cmd = find_on_path(PYTHON_EXECUTABLE); debug(L"Python on path: %s\n", cmd ? cmd->value : L""); if (cmd) { debug(L"located python on PATH: %s\n", cmd->value); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 04:45:28 2015 From: python-checkins at python.org (vinay.sajip) Date: Sun, 13 Dec 2015 09:45:28 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Fixes_=2325844=3A_Merged_fix_from_3=2E5=2E?= Message-ID: <20151213094528.2700.99166@psf.io> https://hg.python.org/cpython/rev/cdf8033d8820 changeset: 99545:cdf8033d8820 parent: 99542:93538e7d6ed8 parent: 99544:9552fcd303fd user: Vinay Sajip date: Sun Dec 13 09:45:19 2015 +0000 summary: Fixes #25844: Merged fix from 3.5. files: PC/launcher.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -114,7 +114,7 @@ if (result >= BUFSIZE) { /* Large environment variable. Accept some leakage */ wchar_t *buf2 = (wchar_t*)malloc(sizeof(wchar_t) * (result+1)); - if (buf2 = NULL) { + if (buf2 == NULL) { error(RC_NO_MEMORY, L"Could not allocate environment buffer"); } GetEnvironmentVariableW(key, buf2, result); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 15:22:38 2015 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Dec 2015 20:22:38 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1Njk2?= =?utf-8?q?=3A_Fix_installation_of_Python_on_UNIX_with_make_-j9=2E?= Message-ID: <20151213202237.10441.84466@psf.io> https://hg.python.org/cpython/rev/87d96b349ff5 changeset: 99547:87d96b349ff5 branch: 3.5 parent: 99544:9552fcd303fd user: Victor Stinner date: Sun Dec 13 21:20:36 2015 +0100 summary: Issue #25696: Fix installation of Python on UNIX with make -j9. files: Makefile.pre.in | 4 ++++ Misc/NEWS | 2 ++ 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1110,6 +1110,10 @@ fi bininstall: altbininstall + -if test ! -d $(DESTDIR)$(LIBPC); then \ + echo "Creating directory $(LIBPC)"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC); \ + fi -if test -f $(DESTDIR)$(BINDIR)/python3$(EXE) -o -h $(DESTDIR)$(BINDIR)/python3$(EXE); \ then rm -f $(DESTDIR)$(BINDIR)/python3$(EXE); \ else true; \ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -84,6 +84,8 @@ Build ----- +- Issue #25696: Fix installation of Python on UNIX with make -j9. + - Issue #25798: Update OS X 10.5 installer to use OpenSSL 1.0.2e. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 15:22:37 2015 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Dec 2015 20:22:37 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1Njk2?= =?utf-8?q?=3A_Fix_installation_of_Python_on_UNIX_with_make_-j9=2E?= Message-ID: <20151213202237.30396.80334@psf.io> https://hg.python.org/cpython/rev/c03ef448b5b2 changeset: 99546:c03ef448b5b2 branch: 2.7 parent: 99540:903a2664d32d user: Victor Stinner date: Sun Dec 13 21:19:28 2015 +0100 summary: Issue #25696: Fix installation of Python on UNIX with make -j9. files: Makefile.pre.in | 4 ++++ Misc/NEWS | 2 ++ 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -914,6 +914,10 @@ # $(PYTHON) -> python2 -> python$(VERSION)) # Also create equivalent chains for other installed files bininstall: altbininstall + -if test ! -d $(DESTDIR)$(LIBPC); then \ + echo "Creating directory $(LIBPC)"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC); \ + fi -if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \ then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \ else true; \ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -56,6 +56,8 @@ Build ----- +- Issue #25696: Fix installation of Python on UNIX with make -j9. + - Issue #25798: Update OS X 10.5+ 32-bit-only installer to build and link with OpenSSL 1.0.2e. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 15:22:38 2015 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Dec 2015 20:22:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_=28Merge_3=2E5=29_Issue_=2325696=3A_Fix_installation_of_?= =?utf-8?q?Python_on_UNIX_with_make_-j9=2E?= Message-ID: <20151213202238.73041.87405@psf.io> https://hg.python.org/cpython/rev/8dd594d36704 changeset: 99548:8dd594d36704 parent: 99545:cdf8033d8820 parent: 99547:87d96b349ff5 user: Victor Stinner date: Sun Dec 13 21:21:36 2015 +0100 summary: (Merge 3.5) Issue #25696: Fix installation of Python on UNIX with make -j9. files: Makefile.pre.in | 4 ++++ Misc/NEWS | 2 ++ 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1110,6 +1110,10 @@ fi bininstall: altbininstall + -if test ! -d $(DESTDIR)$(LIBPC); then \ + echo "Creating directory $(LIBPC)"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC); \ + fi -if test -f $(DESTDIR)$(BINDIR)/python3$(EXE) -o -h $(DESTDIR)$(BINDIR)/python3$(EXE); \ then rm -f $(DESTDIR)$(BINDIR)/python3$(EXE); \ else true; \ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -492,6 +492,8 @@ Build ----- +- Issue #25696: Fix installation of Python on UNIX with make -j9. + - Issue #24986: It is now possible to build Python on Windows without errors when external libraries are not available. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 15:27:03 2015 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Dec 2015 20:27:03 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1Njk2?= =?utf-8?q?=3A_Don=27t_ignore_errors_in_=27make_bininstall=27_on_creating_?= =?utf-8?b?JChMSUJQQyk=?= Message-ID: <20151213202703.25639.59769@psf.io> https://hg.python.org/cpython/rev/d28268c47421 changeset: 99550:d28268c47421 branch: 3.5 parent: 99547:87d96b349ff5 user: Victor Stinner date: Sun Dec 13 21:26:17 2015 +0100 summary: Issue #25696: Don't ignore errors in 'make bininstall' on creating $(LIBPC) directory files: Makefile.pre.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1110,7 +1110,7 @@ fi bininstall: altbininstall - -if test ! -d $(DESTDIR)$(LIBPC); then \ + if test ! -d $(DESTDIR)$(LIBPC); then \ echo "Creating directory $(LIBPC)"; \ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC); \ fi -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 15:27:03 2015 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Dec 2015 20:27:03 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151213202703.10443.18481@psf.io> https://hg.python.org/cpython/rev/e6061d144f45 changeset: 99551:e6061d144f45 parent: 99548:8dd594d36704 parent: 99550:d28268c47421 user: Victor Stinner date: Sun Dec 13 21:26:34 2015 +0100 summary: Merge 3.5 files: Makefile.pre.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1110,7 +1110,7 @@ fi bininstall: altbininstall - -if test ! -d $(DESTDIR)$(LIBPC); then \ + if test ! -d $(DESTDIR)$(LIBPC); then \ echo "Creating directory $(LIBPC)"; \ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC); \ fi -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 15:27:03 2015 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Dec 2015 20:27:03 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1Njk2?= =?utf-8?q?=3A_Don=27t_ignore_errors_in_=27make_bininstall=27_on_creating_?= =?utf-8?b?JChMSUJQQyk=?= Message-ID: <20151213202703.30392.50541@psf.io> https://hg.python.org/cpython/rev/94910d210ef4 changeset: 99549:94910d210ef4 branch: 2.7 parent: 99546:c03ef448b5b2 user: Victor Stinner date: Sun Dec 13 21:25:42 2015 +0100 summary: Issue #25696: Don't ignore errors in 'make bininstall' on creating $(LIBPC) directory files: Makefile.pre.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -914,7 +914,7 @@ # $(PYTHON) -> python2 -> python$(VERSION)) # Also create equivalent chains for other installed files bininstall: altbininstall - -if test ! -d $(DESTDIR)$(LIBPC); then \ + if test ! -d $(DESTDIR)$(LIBPC); then \ echo "Creating directory $(LIBPC)"; \ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC); \ fi -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 15:41:19 2015 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Dec 2015 20:41:19 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODQ2?= =?utf-8?q?=3A_Fix_usage_of_Py=5FARRAY=5FLENGTH=28=29_in_win32=5Fwchdir=28?= =?utf-8?q?=29?= Message-ID: <20151213204118.25631.51202@psf.io> https://hg.python.org/cpython/rev/39ce98d9b6b7 changeset: 99552:39ce98d9b6b7 branch: 3.5 parent: 99550:d28268c47421 user: Victor Stinner date: Sun Dec 13 21:40:26 2015 +0100 summary: Issue #25846: Fix usage of Py_ARRAY_LENGTH() in win32_wchdir() files: Modules/posixmodule.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1345,13 +1345,13 @@ static BOOL __stdcall win32_wchdir(LPCWSTR path) { - wchar_t _new_path[MAX_PATH], *new_path = _new_path; + wchar_t path_buf[MAX_PATH], *new_path = path_buf; int result; wchar_t env[4] = L"=x:"; if(!SetCurrentDirectoryW(path)) return FALSE; - result = GetCurrentDirectoryW(Py_ARRAY_LENGTH(new_path), new_path); + result = GetCurrentDirectoryW(Py_ARRAY_LENGTH(path_buf), new_path); if (!result) return FALSE; if (result > Py_ARRAY_LENGTH(new_path)) { @@ -1372,7 +1372,7 @@ return TRUE; env[1] = new_path[0]; result = SetEnvironmentVariableW(env, new_path); - if (new_path != _new_path) + if (new_path != path_buf) PyMem_RawFree(new_path); return result; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 15:41:19 2015 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Dec 2015 20:41:19 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_=28Merge_3=2E5=29_Issue_=2325846=3A_Fix_usage_of_Py=5FAR?= =?utf-8?b?UkFZX0xFTkdUSCgpIGluIHdpbjMyX3djaGRpcigp?= Message-ID: <20151213204119.10451.66242@psf.io> https://hg.python.org/cpython/rev/e373ec3c2969 changeset: 99553:e373ec3c2969 parent: 99551:e6061d144f45 parent: 99552:39ce98d9b6b7 user: Victor Stinner date: Sun Dec 13 21:41:12 2015 +0100 summary: (Merge 3.5) Issue #25846: Fix usage of Py_ARRAY_LENGTH() in win32_wchdir() files: Modules/posixmodule.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1345,13 +1345,13 @@ static BOOL __stdcall win32_wchdir(LPCWSTR path) { - wchar_t _new_path[MAX_PATH], *new_path = _new_path; + wchar_t path_buf[MAX_PATH], *new_path = path_buf; int result; wchar_t env[4] = L"=x:"; if(!SetCurrentDirectoryW(path)) return FALSE; - result = GetCurrentDirectoryW(Py_ARRAY_LENGTH(new_path), new_path); + result = GetCurrentDirectoryW(Py_ARRAY_LENGTH(path_buf), new_path); if (!result) return FALSE; if (result > Py_ARRAY_LENGTH(new_path)) { @@ -1372,7 +1372,7 @@ return TRUE; env[1] = new_path[0]; result = SetEnvironmentVariableW(env, new_path); - if (new_path != _new_path) + if (new_path != path_buf) PyMem_RawFree(new_path); return result; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 16:58:01 2015 From: python-checkins at python.org (gregory.p.smith) Date: Sun, 13 Dec 2015 21:58:01 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fixes_issue_?= =?utf-8?q?=2320954=3A_=5Fargs=5Ffrom=5Finterpreter=5Fflags_used_by_multip?= =?utf-8?q?rocessing?= Message-ID: <20151213215801.90185.85829@psf.io> https://hg.python.org/cpython/rev/d42f6ce08362 changeset: 99554:d42f6ce08362 branch: 2.7 parent: 99549:94910d210ef4 user: Gregory P. Smith date: Sun Dec 13 13:57:50 2015 -0800 summary: Fixes issue #20954: _args_from_interpreter_flags used by multiprocessing and some tests no longer behaves incorrectly in the presence of the PYTHONHASHSEED environment variable. files: Lib/subprocess.py | 3 ++- Misc/NEWS | 4 ++++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/Lib/subprocess.py b/Lib/subprocess.py --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -498,7 +498,6 @@ 'ignore_environment': 'E', 'verbose': 'v', 'bytes_warning': 'b', - 'hash_randomization': 'R', 'py3k_warning': '3', } args = [] @@ -506,6 +505,8 @@ v = getattr(sys.flags, flag) if v > 0: args.append('-' + opt * v) + if getattr(sys.flags, 'hash_randomization') != 0: + args.append('-R') for opt in sys.warnoptions: args.append('-W' + opt) return args diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,10 @@ Library ------- +- Issue #20954: _args_from_interpreter_flags used by multiprocessing and some + tests no longer behaves incorrectly in the presence of the PYTHONHASHSEED + environment variable. + - Issue #14285: When executing a package with the "python -m package" option, and package initialization raises ImportError, a proper traceback is now reported. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 18:15:04 2015 From: python-checkins at python.org (r.david.murray) Date: Sun, 13 Dec 2015 23:15:04 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge=3A_=2325495=3A_Clarify_b2a=5Fbase64_documentation_?= =?utf-8?q?vis_57_bytes=2E?= Message-ID: <20151213231504.16242.10476@psf.io> https://hg.python.org/cpython/rev/35650db28afe changeset: 99558:35650db28afe parent: 99553:e373ec3c2969 parent: 99557:ea9951598bab user: R David Murray date: Sun Dec 13 18:11:07 2015 -0500 summary: Merge: #25495: Clarify b2a_base64 documentation vis 57 bytes. In 3.6 the parameter to control the appending of the newline was finally added, so I dropped the historical note about why a new line was always appended. files: Doc/library/binascii.rst | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst --- a/Doc/library/binascii.rst +++ b/Doc/library/binascii.rst @@ -56,9 +56,7 @@ Convert binary data to a line of ASCII characters in base64 coding. The return value is the converted line, including a newline char if *newline* is - true. The length of *data* should be at most 57 to adhere to the - base64 standard. - + true. The output of this function conforms to :rfc:`3548`. .. versionchanged:: 3.6 Added the *newline* parameter. @@ -172,7 +170,8 @@ .. seealso:: Module :mod:`base64` - Support for base64 encoding used in MIME email messages. + Support for RFC compliant base64-style encoding in base 16, 32, 64, + and 85. Module :mod:`binhex` Support for the binhex format used on the Macintosh. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 18:15:04 2015 From: python-checkins at python.org (r.david.murray) Date: Sun, 13 Dec 2015 23:15:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogIzI1NDk1OiBDbGFy?= =?utf-8?q?ify_b2a=5Fbase64_documentation_vis_57_bytes=2E?= Message-ID: <20151213231504.30370.62372@psf.io> https://hg.python.org/cpython/rev/3d5bf9bd15a3 changeset: 99556:3d5bf9bd15a3 branch: 3.4 parent: 99543:5015440beec2 user: R David Murray date: Sun Dec 13 18:04:27 2015 -0500 summary: #25495: Clarify b2a_base64 documentation vis 57 bytes. files: Doc/library/binascii.rst | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst --- a/Doc/library/binascii.rst +++ b/Doc/library/binascii.rst @@ -55,8 +55,10 @@ .. function:: b2a_base64(data) Convert binary data to a line of ASCII characters in base64 coding. The return - value is the converted line, including a newline char. The length of *data* - should be at most 57 to adhere to the base64 standard. + value is the converted line, including a newline char. The newline is + added because the original use case for this function was to feed it a + series of 57 byte input lines to get output lines that conform to the + MIME-base64 standard. Otherwise the output conforms to :rfc:`3548`. .. function:: a2b_qp(data, header=False) @@ -168,7 +170,8 @@ .. seealso:: Module :mod:`base64` - Support for base64 encoding used in MIME email messages. + Support for RFC compliant base64-style encoding in base 16, 32, 64, + and 85. Module :mod:`binhex` Support for the binhex format used on the Macintosh. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 18:15:04 2015 From: python-checkins at python.org (r.david.murray) Date: Sun, 13 Dec 2015 23:15:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzI1NDk1OiBDbGFy?= =?utf-8?q?ify_b2a=5Fbase64_documentation_vis_57_bytes=2E?= Message-ID: <20151213231504.10439.49841@psf.io> https://hg.python.org/cpython/rev/7b137466e879 changeset: 99555:7b137466e879 branch: 2.7 user: R David Murray date: Sun Dec 13 18:04:14 2015 -0500 summary: #25495: Clarify b2a_base64 documentation vis 57 bytes. files: Doc/library/binascii.rst | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst --- a/Doc/library/binascii.rst +++ b/Doc/library/binascii.rst @@ -45,8 +45,10 @@ .. function:: b2a_base64(data) Convert binary data to a line of ASCII characters in base64 coding. The return - value is the converted line, including a newline char. The length of *data* - should be at most 57 to adhere to the base64 standard. + value is the converted line, including a newline char. The newline is + added because the original use case for this function was to feed it a + series of 57 byte input lines to get output lines that conform to the + MIME-base64 standard. Otherwise the output conforms to :rfc:`3548`. .. function:: a2b_qp(string[, header]) @@ -165,7 +167,7 @@ .. seealso:: Module :mod:`base64` - Support for base64 encoding used in MIME email messages. + Support for RFC compliant base64-style encoding in base 16, 32, and 64. Module :mod:`binhex` Support for the binhex format used on the Macintosh. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 18:15:04 2015 From: python-checkins at python.org (r.david.murray) Date: Sun, 13 Dec 2015 23:15:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge=3A_=2325495=3A_Clarify_b2a=5Fbase64_documentation_vis_57?= =?utf-8?q?_bytes=2E?= Message-ID: <20151213231504.73044.39294@psf.io> https://hg.python.org/cpython/rev/ea9951598bab changeset: 99557:ea9951598bab branch: 3.5 parent: 99552:39ce98d9b6b7 parent: 99556:3d5bf9bd15a3 user: R David Murray date: Sun Dec 13 18:04:56 2015 -0500 summary: Merge: #25495: Clarify b2a_base64 documentation vis 57 bytes. files: Doc/library/binascii.rst | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst --- a/Doc/library/binascii.rst +++ b/Doc/library/binascii.rst @@ -55,8 +55,10 @@ .. function:: b2a_base64(data) Convert binary data to a line of ASCII characters in base64 coding. The return - value is the converted line, including a newline char. The length of *data* - should be at most 57 to adhere to the base64 standard. + value is the converted line, including a newline char. The newline is + added because the original use case for this function was to feed it a + series of 57 byte input lines to get output lines that conform to the + MIME-base64 standard. Otherwise the output conforms to :rfc:`3548`. .. function:: a2b_qp(data, header=False) @@ -167,7 +169,8 @@ .. seealso:: Module :mod:`base64` - Support for base64 encoding used in MIME email messages. + Support for RFC compliant base64-style encoding in base 16, 32, 64, + and 85. Module :mod:`binhex` Support for the binhex format used on the Macintosh. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 18:22:29 2015 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Dec 2015 23:22:29 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODQ2?= =?utf-8?q?=3A_Fix_usage_of_Py=5FARRAY=5FLENGTH=28=29_in_win32=5Fwchdir=28?= =?utf-8?b?KSAobmV3IHRyeSk=?= Message-ID: <20151213232229.30392.58109@psf.io> https://hg.python.org/cpython/rev/aba6caf7b9f0 changeset: 99559:aba6caf7b9f0 branch: 3.5 parent: 99557:ea9951598bab user: Victor Stinner date: Mon Dec 14 00:21:50 2015 +0100 summary: Issue #25846: Fix usage of Py_ARRAY_LENGTH() in win32_wchdir() (new try) files: Modules/posixmodule.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1354,7 +1354,7 @@ result = GetCurrentDirectoryW(Py_ARRAY_LENGTH(path_buf), new_path); if (!result) return FALSE; - if (result > Py_ARRAY_LENGTH(new_path)) { + if (result > Py_ARRAY_LENGTH(path_buf)) { new_path = PyMem_RawMalloc(result * sizeof(wchar_t)); if (!new_path) { SetLastError(ERROR_OUTOFMEMORY); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 18:22:29 2015 From: python-checkins at python.org (victor.stinner) Date: Sun, 13 Dec 2015 23:22:29 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151213232229.13588.53042@psf.io> https://hg.python.org/cpython/rev/314eeb71b161 changeset: 99560:314eeb71b161 parent: 99558:35650db28afe parent: 99559:aba6caf7b9f0 user: Victor Stinner date: Mon Dec 14 00:22:10 2015 +0100 summary: Merge 3.5 files: Modules/posixmodule.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1354,7 +1354,7 @@ result = GetCurrentDirectoryW(Py_ARRAY_LENGTH(path_buf), new_path); if (!result) return FALSE; - if (result > Py_ARRAY_LENGTH(new_path)) { + if (result > Py_ARRAY_LENGTH(path_buf)) { new_path = PyMem_RawMalloc(result * sizeof(wchar_t)); if (!new_path) { SetLastError(ERROR_OUTOFMEMORY); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 21:45:06 2015 From: python-checkins at python.org (raymond.hettinger) Date: Mon, 14 Dec 2015 02:45:06 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Hoist_constant_expressions?= =?utf-8?q?_=28so-=3Etable_and_so-=3Emask=29_out_of_the_inner-loop=2E?= Message-ID: <20151214024506.13570.94978@psf.io> https://hg.python.org/cpython/rev/c8de4f05c6c3 changeset: 99561:c8de4f05c6c3 user: Raymond Hettinger date: Sun Dec 13 18:45:01 2015 -0800 summary: Hoist constant expressions (so->table and so->mask) out of the inner-loop. files: Objects/setobject.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Objects/setobject.c b/Objects/setobject.c --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -260,16 +260,13 @@ the setobject's fill and used fields. */ static void -set_insert_clean(PySetObject *so, PyObject *key, Py_hash_t hash) +set_insert_clean(setentry *table, size_t mask, PyObject *key, Py_hash_t hash) { - setentry *table = so->table; setentry *entry; size_t perturb = hash; - size_t mask = (size_t)so->mask; size_t i = (size_t)hash & mask; size_t j; - assert(so->fill == so->used); while (1) { entry = &table[i]; if (entry->key == NULL) @@ -285,8 +282,8 @@ i = (i * 5 + 1 + perturb) & mask; } found_null: + entry->hash = hash; entry->key = key; - entry->hash = hash; } /* ======== End logic for probing the hash table ========================== */ @@ -304,6 +301,8 @@ setentry *oldtable, *newtable, *entry; Py_ssize_t oldfill = so->fill; Py_ssize_t oldused = so->used; + Py_ssize_t oldmask = so->mask; + size_t newmask; int is_oldtable_malloced; setentry small_copy[PySet_MINSIZE]; @@ -363,18 +362,17 @@ /* Copy the data over; this is refcount-neutral for active entries; dummy entries aren't copied over, of course */ + newmask = (size_t)so->mask; if (oldfill == oldused) { - for (entry = oldtable; oldused > 0; entry++) { + for (entry = oldtable; entry <= oldtable + oldmask; entry++) { if (entry->key != NULL) { - oldused--; - set_insert_clean(so, entry->key, entry->hash); + set_insert_clean(newtable, newmask, entry->key, entry->hash); } } } else { - for (entry = oldtable; oldused > 0; entry++) { + for (entry = oldtable; entry <= oldtable + oldmask; entry++) { if (entry->key != NULL && entry->key != dummy) { - oldused--; - set_insert_clean(so, entry->key, entry->hash); + set_insert_clean(newtable, newmask, entry->key, entry->hash); } } } @@ -676,13 +674,15 @@ /* If our table is empty, we can use set_insert_clean() */ if (so->fill == 0) { + setentry *newtable = so->table; + size_t newmask = (size_t)so->mask; so->fill = other->used; so->used = other->used; for (i = 0; i <= other->mask; i++, other_entry++) { key = other_entry->key; if (key != NULL && key != dummy) { Py_INCREF(key); - set_insert_clean(so, key, other_entry->hash); + set_insert_clean(newtable, newmask, key, other_entry->hash); } } return 0; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 21:58:14 2015 From: python-checkins at python.org (martin.panter) Date: Mon, 14 Dec 2015 02:58:14 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzIwODM3?= =?utf-8?q?=3A_Base-64_alphabet_clarification_from_revision_1853679c6f71?= Message-ID: <20151214025813.73041.10091@psf.io> https://hg.python.org/cpython/rev/e8cbebb273c6 changeset: 99562:e8cbebb273c6 branch: 2.7 parent: 99555:7b137466e879 user: Martin Panter date: Mon Dec 14 02:54:40 2015 +0000 summary: Issue #20837: Base-64 alphabet clarification from revision 1853679c6f71 files: Doc/library/base64.rst | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -16,7 +16,8 @@ encoding algorithm is not the same as the :program:`uuencode` program. There are two interfaces provided by this module. The modern interface supports -encoding and decoding string objects using all three alphabets. The legacy +encoding and decoding string objects using all three :rfc:`3548` defined +alphabets (normal, URL-safe, and filesystem-safe). The legacy interface provides for encoding and decoding to and from file-like objects as well as strings, but only using the Base64 standard alphabet. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 22:27:25 2015 From: python-checkins at python.org (raymond.hettinger) Date: Mon, 14 Dec 2015 03:27:25 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Undo_inadvertent_line_swap?= Message-ID: <20151214032725.73061.18278@psf.io> https://hg.python.org/cpython/rev/7309be384c6a changeset: 99563:7309be384c6a parent: 99561:c8de4f05c6c3 user: Raymond Hettinger date: Sun Dec 13 19:27:17 2015 -0800 summary: Undo inadvertent line swap files: Objects/setobject.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Objects/setobject.c b/Objects/setobject.c --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -282,8 +282,8 @@ i = (i * 5 + 1 + perturb) & mask; } found_null: + entry->key = key; entry->hash = hash; - entry->key = key; } /* ======== End logic for probing the hash table ========================== */ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 23:15:36 2015 From: python-checkins at python.org (gregory.p.smith) Date: Mon, 14 Dec 2015 04:15:36 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Re-fix_issue_?= =?utf-8?q?=2319284=3A_Don=27t_generate_the_no-op_-R_command_line?= Message-ID: <20151214041536.13572.57069@psf.io> https://hg.python.org/cpython/rev/d76b9c121e61 changeset: 99566:d76b9c121e61 branch: 3.4 user: Gregory P. Smith date: Sun Dec 13 20:05:55 2015 -0800 summary: Re-fix issue #19284: Don't generate the no-op -R command line parameter to "enable" the always on sys.flags.hash_randomization in _args_from_interpreter_flags() used by multiprocessing and some unittests. This simplifies the code. files: Lib/subprocess.py | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/Lib/subprocess.py b/Lib/subprocess.py --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -512,14 +512,11 @@ 'verbose': 'v', 'bytes_warning': 'b', 'quiet': 'q', - 'hash_randomization': 'R', } args = [] for flag, opt in flag_opt_map.items(): v = getattr(sys.flags, flag) if v > 0: - if flag == 'hash_randomization': - v = 1 # Handle specification of an exact seed args.append('-' + opt * v) for opt in sys.warnoptions: args.append('-W' + opt) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 23:15:37 2015 From: python-checkins at python.org (gregory.p.smith) Date: Mon, 14 Dec 2015 04:15:37 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogRml4IHRlc3RfY21k?= =?utf-8?q?=5Fline_not_to_fail_if_PYTHONHASHSEED_is_set_to_a_fixed_seed?= Message-ID: <20151214041536.98358.59383@psf.io> https://hg.python.org/cpython/rev/cefcbe1b934f changeset: 99565:cefcbe1b934f branch: 3.4 user: Gregory P. Smith date: Sun Dec 13 20:01:44 2015 -0800 summary: Fix test_cmd_line not to fail if PYTHONHASHSEED is set to a fixed seed due to test_hash_randomization expecting a different seed per process. files: Lib/test/test_cmd_line.py | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -402,12 +402,24 @@ # Verify that -R enables hash randomization: self.verify_valid_flag('-R') hashes = [] - for i in range(2): + if os.environ.get('PYTHONHASHSEED', 'random') != 'random': + env = dict(os.environ) # copy + # We need to test that it is enabled by default without + # the environment variable enabling it for us. + del env['PYTHONHASHSEED'] + env['__cleanenv'] = '1' # consumed by assert_python_ok() + else: + env = {} + for i in range(3): code = 'print(hash("spam"))' - rc, out, err = assert_python_ok('-c', code) + rc, out, err = assert_python_ok('-c', code, **env) self.assertEqual(rc, 0) hashes.append(out) - self.assertNotEqual(hashes[0], hashes[1]) + hashes = sorted(set(hashes)) # uniq + # Rare chance of failure due to 3 random seeds honestly being equal. + self.assertGreater(len(hashes), 1, + msg='3 runs produced an identical random hash ' + ' for "spam": {}'.format(hashes)) # Verify that sys.flags contains hash_randomization code = 'import sys; print("random is", sys.flags.hash_randomization)' -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 23:15:38 2015 From: python-checkins at python.org (gregory.p.smith) Date: Mon, 14 Dec 2015 04:15:38 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogYXNzZXJ0X3B5dGhv?= =?utf-8?q?n=5Fok_docstring_typo_fix=2E?= Message-ID: <20151214041536.26593.54562@psf.io> https://hg.python.org/cpython/rev/0a85716e7e91 changeset: 99564:0a85716e7e91 branch: 3.4 parent: 99543:5015440beec2 user: Gregory P. Smith date: Sun Dec 13 20:00:24 2015 -0800 summary: assert_python_ok docstring typo fix. files: Lib/test/script_helper.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/script_helper.py b/Lib/test/script_helper.py --- a/Lib/test/script_helper.py +++ b/Lib/test/script_helper.py @@ -107,7 +107,7 @@ variables `env_vars` succeeds (rc == 0) and return a (return code, stdout, stderr) tuple. - If the __cleanenv keyword is set, env_vars is used a fresh environment. + If the __cleanenv keyword is set, env_vars is used as a fresh environment. Python is started in isolated mode (command line option -I), except if the __isolated keyword is set to False. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 23:15:41 2015 From: python-checkins at python.org (gregory.p.smith) Date: Mon, 14 Dec 2015 04:15:41 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNCk6?= =?utf-8?q?_merge_head?= Message-ID: <20151214041541.25643.36878@psf.io> https://hg.python.org/cpython/rev/7e7bdac6b259 changeset: 99567:7e7bdac6b259 branch: 3.4 parent: 99566:d76b9c121e61 parent: 99556:3d5bf9bd15a3 user: Gregory P. Smith date: Sun Dec 13 20:06:35 2015 -0800 summary: merge head files: Doc/library/binascii.rst | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst --- a/Doc/library/binascii.rst +++ b/Doc/library/binascii.rst @@ -55,8 +55,10 @@ .. function:: b2a_base64(data) Convert binary data to a line of ASCII characters in base64 coding. The return - value is the converted line, including a newline char. The length of *data* - should be at most 57 to adhere to the base64 standard. + value is the converted line, including a newline char. The newline is + added because the original use case for this function was to feed it a + series of 57 byte input lines to get output lines that conform to the + MIME-base64 standard. Otherwise the output conforms to :rfc:`3548`. .. function:: a2b_qp(data, header=False) @@ -168,7 +170,8 @@ .. seealso:: Module :mod:`base64` - Support for base64 encoding used in MIME email messages. + Support for RFC compliant base64-style encoding in base 16, 32, 64, + and 85. Module :mod:`binhex` Support for the binhex format used on the Macintosh. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 23:15:41 2015 From: python-checkins at python.org (gregory.p.smith) Date: Mon, 14 Dec 2015 04:15:41 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_*_Re-fix_issue_=2319284=3A_Don=27t_generate_the_no-op_-R_comma?= =?utf-8?q?nd_line?= Message-ID: <20151214041541.73051.47264@psf.io> https://hg.python.org/cpython/rev/014e6f7d7c1a changeset: 99568:014e6f7d7c1a branch: 3.5 parent: 99559:aba6caf7b9f0 parent: 99567:7e7bdac6b259 user: Gregory P. Smith date: Sun Dec 13 20:09:42 2015 -0800 summary: * Re-fix issue #19284: Don't generate the no-op -R command line parameter to "enable" the always on sys.flags.hash_randomization in _args_from_interpreter_flags() used by multiprocessing and some unittests. This simplifies the code. * assert_python_ok docstring typo fix. * Fix test_cmd_line not to fail if PYTHONHASHSEED is set to a fixed seed. files: Lib/subprocess.py | 3 --- Lib/test/support/script_helper.py | 2 +- Lib/test/test_cmd_line.py | 18 +++++++++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Lib/subprocess.py b/Lib/subprocess.py --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -535,14 +535,11 @@ 'verbose': 'v', 'bytes_warning': 'b', 'quiet': 'q', - 'hash_randomization': 'R', } args = [] for flag, opt in flag_opt_map.items(): v = getattr(sys.flags, flag) if v > 0: - if flag == 'hash_randomization': - v = 1 # Handle specification of an exact seed args.append('-' + opt * v) for opt in sys.warnoptions: args.append('-W' + opt) diff --git a/Lib/test/support/script_helper.py b/Lib/test/support/script_helper.py --- a/Lib/test/support/script_helper.py +++ b/Lib/test/support/script_helper.py @@ -127,7 +127,7 @@ variables `env_vars` succeeds (rc == 0) and return a (return code, stdout, stderr) tuple. - If the __cleanenv keyword is set, env_vars is used a fresh environment. + If the __cleanenv keyword is set, env_vars is used as a fresh environment. Python is started in isolated mode (command line option -I), except if the __isolated keyword is set to False. diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -403,12 +403,24 @@ # Verify that -R enables hash randomization: self.verify_valid_flag('-R') hashes = [] - for i in range(2): + if os.environ.get('PYTHONHASHSEED', 'random') != 'random': + env = dict(os.environ) # copy + # We need to test that it is enabled by default without + # the environment variable enabling it for us. + del env['PYTHONHASHSEED'] + env['__cleanenv'] = '1' # consumed by assert_python_ok() + else: + env = {} + for i in range(3): code = 'print(hash("spam"))' - rc, out, err = assert_python_ok('-c', code) + rc, out, err = assert_python_ok('-c', code, **env) self.assertEqual(rc, 0) hashes.append(out) - self.assertNotEqual(hashes[0], hashes[1]) + hashes = sorted(set(hashes)) # uniq + # Rare chance of failure due to 3 random seeds honestly being equal. + self.assertGreater(len(hashes), 1, + msg='3 runs produced an identical random hash ' + ' for "spam": {}'.format(hashes)) # Verify that sys.flags contains hash_randomization code = 'import sys; print("random is", sys.flags.hash_randomization)' -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 13 23:15:42 2015 From: python-checkins at python.org (gregory.p.smith) Date: Mon, 14 Dec 2015 04:15:42 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_*_Re-fix_issue_=2319284=3A_Don=27t_generate_the_no-op_-R?= =?utf-8?q?_command_line?= Message-ID: <20151214041541.16224.60023@psf.io> https://hg.python.org/cpython/rev/41717421b134 changeset: 99569:41717421b134 parent: 99563:7309be384c6a parent: 99568:014e6f7d7c1a user: Gregory P. Smith date: Sun Dec 13 20:15:26 2015 -0800 summary: * Re-fix issue #19284: Don't generate the no-op -R command line parameter to "enable" the always on sys.flags.hash_randomization in _args_from_interpreter_flags() used by multiprocessing and some unittests. This simplifies the code. * assert_python_ok docstring typo fix. * Fix test_cmd_line not to fail if PYTHONHASHSEED is set to a fixed seed. files: Lib/subprocess.py | 3 --- Lib/test/support/script_helper.py | 2 +- Lib/test/test_cmd_line.py | 18 +++++++++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Lib/subprocess.py b/Lib/subprocess.py --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -535,14 +535,11 @@ 'verbose': 'v', 'bytes_warning': 'b', 'quiet': 'q', - 'hash_randomization': 'R', } args = [] for flag, opt in flag_opt_map.items(): v = getattr(sys.flags, flag) if v > 0: - if flag == 'hash_randomization': - v = 1 # Handle specification of an exact seed args.append('-' + opt * v) for opt in sys.warnoptions: args.append('-W' + opt) diff --git a/Lib/test/support/script_helper.py b/Lib/test/support/script_helper.py --- a/Lib/test/support/script_helper.py +++ b/Lib/test/support/script_helper.py @@ -127,7 +127,7 @@ variables `env_vars` succeeds (rc == 0) and return a (return code, stdout, stderr) tuple. - If the __cleanenv keyword is set, env_vars is used a fresh environment. + If the __cleanenv keyword is set, env_vars is used as a fresh environment. Python is started in isolated mode (command line option -I), except if the __isolated keyword is set to False. diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -404,12 +404,24 @@ # Verify that -R enables hash randomization: self.verify_valid_flag('-R') hashes = [] - for i in range(2): + if os.environ.get('PYTHONHASHSEED', 'random') != 'random': + env = dict(os.environ) # copy + # We need to test that it is enabled by default without + # the environment variable enabling it for us. + del env['PYTHONHASHSEED'] + env['__cleanenv'] = '1' # consumed by assert_python_ok() + else: + env = {} + for i in range(3): code = 'print(hash("spam"))' - rc, out, err = assert_python_ok('-c', code) + rc, out, err = assert_python_ok('-c', code, **env) self.assertEqual(rc, 0) hashes.append(out) - self.assertNotEqual(hashes[0], hashes[1]) + hashes = sorted(set(hashes)) # uniq + # Rare chance of failure due to 3 random seeds honestly being equal. + self.assertGreater(len(hashes), 1, + msg='3 runs produced an identical random hash ' + ' for "spam": {}'.format(hashes)) # Verify that sys.flags contains hash_randomization code = 'import sys; print("random is", sys.flags.hash_randomization)' -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 14 00:14:44 2015 From: python-checkins at python.org (martin.panter) Date: Mon, 14 Dec 2015 05:14:44 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzIyMDg4?= =?utf-8?q?=3A_Port_base64_character_ignoring_doc_and_test_from_857d9fe601?= =?utf-8?q?69?= Message-ID: <20151214051444.73053.50873@psf.io> https://hg.python.org/cpython/rev/937774aa1853 changeset: 99570:937774aa1853 branch: 2.7 parent: 99562:e8cbebb273c6 user: Martin Panter date: Mon Dec 14 03:41:59 2015 +0000 summary: Issue #22088: Port base64 character ignoring doc and test from 857d9fe60169 files: Doc/library/base64.rst | 6 +++--- Lib/base64.py | 6 +++--- Lib/test/test_base64.py | 16 +++++++++++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -45,9 +45,9 @@ length 2 (additional characters are ignored) which specifies the alternative alphabet used instead of the ``+`` and ``/`` characters. - The decoded string is returned. A :exc:`TypeError` is raised if *s* were - incorrectly padded or if there are non-alphabet characters present in the - string. + The decoded string is returned. A :exc:`TypeError` is raised if *s* is + incorrectly padded. Non-base64-alphabet characters are + discarded prior to the padding check. .. function:: standard_b64encode(s) diff --git a/Lib/base64.py b/Lib/base64.py --- a/Lib/base64.py +++ b/Lib/base64.py @@ -64,9 +64,9 @@ length 2 (additional characters are ignored) which specifies the alternative alphabet used instead of the '+' and '/' characters. - The decoded string is returned. A TypeError is raised if s were - incorrectly padded or if there are non-alphabet characters present in the - string. + The decoded string is returned. A TypeError is raised if s is + incorrectly padded. Non-base64-alphabet characters are discarded prior + to the padding check. """ if altchars is not None: s = s.translate(string.maketrans(altchars[:2], '+/')) diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -137,9 +137,23 @@ # Non-bytes eq(base64.urlsafe_b64decode(bytearray('01a-b_cd')), '\xd3V\xbeo\xf7\x1d') - def test_b64decode_error(self): + def test_b64decode_padding_error(self): self.assertRaises(TypeError, base64.b64decode, 'abc') + def test_b64decode_invalid_chars(self): + # issue 1466065: Test some invalid characters. + tests = ((b'%3d==', b'\xdd'), + (b'$3d==', b'\xdd'), + (b'[==', b''), + (b'YW]3=', b'am'), + (b'3{d==', b'\xdd'), + (b'3d}==', b'\xdd'), + (b'@@', b''), + (b'!', b''), + (b'YWJj\nYWI=', b'abcab')) + for bstr, res in tests: + self.assertEqual(base64.b64decode(bstr), res) + def test_b32encode(self): eq = self.assertEqual eq(base64.b32encode(''), '') -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 14 01:11:04 2015 From: python-checkins at python.org (gregory.p.smith) Date: Mon, 14 Dec 2015 06:11:04 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2311072=3A_change_the_incorrect_=22deprecation=22?= =?utf-8?q?_of_ftplib_dir=28=29_and_nlst=28=29?= Message-ID: <20151214061104.16236.35735@psf.io> https://hg.python.org/cpython/rev/287bb82768a7 changeset: 99572:287bb82768a7 parent: 99569:41717421b134 parent: 99571:ecef6b3f6639 user: Gregory P. Smith date: Sun Dec 13 22:10:58 2015 -0800 summary: Issue #11072: change the incorrect "deprecation" of ftplib dir() and nlst() APIs into a note that mlsd() is a nicer API if the server supports it. They aren't deprecated, they are all different server commands. Not all servers support all commands. files: Doc/library/ftplib.rst | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst --- a/Doc/library/ftplib.rst +++ b/Doc/library/ftplib.rst @@ -314,7 +314,7 @@ .. method:: FTP.mlsd(path="", facts=[]) - List a directory in a standardized format by using MLSD command + List a directory in a standardized format by using ``MLSD`` command (:rfc:`3659`). If *path* is omitted the current directory is assumed. *facts* is a list of strings representing the type of information desired (e.g. ``["type", "size", "perm"]``). Return a generator object yielding a @@ -333,7 +333,7 @@ directory). Multiple arguments can be used to pass non-standard options to the ``NLST`` command. - .. deprecated:: 3.3 use :meth:`mlsd` instead. + .. note:: If your server supports the command, :meth:`mlsd` offers a better API. .. method:: FTP.dir(argument[, ...]) @@ -345,7 +345,7 @@ as a *callback* function as for :meth:`retrlines`; the default prints to ``sys.stdout``. This method returns ``None``. - .. deprecated:: 3.3 use :meth:`mlsd` instead. + .. note:: If your server supports the command, :meth:`mlsd` offers a better API. .. method:: FTP.rename(fromname, toname) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 14 01:11:04 2015 From: python-checkins at python.org (gregory.p.smith) Date: Mon, 14 Dec 2015 06:11:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzExMDcy?= =?utf-8?q?=3A_change_the_incorrect_=22deprecation=22_of_ftplib_dir=28=29_?= =?utf-8?q?and_nlst=28=29?= Message-ID: <20151214061104.90185.95346@psf.io> https://hg.python.org/cpython/rev/ecef6b3f6639 changeset: 99571:ecef6b3f6639 branch: 3.5 parent: 99568:014e6f7d7c1a user: Gregory P. Smith date: Sun Dec 13 22:10:28 2015 -0800 summary: Issue #11072: change the incorrect "deprecation" of ftplib dir() and nlst() APIs into a note that mlsd() is a nicer API if the server supports it. They aren't deprecated, they are all different server commands. Not all servers support all commands. files: Doc/library/ftplib.rst | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst --- a/Doc/library/ftplib.rst +++ b/Doc/library/ftplib.rst @@ -314,7 +314,7 @@ .. method:: FTP.mlsd(path="", facts=[]) - List a directory in a standardized format by using MLSD command + List a directory in a standardized format by using ``MLSD`` command (:rfc:`3659`). If *path* is omitted the current directory is assumed. *facts* is a list of strings representing the type of information desired (e.g. ``["type", "size", "perm"]``). Return a generator object yielding a @@ -333,7 +333,7 @@ directory). Multiple arguments can be used to pass non-standard options to the ``NLST`` command. - .. deprecated:: 3.3 use :meth:`mlsd` instead. + .. note:: If your server supports the command, :meth:`mlsd` offers a better API. .. method:: FTP.dir(argument[, ...]) @@ -345,7 +345,7 @@ as a *callback* function as for :meth:`retrlines`; the default prints to ``sys.stdout``. This method returns ``None``. - .. deprecated:: 3.3 use :meth:`mlsd` instead. + .. note:: If your server supports the command, :meth:`mlsd` offers a better API. .. method:: FTP.rename(fromname, toname) -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Mon Dec 14 03:43:07 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 14 Dec 2015 08:43:07 +0000 Subject: [Python-checkins] Daily reference leaks (41717421b134): sum=4 Message-ID: <20151214084307.25631.54054@psf.io> results for 41717421b134 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogCAFNCy', '--timeout', '7200'] From lp_benchmark_robot at intel.com Mon Dec 14 09:31:11 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 14 Dec 2015 14:31:11 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-14 Message-ID: <0b7c0329-449c-4a85-9986-878fea6bdc68@irsmsx151.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python default, build date 2015-12-14 10:52:13 +0000 commit: 7309be384c6a1f233b56b1633fbef15b1bbbe242 revision date: 2015-12-14 03:27:17 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.19% -0.92% 9.37% 15.16% :-| pybench 0.26% 0.45% -1.72% 8.69% :-( regex_v8 2.75% -0.23% -4.01% 4.72% :-( nbody 0.12% 0.74% -3.04% 11.81% :-| json_dump_v2 0.21% 1.92% -1.21% 11.33% :-| normal_startup 0.98% -0.88% -1.02% 5.05% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Mon Dec 14 09:33:54 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 14 Dec 2015 14:33:54 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-14 Message-ID: <7ca5bea9-b18f-47c2-b5d9-78473d256e41@irsmsx151.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python 2.7, build date 2015-12-14 09:14:27 +0000 commit: e8cbebb273c6c211d88e4591dbbce20268296564 revision date: 2015-12-14 02:54:40 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-| django_v2 0.38% -0.01% 1.24% 12.67% :-) pybench 0.15% -0.06% 6.08% 7.77% :-( regex_v8 1.29% -0.40% -2.94% 8.62% :-) nbody 0.12% -0.04% 7.83% 6.39% :-| json_dump_v2 0.26% -0.35% 1.41% 15.65% :-( normal_startup 1.90% -0.54% -2.42% 2.81% :-| ssbench 0.45% -0.74% 0.28% 1.99% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Tue Dec 15 00:30:36 2015 From: python-checkins at python.org (yury.selivanov) Date: Tue, 15 Dec 2015 05:30:36 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogd2hhdHNuZXcvMy41?= =?utf-8?q?=3A_Mention_new_asyncio_APIs_in_3=2E5=2E1?= Message-ID: <20151215053035.130021.83153@psf.io> https://hg.python.org/cpython/rev/e544a0b58706 changeset: 99573:e544a0b58706 branch: 3.5 parent: 99571:ecef6b3f6639 user: Yury Selivanov date: Tue Dec 15 00:30:18 2015 -0500 summary: whatsnew/3.5: Mention new asyncio APIs in 3.5.1 files: Doc/whatsnew/3.5.rst | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -810,6 +810,18 @@ now accept all kinds of :term:`awaitable objects `. (Contributed by Yury Selivanov.) +* New :func:`~asyncio.run_coroutine_threadsafe` function to submit + coroutines to event loops from other threads. + (Contributed by Vincent Michel.) + +* New :meth:`Transport.is_closing() ` + method to check if the transport is closing or closed. + (Contributed by Yury Selivanov.) + +* The :meth:`loop.create_server() ` + method can now accept a list of hosts. + (Contributed by Yann Sionneau.) + bz2 --- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 15 00:30:36 2015 From: python-checkins at python.org (yury.selivanov) Date: Tue, 15 Dec 2015 05:30:36 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151215053035.2805.50718@psf.io> https://hg.python.org/cpython/rev/f8afbc4749a1 changeset: 99574:f8afbc4749a1 parent: 99572:287bb82768a7 parent: 99573:e544a0b58706 user: Yury Selivanov date: Tue Dec 15 00:30:32 2015 -0500 summary: Merge 3.5 files: Doc/whatsnew/3.5.rst | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -810,6 +810,18 @@ now accept all kinds of :term:`awaitable objects `. (Contributed by Yury Selivanov.) +* New :func:`~asyncio.run_coroutine_threadsafe` function to submit + coroutines to event loops from other threads. + (Contributed by Vincent Michel.) + +* New :meth:`Transport.is_closing() ` + method to check if the transport is closing or closed. + (Contributed by Yury Selivanov.) + +* The :meth:`loop.create_server() ` + method can now accept a list of hosts. + (Contributed by Yann Sionneau.) + bz2 --- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 15 00:38:44 2015 From: python-checkins at python.org (yury.selivanov) Date: Tue, 15 Dec 2015 05:38:44 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151215053844.21447.49705@psf.io> https://hg.python.org/cpython/rev/32a83285fdaa changeset: 99576:32a83285fdaa parent: 99574:f8afbc4749a1 parent: 99575:243b19a8ce1e user: Yury Selivanov date: Tue Dec 15 00:38:38 2015 -0500 summary: Merge 3.5 files: Doc/whatsnew/3.5.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -814,7 +814,7 @@ coroutines to event loops from other threads. (Contributed by Vincent Michel.) -* New :meth:`Transport.is_closing() ` +* New :meth:`Transport.is_closing() ` method to check if the transport is closing or closed. (Contributed by Yury Selivanov.) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 15 00:38:45 2015 From: python-checkins at python.org (yury.selivanov) Date: Tue, 15 Dec 2015 05:38:45 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_docs/whatsnew/?= =?utf-8?q?3=2E5=3A_Fix_ref_link?= Message-ID: <20151215053843.37480.58490@psf.io> https://hg.python.org/cpython/rev/243b19a8ce1e changeset: 99575:243b19a8ce1e branch: 3.5 parent: 99573:e544a0b58706 user: Yury Selivanov date: Tue Dec 15 00:38:28 2015 -0500 summary: docs/whatsnew/3.5: Fix ref link files: Doc/whatsnew/3.5.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -814,7 +814,7 @@ coroutines to event loops from other threads. (Contributed by Vincent Michel.) -* New :meth:`Transport.is_closing() ` +* New :meth:`Transport.is_closing() ` method to check if the transport is closing or closed. (Contributed by Yury Selivanov.) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 15 00:45:44 2015 From: python-checkins at python.org (yury.selivanov) Date: Tue, 15 Dec 2015 05:45:44 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151215054544.2803.12241@psf.io> https://hg.python.org/cpython/rev/21cffbf0d73d changeset: 99578:21cffbf0d73d parent: 99576:32a83285fdaa parent: 99577:33ff335da34c user: Yury Selivanov date: Tue Dec 15 00:45:39 2015 -0500 summary: Merge 3.5 files: Doc/library/asyncio-task.rst | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -539,6 +539,9 @@ .. versionadded:: 3.4.4 + .. versionchanged:: 3.5.1 + The function accepts any :term:`awaitable` object. + .. seealso:: The :meth:`BaseEventLoop.create_task` method. @@ -721,4 +724,4 @@ Unlike the functions above, :func:`run_coroutine_threadsafe` requires the *loop* argument to be passed explicitely. - .. versionadded:: 3.4.4, 3.5.1 + .. versionadded:: 3.5.1 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 15 00:45:45 2015 From: python-checkins at python.org (yury.selivanov) Date: Tue, 15 Dec 2015 05:45:45 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_docs/asyncio?= =?utf-8?q?=3A_Update_ensure=5Ffuture_=26_run=5Fcoroutine=5Fthreadsafe_doc?= =?utf-8?q?s?= Message-ID: <20151215054544.130027.56890@psf.io> https://hg.python.org/cpython/rev/33ff335da34c changeset: 99577:33ff335da34c branch: 3.5 parent: 99575:243b19a8ce1e user: Yury Selivanov date: Tue Dec 15 00:45:24 2015 -0500 summary: docs/asyncio: Update ensure_future & run_coroutine_threadsafe docs files: Doc/library/asyncio-task.rst | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -539,6 +539,9 @@ .. versionadded:: 3.4.4 + .. versionchanged:: 3.5.1 + The function accepts any :term:`awaitable` object. + .. seealso:: The :meth:`BaseEventLoop.create_task` method. @@ -721,4 +724,4 @@ Unlike the functions above, :func:`run_coroutine_threadsafe` requires the *loop* argument to be passed explicitely. - .. versionadded:: 3.4.4, 3.5.1 + .. versionadded:: 3.5.1 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 15 03:42:36 2015 From: python-checkins at python.org (raymond.hettinger) Date: Tue, 15 Dec 2015 08:42:36 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Minor_tweek=2E__Counting_d?= =?utf-8?q?own_rather_than_up_reduces_register_pressure=2E?= Message-ID: <20151215084235.6472.24686@psf.io> https://hg.python.org/cpython/rev/4181afce4fbd changeset: 99579:4181afce4fbd user: Raymond Hettinger date: Tue Dec 15 00:42:30 2015 -0800 summary: Minor tweek. Counting down rather than up reduces register pressure. files: Objects/setobject.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Objects/setobject.c b/Objects/setobject.c --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -678,7 +678,7 @@ size_t newmask = (size_t)so->mask; so->fill = other->used; so->used = other->used; - for (i = 0; i <= other->mask; i++, other_entry++) { + for (i = other->mask + 1; i > 0 ; i--, other_entry++) { key = other_entry->key; if (key != NULL && key != dummy) { Py_INCREF(key); -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Tue Dec 15 03:44:10 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 15 Dec 2015 08:44:10 +0000 Subject: [Python-checkins] Daily reference leaks (32a83285fdaa): sum=7 Message-ID: <20151215084401.26857.14889@psf.io> results for 32a83285fdaa on branch "default" -------------------------------------------- test_asyncio leaked [0, 0, 3] memory blocks, sum=3 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/refloghoOpuT', '--timeout', '7200'] From python-checkins at python.org Tue Dec 15 05:31:22 2015 From: python-checkins at python.org (victor.stinner) Date: Tue, 15 Dec 2015 10:31:22 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325868=3A_Try_to_m?= =?utf-8?q?ake_test=5Feintr=2Etest=5Fsigwaitinfo=28=29_more_reliable?= Message-ID: <20151215103122.22467.89604@psf.io> https://hg.python.org/cpython/rev/7f49af7046e4 changeset: 99580:7f49af7046e4 user: Victor Stinner date: Tue Dec 15 11:29:59 2015 +0100 summary: Issue #25868: Try to make test_eintr.test_sigwaitinfo() more reliable especially on slow buildbots Use a pipe to synchronize the parent and the child processes. files: Lib/test/eintrdata/eintr_tester.py | 20 +++++++++++++---- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Lib/test/eintrdata/eintr_tester.py b/Lib/test/eintrdata/eintr_tester.py --- a/Lib/test/eintrdata/eintr_tester.py +++ b/Lib/test/eintrdata/eintr_tester.py @@ -377,10 +377,10 @@ @unittest.skipUnless(hasattr(signal, 'sigwaitinfo'), 'need signal.sigwaitinfo()') def test_sigwaitinfo(self): - # Issue #25277: The sleep is a weak synchronization between the parent - # and the child process. If the sleep is too low, the test hangs on - # slow or highly loaded systems. - self.sleep_time = 2.0 + # Issue #25277, #25868: give a few miliseconds to the parent process + # between os.write() and signal.sigwaitinfo() to works around a race + # condition + self.sleep_time = 0.100 signum = signal.SIGUSR1 pid = os.getpid() @@ -388,18 +388,28 @@ old_handler = signal.signal(signum, lambda *args: None) self.addCleanup(signal.signal, signum, old_handler) + rpipe, wpipe = os.pipe() + code = '\n'.join(( 'import os, time', 'pid = %s' % os.getpid(), 'signum = %s' % int(signum), 'sleep_time = %r' % self.sleep_time, + 'rpipe = %r' % rpipe, + 'os.read(rpipe, 1)', + 'os.close(rpipe)', 'time.sleep(sleep_time)', 'os.kill(pid, signum)', )) t0 = time.monotonic() - proc = self.subprocess(code) + proc = self.subprocess(code, pass_fds=(rpipe,)) + os.close(rpipe) with kill_on_error(proc): + # sync child-parent + os.write(wpipe, b'x') + os.close(wpipe) + # parent signal.sigwaitinfo([signum]) dt = time.monotonic() - t0 -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Tue Dec 15 08:09:17 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 15 Dec 2015 13:09:17 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-15 Message-ID: <51fad3f5-2228-4064-9271-fb3ed4da44a6@irsmsx103.ger.corp.intel.com> Results for project Python default, build date 2015-12-15 04:02:13 +0000 commit: 287bb82768a7f1c016d59e393f557239e4e56f0e revision date: 2015-12-14 06:10:58 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.38% -0.66% 8.77% 15.84% :-| pybench 0.17% -0.19% -1.91% 8.80% :-( regex_v8 3.08% -0.86% -4.90% 6.09% :-( nbody 0.08% 0.11% -2.92% 11.07% :-| json_dump_v2 0.22% 0.18% -1.02% 10.02% :-| normal_startup 0.73% 0.70% -0.41% 4.85% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Tue Dec 15 08:11:33 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 15 Dec 2015 13:11:33 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-15 Message-ID: No new revisions. Here are the previous results: Results for project Python 2.7, build date 2015-12-15 09:40:38 +0000 commit: 937774aa18531e1296e06cd754431d96e07e70f4 revision date: 2015-12-14 03:41:59 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-| django_v2 0.39% -0.73% 0.52% 11.33% :-) pybench 0.10% -0.02% 6.06% 6.76% :-( regex_v8 1.60% 0.17% -2.76% 8.75% :-) nbody 0.29% -0.28% 7.58% 5.88% :-| json_dump_v2 0.35% 0.23% 1.63% 16.14% :-| normal_startup 1.98% 0.55% -1.86% 3.19% :-| ssbench 0.47% 0.31% 0.59% 1.67% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Tue Dec 15 16:45:42 2015 From: python-checkins at python.org (nick.coghlan) Date: Tue, 15 Dec 2015 21:45:42 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_493=3A_Add_Barry_as_BDFL-?= =?utf-8?q?Delegate?= Message-ID: <20151215214540.130039.24145@psf.io> https://hg.python.org/peps/rev/9d11368203e0 changeset: 6140:9d11368203e0 user: Nick Coghlan date: Wed Dec 16 07:45:33 2015 +1000 summary: PEP 493: Add Barry as BDFL-Delegate files: pep-0493.txt | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/pep-0493.txt b/pep-0493.txt --- a/pep-0493.txt +++ b/pep-0493.txt @@ -5,6 +5,7 @@ Author: Nick Coghlan , Robert Kuska , Marc-Andr? Lemburg +BDFL-Delegate: Barry Warsaw Status: Draft Type: Standards Track Content-Type: text/x-rst -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Wed Dec 16 00:27:22 2015 From: python-checkins at python.org (martin.panter) Date: Wed, 16 Dec 2015 05:27:22 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2323788=3A_Merge_test=5Fbad=5Faddress=28=29_clean?= =?utf-8?q?up_from_3=2E5?= Message-ID: <20151216052722.79181.97265@psf.io> https://hg.python.org/cpython/rev/16accac4b2f6 changeset: 99582:16accac4b2f6 parent: 99580:7f49af7046e4 parent: 99581:e81189f75d04 user: Martin Panter date: Wed Dec 16 05:04:29 2015 +0000 summary: Issue #23788: Merge test_bad_address() cleanup from 3.5 files: Lib/test/test_urllib2_localnet.py | 29 ------------------- Lib/test/test_urllibnet.py | 26 +++++++++++++--- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py --- a/Lib/test/test_urllib2_localnet.py +++ b/Lib/test/test_urllib2_localnet.py @@ -626,35 +626,6 @@ url = open_url.geturl() self.assertEqual(url, "http://localhost:%s" % handler.port) - def test_bad_address(self): - # Make sure proper exception is raised when connecting to a bogus - # address. - - # as indicated by the comment below, this might fail with some ISP, - # so we run the test only when -unetwork/-uall is specified to - # mitigate the problem a bit (see #17564) - support.requires('network') - self.assertRaises(OSError, - # Given that both VeriSign and various ISPs have in - # the past or are presently hijacking various invalid - # domain name requests in an attempt to boost traffic - # to their own sites, finding a domain name to use - # for this test is difficult. RFC2606 leads one to - # believe that '.invalid' should work, but experience - # seemed to indicate otherwise. Single character - # TLDs are likely to remain invalid, so this seems to - # be the best choice. The trailing '.' prevents a - # related problem: The normal DNS resolver appends - # the domain names from the search path if there is - # no '.' the end and, and if one of those domains - # implements a '*' rule a result is returned. - # However, none of this will prevent the test from - # failing if the ISP hijacks all invalid domain - # requests. The real solution would be to be able to - # parameterize the framework with a mock resolver. - urllib.request.urlopen, - "http://sadflkjsasf.i.nvali.d./") - def test_iteration(self): expected_response = b"pycon 2008..." handler = self.start_server([(200, [], expected_response)]) diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -113,7 +113,25 @@ def test_bad_address(self): # Make sure proper exception is raised when connecting to a bogus # address. - bogus_domain = "sadflkjsasf.i.nvali.d" + + # Given that both VeriSign and various ISPs have in + # the past or are presently hijacking various invalid + # domain name requests in an attempt to boost traffic + # to their own sites, finding a domain name to use + # for this test is difficult. RFC2606 leads one to + # believe that '.invalid' should work, but experience + # seemed to indicate otherwise. Single character + # TLDs are likely to remain invalid, so this seems to + # be the best choice. The trailing '.' prevents a + # related problem: The normal DNS resolver appends + # the domain names from the search path if there is + # no '.' the end and, and if one of those domains + # implements a '*' rule a result is returned. + # However, none of this will prevent the test from + # failing if the ISP hijacks all invalid domain + # requests. The real solution would be to be able to + # parameterize the framework with a mock resolver. + bogus_domain = "sadflkjsasf.i.nvali.d." try: socket.gethostbyname(bogus_domain) except OSError: @@ -128,11 +146,7 @@ 'can be caused by a broken DNS server ' '(e.g. returns 404 or hijacks page)') with self.assertRaises(OSError, msg=failure_explanation): - # SF patch 809915: In Sep 2003, VeriSign started highjacking - # invalid .com and .net addresses to boost traffic to their own - # site. This test started failing then. One hopes the .invalid - # domain will be spared to serve its defined purpose. - urllib.request.urlopen("http://sadflkjsasf.i.nvali.d/") + urllib.request.urlopen("http://{}/".format(bogus_domain)) class urlretrieveNetworkTests(unittest.TestCase): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 00:27:24 2015 From: python-checkins at python.org (martin.panter) Date: Wed, 16 Dec 2015 05:27:24 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIzNzg4?= =?utf-8?q?=3A_Merge_redundant_test=5Fbad=5Faddress=28=29_into_test=5Furll?= =?utf-8?q?ibnet?= Message-ID: <20151216052722.26835.34123@psf.io> https://hg.python.org/cpython/rev/e81189f75d04 changeset: 99581:e81189f75d04 branch: 3.5 parent: 99577:33ff335da34c user: Martin Panter date: Wed Dec 16 04:36:20 2015 +0000 summary: Issue #23788: Merge redundant test_bad_address() into test_urllibnet In Python 2, these were duplicated; one for urllib.urlopen() and one for urllib2.urlopen(). The test_urllibnet version has a better precondition to avoid false failures with bad DNS, and the test_urllib2_localnet version had a more up-to-date comment and domain name. files: Lib/test/test_urllib2_localnet.py | 29 ------------------- Lib/test/test_urllibnet.py | 26 +++++++++++++--- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py --- a/Lib/test/test_urllib2_localnet.py +++ b/Lib/test/test_urllib2_localnet.py @@ -626,35 +626,6 @@ url = open_url.geturl() self.assertEqual(url, "http://localhost:%s" % handler.port) - def test_bad_address(self): - # Make sure proper exception is raised when connecting to a bogus - # address. - - # as indicated by the comment below, this might fail with some ISP, - # so we run the test only when -unetwork/-uall is specified to - # mitigate the problem a bit (see #17564) - support.requires('network') - self.assertRaises(OSError, - # Given that both VeriSign and various ISPs have in - # the past or are presently hijacking various invalid - # domain name requests in an attempt to boost traffic - # to their own sites, finding a domain name to use - # for this test is difficult. RFC2606 leads one to - # believe that '.invalid' should work, but experience - # seemed to indicate otherwise. Single character - # TLDs are likely to remain invalid, so this seems to - # be the best choice. The trailing '.' prevents a - # related problem: The normal DNS resolver appends - # the domain names from the search path if there is - # no '.' the end and, and if one of those domains - # implements a '*' rule a result is returned. - # However, none of this will prevent the test from - # failing if the ISP hijacks all invalid domain - # requests. The real solution would be to be able to - # parameterize the framework with a mock resolver. - urllib.request.urlopen, - "http://sadflkjsasf.i.nvali.d./") - def test_iteration(self): expected_response = b"pycon 2008..." handler = self.start_server([(200, [], expected_response)]) diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -113,7 +113,25 @@ def test_bad_address(self): # Make sure proper exception is raised when connecting to a bogus # address. - bogus_domain = "sadflkjsasf.i.nvali.d" + + # Given that both VeriSign and various ISPs have in + # the past or are presently hijacking various invalid + # domain name requests in an attempt to boost traffic + # to their own sites, finding a domain name to use + # for this test is difficult. RFC2606 leads one to + # believe that '.invalid' should work, but experience + # seemed to indicate otherwise. Single character + # TLDs are likely to remain invalid, so this seems to + # be the best choice. The trailing '.' prevents a + # related problem: The normal DNS resolver appends + # the domain names from the search path if there is + # no '.' the end and, and if one of those domains + # implements a '*' rule a result is returned. + # However, none of this will prevent the test from + # failing if the ISP hijacks all invalid domain + # requests. The real solution would be to be able to + # parameterize the framework with a mock resolver. + bogus_domain = "sadflkjsasf.i.nvali.d." try: socket.gethostbyname(bogus_domain) except OSError: @@ -128,11 +146,7 @@ 'can be caused by a broken DNS server ' '(e.g. returns 404 or hijacks page)') with self.assertRaises(OSError, msg=failure_explanation): - # SF patch 809915: In Sep 2003, VeriSign started highjacking - # invalid .com and .net addresses to boost traffic to their own - # site. This test started failing then. One hopes the .invalid - # domain will be spared to serve its defined purpose. - urllib.request.urlopen("http://sadflkjsasf.i.nvali.d/") + urllib.request.urlopen("http://{}/".format(bogus_domain)) class urlretrieveNetworkTests(unittest.TestCase): -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Wed Dec 16 03:44:43 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 16 Dec 2015 08:44:43 +0000 Subject: [Python-checkins] Daily reference leaks (16accac4b2f6): sum=4 Message-ID: <20151216084443.2799.85948@psf.io> results for 16accac4b2f6 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogHAK8ZD', '--timeout', '7200'] From lp_benchmark_robot at intel.com Wed Dec 16 08:42:18 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 16 Dec 2015 13:42:18 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-16 Message-ID: <4a1d190b-fcf5-4bc3-aefe-2a8c8ab12664@irsmsx106.ger.corp.intel.com> Results for project Python default, build date 2015-12-16 03:02:12 +0000 commit: 7f49af7046e4f3d80dc69516583213a9890b6172 revision date: 2015-12-15 10:29:59 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.19% 0.04% 8.80% 16.16% :-| pybench 0.17% 0.25% -1.65% 8.67% :-( regex_v8 2.91% 0.12% -4.77% 5.50% :-( nbody 0.10% 0.04% -2.88% 12.04% :-| json_dump_v2 0.27% -0.35% -1.38% 10.31% :-( normal_startup 0.76% -1.77% -2.25% 4.43% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Wed Dec 16 08:46:47 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 16 Dec 2015 13:46:47 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-16 Message-ID: <4b5a06f6-2bca-4411-9bd7-89a7d5c2ffe7@irsmsx106.ger.corp.intel.com> Results for project Python 2.7, build date 2015-12-16 07:45:34 +0000 commit: 937774aa18531e1296e06cd754431d96e07e70f4 revision date: 2015-12-14 03:41:59 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.13% 0.80% 2.03% 11.26% :-) pybench 0.16% -0.05% 6.03% 7.65% :-( regex_v8 1.09% 0.39% -2.54% 8.69% :-) nbody 0.11% -0.24% 7.61% 6.56% :-| json_dump_v2 0.27% 0.25% 1.65% 16.03% :-( normal_startup 1.85% -2.80% -5.29% 2.05% :-| ssbench 0.14% 1.17% 1.45% 0.99% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Wed Dec 16 19:36:10 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:36:10 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogYXN5bmNpbzogU2tp?= =?utf-8?q?p_getaddrinfo_if_host_is_already_resolved=2E?= Message-ID: <20151217003609.32127.68578@psf.io> https://hg.python.org/cpython/rev/51df143c098d changeset: 99583:51df143c098d branch: 3.4 parent: 99567:7e7bdac6b259 user: Yury Selivanov date: Wed Dec 16 19:31:17 2015 -0500 summary: asyncio: Skip getaddrinfo if host is already resolved. getaddrinfo takes an exclusive lock on some platforms, causing clients to queue up waiting for the lock if many names are being resolved concurrently. Users may want to handle name resolution in their own code, for the sake of caching, using an alternate resolver, or to measure DNS duration separately from connection duration. Skip getaddrinfo if the "host" passed into create_connection is already resolved. See https://github.com/python/asyncio/pull/302 for details. Patch by A. Jesse Jiryu Davis. files: Lib/asyncio/base_events.py | 117 +++- Lib/asyncio/proactor_events.py | 3 +- Lib/asyncio/selector_events.py | 3 +- Lib/asyncio/test_utils.py | 9 +- Lib/test/test_asyncio/test_base_events.py | 208 +++++++++- Lib/test/test_asyncio/test_events.py | 4 - Lib/test/test_asyncio/test_proactor_events.py | 6 +- 7 files changed, 283 insertions(+), 67 deletions(-) diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -16,8 +16,10 @@ import collections import concurrent.futures +import functools import heapq import inspect +import ipaddress import itertools import logging import os @@ -70,49 +72,83 @@ return repr(fd) +# Linux's sock.type is a bitmask that can include extra info about socket. +_SOCKET_TYPE_MASK = 0 +if hasattr(socket, 'SOCK_NONBLOCK'): + _SOCKET_TYPE_MASK |= socket.SOCK_NONBLOCK +if hasattr(socket, 'SOCK_CLOEXEC'): + _SOCKET_TYPE_MASK |= socket.SOCK_CLOEXEC + + + at functools.lru_cache(maxsize=1024) +def _ipaddr_info(host, port, family, type, proto): + # Try to skip getaddrinfo if "host" is already an IP. Since getaddrinfo + # blocks on an exclusive lock on some platforms, users might handle name + # resolution in their own code and pass in resolved IPs. + if proto not in {0, socket.IPPROTO_TCP, socket.IPPROTO_UDP} or host is None: + return None + + type &= ~_SOCKET_TYPE_MASK + if type == socket.SOCK_STREAM: + proto = socket.IPPROTO_TCP + elif type == socket.SOCK_DGRAM: + proto = socket.IPPROTO_UDP + else: + return None + + if hasattr(socket, 'inet_pton'): + if family == socket.AF_UNSPEC: + afs = [socket.AF_INET, socket.AF_INET6] + else: + afs = [family] + + for af in afs: + # Linux's inet_pton doesn't accept an IPv6 zone index after host, + # like '::1%lo0', so strip it. If we happen to make an invalid + # address look valid, we fail later in sock.connect or sock.bind. + try: + if af == socket.AF_INET6: + socket.inet_pton(af, host.partition('%')[0]) + else: + socket.inet_pton(af, host) + return af, type, proto, '', (host, port) + except OSError: + pass + + # "host" is not an IP address. + return None + + # No inet_pton. (On Windows it's only available since Python 3.4.) + # Even though getaddrinfo with AI_NUMERICHOST would be non-blocking, it + # still requires a lock on some platforms, and waiting for that lock could + # block the event loop. Use ipaddress instead, it's just text parsing. + try: + addr = ipaddress.IPv4Address(host) + except ValueError: + try: + addr = ipaddress.IPv6Address(host.partition('%')[0]) + except ValueError: + return None + + af = socket.AF_INET if addr.version == 4 else socket.AF_INET6 + if family not in (socket.AF_UNSPEC, af): + # "host" is wrong IP version for "family". + return None + + return af, type, proto, '', (host, port) + + def _check_resolved_address(sock, address): # Ensure that the address is already resolved to avoid the trap of hanging # the entire event loop when the address requires doing a DNS lookup. - # - # getaddrinfo() is slow (around 10 us per call): this function should only - # be called in debug mode - family = sock.family - if family == socket.AF_INET: - host, port = address - elif family == socket.AF_INET6: - host, port = address[:2] - else: + if hasattr(socket, 'AF_UNIX') and sock.family == socket.AF_UNIX: return - # On Windows, socket.inet_pton() is only available since Python 3.4 - if hasattr(socket, 'inet_pton'): - # getaddrinfo() is slow and has known issue: prefer inet_pton() - # if available - try: - socket.inet_pton(family, host) - except OSError as exc: - raise ValueError("address must be resolved (IP address), " - "got host %r: %s" - % (host, exc)) - else: - # Use getaddrinfo(flags=AI_NUMERICHOST) to ensure that the address is - # already resolved. - type_mask = 0 - if hasattr(socket, 'SOCK_NONBLOCK'): - type_mask |= socket.SOCK_NONBLOCK - if hasattr(socket, 'SOCK_CLOEXEC'): - type_mask |= socket.SOCK_CLOEXEC - try: - socket.getaddrinfo(host, port, - family=family, - type=(sock.type & ~type_mask), - proto=sock.proto, - flags=socket.AI_NUMERICHOST) - except socket.gaierror as err: - raise ValueError("address must be resolved (IP address), " - "got host %r: %s" - % (host, err)) + host, port = address[:2] + if _ipaddr_info(host, port, sock.family, sock.type, sock.proto) is None: + raise ValueError("address must be resolved (IP address)," + " got host %r" % host) def _run_until_complete_cb(fut): @@ -535,7 +571,12 @@ def getaddrinfo(self, host, port, *, family=0, type=0, proto=0, flags=0): - if self._debug: + info = _ipaddr_info(host, port, family, type, proto) + if info is not None: + fut = futures.Future(loop=self) + fut.set_result([info]) + return fut + elif self._debug: return self.run_in_executor(None, self._getaddrinfo_debug, host, port, family, type, proto, flags) else: diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -441,8 +441,7 @@ def sock_connect(self, sock, address): try: - if self._debug: - base_events._check_resolved_address(sock, address) + base_events._check_resolved_address(sock, address) except ValueError as err: fut = futures.Future(loop=self) fut.set_exception(err) diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -397,8 +397,7 @@ raise ValueError("the socket must be non-blocking") fut = futures.Future(loop=self) try: - if self._debug: - base_events._check_resolved_address(sock, address) + base_events._check_resolved_address(sock, address) except ValueError as err: fut.set_exception(err) else: diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py --- a/Lib/asyncio/test_utils.py +++ b/Lib/asyncio/test_utils.py @@ -446,9 +446,14 @@ finally: logger.setLevel(old_level) -def mock_nonblocking_socket(): + +def mock_nonblocking_socket(proto=socket.IPPROTO_TCP, type=socket.SOCK_STREAM, + family=socket.AF_INET): """Create a mock of a non-blocking socket.""" - sock = mock.Mock(socket.socket) + sock = mock.MagicMock(socket.socket) + sock.proto = proto + sock.type = type + sock.family = family sock.gettimeout.return_value = 0.0 return sock diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -32,6 +32,120 @@ PY34 = sys.version_info >= (3, 4) +def mock_socket_module(): + m_socket = mock.MagicMock(spec=socket) + for name in ( + 'AF_INET', 'AF_INET6', 'AF_UNSPEC', 'IPPROTO_TCP', 'IPPROTO_UDP', + 'SOCK_STREAM', 'SOCK_DGRAM', 'SOL_SOCKET', 'SO_REUSEADDR', 'inet_pton' + ): + if hasattr(socket, name): + setattr(m_socket, name, getattr(socket, name)) + else: + delattr(m_socket, name) + + m_socket.socket = mock.MagicMock() + m_socket.socket.return_value = test_utils.mock_nonblocking_socket() + + return m_socket + + +def patch_socket(f): + return mock.patch('asyncio.base_events.socket', + new_callable=mock_socket_module)(f) + + +class BaseEventTests(test_utils.TestCase): + + def setUp(self): + super().setUp() + base_events._ipaddr_info.cache_clear() + + def tearDown(self): + base_events._ipaddr_info.cache_clear() + super().tearDown() + + def test_ipaddr_info(self): + UNSPEC = socket.AF_UNSPEC + INET = socket.AF_INET + INET6 = socket.AF_INET6 + STREAM = socket.SOCK_STREAM + DGRAM = socket.SOCK_DGRAM + TCP = socket.IPPROTO_TCP + UDP = socket.IPPROTO_UDP + + self.assertEqual( + (INET, STREAM, TCP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, INET, STREAM, TCP)) + + self.assertEqual( + (INET, STREAM, TCP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, STREAM, TCP)) + + self.assertEqual( + (INET, DGRAM, UDP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, DGRAM, UDP)) + + # Socket type STREAM implies TCP protocol. + self.assertEqual( + (INET, STREAM, TCP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, STREAM, 0)) + + # Socket type DGRAM implies UDP protocol. + self.assertEqual( + (INET, DGRAM, UDP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, DGRAM, 0)) + + # No socket type. + self.assertIsNone( + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, 0, 0)) + + # IPv4 address with family IPv6. + self.assertIsNone( + base_events._ipaddr_info('1.2.3.4', 1, INET6, STREAM, TCP)) + + self.assertEqual( + (INET6, STREAM, TCP, '', ('::3', 1)), + base_events._ipaddr_info('::3', 1, INET6, STREAM, TCP)) + + self.assertEqual( + (INET6, STREAM, TCP, '', ('::3', 1)), + base_events._ipaddr_info('::3', 1, UNSPEC, STREAM, TCP)) + + # IPv6 address with family IPv4. + self.assertIsNone( + base_events._ipaddr_info('::3', 1, INET, STREAM, TCP)) + + # IPv6 address with zone index. + self.assertEqual( + (INET6, STREAM, TCP, '', ('::3%lo0', 1)), + base_events._ipaddr_info('::3%lo0', 1, INET6, STREAM, TCP)) + + @patch_socket + def test_ipaddr_info_no_inet_pton(self, m_socket): + del m_socket.inet_pton + self.test_ipaddr_info() + + def test_check_resolved_address(self): + sock = socket.socket(socket.AF_INET) + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + + sock = socket.socket(socket.AF_INET6) + base_events._check_resolved_address(sock, ('::3', 1)) + base_events._check_resolved_address(sock, ('::3%lo0', 1)) + self.assertRaises(ValueError, + base_events._check_resolved_address, sock, ('foo', 1)) + + def test_check_resolved_sock_type(self): + # Ensure we ignore extra flags in sock.type. + if hasattr(socket, 'SOCK_NONBLOCK'): + sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_NONBLOCK) + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + + if hasattr(socket, 'SOCK_CLOEXEC'): + sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_CLOEXEC) + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + + class BaseEventLoopTests(test_utils.TestCase): def setUp(self): @@ -875,7 +989,12 @@ self.loop = asyncio.new_event_loop() self.set_event_loop(self.loop) - @mock.patch('asyncio.base_events.socket') + def tearDown(self): + # Clear mocked constants like AF_INET from the cache. + base_events._ipaddr_info.cache_clear() + super().tearDown() + + @patch_socket def test_create_connection_multiple_errors(self, m_socket): class MyProto(asyncio.Protocol): @@ -908,7 +1027,7 @@ self.assertEqual(str(cm.exception), 'Multiple exceptions: err1, err2') - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_connection_timeout(self, m_socket): # Ensure that the socket is closed on timeout sock = mock.Mock() @@ -986,7 +1105,7 @@ with self.assertRaises(OSError): self.loop.run_until_complete(coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_connection_multiple_errors_local_addr(self, m_socket): def bind(addr): @@ -1018,6 +1137,46 @@ self.assertTrue(str(cm.exception).startswith('Multiple exceptions: ')) self.assertTrue(m_socket.socket.return_value.close.called) + def _test_create_connection_ip_addr(self, m_socket, allow_inet_pton): + # Test the fallback code, even if this system has inet_pton. + if not allow_inet_pton: + del m_socket.inet_pton + + def getaddrinfo(*args, **kw): + self.fail('should not have called getaddrinfo') + + m_socket.getaddrinfo = getaddrinfo + sock = m_socket.socket.return_value + + self.loop.add_reader = mock.Mock() + self.loop.add_reader._is_coroutine = False + self.loop.add_writer = mock.Mock() + self.loop.add_writer._is_coroutine = False + + coro = self.loop.create_connection(MyProto, '1.2.3.4', 80) + self.loop.run_until_complete(coro) + sock.connect.assert_called_with(('1.2.3.4', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + + sock.family = socket.AF_INET6 + coro = self.loop.create_connection(MyProto, '::2', 80) + + self.loop.run_until_complete(coro) + sock.connect.assert_called_with(('::2', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET6, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + + @patch_socket + def test_create_connection_ip_addr(self, m_socket): + self._test_create_connection_ip_addr(m_socket, True) + + @patch_socket + def test_create_connection_no_inet_pton(self, m_socket): + self._test_create_connection_ip_addr(m_socket, False) + def test_create_connection_no_local_addr(self): @asyncio.coroutine def getaddrinfo(host, *args, **kw): @@ -1153,11 +1312,9 @@ f = self.loop.create_server(MyProto, '0.0.0.0', 0) self.assertRaises(OSError, self.loop.run_until_complete, f) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_server_nosoreuseport(self, m_socket): m_socket.getaddrinfo = socket.getaddrinfo - m_socket.SOCK_STREAM = socket.SOCK_STREAM - m_socket.SOL_SOCKET = socket.SOL_SOCKET del m_socket.SO_REUSEPORT m_socket.socket.return_value = mock.Mock() @@ -1166,7 +1323,7 @@ self.assertRaises(ValueError, self.loop.run_until_complete, f) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_server_cant_bind(self, m_socket): class Err(OSError): @@ -1182,7 +1339,7 @@ self.assertRaises(OSError, self.loop.run_until_complete, fut) self.assertTrue(m_sock.close.called) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_no_addrinfo(self, m_socket): m_socket.getaddrinfo.return_value = [] m_socket.getaddrinfo._is_coroutine = False @@ -1211,7 +1368,7 @@ self.assertRaises( OSError, self.loop.run_until_complete, coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_socket_err(self, m_socket): m_socket.getaddrinfo = socket.getaddrinfo m_socket.socket.side_effect = OSError @@ -1234,7 +1391,7 @@ self.assertRaises( ValueError, self.loop.run_until_complete, coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_setblk_err(self, m_socket): m_socket.socket.return_value.setblocking.side_effect = OSError @@ -1250,12 +1407,11 @@ asyncio.DatagramProtocol) self.assertRaises(ValueError, self.loop.run_until_complete, coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_cant_bind(self, m_socket): class Err(OSError): pass - m_socket.AF_INET6 = socket.AF_INET6 m_socket.getaddrinfo = socket.getaddrinfo m_sock = m_socket.socket.return_value = mock.Mock() m_sock.bind.side_effect = Err @@ -1369,11 +1525,8 @@ self.loop.run_until_complete(protocol.done) self.assertEqual('CLOSED', protocol.state) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_nosoreuseport(self, m_socket): - m_socket.getaddrinfo = socket.getaddrinfo - m_socket.SOCK_DGRAM = socket.SOCK_DGRAM - m_socket.SOL_SOCKET = socket.SOL_SOCKET del m_socket.SO_REUSEPORT m_socket.socket.return_value = mock.Mock() @@ -1385,6 +1538,29 @@ self.assertRaises(ValueError, self.loop.run_until_complete, coro) + @patch_socket + def test_create_datagram_endpoint_ip_addr(self, m_socket): + def getaddrinfo(*args, **kw): + self.fail('should not have called getaddrinfo') + + m_socket.getaddrinfo = getaddrinfo + m_socket.socket.return_value.bind = bind = mock.Mock() + self.loop.add_reader = mock.Mock() + self.loop.add_reader._is_coroutine = False + + reuseport_supported = hasattr(socket, 'SO_REUSEPORT') + coro = self.loop.create_datagram_endpoint( + lambda: MyDatagramProto(loop=self.loop), + local_addr=('1.2.3.4', 0), + reuse_address=False, + reuse_port=reuseport_supported) + + self.loop.run_until_complete(coro) + bind.assert_called_with(('1.2.3.4', 0)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_UDP, + type=m_socket.SOCK_DGRAM) + def test_accept_connection_retry(self): sock = mock.Mock() sock.accept.side_effect = BlockingIOError() diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -1573,10 +1573,6 @@ 'selector': self.loop._selector.__class__.__name__}) def test_sock_connect_address(self): - # In debug mode, sock_connect() must ensure that the address is already - # resolved (call _check_resolved_address()) - self.loop.set_debug(True) - addresses = [(socket.AF_INET, ('www.python.org', 80))] if support.IPV6_ENABLED: addresses.extend(( diff --git a/Lib/test/test_asyncio/test_proactor_events.py b/Lib/test/test_asyncio/test_proactor_events.py --- a/Lib/test/test_asyncio/test_proactor_events.py +++ b/Lib/test/test_asyncio/test_proactor_events.py @@ -436,7 +436,7 @@ class BaseProactorEventLoopTests(test_utils.TestCase): def setUp(self): - self.sock = mock.Mock(socket.socket) + self.sock = test_utils.mock_nonblocking_socket() self.proactor = mock.Mock() self.ssock, self.csock = mock.Mock(), mock.Mock() @@ -491,8 +491,8 @@ self.proactor.send.assert_called_with(self.sock, b'data') def test_sock_connect(self): - self.loop.sock_connect(self.sock, 123) - self.proactor.connect.assert_called_with(self.sock, 123) + self.loop.sock_connect(self.sock, ('1.2.3.4', 123)) + self.proactor.connect.assert_called_with(self.sock, ('1.2.3.4', 123)) def test_sock_accept(self): self.loop.sock_accept(self.sock) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 19:36:10 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:36:10 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151217003610.19150.47300@psf.io> https://hg.python.org/cpython/rev/ceb50507ae88 changeset: 99585:ceb50507ae88 parent: 99582:16accac4b2f6 parent: 99584:53106c39c2e0 user: Yury Selivanov date: Wed Dec 16 19:31:55 2015 -0500 summary: Merge 3.5 files: Lib/asyncio/base_events.py | 117 +++- Lib/asyncio/proactor_events.py | 3 +- Lib/asyncio/selector_events.py | 3 +- Lib/asyncio/test_utils.py | 9 +- Lib/test/test_asyncio/test_base_events.py | 208 +++++++++- Lib/test/test_asyncio/test_events.py | 4 - Lib/test/test_asyncio/test_proactor_events.py | 6 +- 7 files changed, 283 insertions(+), 67 deletions(-) diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -16,8 +16,10 @@ import collections import concurrent.futures +import functools import heapq import inspect +import ipaddress import itertools import logging import os @@ -70,49 +72,83 @@ return repr(fd) +# Linux's sock.type is a bitmask that can include extra info about socket. +_SOCKET_TYPE_MASK = 0 +if hasattr(socket, 'SOCK_NONBLOCK'): + _SOCKET_TYPE_MASK |= socket.SOCK_NONBLOCK +if hasattr(socket, 'SOCK_CLOEXEC'): + _SOCKET_TYPE_MASK |= socket.SOCK_CLOEXEC + + + at functools.lru_cache(maxsize=1024) +def _ipaddr_info(host, port, family, type, proto): + # Try to skip getaddrinfo if "host" is already an IP. Since getaddrinfo + # blocks on an exclusive lock on some platforms, users might handle name + # resolution in their own code and pass in resolved IPs. + if proto not in {0, socket.IPPROTO_TCP, socket.IPPROTO_UDP} or host is None: + return None + + type &= ~_SOCKET_TYPE_MASK + if type == socket.SOCK_STREAM: + proto = socket.IPPROTO_TCP + elif type == socket.SOCK_DGRAM: + proto = socket.IPPROTO_UDP + else: + return None + + if hasattr(socket, 'inet_pton'): + if family == socket.AF_UNSPEC: + afs = [socket.AF_INET, socket.AF_INET6] + else: + afs = [family] + + for af in afs: + # Linux's inet_pton doesn't accept an IPv6 zone index after host, + # like '::1%lo0', so strip it. If we happen to make an invalid + # address look valid, we fail later in sock.connect or sock.bind. + try: + if af == socket.AF_INET6: + socket.inet_pton(af, host.partition('%')[0]) + else: + socket.inet_pton(af, host) + return af, type, proto, '', (host, port) + except OSError: + pass + + # "host" is not an IP address. + return None + + # No inet_pton. (On Windows it's only available since Python 3.4.) + # Even though getaddrinfo with AI_NUMERICHOST would be non-blocking, it + # still requires a lock on some platforms, and waiting for that lock could + # block the event loop. Use ipaddress instead, it's just text parsing. + try: + addr = ipaddress.IPv4Address(host) + except ValueError: + try: + addr = ipaddress.IPv6Address(host.partition('%')[0]) + except ValueError: + return None + + af = socket.AF_INET if addr.version == 4 else socket.AF_INET6 + if family not in (socket.AF_UNSPEC, af): + # "host" is wrong IP version for "family". + return None + + return af, type, proto, '', (host, port) + + def _check_resolved_address(sock, address): # Ensure that the address is already resolved to avoid the trap of hanging # the entire event loop when the address requires doing a DNS lookup. - # - # getaddrinfo() is slow (around 10 us per call): this function should only - # be called in debug mode - family = sock.family - if family == socket.AF_INET: - host, port = address - elif family == socket.AF_INET6: - host, port = address[:2] - else: + if hasattr(socket, 'AF_UNIX') and sock.family == socket.AF_UNIX: return - # On Windows, socket.inet_pton() is only available since Python 3.4 - if hasattr(socket, 'inet_pton'): - # getaddrinfo() is slow and has known issue: prefer inet_pton() - # if available - try: - socket.inet_pton(family, host) - except OSError as exc: - raise ValueError("address must be resolved (IP address), " - "got host %r: %s" - % (host, exc)) - else: - # Use getaddrinfo(flags=AI_NUMERICHOST) to ensure that the address is - # already resolved. - type_mask = 0 - if hasattr(socket, 'SOCK_NONBLOCK'): - type_mask |= socket.SOCK_NONBLOCK - if hasattr(socket, 'SOCK_CLOEXEC'): - type_mask |= socket.SOCK_CLOEXEC - try: - socket.getaddrinfo(host, port, - family=family, - type=(sock.type & ~type_mask), - proto=sock.proto, - flags=socket.AI_NUMERICHOST) - except socket.gaierror as err: - raise ValueError("address must be resolved (IP address), " - "got host %r: %s" - % (host, err)) + host, port = address[:2] + if _ipaddr_info(host, port, sock.family, sock.type, sock.proto) is None: + raise ValueError("address must be resolved (IP address)," + " got host %r" % host) def _run_until_complete_cb(fut): @@ -535,7 +571,12 @@ def getaddrinfo(self, host, port, *, family=0, type=0, proto=0, flags=0): - if self._debug: + info = _ipaddr_info(host, port, family, type, proto) + if info is not None: + fut = futures.Future(loop=self) + fut.set_result([info]) + return fut + elif self._debug: return self.run_in_executor(None, self._getaddrinfo_debug, host, port, family, type, proto, flags) else: diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -441,8 +441,7 @@ def sock_connect(self, sock, address): try: - if self._debug: - base_events._check_resolved_address(sock, address) + base_events._check_resolved_address(sock, address) except ValueError as err: fut = futures.Future(loop=self) fut.set_exception(err) diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -397,8 +397,7 @@ raise ValueError("the socket must be non-blocking") fut = futures.Future(loop=self) try: - if self._debug: - base_events._check_resolved_address(sock, address) + base_events._check_resolved_address(sock, address) except ValueError as err: fut.set_exception(err) else: diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py --- a/Lib/asyncio/test_utils.py +++ b/Lib/asyncio/test_utils.py @@ -446,9 +446,14 @@ finally: logger.setLevel(old_level) -def mock_nonblocking_socket(): + +def mock_nonblocking_socket(proto=socket.IPPROTO_TCP, type=socket.SOCK_STREAM, + family=socket.AF_INET): """Create a mock of a non-blocking socket.""" - sock = mock.Mock(socket.socket) + sock = mock.MagicMock(socket.socket) + sock.proto = proto + sock.type = type + sock.family = family sock.gettimeout.return_value = 0.0 return sock diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -32,6 +32,120 @@ PY34 = sys.version_info >= (3, 4) +def mock_socket_module(): + m_socket = mock.MagicMock(spec=socket) + for name in ( + 'AF_INET', 'AF_INET6', 'AF_UNSPEC', 'IPPROTO_TCP', 'IPPROTO_UDP', + 'SOCK_STREAM', 'SOCK_DGRAM', 'SOL_SOCKET', 'SO_REUSEADDR', 'inet_pton' + ): + if hasattr(socket, name): + setattr(m_socket, name, getattr(socket, name)) + else: + delattr(m_socket, name) + + m_socket.socket = mock.MagicMock() + m_socket.socket.return_value = test_utils.mock_nonblocking_socket() + + return m_socket + + +def patch_socket(f): + return mock.patch('asyncio.base_events.socket', + new_callable=mock_socket_module)(f) + + +class BaseEventTests(test_utils.TestCase): + + def setUp(self): + super().setUp() + base_events._ipaddr_info.cache_clear() + + def tearDown(self): + base_events._ipaddr_info.cache_clear() + super().tearDown() + + def test_ipaddr_info(self): + UNSPEC = socket.AF_UNSPEC + INET = socket.AF_INET + INET6 = socket.AF_INET6 + STREAM = socket.SOCK_STREAM + DGRAM = socket.SOCK_DGRAM + TCP = socket.IPPROTO_TCP + UDP = socket.IPPROTO_UDP + + self.assertEqual( + (INET, STREAM, TCP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, INET, STREAM, TCP)) + + self.assertEqual( + (INET, STREAM, TCP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, STREAM, TCP)) + + self.assertEqual( + (INET, DGRAM, UDP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, DGRAM, UDP)) + + # Socket type STREAM implies TCP protocol. + self.assertEqual( + (INET, STREAM, TCP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, STREAM, 0)) + + # Socket type DGRAM implies UDP protocol. + self.assertEqual( + (INET, DGRAM, UDP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, DGRAM, 0)) + + # No socket type. + self.assertIsNone( + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, 0, 0)) + + # IPv4 address with family IPv6. + self.assertIsNone( + base_events._ipaddr_info('1.2.3.4', 1, INET6, STREAM, TCP)) + + self.assertEqual( + (INET6, STREAM, TCP, '', ('::3', 1)), + base_events._ipaddr_info('::3', 1, INET6, STREAM, TCP)) + + self.assertEqual( + (INET6, STREAM, TCP, '', ('::3', 1)), + base_events._ipaddr_info('::3', 1, UNSPEC, STREAM, TCP)) + + # IPv6 address with family IPv4. + self.assertIsNone( + base_events._ipaddr_info('::3', 1, INET, STREAM, TCP)) + + # IPv6 address with zone index. + self.assertEqual( + (INET6, STREAM, TCP, '', ('::3%lo0', 1)), + base_events._ipaddr_info('::3%lo0', 1, INET6, STREAM, TCP)) + + @patch_socket + def test_ipaddr_info_no_inet_pton(self, m_socket): + del m_socket.inet_pton + self.test_ipaddr_info() + + def test_check_resolved_address(self): + sock = socket.socket(socket.AF_INET) + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + + sock = socket.socket(socket.AF_INET6) + base_events._check_resolved_address(sock, ('::3', 1)) + base_events._check_resolved_address(sock, ('::3%lo0', 1)) + self.assertRaises(ValueError, + base_events._check_resolved_address, sock, ('foo', 1)) + + def test_check_resolved_sock_type(self): + # Ensure we ignore extra flags in sock.type. + if hasattr(socket, 'SOCK_NONBLOCK'): + sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_NONBLOCK) + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + + if hasattr(socket, 'SOCK_CLOEXEC'): + sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_CLOEXEC) + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + + class BaseEventLoopTests(test_utils.TestCase): def setUp(self): @@ -875,7 +989,12 @@ self.loop = asyncio.new_event_loop() self.set_event_loop(self.loop) - @mock.patch('asyncio.base_events.socket') + def tearDown(self): + # Clear mocked constants like AF_INET from the cache. + base_events._ipaddr_info.cache_clear() + super().tearDown() + + @patch_socket def test_create_connection_multiple_errors(self, m_socket): class MyProto(asyncio.Protocol): @@ -908,7 +1027,7 @@ self.assertEqual(str(cm.exception), 'Multiple exceptions: err1, err2') - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_connection_timeout(self, m_socket): # Ensure that the socket is closed on timeout sock = mock.Mock() @@ -986,7 +1105,7 @@ with self.assertRaises(OSError): self.loop.run_until_complete(coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_connection_multiple_errors_local_addr(self, m_socket): def bind(addr): @@ -1018,6 +1137,46 @@ self.assertTrue(str(cm.exception).startswith('Multiple exceptions: ')) self.assertTrue(m_socket.socket.return_value.close.called) + def _test_create_connection_ip_addr(self, m_socket, allow_inet_pton): + # Test the fallback code, even if this system has inet_pton. + if not allow_inet_pton: + del m_socket.inet_pton + + def getaddrinfo(*args, **kw): + self.fail('should not have called getaddrinfo') + + m_socket.getaddrinfo = getaddrinfo + sock = m_socket.socket.return_value + + self.loop.add_reader = mock.Mock() + self.loop.add_reader._is_coroutine = False + self.loop.add_writer = mock.Mock() + self.loop.add_writer._is_coroutine = False + + coro = self.loop.create_connection(MyProto, '1.2.3.4', 80) + self.loop.run_until_complete(coro) + sock.connect.assert_called_with(('1.2.3.4', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + + sock.family = socket.AF_INET6 + coro = self.loop.create_connection(MyProto, '::2', 80) + + self.loop.run_until_complete(coro) + sock.connect.assert_called_with(('::2', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET6, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + + @patch_socket + def test_create_connection_ip_addr(self, m_socket): + self._test_create_connection_ip_addr(m_socket, True) + + @patch_socket + def test_create_connection_no_inet_pton(self, m_socket): + self._test_create_connection_ip_addr(m_socket, False) + def test_create_connection_no_local_addr(self): @asyncio.coroutine def getaddrinfo(host, *args, **kw): @@ -1153,11 +1312,9 @@ f = self.loop.create_server(MyProto, '0.0.0.0', 0) self.assertRaises(OSError, self.loop.run_until_complete, f) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_server_nosoreuseport(self, m_socket): m_socket.getaddrinfo = socket.getaddrinfo - m_socket.SOCK_STREAM = socket.SOCK_STREAM - m_socket.SOL_SOCKET = socket.SOL_SOCKET del m_socket.SO_REUSEPORT m_socket.socket.return_value = mock.Mock() @@ -1166,7 +1323,7 @@ self.assertRaises(ValueError, self.loop.run_until_complete, f) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_server_cant_bind(self, m_socket): class Err(OSError): @@ -1182,7 +1339,7 @@ self.assertRaises(OSError, self.loop.run_until_complete, fut) self.assertTrue(m_sock.close.called) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_no_addrinfo(self, m_socket): m_socket.getaddrinfo.return_value = [] m_socket.getaddrinfo._is_coroutine = False @@ -1211,7 +1368,7 @@ self.assertRaises( OSError, self.loop.run_until_complete, coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_socket_err(self, m_socket): m_socket.getaddrinfo = socket.getaddrinfo m_socket.socket.side_effect = OSError @@ -1234,7 +1391,7 @@ self.assertRaises( ValueError, self.loop.run_until_complete, coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_setblk_err(self, m_socket): m_socket.socket.return_value.setblocking.side_effect = OSError @@ -1250,12 +1407,11 @@ asyncio.DatagramProtocol) self.assertRaises(ValueError, self.loop.run_until_complete, coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_cant_bind(self, m_socket): class Err(OSError): pass - m_socket.AF_INET6 = socket.AF_INET6 m_socket.getaddrinfo = socket.getaddrinfo m_sock = m_socket.socket.return_value = mock.Mock() m_sock.bind.side_effect = Err @@ -1369,11 +1525,8 @@ self.loop.run_until_complete(protocol.done) self.assertEqual('CLOSED', protocol.state) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_nosoreuseport(self, m_socket): - m_socket.getaddrinfo = socket.getaddrinfo - m_socket.SOCK_DGRAM = socket.SOCK_DGRAM - m_socket.SOL_SOCKET = socket.SOL_SOCKET del m_socket.SO_REUSEPORT m_socket.socket.return_value = mock.Mock() @@ -1385,6 +1538,29 @@ self.assertRaises(ValueError, self.loop.run_until_complete, coro) + @patch_socket + def test_create_datagram_endpoint_ip_addr(self, m_socket): + def getaddrinfo(*args, **kw): + self.fail('should not have called getaddrinfo') + + m_socket.getaddrinfo = getaddrinfo + m_socket.socket.return_value.bind = bind = mock.Mock() + self.loop.add_reader = mock.Mock() + self.loop.add_reader._is_coroutine = False + + reuseport_supported = hasattr(socket, 'SO_REUSEPORT') + coro = self.loop.create_datagram_endpoint( + lambda: MyDatagramProto(loop=self.loop), + local_addr=('1.2.3.4', 0), + reuse_address=False, + reuse_port=reuseport_supported) + + self.loop.run_until_complete(coro) + bind.assert_called_with(('1.2.3.4', 0)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_UDP, + type=m_socket.SOCK_DGRAM) + def test_accept_connection_retry(self): sock = mock.Mock() sock.accept.side_effect = BlockingIOError() diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -1573,10 +1573,6 @@ 'selector': self.loop._selector.__class__.__name__}) def test_sock_connect_address(self): - # In debug mode, sock_connect() must ensure that the address is already - # resolved (call _check_resolved_address()) - self.loop.set_debug(True) - addresses = [(socket.AF_INET, ('www.python.org', 80))] if support.IPV6_ENABLED: addresses.extend(( diff --git a/Lib/test/test_asyncio/test_proactor_events.py b/Lib/test/test_asyncio/test_proactor_events.py --- a/Lib/test/test_asyncio/test_proactor_events.py +++ b/Lib/test/test_asyncio/test_proactor_events.py @@ -436,7 +436,7 @@ class BaseProactorEventLoopTests(test_utils.TestCase): def setUp(self): - self.sock = mock.Mock(socket.socket) + self.sock = test_utils.mock_nonblocking_socket() self.proactor = mock.Mock() self.ssock, self.csock = mock.Mock(), mock.Mock() @@ -491,8 +491,8 @@ self.proactor.send.assert_called_with(self.sock, b'data') def test_sock_connect(self): - self.loop.sock_connect(self.sock, 123) - self.proactor.connect.assert_called_with(self.sock, 123) + self.loop.sock_connect(self.sock, ('1.2.3.4', 123)) + self.proactor.connect.assert_called_with(self.sock, ('1.2.3.4', 123)) def test_sock_accept(self): self.loop.sock_accept(self.sock) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 19:36:13 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:36:13 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Normalize_whit?= =?utf-8?q?espace?= Message-ID: <20151217003610.57630.37301@psf.io> https://hg.python.org/cpython/rev/33c7980552a6 changeset: 99586:33c7980552a6 branch: 3.4 parent: 99583:51df143c098d user: Yury Selivanov date: Wed Dec 16 19:35:30 2015 -0500 summary: Normalize whitespace files: Lib/test/test_asyncio/test_base_events.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -1368,7 +1368,7 @@ self.assertRaises( OSError, self.loop.run_until_complete, coro) - @patch_socket + @patch_socket def test_create_datagram_endpoint_socket_err(self, m_socket): m_socket.getaddrinfo = socket.getaddrinfo m_socket.socket.side_effect = OSError -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 19:36:13 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:36:13 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_3=2E4?= Message-ID: <20151217003610.73388.936@psf.io> https://hg.python.org/cpython/rev/53106c39c2e0 changeset: 99584:53106c39c2e0 branch: 3.5 parent: 99581:e81189f75d04 parent: 99583:51df143c098d user: Yury Selivanov date: Wed Dec 16 19:31:40 2015 -0500 summary: Merge 3.4 files: Lib/asyncio/base_events.py | 117 +++- Lib/asyncio/proactor_events.py | 3 +- Lib/asyncio/selector_events.py | 3 +- Lib/asyncio/test_utils.py | 9 +- Lib/test/test_asyncio/test_base_events.py | 208 +++++++++- Lib/test/test_asyncio/test_events.py | 4 - Lib/test/test_asyncio/test_proactor_events.py | 6 +- 7 files changed, 283 insertions(+), 67 deletions(-) diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -16,8 +16,10 @@ import collections import concurrent.futures +import functools import heapq import inspect +import ipaddress import itertools import logging import os @@ -70,49 +72,83 @@ return repr(fd) +# Linux's sock.type is a bitmask that can include extra info about socket. +_SOCKET_TYPE_MASK = 0 +if hasattr(socket, 'SOCK_NONBLOCK'): + _SOCKET_TYPE_MASK |= socket.SOCK_NONBLOCK +if hasattr(socket, 'SOCK_CLOEXEC'): + _SOCKET_TYPE_MASK |= socket.SOCK_CLOEXEC + + + at functools.lru_cache(maxsize=1024) +def _ipaddr_info(host, port, family, type, proto): + # Try to skip getaddrinfo if "host" is already an IP. Since getaddrinfo + # blocks on an exclusive lock on some platforms, users might handle name + # resolution in their own code and pass in resolved IPs. + if proto not in {0, socket.IPPROTO_TCP, socket.IPPROTO_UDP} or host is None: + return None + + type &= ~_SOCKET_TYPE_MASK + if type == socket.SOCK_STREAM: + proto = socket.IPPROTO_TCP + elif type == socket.SOCK_DGRAM: + proto = socket.IPPROTO_UDP + else: + return None + + if hasattr(socket, 'inet_pton'): + if family == socket.AF_UNSPEC: + afs = [socket.AF_INET, socket.AF_INET6] + else: + afs = [family] + + for af in afs: + # Linux's inet_pton doesn't accept an IPv6 zone index after host, + # like '::1%lo0', so strip it. If we happen to make an invalid + # address look valid, we fail later in sock.connect or sock.bind. + try: + if af == socket.AF_INET6: + socket.inet_pton(af, host.partition('%')[0]) + else: + socket.inet_pton(af, host) + return af, type, proto, '', (host, port) + except OSError: + pass + + # "host" is not an IP address. + return None + + # No inet_pton. (On Windows it's only available since Python 3.4.) + # Even though getaddrinfo with AI_NUMERICHOST would be non-blocking, it + # still requires a lock on some platforms, and waiting for that lock could + # block the event loop. Use ipaddress instead, it's just text parsing. + try: + addr = ipaddress.IPv4Address(host) + except ValueError: + try: + addr = ipaddress.IPv6Address(host.partition('%')[0]) + except ValueError: + return None + + af = socket.AF_INET if addr.version == 4 else socket.AF_INET6 + if family not in (socket.AF_UNSPEC, af): + # "host" is wrong IP version for "family". + return None + + return af, type, proto, '', (host, port) + + def _check_resolved_address(sock, address): # Ensure that the address is already resolved to avoid the trap of hanging # the entire event loop when the address requires doing a DNS lookup. - # - # getaddrinfo() is slow (around 10 us per call): this function should only - # be called in debug mode - family = sock.family - if family == socket.AF_INET: - host, port = address - elif family == socket.AF_INET6: - host, port = address[:2] - else: + if hasattr(socket, 'AF_UNIX') and sock.family == socket.AF_UNIX: return - # On Windows, socket.inet_pton() is only available since Python 3.4 - if hasattr(socket, 'inet_pton'): - # getaddrinfo() is slow and has known issue: prefer inet_pton() - # if available - try: - socket.inet_pton(family, host) - except OSError as exc: - raise ValueError("address must be resolved (IP address), " - "got host %r: %s" - % (host, exc)) - else: - # Use getaddrinfo(flags=AI_NUMERICHOST) to ensure that the address is - # already resolved. - type_mask = 0 - if hasattr(socket, 'SOCK_NONBLOCK'): - type_mask |= socket.SOCK_NONBLOCK - if hasattr(socket, 'SOCK_CLOEXEC'): - type_mask |= socket.SOCK_CLOEXEC - try: - socket.getaddrinfo(host, port, - family=family, - type=(sock.type & ~type_mask), - proto=sock.proto, - flags=socket.AI_NUMERICHOST) - except socket.gaierror as err: - raise ValueError("address must be resolved (IP address), " - "got host %r: %s" - % (host, err)) + host, port = address[:2] + if _ipaddr_info(host, port, sock.family, sock.type, sock.proto) is None: + raise ValueError("address must be resolved (IP address)," + " got host %r" % host) def _run_until_complete_cb(fut): @@ -535,7 +571,12 @@ def getaddrinfo(self, host, port, *, family=0, type=0, proto=0, flags=0): - if self._debug: + info = _ipaddr_info(host, port, family, type, proto) + if info is not None: + fut = futures.Future(loop=self) + fut.set_result([info]) + return fut + elif self._debug: return self.run_in_executor(None, self._getaddrinfo_debug, host, port, family, type, proto, flags) else: diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -441,8 +441,7 @@ def sock_connect(self, sock, address): try: - if self._debug: - base_events._check_resolved_address(sock, address) + base_events._check_resolved_address(sock, address) except ValueError as err: fut = futures.Future(loop=self) fut.set_exception(err) diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -397,8 +397,7 @@ raise ValueError("the socket must be non-blocking") fut = futures.Future(loop=self) try: - if self._debug: - base_events._check_resolved_address(sock, address) + base_events._check_resolved_address(sock, address) except ValueError as err: fut.set_exception(err) else: diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py --- a/Lib/asyncio/test_utils.py +++ b/Lib/asyncio/test_utils.py @@ -446,9 +446,14 @@ finally: logger.setLevel(old_level) -def mock_nonblocking_socket(): + +def mock_nonblocking_socket(proto=socket.IPPROTO_TCP, type=socket.SOCK_STREAM, + family=socket.AF_INET): """Create a mock of a non-blocking socket.""" - sock = mock.Mock(socket.socket) + sock = mock.MagicMock(socket.socket) + sock.proto = proto + sock.type = type + sock.family = family sock.gettimeout.return_value = 0.0 return sock diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -32,6 +32,120 @@ PY34 = sys.version_info >= (3, 4) +def mock_socket_module(): + m_socket = mock.MagicMock(spec=socket) + for name in ( + 'AF_INET', 'AF_INET6', 'AF_UNSPEC', 'IPPROTO_TCP', 'IPPROTO_UDP', + 'SOCK_STREAM', 'SOCK_DGRAM', 'SOL_SOCKET', 'SO_REUSEADDR', 'inet_pton' + ): + if hasattr(socket, name): + setattr(m_socket, name, getattr(socket, name)) + else: + delattr(m_socket, name) + + m_socket.socket = mock.MagicMock() + m_socket.socket.return_value = test_utils.mock_nonblocking_socket() + + return m_socket + + +def patch_socket(f): + return mock.patch('asyncio.base_events.socket', + new_callable=mock_socket_module)(f) + + +class BaseEventTests(test_utils.TestCase): + + def setUp(self): + super().setUp() + base_events._ipaddr_info.cache_clear() + + def tearDown(self): + base_events._ipaddr_info.cache_clear() + super().tearDown() + + def test_ipaddr_info(self): + UNSPEC = socket.AF_UNSPEC + INET = socket.AF_INET + INET6 = socket.AF_INET6 + STREAM = socket.SOCK_STREAM + DGRAM = socket.SOCK_DGRAM + TCP = socket.IPPROTO_TCP + UDP = socket.IPPROTO_UDP + + self.assertEqual( + (INET, STREAM, TCP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, INET, STREAM, TCP)) + + self.assertEqual( + (INET, STREAM, TCP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, STREAM, TCP)) + + self.assertEqual( + (INET, DGRAM, UDP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, DGRAM, UDP)) + + # Socket type STREAM implies TCP protocol. + self.assertEqual( + (INET, STREAM, TCP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, STREAM, 0)) + + # Socket type DGRAM implies UDP protocol. + self.assertEqual( + (INET, DGRAM, UDP, '', ('1.2.3.4', 1)), + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, DGRAM, 0)) + + # No socket type. + self.assertIsNone( + base_events._ipaddr_info('1.2.3.4', 1, UNSPEC, 0, 0)) + + # IPv4 address with family IPv6. + self.assertIsNone( + base_events._ipaddr_info('1.2.3.4', 1, INET6, STREAM, TCP)) + + self.assertEqual( + (INET6, STREAM, TCP, '', ('::3', 1)), + base_events._ipaddr_info('::3', 1, INET6, STREAM, TCP)) + + self.assertEqual( + (INET6, STREAM, TCP, '', ('::3', 1)), + base_events._ipaddr_info('::3', 1, UNSPEC, STREAM, TCP)) + + # IPv6 address with family IPv4. + self.assertIsNone( + base_events._ipaddr_info('::3', 1, INET, STREAM, TCP)) + + # IPv6 address with zone index. + self.assertEqual( + (INET6, STREAM, TCP, '', ('::3%lo0', 1)), + base_events._ipaddr_info('::3%lo0', 1, INET6, STREAM, TCP)) + + @patch_socket + def test_ipaddr_info_no_inet_pton(self, m_socket): + del m_socket.inet_pton + self.test_ipaddr_info() + + def test_check_resolved_address(self): + sock = socket.socket(socket.AF_INET) + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + + sock = socket.socket(socket.AF_INET6) + base_events._check_resolved_address(sock, ('::3', 1)) + base_events._check_resolved_address(sock, ('::3%lo0', 1)) + self.assertRaises(ValueError, + base_events._check_resolved_address, sock, ('foo', 1)) + + def test_check_resolved_sock_type(self): + # Ensure we ignore extra flags in sock.type. + if hasattr(socket, 'SOCK_NONBLOCK'): + sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_NONBLOCK) + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + + if hasattr(socket, 'SOCK_CLOEXEC'): + sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_CLOEXEC) + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + + class BaseEventLoopTests(test_utils.TestCase): def setUp(self): @@ -875,7 +989,12 @@ self.loop = asyncio.new_event_loop() self.set_event_loop(self.loop) - @mock.patch('asyncio.base_events.socket') + def tearDown(self): + # Clear mocked constants like AF_INET from the cache. + base_events._ipaddr_info.cache_clear() + super().tearDown() + + @patch_socket def test_create_connection_multiple_errors(self, m_socket): class MyProto(asyncio.Protocol): @@ -908,7 +1027,7 @@ self.assertEqual(str(cm.exception), 'Multiple exceptions: err1, err2') - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_connection_timeout(self, m_socket): # Ensure that the socket is closed on timeout sock = mock.Mock() @@ -986,7 +1105,7 @@ with self.assertRaises(OSError): self.loop.run_until_complete(coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_connection_multiple_errors_local_addr(self, m_socket): def bind(addr): @@ -1018,6 +1137,46 @@ self.assertTrue(str(cm.exception).startswith('Multiple exceptions: ')) self.assertTrue(m_socket.socket.return_value.close.called) + def _test_create_connection_ip_addr(self, m_socket, allow_inet_pton): + # Test the fallback code, even if this system has inet_pton. + if not allow_inet_pton: + del m_socket.inet_pton + + def getaddrinfo(*args, **kw): + self.fail('should not have called getaddrinfo') + + m_socket.getaddrinfo = getaddrinfo + sock = m_socket.socket.return_value + + self.loop.add_reader = mock.Mock() + self.loop.add_reader._is_coroutine = False + self.loop.add_writer = mock.Mock() + self.loop.add_writer._is_coroutine = False + + coro = self.loop.create_connection(MyProto, '1.2.3.4', 80) + self.loop.run_until_complete(coro) + sock.connect.assert_called_with(('1.2.3.4', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + + sock.family = socket.AF_INET6 + coro = self.loop.create_connection(MyProto, '::2', 80) + + self.loop.run_until_complete(coro) + sock.connect.assert_called_with(('::2', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET6, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + + @patch_socket + def test_create_connection_ip_addr(self, m_socket): + self._test_create_connection_ip_addr(m_socket, True) + + @patch_socket + def test_create_connection_no_inet_pton(self, m_socket): + self._test_create_connection_ip_addr(m_socket, False) + def test_create_connection_no_local_addr(self): @asyncio.coroutine def getaddrinfo(host, *args, **kw): @@ -1153,11 +1312,9 @@ f = self.loop.create_server(MyProto, '0.0.0.0', 0) self.assertRaises(OSError, self.loop.run_until_complete, f) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_server_nosoreuseport(self, m_socket): m_socket.getaddrinfo = socket.getaddrinfo - m_socket.SOCK_STREAM = socket.SOCK_STREAM - m_socket.SOL_SOCKET = socket.SOL_SOCKET del m_socket.SO_REUSEPORT m_socket.socket.return_value = mock.Mock() @@ -1166,7 +1323,7 @@ self.assertRaises(ValueError, self.loop.run_until_complete, f) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_server_cant_bind(self, m_socket): class Err(OSError): @@ -1182,7 +1339,7 @@ self.assertRaises(OSError, self.loop.run_until_complete, fut) self.assertTrue(m_sock.close.called) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_no_addrinfo(self, m_socket): m_socket.getaddrinfo.return_value = [] m_socket.getaddrinfo._is_coroutine = False @@ -1211,7 +1368,7 @@ self.assertRaises( OSError, self.loop.run_until_complete, coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_socket_err(self, m_socket): m_socket.getaddrinfo = socket.getaddrinfo m_socket.socket.side_effect = OSError @@ -1234,7 +1391,7 @@ self.assertRaises( ValueError, self.loop.run_until_complete, coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_setblk_err(self, m_socket): m_socket.socket.return_value.setblocking.side_effect = OSError @@ -1250,12 +1407,11 @@ asyncio.DatagramProtocol) self.assertRaises(ValueError, self.loop.run_until_complete, coro) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_cant_bind(self, m_socket): class Err(OSError): pass - m_socket.AF_INET6 = socket.AF_INET6 m_socket.getaddrinfo = socket.getaddrinfo m_sock = m_socket.socket.return_value = mock.Mock() m_sock.bind.side_effect = Err @@ -1369,11 +1525,8 @@ self.loop.run_until_complete(protocol.done) self.assertEqual('CLOSED', protocol.state) - @mock.patch('asyncio.base_events.socket') + @patch_socket def test_create_datagram_endpoint_nosoreuseport(self, m_socket): - m_socket.getaddrinfo = socket.getaddrinfo - m_socket.SOCK_DGRAM = socket.SOCK_DGRAM - m_socket.SOL_SOCKET = socket.SOL_SOCKET del m_socket.SO_REUSEPORT m_socket.socket.return_value = mock.Mock() @@ -1385,6 +1538,29 @@ self.assertRaises(ValueError, self.loop.run_until_complete, coro) + @patch_socket + def test_create_datagram_endpoint_ip_addr(self, m_socket): + def getaddrinfo(*args, **kw): + self.fail('should not have called getaddrinfo') + + m_socket.getaddrinfo = getaddrinfo + m_socket.socket.return_value.bind = bind = mock.Mock() + self.loop.add_reader = mock.Mock() + self.loop.add_reader._is_coroutine = False + + reuseport_supported = hasattr(socket, 'SO_REUSEPORT') + coro = self.loop.create_datagram_endpoint( + lambda: MyDatagramProto(loop=self.loop), + local_addr=('1.2.3.4', 0), + reuse_address=False, + reuse_port=reuseport_supported) + + self.loop.run_until_complete(coro) + bind.assert_called_with(('1.2.3.4', 0)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_UDP, + type=m_socket.SOCK_DGRAM) + def test_accept_connection_retry(self): sock = mock.Mock() sock.accept.side_effect = BlockingIOError() diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -1573,10 +1573,6 @@ 'selector': self.loop._selector.__class__.__name__}) def test_sock_connect_address(self): - # In debug mode, sock_connect() must ensure that the address is already - # resolved (call _check_resolved_address()) - self.loop.set_debug(True) - addresses = [(socket.AF_INET, ('www.python.org', 80))] if support.IPV6_ENABLED: addresses.extend(( diff --git a/Lib/test/test_asyncio/test_proactor_events.py b/Lib/test/test_asyncio/test_proactor_events.py --- a/Lib/test/test_asyncio/test_proactor_events.py +++ b/Lib/test/test_asyncio/test_proactor_events.py @@ -436,7 +436,7 @@ class BaseProactorEventLoopTests(test_utils.TestCase): def setUp(self): - self.sock = mock.Mock(socket.socket) + self.sock = test_utils.mock_nonblocking_socket() self.proactor = mock.Mock() self.ssock, self.csock = mock.Mock(), mock.Mock() @@ -491,8 +491,8 @@ self.proactor.send.assert_called_with(self.sock, b'data') def test_sock_connect(self): - self.loop.sock_connect(self.sock, 123) - self.proactor.connect.assert_called_with(self.sock, 123) + self.loop.sock_connect(self.sock, ('1.2.3.4', 123)) + self.proactor.connect.assert_called_with(self.sock, ('1.2.3.4', 123)) def test_sock_accept(self): self.loop.sock_accept(self.sock) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 19:36:15 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:36:15 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151217003615.19140.14671@psf.io> https://hg.python.org/cpython/rev/3d19bbabb5ec changeset: 99588:3d19bbabb5ec parent: 99585:ceb50507ae88 parent: 99587:5629ccdfc874 user: Yury Selivanov date: Wed Dec 16 19:36:01 2015 -0500 summary: Merge 3.5 files: Lib/test/test_asyncio/test_base_events.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -1368,7 +1368,7 @@ self.assertRaises( OSError, self.loop.run_until_complete, coro) - @patch_socket + @patch_socket def test_create_datagram_endpoint_socket_err(self, m_socket): m_socket.getaddrinfo = socket.getaddrinfo m_socket.socket.side_effect = OSError -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 19:36:27 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:36:27 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_3=2E4?= Message-ID: <20151217003615.73370.35365@psf.io> https://hg.python.org/cpython/rev/5629ccdfc874 changeset: 99587:5629ccdfc874 branch: 3.5 parent: 99584:53106c39c2e0 parent: 99586:33c7980552a6 user: Yury Selivanov date: Wed Dec 16 19:35:39 2015 -0500 summary: Merge 3.4 files: Lib/test/test_asyncio/test_base_events.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -1368,7 +1368,7 @@ self.assertRaises( OSError, self.loop.run_until_complete, coro) - @patch_socket + @patch_socket def test_create_datagram_endpoint_socket_err(self, m_socket): m_socket.getaddrinfo = socket.getaddrinfo m_socket.socket.side_effect = OSError -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 19:40:33 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:40:33 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_asyncio/tests?= =?utf-8?q?=3A_Fix_deprecation_warning?= Message-ID: <20151217004033.16752.93671@psf.io> https://hg.python.org/cpython/rev/bc0dcc3d9ebe changeset: 99589:bc0dcc3d9ebe branch: 3.4 parent: 99586:33c7980552a6 user: Yury Selivanov date: Wed Dec 16 19:40:03 2015 -0500 summary: asyncio/tests: Fix deprecation warning files: Lib/test/test_asyncio/test_streams.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -351,7 +351,7 @@ self.assertEqual(b'', data) self.assertEqual(self.DATA, stream._buffer) - with self.assertRaisesRegexp(ValueError, 'less than zero'): + with self.assertRaisesRegex(ValueError, 'less than zero'): self.loop.run_until_complete(stream.readexactly(-1)) self.assertEqual(self.DATA, stream._buffer) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 19:40:33 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:40:33 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151217004033.6463.64967@psf.io> https://hg.python.org/cpython/rev/e54e1d02c5a2 changeset: 99591:e54e1d02c5a2 parent: 99588:3d19bbabb5ec parent: 99590:4e263be33d4f user: Yury Selivanov date: Wed Dec 16 19:40:23 2015 -0500 summary: Merge 3.5 files: Lib/test/test_asyncio/test_streams.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -351,7 +351,7 @@ self.assertEqual(b'', data) self.assertEqual(self.DATA, stream._buffer) - with self.assertRaisesRegexp(ValueError, 'less than zero'): + with self.assertRaisesRegex(ValueError, 'less than zero'): self.loop.run_until_complete(stream.readexactly(-1)) self.assertEqual(self.DATA, stream._buffer) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 19:40:34 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:40:34 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_3=2E4?= Message-ID: <20151217004033.2934.91847@psf.io> https://hg.python.org/cpython/rev/4e263be33d4f changeset: 99590:4e263be33d4f branch: 3.5 parent: 99587:5629ccdfc874 parent: 99589:bc0dcc3d9ebe user: Yury Selivanov date: Wed Dec 16 19:40:11 2015 -0500 summary: Merge 3.4 files: Lib/test/test_asyncio/test_streams.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -351,7 +351,7 @@ self.assertEqual(b'', data) self.assertEqual(self.DATA, stream._buffer) - with self.assertRaisesRegexp(ValueError, 'less than zero'): + with self.assertRaisesRegex(ValueError, 'less than zero'): self.loop.run_until_complete(stream.readexactly(-1)) self.assertEqual(self.DATA, stream._buffer) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 19:51:37 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:51:37 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151217005136.83195.4128@psf.io> https://hg.python.org/cpython/rev/a4c1b8e699d8 changeset: 99594:a4c1b8e699d8 parent: 99591:e54e1d02c5a2 parent: 99593:e94c278daa10 user: Yury Selivanov date: Wed Dec 16 19:51:31 2015 -0500 summary: Merge 3.5 files: Lib/test/test_asyncio/test_base_events.py | 18 ++++++---- Lib/test/test_asyncio/test_streams.py | 13 ++++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -127,23 +127,27 @@ def test_check_resolved_address(self): sock = socket.socket(socket.AF_INET) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) sock = socket.socket(socket.AF_INET6) - base_events._check_resolved_address(sock, ('::3', 1)) - base_events._check_resolved_address(sock, ('::3%lo0', 1)) - self.assertRaises(ValueError, - base_events._check_resolved_address, sock, ('foo', 1)) + with sock: + base_events._check_resolved_address(sock, ('::3', 1)) + base_events._check_resolved_address(sock, ('::3%lo0', 1)) + with self.assertRaises(ValueError): + base_events._check_resolved_address(sock, ('foo', 1)) def test_check_resolved_sock_type(self): # Ensure we ignore extra flags in sock.type. if hasattr(socket, 'SOCK_NONBLOCK'): sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_NONBLOCK) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) if hasattr(socket, 'SOCK_CLOEXEC'): sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_CLOEXEC) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) class BaseEventLoopTests(test_utils.TestCase): diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -647,12 +647,13 @@ def server(): # Runs in a separate thread. sock = socket.socket() - sock.bind(('localhost', 0)) - sock.listen(1) - addr = sock.getsockname() - q.put(addr) - clt, _ = sock.accept() - clt.close() + with sock: + sock.bind(('localhost', 0)) + sock.listen(1) + addr = sock.getsockname() + q.put(addr) + clt, _ = sock.accept() + clt.close() @asyncio.coroutine def client(host, port): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 19:51:37 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:51:37 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_3=2E4?= Message-ID: <20151217005136.90152.73556@psf.io> https://hg.python.org/cpython/rev/e94c278daa10 changeset: 99593:e94c278daa10 branch: 3.5 parent: 99590:4e263be33d4f parent: 99592:5fdcadf94c0d user: Yury Selivanov date: Wed Dec 16 19:51:19 2015 -0500 summary: Merge 3.4 files: Lib/test/test_asyncio/test_base_events.py | 18 ++++++---- Lib/test/test_asyncio/test_streams.py | 13 ++++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -127,23 +127,27 @@ def test_check_resolved_address(self): sock = socket.socket(socket.AF_INET) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) sock = socket.socket(socket.AF_INET6) - base_events._check_resolved_address(sock, ('::3', 1)) - base_events._check_resolved_address(sock, ('::3%lo0', 1)) - self.assertRaises(ValueError, - base_events._check_resolved_address, sock, ('foo', 1)) + with sock: + base_events._check_resolved_address(sock, ('::3', 1)) + base_events._check_resolved_address(sock, ('::3%lo0', 1)) + with self.assertRaises(ValueError): + base_events._check_resolved_address(sock, ('foo', 1)) def test_check_resolved_sock_type(self): # Ensure we ignore extra flags in sock.type. if hasattr(socket, 'SOCK_NONBLOCK'): sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_NONBLOCK) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) if hasattr(socket, 'SOCK_CLOEXEC'): sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_CLOEXEC) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) class BaseEventLoopTests(test_utils.TestCase): diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -647,12 +647,13 @@ def server(): # Runs in a separate thread. sock = socket.socket() - sock.bind(('localhost', 0)) - sock.listen(1) - addr = sock.getsockname() - q.put(addr) - clt, _ = sock.accept() - clt.close() + with sock: + sock.bind(('localhost', 0)) + sock.listen(1) + addr = sock.getsockname() + q.put(addr) + clt, _ = sock.accept() + clt.close() @asyncio.coroutine def client(host, port): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 19:51:38 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 00:51:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_asyncio/tests?= =?utf-8?q?=3A_Fix_some_ResourceWarnings?= Message-ID: <20151217005136.90174.95874@psf.io> https://hg.python.org/cpython/rev/5fdcadf94c0d changeset: 99592:5fdcadf94c0d branch: 3.4 parent: 99589:bc0dcc3d9ebe user: Yury Selivanov date: Wed Dec 16 19:51:09 2015 -0500 summary: asyncio/tests: Fix some ResourceWarnings files: Lib/test/test_asyncio/test_base_events.py | 18 ++++++---- Lib/test/test_asyncio/test_streams.py | 13 ++++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -127,23 +127,27 @@ def test_check_resolved_address(self): sock = socket.socket(socket.AF_INET) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) sock = socket.socket(socket.AF_INET6) - base_events._check_resolved_address(sock, ('::3', 1)) - base_events._check_resolved_address(sock, ('::3%lo0', 1)) - self.assertRaises(ValueError, - base_events._check_resolved_address, sock, ('foo', 1)) + with sock: + base_events._check_resolved_address(sock, ('::3', 1)) + base_events._check_resolved_address(sock, ('::3%lo0', 1)) + with self.assertRaises(ValueError): + base_events._check_resolved_address(sock, ('foo', 1)) def test_check_resolved_sock_type(self): # Ensure we ignore extra flags in sock.type. if hasattr(socket, 'SOCK_NONBLOCK'): sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_NONBLOCK) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) if hasattr(socket, 'SOCK_CLOEXEC'): sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_CLOEXEC) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) class BaseEventLoopTests(test_utils.TestCase): diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -647,12 +647,13 @@ def server(): # Runs in a separate thread. sock = socket.socket() - sock.bind(('localhost', 0)) - sock.listen(1) - addr = sock.getsockname() - q.put(addr) - clt, _ = sock.accept() - clt.close() + with sock: + sock.bind(('localhost', 0)) + sock.listen(1) + addr = sock.getsockname() + q.put(addr) + clt, _ = sock.accept() + clt.close() @asyncio.coroutine def client(host, port): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 20:23:52 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 01:23:52 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151217012352.7688.79046@psf.io> https://hg.python.org/cpython/rev/37c4e7463b18 changeset: 99597:37c4e7463b18 parent: 99594:a4c1b8e699d8 parent: 99596:d56cfe234627 user: Yury Selivanov date: Wed Dec 16 20:23:47 2015 -0500 summary: Merge 3.5 files: Lib/test/test_asyncio/test_base_events.py | 47 ++++++---- 1 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -1157,21 +1157,28 @@ self.loop.add_writer = mock.Mock() self.loop.add_writer._is_coroutine = False - coro = self.loop.create_connection(MyProto, '1.2.3.4', 80) - self.loop.run_until_complete(coro) - sock.connect.assert_called_with(('1.2.3.4', 80)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET, - proto=m_socket.IPPROTO_TCP, - type=m_socket.SOCK_STREAM) + coro = self.loop.create_connection(asyncio.Protocol, '1.2.3.4', 80) + t, p = self.loop.run_until_complete(coro) + try: + sock.connect.assert_called_with(('1.2.3.4', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close sock.family = socket.AF_INET6 - coro = self.loop.create_connection(MyProto, '::2', 80) - - self.loop.run_until_complete(coro) - sock.connect.assert_called_with(('::2', 80)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET6, - proto=m_socket.IPPROTO_TCP, - type=m_socket.SOCK_STREAM) + coro = self.loop.create_connection(asyncio.Protocol, '::2', 80) + t, p = self.loop.run_until_complete(coro) + try: + sock.connect.assert_called_with(('::2', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET6, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close @patch_socket def test_create_connection_ip_addr(self, m_socket): @@ -1559,11 +1566,15 @@ reuse_address=False, reuse_port=reuseport_supported) - self.loop.run_until_complete(coro) - bind.assert_called_with(('1.2.3.4', 0)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET, - proto=m_socket.IPPROTO_UDP, - type=m_socket.SOCK_DGRAM) + t, p = self.loop.run_until_complete(coro) + try: + bind.assert_called_with(('1.2.3.4', 0)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_UDP, + type=m_socket.SOCK_DGRAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close def test_accept_connection_retry(self): sock = mock.Mock() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 20:23:53 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 01:23:53 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_3=2E4?= Message-ID: <20151217012352.73390.39113@psf.io> https://hg.python.org/cpython/rev/d56cfe234627 changeset: 99596:d56cfe234627 branch: 3.5 parent: 99593:e94c278daa10 parent: 99595:56095b0e7890 user: Yury Selivanov date: Wed Dec 16 20:23:37 2015 -0500 summary: Merge 3.4 files: Lib/test/test_asyncio/test_base_events.py | 47 ++++++---- 1 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -1157,21 +1157,28 @@ self.loop.add_writer = mock.Mock() self.loop.add_writer._is_coroutine = False - coro = self.loop.create_connection(MyProto, '1.2.3.4', 80) - self.loop.run_until_complete(coro) - sock.connect.assert_called_with(('1.2.3.4', 80)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET, - proto=m_socket.IPPROTO_TCP, - type=m_socket.SOCK_STREAM) + coro = self.loop.create_connection(asyncio.Protocol, '1.2.3.4', 80) + t, p = self.loop.run_until_complete(coro) + try: + sock.connect.assert_called_with(('1.2.3.4', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close sock.family = socket.AF_INET6 - coro = self.loop.create_connection(MyProto, '::2', 80) - - self.loop.run_until_complete(coro) - sock.connect.assert_called_with(('::2', 80)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET6, - proto=m_socket.IPPROTO_TCP, - type=m_socket.SOCK_STREAM) + coro = self.loop.create_connection(asyncio.Protocol, '::2', 80) + t, p = self.loop.run_until_complete(coro) + try: + sock.connect.assert_called_with(('::2', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET6, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close @patch_socket def test_create_connection_ip_addr(self, m_socket): @@ -1559,11 +1566,15 @@ reuse_address=False, reuse_port=reuseport_supported) - self.loop.run_until_complete(coro) - bind.assert_called_with(('1.2.3.4', 0)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET, - proto=m_socket.IPPROTO_UDP, - type=m_socket.SOCK_DGRAM) + t, p = self.loop.run_until_complete(coro) + try: + bind.assert_called_with(('1.2.3.4', 0)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_UDP, + type=m_socket.SOCK_DGRAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close def test_accept_connection_retry(self): sock = mock.Mock() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 20:23:53 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 01:23:53 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_asyncio/tests?= =?utf-8?q?=3A_Fix_ResourceWarnings_related_to_unclosed_transports?= Message-ID: <20151217012352.73376.52855@psf.io> https://hg.python.org/cpython/rev/56095b0e7890 changeset: 99595:56095b0e7890 branch: 3.4 parent: 99592:5fdcadf94c0d user: Yury Selivanov date: Wed Dec 16 20:23:26 2015 -0500 summary: asyncio/tests: Fix ResourceWarnings related to unclosed transports files: Lib/test/test_asyncio/test_base_events.py | 47 ++++++---- 1 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -1157,21 +1157,28 @@ self.loop.add_writer = mock.Mock() self.loop.add_writer._is_coroutine = False - coro = self.loop.create_connection(MyProto, '1.2.3.4', 80) - self.loop.run_until_complete(coro) - sock.connect.assert_called_with(('1.2.3.4', 80)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET, - proto=m_socket.IPPROTO_TCP, - type=m_socket.SOCK_STREAM) + coro = self.loop.create_connection(asyncio.Protocol, '1.2.3.4', 80) + t, p = self.loop.run_until_complete(coro) + try: + sock.connect.assert_called_with(('1.2.3.4', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close sock.family = socket.AF_INET6 - coro = self.loop.create_connection(MyProto, '::2', 80) - - self.loop.run_until_complete(coro) - sock.connect.assert_called_with(('::2', 80)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET6, - proto=m_socket.IPPROTO_TCP, - type=m_socket.SOCK_STREAM) + coro = self.loop.create_connection(asyncio.Protocol, '::2', 80) + t, p = self.loop.run_until_complete(coro) + try: + sock.connect.assert_called_with(('::2', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET6, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close @patch_socket def test_create_connection_ip_addr(self, m_socket): @@ -1559,11 +1566,15 @@ reuse_address=False, reuse_port=reuseport_supported) - self.loop.run_until_complete(coro) - bind.assert_called_with(('1.2.3.4', 0)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET, - proto=m_socket.IPPROTO_UDP, - type=m_socket.SOCK_DGRAM) + t, p = self.loop.run_until_complete(coro) + try: + bind.assert_called_with(('1.2.3.4', 0)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_UDP, + type=m_socket.SOCK_DGRAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close def test_accept_connection_retry(self): sock = mock.Mock() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 20:41:44 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 01:41:44 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_asyncio/tests?= =?utf-8?q?=3A_Fix_a_ResourceWarning_due_to_unclosed_loop?= Message-ID: <20151217014144.19150.61324@psf.io> https://hg.python.org/cpython/rev/d450b88db7f5 changeset: 99598:d450b88db7f5 branch: 3.4 parent: 99595:56095b0e7890 user: Yury Selivanov date: Wed Dec 16 20:41:11 2015 -0500 summary: asyncio/tests: Fix a ResourceWarning due to unclosed loop files: Lib/test/test_asyncio/test_tasks.py | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -2212,6 +2212,10 @@ self.loop = asyncio.new_event_loop() asyncio.set_event_loop(None) + def tearDown(self): + self.loop.close() + self.loop = None + def test_sleep_zero(self): result = 0 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 20:41:45 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 01:41:45 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_3=2E4?= Message-ID: <20151217014144.83195.87819@psf.io> https://hg.python.org/cpython/rev/448d5be62d46 changeset: 99599:448d5be62d46 branch: 3.5 parent: 99596:d56cfe234627 parent: 99598:d450b88db7f5 user: Yury Selivanov date: Wed Dec 16 20:41:25 2015 -0500 summary: Merge 3.4 files: Lib/test/test_asyncio/test_tasks.py | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -2212,6 +2212,10 @@ self.loop = asyncio.new_event_loop() asyncio.set_event_loop(None) + def tearDown(self): + self.loop.close() + self.loop = None + def test_sleep_zero(self): result = 0 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 20:41:45 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 01:41:45 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151217014144.83219.37456@psf.io> https://hg.python.org/cpython/rev/deb62ffe8e51 changeset: 99600:deb62ffe8e51 parent: 99597:37c4e7463b18 parent: 99599:448d5be62d46 user: Yury Selivanov date: Wed Dec 16 20:41:39 2015 -0500 summary: Merge 3.5 files: Lib/test/test_asyncio/test_tasks.py | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -2212,6 +2212,10 @@ self.loop = asyncio.new_event_loop() asyncio.set_event_loop(None) + def tearDown(self): + self.loop.close() + self.loop = None + def test_sleep_zero(self): result = 0 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 21:31:19 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 02:31:19 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_3=2E4?= Message-ID: <20151217023119.7702.22808@psf.io> https://hg.python.org/cpython/rev/580e32ac1359 changeset: 99602:580e32ac1359 branch: 3.5 parent: 99599:448d5be62d46 parent: 99601:f02c61f08333 user: Yury Selivanov date: Wed Dec 16 21:31:04 2015 -0500 summary: Merge 3.4 files: Doc/library/asyncio-protocol.rst | 6 +++--- Doc/library/asyncio-stream.rst | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/asyncio-protocol.rst b/Doc/library/asyncio-protocol.rst --- a/Doc/library/asyncio-protocol.rst +++ b/Doc/library/asyncio-protocol.rst @@ -1,8 +1,8 @@ .. currentmodule:: asyncio -+++++++++++++++++++++++++++++++++++++++++ -Transports and protocols (low-level API) -+++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++ +Transports and protocols (callback based API) +++++++++++++++++++++++++++++++++++++++++++++++ .. _asyncio-transport: diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst --- a/Doc/library/asyncio-stream.rst +++ b/Doc/library/asyncio-stream.rst @@ -2,9 +2,9 @@ .. _asyncio-streams: -++++++++++++++++++++++++ -Streams (high-level API) -++++++++++++++++++++++++ ++++++++++++++++++++++++++++++ +Streams (coroutine based API) ++++++++++++++++++++++++++++++ Stream functions ================ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 21:31:19 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 02:31:19 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151217023119.6451.52468@psf.io> https://hg.python.org/cpython/rev/2bd893405c62 changeset: 99603:2bd893405c62 parent: 99600:deb62ffe8e51 parent: 99602:580e32ac1359 user: Yury Selivanov date: Wed Dec 16 21:31:15 2015 -0500 summary: Merge 3.5 files: Doc/library/asyncio-protocol.rst | 6 +++--- Doc/library/asyncio-stream.rst | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/asyncio-protocol.rst b/Doc/library/asyncio-protocol.rst --- a/Doc/library/asyncio-protocol.rst +++ b/Doc/library/asyncio-protocol.rst @@ -1,8 +1,8 @@ .. currentmodule:: asyncio -+++++++++++++++++++++++++++++++++++++++++ -Transports and protocols (low-level API) -+++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++ +Transports and protocols (callback based API) +++++++++++++++++++++++++++++++++++++++++++++++ .. _asyncio-transport: diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst --- a/Doc/library/asyncio-stream.rst +++ b/Doc/library/asyncio-stream.rst @@ -2,9 +2,9 @@ .. _asyncio-streams: -++++++++++++++++++++++++ -Streams (high-level API) -++++++++++++++++++++++++ ++++++++++++++++++++++++++++++ +Streams (coroutine based API) ++++++++++++++++++++++++++++++ Stream functions ================ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 16 21:31:20 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 02:31:20 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_docs/asyncio?= =?utf-8?q?=3A_Twek_sections_names_per_Nick_Coghlan_suggestion?= Message-ID: <20151217023119.83197.78924@psf.io> https://hg.python.org/cpython/rev/f02c61f08333 changeset: 99601:f02c61f08333 branch: 3.4 parent: 99598:d450b88db7f5 user: Yury Selivanov date: Wed Dec 16 21:30:52 2015 -0500 summary: docs/asyncio: Twek sections names per Nick Coghlan suggestion files: Doc/library/asyncio-protocol.rst | 6 +++--- Doc/library/asyncio-stream.rst | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/asyncio-protocol.rst b/Doc/library/asyncio-protocol.rst --- a/Doc/library/asyncio-protocol.rst +++ b/Doc/library/asyncio-protocol.rst @@ -1,8 +1,8 @@ .. currentmodule:: asyncio -+++++++++++++++++++++++++++++++++++++++++ -Transports and protocols (low-level API) -+++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++ +Transports and protocols (callback based API) +++++++++++++++++++++++++++++++++++++++++++++++ .. _asyncio-transport: diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst --- a/Doc/library/asyncio-stream.rst +++ b/Doc/library/asyncio-stream.rst @@ -2,9 +2,9 @@ .. _asyncio-streams: -++++++++++++++++++++++++ -Streams (high-level API) -++++++++++++++++++++++++ ++++++++++++++++++++++++++++++ +Streams (coroutine based API) ++++++++++++++++++++++++++++++ Stream functions ================ -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Thu Dec 17 03:43:57 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 17 Dec 2015 08:43:57 +0000 Subject: [Python-checkins] Daily reference leaks (2bd893405c62): sum=4 Message-ID: <20151217084356.90162.89233@psf.io> results for 2bd893405c62 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogyTPzRt', '--timeout', '7200'] From lp_benchmark_robot at intel.com Thu Dec 17 04:16:05 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 17 Dec 2015 09:16:05 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-17 Message-ID: <008eb7e4-447e-4d85-90a1-44467e5d1895@irsmsx103.ger.corp.intel.com> Results for project Python default, build date 2015-12-17 03:02:15 +0000 commit: 2bd893405c620bdc06715986b120d0fb58890168 revision date: 2015-12-17 02:31:15 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.20% 0.51% 9.27% 15.41% :-| pybench 0.19% -0.00% -1.65% 8.21% :-( regex_v8 2.93% -0.01% -4.78% 5.63% :-( nbody 0.31% -0.16% -3.04% 10.34% :-| json_dump_v2 0.18% 0.21% -1.17% 10.43% :-( normal_startup 0.77% -0.22% -2.24% 4.74% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Thu Dec 17 04:19:11 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 17 Dec 2015 09:19:11 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-17 Message-ID: No new revisions. Here are the previous results: Results for project Python 2.7, build date 2015-12-17 03:51:27 +0000 commit: 937774aa18531e1296e06cd754431d96e07e70f4 revision date: 2015-12-14 03:41:59 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.13% 0.80% 2.03% 11.26% :-) pybench 0.16% -0.05% 6.03% 7.65% :-( regex_v8 1.09% 0.39% -2.54% 8.69% :-) nbody 0.11% -0.24% 7.61% 6.56% :-| json_dump_v2 0.27% 0.25% 1.65% 16.03% :-( normal_startup 1.85% -2.80% -5.29% 2.05% :-| ssbench 0.14% 1.17% 1.45% 0.99% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Thu Dec 17 05:21:38 2015 From: python-checkins at python.org (martin.panter) Date: Thu, 17 Dec 2015 10:21:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fix_a_couple_o?= =?utf-8?q?f_typos_in_code_comments?= Message-ID: <20151217102130.73366.34008@psf.io> https://hg.python.org/cpython/rev/e4db4b3b1547 changeset: 99604:e4db4b3b1547 branch: 3.5 parent: 99602:580e32ac1359 user: Martin Panter date: Thu Dec 17 10:18:28 2015 +0000 summary: Fix a couple of typos in code comments files: Lib/test/string_tests.py | 2 +- Lib/test/test_zipfile64.py | 2 +- Python/fileutils.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -685,7 +685,7 @@ class CommonTest(BaseTest): - # This testcase contains test that can be used in all + # This testcase contains tests that can be used in all # stringlike classes. Currently this is str, unicode # UserString and the string module. diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py --- a/Lib/test/test_zipfile64.py +++ b/Lib/test/test_zipfile64.py @@ -3,7 +3,7 @@ # from test_zipfile from test import support -# XXX(nnorwitz): disable this test by looking for extra largfile resource +# XXX(nnorwitz): disable this test by looking for extralargefile resource, # which doesn't exist. This test takes over 30 minutes to run in general # and requires more disk space than most of the buildbots. support.requires( diff --git a/Python/fileutils.c b/Python/fileutils.c --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -599,7 +599,7 @@ On Windows, use GetFileType() and GetFileInformationByHandle() which support files larger than 2 GB. fstat() may fail with EOVERFLOW on files larger - than 2 GB because the file size type is an signed 32-bit integer: see issue + than 2 GB because the file size type is a signed 32-bit integer: see issue #23152. On Windows, set the last Windows error and return nonzero on error. On @@ -669,7 +669,7 @@ On Windows, use GetFileType() and GetFileInformationByHandle() which support files larger than 2 GB. fstat() may fail with EOVERFLOW on files larger - than 2 GB because the file size type is an signed 32-bit integer: see issue + than 2 GB because the file size type is a signed 32-bit integer: see issue #23152. Raise an exception and return -1 on error. On Windows, set the last Windows -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 17 05:21:38 2015 From: python-checkins at python.org (martin.panter) Date: Thu, 17 Dec 2015 10:21:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_typo_fixes_from_3=2E5?= Message-ID: <20151217102130.90162.63875@psf.io> https://hg.python.org/cpython/rev/9a2cbf3c4324 changeset: 99605:9a2cbf3c4324 parent: 99603:2bd893405c62 parent: 99604:e4db4b3b1547 user: Martin Panter date: Thu Dec 17 10:20:21 2015 +0000 summary: Merge typo fixes from 3.5 files: Lib/test/string_tests.py | 2 +- Lib/test/test_zipfile64.py | 2 +- Python/fileutils.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -685,7 +685,7 @@ class CommonTest(BaseTest): - # This testcase contains test that can be used in all + # This testcase contains tests that can be used in all # stringlike classes. Currently this is str, unicode # UserString and the string module. diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py --- a/Lib/test/test_zipfile64.py +++ b/Lib/test/test_zipfile64.py @@ -3,7 +3,7 @@ # from test_zipfile from test import support -# XXX(nnorwitz): disable this test by looking for extra largfile resource +# XXX(nnorwitz): disable this test by looking for extralargefile resource, # which doesn't exist. This test takes over 30 minutes to run in general # and requires more disk space than most of the buildbots. support.requires( diff --git a/Python/fileutils.c b/Python/fileutils.c --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -599,7 +599,7 @@ On Windows, use GetFileType() and GetFileInformationByHandle() which support files larger than 2 GB. fstat() may fail with EOVERFLOW on files larger - than 2 GB because the file size type is an signed 32-bit integer: see issue + than 2 GB because the file size type is a signed 32-bit integer: see issue #23152. On Windows, set the last Windows error and return nonzero on error. On @@ -669,7 +669,7 @@ On Windows, use GetFileType() and GetFileInformationByHandle() which support files larger than 2 GB. fstat() may fail with EOVERFLOW on files larger - than 2 GB because the file size type is an signed 32-bit integer: see issue + than 2 GB because the file size type is a signed 32-bit integer: see issue #23152. Raise an exception and return -1 on error. On Windows, set the last Windows -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 17 05:37:00 2015 From: python-checkins at python.org (martin.panter) Date: Thu, 17 Dec 2015 10:37:00 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_3=2E4_into_3=2E5?= Message-ID: <20151217103659.7692.8323@psf.io> https://hg.python.org/cpython/rev/dcd2e66b8082 changeset: 99607:dcd2e66b8082 branch: 3.5 parent: 99604:e4db4b3b1547 parent: 99606:bb7a19e42566 user: Martin Panter date: Thu Dec 17 10:34:44 2015 +0000 summary: Merge 3.4 into 3.5 files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 17 05:37:00 2015 From: python-checkins at python.org (martin.panter) Date: Thu, 17 Dec 2015 10:37:00 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogSXNzdWUgIzI1ODA5?= =?utf-8?q?=3A_Skip_testing_platform-dependent_French_thousands_separator?= Message-ID: <20151217103659.7686.60892@psf.io> https://hg.python.org/cpython/rev/bb7a19e42566 changeset: 99606:bb7a19e42566 branch: 3.4 parent: 99601:f02c61f08333 user: Martin Panter date: Sat Dec 12 06:53:34 2015 +0000 summary: Issue #25809: Skip testing platform-dependent French thousands separator files: Lib/test/test__locale.py | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py --- a/Lib/test/test__locale.py +++ b/Lib/test/test__locale.py @@ -67,7 +67,9 @@ known_numerics = { 'en_US': ('.', ','), 'de_DE' : (',', '.'), - 'fr_FR.UTF-8' : (',', ' '), + # The French thousands separator may be a breaking or non-breaking space + # depending on the platform, so do not test it + 'fr_FR' : (',', ''), 'ps_AF': ('\u066b', '\u066c'), } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 17 05:37:00 2015 From: python-checkins at python.org (martin.panter) Date: Thu, 17 Dec 2015 10:37:00 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_from_3=2E5?= Message-ID: <20151217103659.16744.15388@psf.io> https://hg.python.org/cpython/rev/cca2ed4e8b41 changeset: 99608:cca2ed4e8b41 parent: 99605:9a2cbf3c4324 parent: 99607:dcd2e66b8082 user: Martin Panter date: Thu Dec 17 10:35:05 2015 +0000 summary: Merge from 3.5 files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 17 16:28:08 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 21:28:08 +0000 Subject: [Python-checkins] =?utf-8?q?devguide=3A_Add_myself_to_ast/compile?= =?utf-8?q?r_=26_bytecode_interest_areas=2E?= Message-ID: <20151217212805.7686.32271@psf.io> https://hg.python.org/devguide/rev/8af10476fb08 changeset: 776:8af10476fb08 user: Yury Selivanov date: Thu Dec 17 16:28:03 2015 -0500 summary: Add myself to ast/compiler & bytecode interest areas. files: experts.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/experts.rst b/experts.rst --- a/experts.rst +++ b/experts.rst @@ -310,13 +310,13 @@ ================== =========== algorithms argument clinic larry -ast/compiler ncoghlan, benjamin.peterson, brett.cannon, georg.brandl +ast/compiler ncoghlan, benjamin.peterson, brett.cannon, georg.brandl, yselivanov autoconf/makefiles twouters* bsd benchmarks pitrou, brett.cannon bug tracker ezio.melotti buildbots pitrou, zach.ware -bytecode benjamin.peterson, pitrou, georg.brandl +bytecode benjamin.peterson, pitrou, georg.brandl, yselivanov context managers ncoghlan coverity scan christian.heimes, brett.cannon, twouters cryptography christian.heimes, gregory.p.smith, dstufft -- Repository URL: https://hg.python.org/devguide From python-checkins at python.org Thu Dec 17 18:26:58 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 23:26:58 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogZG9jczogRG9jdW1l?= =?utf-8?q?nt_ASYNC/AWAIT_tokens_=28issue_=2325580=29?= Message-ID: <20151217232658.6463.36473@psf.io> https://hg.python.org/cpython/rev/aa79b2a5b2e1 changeset: 99609:aa79b2a5b2e1 branch: 3.5 parent: 99607:dcd2e66b8082 user: Yury Selivanov date: Thu Dec 17 18:26:41 2015 -0500 summary: docs: Document ASYNC/AWAIT tokens (issue #25580) Initial patch by SilentGhost files: Doc/library/token.rst | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/Doc/library/token.rst b/Doc/library/token.rst --- a/Doc/library/token.rst +++ b/Doc/library/token.rst @@ -97,10 +97,16 @@ RARROW ELLIPSIS OP + AWAIT + ASYNC ERRORTOKEN N_TOKENS NT_OFFSET + .. versionchanged:: 3.5 + Added :data:`AWAIT` and :data:`ASYNC` tokens. Starting with + Python 3.7, "async" and "await" will be tokenized as :data:`NAME` + tokens, and :data:`AWAIT` and :data:`ASYNC` will be removed. .. seealso:: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 17 18:26:59 2015 From: python-checkins at python.org (yury.selivanov) Date: Thu, 17 Dec 2015 23:26:59 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20151217232658.73376.25475@psf.io> https://hg.python.org/cpython/rev/c11bdccc4547 changeset: 99610:c11bdccc4547 parent: 99608:cca2ed4e8b41 parent: 99609:aa79b2a5b2e1 user: Yury Selivanov date: Thu Dec 17 18:26:53 2015 -0500 summary: Merge 3.5 files: Doc/library/token.rst | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/Doc/library/token.rst b/Doc/library/token.rst --- a/Doc/library/token.rst +++ b/Doc/library/token.rst @@ -97,10 +97,16 @@ RARROW ELLIPSIS OP + AWAIT + ASYNC ERRORTOKEN N_TOKENS NT_OFFSET + .. versionchanged:: 3.5 + Added :data:`AWAIT` and :data:`ASYNC` tokens. Starting with + Python 3.7, "async" and "await" will be tokenized as :data:`NAME` + tokens, and :data:`AWAIT` and :data:`ASYNC` will be removed. .. seealso:: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 02:55:18 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 07:55:18 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325893=3A_Removed_unused_variable_reqdSize=2E?= Message-ID: <20151218075518.7684.52265@psf.io> https://hg.python.org/cpython/rev/b72736cfc904 changeset: 99612:b72736cfc904 parent: 99610:c11bdccc4547 parent: 99611:12ca4a3695f9 user: Serhiy Storchaka date: Fri Dec 18 09:54:59 2015 +0200 summary: Issue #25893: Removed unused variable reqdSize. Added test for return code for the last RegQueryValueExW. files: PC/getpathp.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/PC/getpathp.c b/PC/getpathp.c --- a/PC/getpathp.c +++ b/PC/getpathp.c @@ -321,7 +321,6 @@ dataBuf = PyMem_RawMalloc((dataSize+1) * sizeof(WCHAR)); if (dataBuf) { WCHAR *szCur = dataBuf; - DWORD reqdSize = dataSize; /* Copy our collected strings */ for (index=0;index 0) { @@ -349,6 +348,10 @@ */ rc = RegQueryValueExW(newKey, NULL, 0, NULL, (LPBYTE)szCur, &dataSize); + if (rc != ERROR_SUCCESS) { + PyMem_RawFree(dataBuf); + goto done; + } } /* And set the result - caller must free */ retval = dataBuf; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 02:55:18 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 07:55:18 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODkz?= =?utf-8?q?=3A_Removed_unused_variable_reqdSize=2E?= Message-ID: <20151218075518.7678.29746@psf.io> https://hg.python.org/cpython/rev/12ca4a3695f9 changeset: 99611:12ca4a3695f9 branch: 3.5 parent: 99609:aa79b2a5b2e1 user: Serhiy Storchaka date: Fri Dec 18 09:54:19 2015 +0200 summary: Issue #25893: Removed unused variable reqdSize. Added test for return code for the last RegQueryValueExW. files: PC/getpathp.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/PC/getpathp.c b/PC/getpathp.c --- a/PC/getpathp.c +++ b/PC/getpathp.c @@ -321,7 +321,6 @@ dataBuf = PyMem_RawMalloc((dataSize+1) * sizeof(WCHAR)); if (dataBuf) { WCHAR *szCur = dataBuf; - DWORD reqdSize = dataSize; /* Copy our collected strings */ for (index=0;index 0) { @@ -349,6 +348,10 @@ */ rc = RegQueryValueExW(newKey, NULL, 0, NULL, (LPBYTE)szCur, &dataSize); + if (rc != ERROR_SUCCESS) { + PyMem_RawFree(dataBuf); + goto done; + } } /* And set the result - caller must free */ retval = dataBuf; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 03:03:40 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 08:03:40 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issues_=2325890=2C_=232589?= =?utf-8?q?1=2C_=2325892=3A_Removed_unused_variables_in_Windows_code=2E?= Message-ID: <20151218080334.83205.89828@psf.io> https://hg.python.org/cpython/rev/77bd84a6964a changeset: 99613:77bd84a6964a user: Serhiy Storchaka date: Fri Dec 18 10:03:13 2015 +0200 summary: Issues #25890, #25891, #25892: Removed unused variables in Windows code. Reported by Alexander Riccio. files: Modules/posixmodule.c | 2 -- Objects/unicodeobject.c | 1 - 2 files changed, 0 insertions(+), 3 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -3463,7 +3463,6 @@ char *bufptr = namebuf; /* only claim to have space for MAX_PATH */ Py_ssize_t len = Py_ARRAY_LENGTH(namebuf)-4; - PyObject *po = NULL; wchar_t *wnamebuf = NULL; if (!path->narrow) { @@ -12380,7 +12379,6 @@ HANDLE tok; TOKEN_PRIVILEGES tok_priv; LUID luid; - int meth_idx = 0; if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &tok)) return 0; diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -7332,7 +7332,6 @@ BOOL usedDefaultChar = FALSE; BOOL *pusedDefaultChar = &usedDefaultChar; int outsize; - PyObject *exc = NULL; wchar_t *p; Py_ssize_t size; const DWORD flags = encode_code_page_flags(code_page, NULL); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 03:07:28 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 08:07:28 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325890=3A_Removed_?= =?utf-8?q?yet_one_unused_variable=2E?= Message-ID: <20151218080716.2936.29253@psf.io> https://hg.python.org/cpython/rev/3f32bacd353d changeset: 99614:3f32bacd353d user: Serhiy Storchaka date: Fri Dec 18 10:06:58 2015 +0200 summary: Issue #25890: Removed yet one unused variable. files: Modules/posixmodule.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -3460,7 +3460,6 @@ BOOL result; WIN32_FIND_DATA FileData; char namebuf[MAX_PATH+4]; /* Overallocate for "\*.*" */ - char *bufptr = namebuf; /* only claim to have space for MAX_PATH */ Py_ssize_t len = Py_ARRAY_LENGTH(namebuf)-4; wchar_t *wnamebuf = NULL; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 03:24:32 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 08:24:32 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Test_UTF-32LE_?= =?utf-8?q?before_UTF-16LE_since_UTF-16LE_BOM_is_a_prefix_of_UTF-32LE_BOM?= =?utf-8?q?=2E?= Message-ID: <20151218082431.2918.61099@psf.io> https://hg.python.org/cpython/rev/3106caffa79d changeset: 99616:3106caffa79d branch: 3.5 parent: 99611:12ca4a3695f9 user: Serhiy Storchaka date: Fri Dec 18 10:23:09 2015 +0200 summary: Test UTF-32LE before UTF-16LE since UTF-16LE BOM is a prefix of UTF-32LE BOM. files: PC/launcher.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -965,10 +965,12 @@ */ static BOM BOMs[] = { { 3, { 0xEF, 0xBB, 0xBF }, CP_UTF8 }, /* UTF-8 - keep first */ + /* Test UTF-32LE before UTF-16LE since UTF-16LE BOM is a prefix + * of UTF-32LE BOM. */ + { 4, { 0xFF, 0xFE, 0x00, 0x00 }, CP_UTF32LE }, /* UTF-32LE */ + { 4, { 0x00, 0x00, 0xFE, 0xFF }, CP_UTF32BE }, /* UTF-32BE */ { 2, { 0xFF, 0xFE }, CP_UTF16LE }, /* UTF-16LE */ { 2, { 0xFE, 0xFF }, CP_UTF16BE }, /* UTF-16BE */ - { 4, { 0xFF, 0xFE, 0x00, 0x00 }, CP_UTF32LE }, /* UTF-32LE */ - { 4, { 0x00, 0x00, 0xFE, 0xFF }, CP_UTF32BE }, /* UTF-32BE */ { 0 } /* sentinel */ }; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 03:24:32 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 08:24:32 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325889=3A_Got_rid_?= =?utf-8?q?of_warning_about_mixing_signed/unsigned_char_pointers=2E?= Message-ID: <20151218082431.83221.98342@psf.io> https://hg.python.org/cpython/rev/2481ae1ce35c changeset: 99615:2481ae1ce35c user: Serhiy Storchaka date: Fri Dec 18 10:19:30 2015 +0200 summary: Issue #25889: Got rid of warning about mixing signed/unsigned char pointers. files: PC/launcher.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1106,7 +1106,7 @@ */ FILE * fp; errno_t rc = _wfopen_s(&fp, *argv, L"rb"); - unsigned char buffer[BUFSIZE]; + char buffer[BUFSIZE]; wchar_t shebang_line[BUFSIZE + 1]; size_t read; char *p; @@ -1128,7 +1128,8 @@ fclose(fp); if ((read >= 4) && (buffer[3] == '\n') && (buffer[2] == '\r')) { - ip = find_by_magic((buffer[1] << 8 | buffer[0]) & 0xFFFF); + ip = find_by_magic((((unsigned char)buffer[1]) << 8 | + (unsigned char)buffer[0]) & 0xFFFF); if (ip != NULL) { debug(L"script file is compiled against Python %ls\n", ip->version); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 03:24:35 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 08:24:35 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Test_UTF-32LE_before_UTF-16LE_since_UTF-16LE_BOM_is_a_pr?= =?utf-8?q?efix_of_UTF-32LE_BOM=2E?= Message-ID: <20151218082432.73366.52470@psf.io> https://hg.python.org/cpython/rev/a3f076d4f54f changeset: 99617:a3f076d4f54f parent: 99615:2481ae1ce35c parent: 99616:3106caffa79d user: Serhiy Storchaka date: Fri Dec 18 10:23:29 2015 +0200 summary: Test UTF-32LE before UTF-16LE since UTF-16LE BOM is a prefix of UTF-32LE BOM. files: PC/launcher.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -965,10 +965,12 @@ */ static BOM BOMs[] = { { 3, { 0xEF, 0xBB, 0xBF }, CP_UTF8 }, /* UTF-8 - keep first */ + /* Test UTF-32LE before UTF-16LE since UTF-16LE BOM is a prefix + * of UTF-32LE BOM. */ + { 4, { 0xFF, 0xFE, 0x00, 0x00 }, CP_UTF32LE }, /* UTF-32LE */ + { 4, { 0x00, 0x00, 0xFE, 0xFF }, CP_UTF32BE }, /* UTF-32BE */ { 2, { 0xFF, 0xFE }, CP_UTF16LE }, /* UTF-16LE */ { 2, { 0xFE, 0xFF }, CP_UTF16BE }, /* UTF-16BE */ - { 4, { 0xFF, 0xFE, 0x00, 0x00 }, CP_UTF32LE }, /* UTF-32LE */ - { 4, { 0x00, 0x00, 0xFE, 0xFF }, CP_UTF32BE }, /* UTF-32BE */ { 0 } /* sentinel */ }; -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Fri Dec 18 03:42:08 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 18 Dec 2015 08:42:08 +0000 Subject: [Python-checkins] Daily reference leaks (c11bdccc4547): sum=4 Message-ID: <20151218084208.32127.78697@psf.io> results for c11bdccc4547 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogkU7Sw7', '--timeout', '7200'] From python-checkins at python.org Fri Dec 18 06:13:55 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 11:13:55 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325899=3A_Fixed_typo_in_=2Ebzrignore=2E?= Message-ID: <20151218111355.7704.91423@psf.io> https://hg.python.org/cpython/rev/e1d5f645b476 changeset: 99622:e1d5f645b476 parent: 99619:1eeb25f08cfd parent: 99620:7b176dafb56b user: Serhiy Storchaka date: Fri Dec 18 13:13:29 2015 +0200 summary: Issue #25899: Fixed typo in .bzrignore. files: .bzrignore | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/.bzrignore b/.bzrignore --- a/.bzrignore +++ b/.bzrignore @@ -1,4 +1,4 @@ -?.purify +.purify autom4te.cache config.log config.cache -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 06:13:55 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 11:13:55 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1ODk5?= =?utf-8?q?=3A_Fixed_typo_in_=2Ebzrignore=2E?= Message-ID: <20151218111355.7684.5041@psf.io> https://hg.python.org/cpython/rev/8873f34e2186 changeset: 99621:8873f34e2186 branch: 2.7 parent: 99570:937774aa1853 user: Serhiy Storchaka date: Fri Dec 18 13:12:33 2015 +0200 summary: Issue #25899: Fixed typo in .bzrignore. files: .bzrignore | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/.bzrignore b/.bzrignore --- a/.bzrignore +++ b/.bzrignore @@ -1,4 +1,4 @@ -?.purify +.purify autom4te.cache config.log config.cache -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 06:13:55 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 11:13:55 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODk5?= =?utf-8?q?=3A_Converted_non-ASCII_characters_in_docstrings_and_manpage?= Message-ID: <20151218111354.7692.62670@psf.io> https://hg.python.org/cpython/rev/c87b2f61650f changeset: 99618:c87b2f61650f branch: 3.5 parent: 99616:3106caffa79d user: Serhiy Storchaka date: Fri Dec 18 13:05:04 2015 +0200 summary: Issue #25899: Converted non-ASCII characters in docstrings and manpage to ASCII replacements. Original patch by Chris Angelico. files: Lib/multiprocessing/connection.py | 2 +- Misc/python.man | 2 +- Python/marshal.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -397,7 +397,7 @@ self._send(header) self._send(buf) else: - # Issue #?20540: concatenate before sending, to avoid delays due + # Issue #20540: concatenate before sending, to avoid delays due # to Nagle's algorithm on a TCP socket. # Also note we want to avoid sending a 0-length buffer separately, # to avoid "broken pipe" errors if the other end closed the pipe. diff --git a/Misc/python.man b/Misc/python.man --- a/Misc/python.man +++ b/Misc/python.man @@ -143,7 +143,7 @@ .TP .B \-I Run Python in isolated mode. This also implies \fB\-E\fP and \fB\-s\fP. In -isolated mode sys.path contains neither the script?s directory nor the user?s +isolated mode sys.path contains neither the script's directory nor the user's site-packages directory. All PYTHON* environment variables are ignored, too. Further restrictions may be imposed to prevent the user from injecting malicious code. diff --git a/Python/marshal.c b/Python/marshal.c --- a/Python/marshal.c +++ b/Python/marshal.c @@ -1644,7 +1644,7 @@ open() or os.popen(). It must be opened in binary mode ('wb' or 'w+b').\n\ \n\ If the value has (or contains an object that has) an unsupported type, a\n\ -ValueError exception is raised ? but garbage data will also be written\n\ +ValueError exception is raised - but garbage data will also be written\n\ to the file. The object will not be properly read back by load()\n\ \n\ The version argument indicates the data format that dump should use."); @@ -1695,7 +1695,7 @@ "load(file)\n\ \n\ Read one value from the open file and return it. If no valid value is\n\ -read (e.g. because the data has a different Python version?s\n\ +read (e.g. because the data has a different Python version's\n\ incompatible marshal format), raise EOFError, ValueError or TypeError.\n\ The file must be an open file object opened in binary mode ('rb' or\n\ 'r+b').\n\ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 06:13:56 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 11:13:56 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325899=3A_Converted_non-ASCII_characters_in_docs?= =?utf-8?q?trings_and_manpage?= Message-ID: <20151218111355.16754.47248@psf.io> https://hg.python.org/cpython/rev/1eeb25f08cfd changeset: 99619:1eeb25f08cfd parent: 99617:a3f076d4f54f parent: 99618:c87b2f61650f user: Serhiy Storchaka date: Fri Dec 18 13:10:37 2015 +0200 summary: Issue #25899: Converted non-ASCII characters in docstrings and manpage to ASCII replacements. Removed UTF-8 BOM from Misc/NEWS. Original patch by Chris Angelico. files: Lib/http/client.py | 4 ++-- Lib/multiprocessing/connection.py | 2 +- Lib/urllib/request.py | 6 +++--- Misc/NEWS | 2 +- Misc/python.man | 2 +- Python/marshal.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Lib/http/client.py b/Lib/http/client.py --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -735,9 +735,9 @@ guessed. When the method is local-file, returned headers will include - a Date representing the file?s last-modified time, a + a Date representing the file's last-modified time, a Content-Length giving file size, and a Content-Type - containing a guess at the file?s type. See also the + containing a guess at the file's type. See also the description of the mimetools module. ''' diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -397,7 +397,7 @@ self._send(header) self._send(buf) else: - # Issue #?20540: concatenate before sending, to avoid delays due + # Issue #20540: concatenate before sending, to avoid delays due # to Nagle's algorithm on a TCP socket. # Also note we want to avoid sending a 0-length buffer separately, # to avoid "broken pipe" errors if the other end closed the pipe. diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -179,14 +179,14 @@ urllib.response.addinfourl object which can work as context manager and has methods such as: - * geturl() ? return the URL of the resource retrieved, commonly used to + * geturl() - return the URL of the resource retrieved, commonly used to determine if a redirect was followed - * info() ? return the meta-information of the page, such as headers, in the + * info() - return the meta-information of the page, such as headers, in the form of an email.message_from_string() instance (see Quick Reference to HTTP Headers) - * getcode() ? return the HTTP status code of the response. Raises URLError + * getcode() - return the HTTP status code of the response. Raises URLError on errors. Note that *None& may be returned if no handler handles the request (though diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1,4 +1,4 @@ -?+++++++++++ ++++++++++++ Python News +++++++++++ diff --git a/Misc/python.man b/Misc/python.man --- a/Misc/python.man +++ b/Misc/python.man @@ -143,7 +143,7 @@ .TP .B \-I Run Python in isolated mode. This also implies \fB\-E\fP and \fB\-s\fP. In -isolated mode sys.path contains neither the script?s directory nor the user?s +isolated mode sys.path contains neither the script's directory nor the user's site-packages directory. All PYTHON* environment variables are ignored, too. Further restrictions may be imposed to prevent the user from injecting malicious code. diff --git a/Python/marshal.c b/Python/marshal.c --- a/Python/marshal.c +++ b/Python/marshal.c @@ -1644,7 +1644,7 @@ open() or os.popen(). It must be opened in binary mode ('wb' or 'w+b').\n\ \n\ If the value has (or contains an object that has) an unsupported type, a\n\ -ValueError exception is raised ? but garbage data will also be written\n\ +ValueError exception is raised - but garbage data will also be written\n\ to the file. The object will not be properly read back by load()\n\ \n\ The version argument indicates the data format that dump should use."); @@ -1695,7 +1695,7 @@ "load(file)\n\ \n\ Read one value from the open file and return it. If no valid value is\n\ -read (e.g. because the data has a different Python version?s\n\ +read (e.g. because the data has a different Python version's\n\ incompatible marshal format), raise EOFError, ValueError or TypeError.\n\ The file must be an open file object opened in binary mode ('rb' or\n\ 'r+b').\n\ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 06:14:05 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 11:14:05 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODk5?= =?utf-8?q?=3A_Fixed_typo_in_=2Ebzrignore=2E?= Message-ID: <20151218111355.90152.46621@psf.io> https://hg.python.org/cpython/rev/7b176dafb56b changeset: 99620:7b176dafb56b branch: 3.5 parent: 99618:c87b2f61650f user: Serhiy Storchaka date: Fri Dec 18 13:12:33 2015 +0200 summary: Issue #25899: Fixed typo in .bzrignore. files: .bzrignore | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/.bzrignore b/.bzrignore --- a/.bzrignore +++ b/.bzrignore @@ -1,4 +1,4 @@ -?.purify +.purify autom4te.cache config.log config.cache -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 06:23:53 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 11:23:53 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325899=3A_Converte?= =?utf-8?q?d_Objects/listsort=2Etxt_to_UTF-8=2E?= Message-ID: <20151218112353.19148.69142@psf.io> https://hg.python.org/cpython/rev/505593490f4c changeset: 99623:505593490f4c user: Serhiy Storchaka date: Fri Dec 18 13:23:33 2015 +0200 summary: Issue #25899: Converted Objects/listsort.txt to UTF-8. Original patch by Chris Angelico. files: Objects/listsort.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Objects/listsort.txt b/Objects/listsort.txt --- a/Objects/listsort.txt +++ b/Objects/listsort.txt @@ -486,7 +486,7 @@ I first learned about the galloping strategy in a related context; see: "Adaptive Set Intersections, Unions, and Differences" (2000) - Erik D. Demaine, Alejandro L?pez-Ortiz, J. Ian Munro + Erik D. Demaine, Alejandro L??pez-Ortiz, J. Ian Munro and its followup(s). An earlier paper called the same strategy "exponential search": -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Fri Dec 18 08:25:31 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 18 Dec 2015 13:25:31 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-18 Message-ID: <11e4a857-a6bc-4664-b12f-f30482bc4979@irsmsx153.ger.corp.intel.com> Results for project Python default, build date 2015-12-18 03:07:10 +0000 commit: c11bdccc454743cd734014423607eb2ab2af8eb0 revision date: 2015-12-17 23:26:53 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.21% 2.14% 11.21% 14.98% :-| pybench 0.09% 0.05% -1.60% 6.17% :-( regex_v8 2.70% 0.62% -4.13% 3.17% :-) nbody 0.06% 4.14% 1.22% 7.29% :-| json_dump_v2 0.23% -0.56% -1.73% 11.40% :-| normal_startup 0.89% 0.43% -1.47% 4.95% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Fri Dec 18 08:27:44 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 18 Dec 2015 13:27:44 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-18 Message-ID: No new revisions. Here are the previous results: Results for project Python 2.7, build date 2015-12-18 03:58:54 +0000 commit: 937774aa18531e1296e06cd754431d96e07e70f4 revision date: 2015-12-14 03:41:59 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.13% 0.80% 2.03% 11.26% :-) pybench 0.16% -0.05% 6.03% 7.65% :-( regex_v8 1.09% 0.39% -2.54% 8.69% :-) nbody 0.11% -0.24% 7.61% 6.56% :-| json_dump_v2 0.27% 0.25% 1.65% 16.03% :-( normal_startup 1.85% -2.80% -5.29% 2.05% :-| ssbench 0.14% 1.17% 1.45% 0.99% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Fri Dec 18 12:37:27 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 17:37:27 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Fixed_markup_and_spaces_in_Misc/NEWS=2E?= Message-ID: <20151218173727.16762.23512@psf.io> https://hg.python.org/cpython/rev/e7ed7db521e9 changeset: 99625:e7ed7db521e9 parent: 99623:505593490f4c parent: 99624:ed2420379b8d user: Serhiy Storchaka date: Fri Dec 18 19:37:02 2015 +0200 summary: Fixed markup and spaces in Misc/NEWS. files: Misc/NEWS | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -138,7 +138,7 @@ - Issue #19771: Also in runpy and the "-m" option, omit the irrelevant message ". . . is a package and cannot be directly executed" if the package - could not even be initialized (e.g. due to a bad *.pyc file). + could not even be initialized (e.g. due to a bad ``*.pyc`` file). - Issue #25177: Fixed problem with the mean of very small and very large numbers. As a side effect, statistics.mean and statistics.variance should @@ -236,7 +236,7 @@ - Issue #25411: Improved Unicode support in SMTPHandler through better use of the email package. Thanks to user simon04 for the patch. -- Move the imp module from a PendingDeprecationWarning to DeprecationWarning. +- Move the imp module from a PendingDeprecationWarning to DeprecationWarning. - Issue #25407: Remove mentions of the formatter module being removed in Python 3.6. @@ -311,11 +311,11 @@ - Issue #24633: site-packages/README -> README.txt. -- Issue #24879: help() and pydoc can now list named tuple fields in the +- Issue #24879: help() and pydoc can now list named tuple fields in the order they were defined rather than alphabetically. The ordering is determined by the _fields attribute if present. -- Issue #24874: Improve speed of itertools.cycle() and make its +- Issue #24874: Improve speed of itertools.cycle() and make its pickle more compact. - Fix crash in itertools.cycle.__setstate__() when the first argument wasn't @@ -390,7 +390,7 @@ Consistently use the revised idleConf.CurrentTheme everywhere in idlelib. - Issue #24782: Extension configuration is now a tab in the IDLE Preferences - dialog rather than a separate dialog. The former tabs are now a sorted + dialog rather than a separate dialog. The former tabs are now a sorted list. Patch by Mark Roseman. - Issue #22726: Re-activate the config dialog help button with some content @@ -859,7 +859,7 @@ Consistently use the revised idleConf.CurrentTheme everywhere in idlelib. - Issue #24782: Extension configuration is now a tab in the IDLE Preferences - dialog rather than a separate dialog. The former tabs are now a sorted + dialog rather than a separate dialog. The former tabs are now a sorted list. Patch by Mark Roseman. - Issue #22726: Re-activate the config dialog help button with some content -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 12:37:30 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 18 Dec 2015 17:37:30 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fixed_markup_a?= =?utf-8?q?nd_spaces_in_Misc/NEWS=2E?= Message-ID: <20151218173727.2914.13364@psf.io> https://hg.python.org/cpython/rev/ed2420379b8d changeset: 99624:ed2420379b8d branch: 3.5 parent: 99620:7b176dafb56b user: Serhiy Storchaka date: Fri Dec 18 19:36:24 2015 +0200 summary: Fixed markup and spaces in Misc/NEWS. files: Misc/NEWS | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -43,7 +43,7 @@ - Issue #19771: Also in runpy and the "-m" option, omit the irrelevant message ". . . is a package and cannot be directly executed" if the package - could not even be initialized (e.g. due to a bad *.pyc file). + could not even be initialized (e.g. due to a bad ``*.pyc`` file). - Issue #25177: Fixed problem with the mean of very small and very large numbers. As a side effect, statistics.mean and statistics.variance should @@ -435,7 +435,7 @@ Consistently use the revised idleConf.CurrentTheme everywhere in idlelib. - Issue #24782: Extension configuration is now a tab in the IDLE Preferences - dialog rather than a separate dialog. The former tabs are now a sorted + dialog rather than a separate dialog. The former tabs are now a sorted list. Patch by Mark Roseman. - Issue #22726: Re-activate the config dialog help button with some content -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 12:44:51 2015 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 18 Dec 2015 17:44:51 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Fix_link_for_=22Registering_w?= =?utf-8?q?ith_the_Package_Index=22=2E?= Message-ID: <20151218174213.83219.34393@psf.io> https://hg.python.org/peps/rev/0158df3ae238 changeset: 6141:0158df3ae238 user: Guido van Rossum date: Fri Dec 18 09:42:08 2015 -0800 summary: Fix link for "Registering with the Package Index". files: pep-0423.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0423.txt b/pep-0423.txt --- a/pep-0423.txt +++ b/pep-0423.txt @@ -818,7 +818,7 @@ .. _`The Zen of Python`: http://www.python.org/dev/peps/pep-0020/ .. _`Plone community`: http://plone.org/community/develop .. _`Registering with the Package Index`: - http://docs.python.org/dev/packaging/packageindex.html + https://docs.python.org/3/distutils/packageindex.html .. _`Python Standard Library`: http://docs.python.org/library/index.html .. _`PEP 345 about Obsolete-Dist`: -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Fri Dec 18 15:47:48 2015 From: python-checkins at python.org (terry.reedy) Date: Fri, 18 Dec 2015 20:47:48 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_with_3=2E4?= Message-ID: <20151218204748.6433.97169@psf.io> https://hg.python.org/cpython/rev/e4f3e3ccd06f changeset: 99628:e4f3e3ccd06f branch: 3.5 parent: 99624:ed2420379b8d parent: 99627:42963dd81600 user: Terry Jan Reedy date: Fri Dec 18 15:47:13 2015 -0500 summary: Merge with 3.4 files: Lib/idlelib/README.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/idlelib/README.txt b/Lib/idlelib/README.txt --- a/Lib/idlelib/README.txt +++ b/Lib/idlelib/README.txt @@ -1,6 +1,6 @@ README.txt: an index to idlelib files and the IDLE menu. -IDLE is Python?s Integrated Development and Learning +IDLE is Python's Integrated Development and Learning Environment. The user documentation is part of the Library Reference and is available in IDLE by selecting Help => IDLE Help. This README documents idlelib for IDLE developers and curious users. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 15:47:48 2015 From: python-checkins at python.org (terry.reedy) Date: Fri, 18 Dec 2015 20:47:48 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_with_3=2E5?= Message-ID: <20151218204748.32107.53846@psf.io> https://hg.python.org/cpython/rev/128fa5eea9b1 changeset: 99629:128fa5eea9b1 parent: 99625:e7ed7db521e9 parent: 99628:e4f3e3ccd06f user: Terry Jan Reedy date: Fri Dec 18 15:47:28 2015 -0500 summary: Merge with 3.5 files: Lib/idlelib/README.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/idlelib/README.txt b/Lib/idlelib/README.txt --- a/Lib/idlelib/README.txt +++ b/Lib/idlelib/README.txt @@ -1,6 +1,6 @@ README.txt: an index to idlelib files and the IDLE menu. -IDLE is Python?s Integrated Development and Learning +IDLE is Python's Integrated Development and Learning Environment. The user documentation is part of the Library Reference and is available in IDLE by selecting Help => IDLE Help. This README documents idlelib for IDLE developers and curious users. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 15:47:49 2015 From: python-checkins at python.org (terry.reedy) Date: Fri, 18 Dec 2015 20:47:49 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1OTA1?= =?utf-8?q?=3A_Revert_unwanted_conversion_of_=27_to_=E2=80=99_RIGHT_SINGLE?= =?utf-8?q?_QUOTATION?= Message-ID: <20151218204748.73394.27340@psf.io> https://hg.python.org/cpython/rev/11c789c034fe changeset: 99626:11c789c034fe branch: 2.7 parent: 99621:8873f34e2186 user: Terry Jan Reedy date: Fri Dec 18 15:46:52 2015 -0500 summary: Issue #25905: Revert unwanted conversion of ' to ??? RIGHT SINGLE QUOTATION MARK. files: Lib/idlelib/README.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/idlelib/README.txt b/Lib/idlelib/README.txt --- a/Lib/idlelib/README.txt +++ b/Lib/idlelib/README.txt @@ -1,6 +1,6 @@ README.txt: an index to idlelib files and the IDLE menu. -IDLE is Python?s Integrated Development and Learning +IDLE is Python's Integrated Development and Learning Environment. The user documentation is part of the Library Reference and is available in IDLE by selecting Help => IDLE Help. This README documents idlelib for IDLE developers and curious users. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 18 15:47:49 2015 From: python-checkins at python.org (terry.reedy) Date: Fri, 18 Dec 2015 20:47:49 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogSXNzdWUgIzI1OTA1?= =?utf-8?q?=3A_Revert_unwanted_conversion_of_=27_to_=E2=80=99_RIGHT_SINGLE?= =?utf-8?q?_QUOTATION?= Message-ID: <20151218204748.73386.58097@psf.io> https://hg.python.org/cpython/rev/42963dd81600 changeset: 99627:42963dd81600 branch: 3.4 parent: 99606:bb7a19e42566 user: Terry Jan Reedy date: Fri Dec 18 15:46:57 2015 -0500 summary: Issue #25905: Revert unwanted conversion of ' to ??? RIGHT SINGLE QUOTATION MARK. files: Lib/idlelib/README.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/idlelib/README.txt b/Lib/idlelib/README.txt --- a/Lib/idlelib/README.txt +++ b/Lib/idlelib/README.txt @@ -1,6 +1,6 @@ README.txt: an index to idlelib files and the IDLE menu. -IDLE is Python?s Integrated Development and Learning +IDLE is Python's Integrated Development and Learning Environment. The user documentation is part of the Library Reference and is available in IDLE by selecting Help => IDLE Help. This README documents idlelib for IDLE developers and curious users. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 19 02:43:51 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Dec 2015 07:43:51 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2322227=3A_The_TarF?= =?utf-8?q?ile_iterator_is_reimplemented_using_generator=2E?= Message-ID: <20151219074342.57616.17511@psf.io> https://hg.python.org/cpython/rev/a8f24e26abc7 changeset: 99630:a8f24e26abc7 user: Serhiy Storchaka date: Sat Dec 19 09:43:14 2015 +0200 summary: Issue #22227: The TarFile iterator is reimplemented using generator. This implementation is simpler that using class. files: Lib/tarfile.py | 68 ++++++++++++++----------------------- Misc/NEWS | 3 + 2 files changed, 29 insertions(+), 42 deletions(-) diff --git a/Lib/tarfile.py b/Lib/tarfile.py --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -2372,9 +2372,32 @@ """Provide an iterator object. """ if self._loaded: - return iter(self.members) - else: - return TarIter(self) + yield from self.members + return + + # Yield items using TarFile's next() method. + # When all members have been read, set TarFile as _loaded. + index = 0 + # Fix for SF #1100429: Under rare circumstances it can + # happen that getmembers() is called during iteration, + # which will have already exhausted the next() method. + if self.firstmember is not None: + tarinfo = self.next() + index += 1 + yield tarinfo + + while True: + if index < len(self.members): + tarinfo = self.members[index] + elif not self._loaded: + tarinfo = self.next() + if not tarinfo: + self._loaded = True + return + else: + return + index += 1 + yield tarinfo def _dbg(self, level, msg): """Write debugging output to sys.stderr. @@ -2395,45 +2418,6 @@ if not self._extfileobj: self.fileobj.close() self.closed = True -# class TarFile - -class TarIter: - """Iterator Class. - - for tarinfo in TarFile(...): - suite... - """ - - def __init__(self, tarfile): - """Construct a TarIter object. - """ - self.tarfile = tarfile - self.index = 0 - def __iter__(self): - """Return iterator object. - """ - return self - def __next__(self): - """Return the next item using TarFile's next() method. - When all members have been read, set TarFile as _loaded. - """ - # Fix for SF #1100429: Under rare circumstances it can - # happen that getmembers() is called during iteration, - # which will cause TarIter to stop prematurely. - - if self.index == 0 and self.tarfile.firstmember is not None: - tarinfo = self.tarfile.next() - elif self.index < len(self.tarfile.members): - tarinfo = self.tarfile.members[self.index] - elif not self.tarfile._loaded: - tarinfo = self.tarfile.next() - if not tarinfo: - self.tarfile._loaded = True - raise StopIteration - else: - raise StopIteration - self.index += 1 - return tarinfo #-------------------- # exported functions diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -109,6 +109,9 @@ Library ------- +- Issue #22227: The TarFile iterator is reimplemented using generator. + This implementation is simpler that using class. + - Issue #25638: Optimized ElementTree.iterparse(); it is now 2x faster. Optimized ElementTree parsing; it is now 10% faster. -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sat Dec 19 03:43:53 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 19 Dec 2015 08:43:53 +0000 Subject: [Python-checkins] Daily reference leaks (128fa5eea9b1): sum=4 Message-ID: <20151219084352.19160.93602@psf.io> results for 128fa5eea9b1 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogWl628x', '--timeout', '7200'] From python-checkins at python.org Sat Dec 19 13:08:28 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Dec 2015 18:08:28 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1NDIx?= =?utf-8?q?=3A_=5F=5Fsizeof=5F=5F_methods_of_builtin_types_now_use_dynamic?= =?utf-8?q?_basic_size=2E?= Message-ID: <20151219180828.73386.7101@psf.io> https://hg.python.org/cpython/rev/be3998aed1e7 changeset: 99633:be3998aed1e7 branch: 2.7 parent: 99626:11c789c034fe user: Serhiy Storchaka date: Sat Dec 19 20:07:48 2015 +0200 summary: Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. This allows sys.getsize() to work correctly with their subclasses with __slots__ defined. files: Lib/test/test_sys.py | 33 ++++++++++++++++++++++- Misc/NEWS | 4 ++ Modules/_collectionsmodule.c | 2 +- Modules/_io/bufferedio.c | 2 +- Modules/_io/bytesio.c | 2 +- Modules/_struct.c | 2 +- Modules/arraymodule.c | 2 +- Modules/mmapmodule.c | 2 +- Modules/parsermodule.c | 2 +- Objects/bytearrayobject.c | 2 +- Objects/dictobject.c | 2 +- Objects/listobject.c | 2 +- Objects/setobject.c | 2 +- 13 files changed, 46 insertions(+), 13 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1,9 +1,12 @@ # -*- coding: iso-8859-1 -*- import unittest, test.test_support from test.script_helper import assert_python_ok, assert_python_failure -import sys, os, cStringIO +import cStringIO +import gc +import operator +import os import struct -import operator +import sys class SysModuleTest(unittest.TestCase): @@ -754,6 +757,32 @@ check(xrange(1), size('3l')) check(xrange(66000), size('3l')) + def check_slots(self, obj, base, extra): + expected = sys.getsizeof(base) + struct.calcsize(extra) + if gc.is_tracked(obj) and not gc.is_tracked(base): + expected += struct.calcsize('3P') # PyGC_Head + self.assertEqual(sys.getsizeof(obj), expected) + + def test_slots(self): + # check all subclassable types defined in Objects/ that allow + # non-empty __slots__ + check = self.check_slots + class BA(bytearray): + __slots__ = 'a', 'b', 'c' + check(BA(), bytearray(), '3P') + class D(dict): + __slots__ = 'a', 'b', 'c' + check(D(x=[]), {'x': []}, '3P') + class L(list): + __slots__ = 'a', 'b', 'c' + check(L(), [], '3P') + class S(set): + __slots__ = 'a', 'b', 'c' + check(S(), set(), '3P') + class FS(frozenset): + __slots__ = 'a', 'b', 'c' + check(FS(), frozenset(), '3P') + def test_pythontypes(self): # check all types defined in Python/ size = test.test_support.calcobjsize diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,10 @@ Core and Builtins ----------------- +- Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. + This allows sys.getsize() to work correctly with their subclasses with + __slots__ defined. + - Issue #19543: Added Py3k warning for decoding unicode. - Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1103,7 +1103,7 @@ Py_ssize_t res; Py_ssize_t blocks; - res = sizeof(dequeobject); + res = _PyObject_SIZE(Py_TYPE(deque)); blocks = (deque->leftindex + deque->len + BLOCKLEN - 1) / BLOCKLEN; assert(deque->leftindex + deque->len - 1 == (blocks - 1) * BLOCKLEN + deque->rightindex); diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -391,7 +391,7 @@ { Py_ssize_t res; - res = sizeof(buffered); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->buffer) res += self->buffer_size; return PyLong_FromSsize_t(res); diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -809,7 +809,7 @@ { Py_ssize_t res; - res = sizeof(bytesio); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->buf) res += self->buf_size; return PyLong_FromSsize_t(res); diff --git a/Modules/_struct.c b/Modules/_struct.c --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1737,7 +1737,7 @@ { Py_ssize_t size; - size = sizeof(PyStructObject) + sizeof(formatcode) * (self->s_len + 1); + size = _PyObject_SIZE(Py_TYPE(self)) + sizeof(formatcode) * (self->s_len + 1); return PyLong_FromSsize_t(size); } diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1541,7 +1541,7 @@ array_sizeof(arrayobject *self, PyObject *unused) { Py_ssize_t res; - res = sizeof(arrayobject) + self->allocated * self->ob_descr->itemsize; + res = _PyObject_SIZE(Py_TYPE(self)) + self->allocated * self->ob_descr->itemsize; return PyLong_FromSsize_t(res); } diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -655,7 +655,7 @@ { Py_ssize_t res; - res = sizeof(mmap_object); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->tagname) res += strlen(self->tagname) + 1; return PyLong_FromSsize_t(res); diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -720,7 +720,7 @@ { Py_ssize_t res; - res = sizeof(PyST_Object) + _PyNode_SizeOf(st->st_node); + res = _PyObject_SIZE(Py_TYPE(st)) + _PyNode_SizeOf(st->st_node); return PyLong_FromSsize_t(res); } diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -2780,7 +2780,7 @@ { Py_ssize_t res; - res = sizeof(PyByteArrayObject) + self->ob_alloc * sizeof(char); + res = _PyObject_SIZE(Py_TYPE(self)) + self->ob_alloc * sizeof(char); return PyInt_FromSsize_t(res); } diff --git a/Objects/dictobject.c b/Objects/dictobject.c --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2152,7 +2152,7 @@ { Py_ssize_t res; - res = sizeof(PyDictObject); + res = _PyObject_SIZE(Py_TYPE(mp)); if (mp->ma_table != mp->ma_smalltable) res = res + (mp->ma_mask + 1) * sizeof(PyDictEntry); return PyInt_FromSsize_t(res); diff --git a/Objects/listobject.c b/Objects/listobject.c --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2469,7 +2469,7 @@ { Py_ssize_t res; - res = sizeof(PyListObject) + self->allocated * sizeof(void*); + res = _PyObject_SIZE(Py_TYPE(self)) + self->allocated * sizeof(void*); return PyInt_FromSsize_t(res); } diff --git a/Objects/setobject.c b/Objects/setobject.c --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1985,7 +1985,7 @@ { Py_ssize_t res; - res = sizeof(PySetObject); + res = _PyObject_SIZE(Py_TYPE(so)); if (so->table != so->smalltable) res = res + (so->mask + 1) * sizeof(setentry); return PyInt_FromSsize_t(res); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 19 13:08:28 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Dec 2015 18:08:28 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325421=3A_=5F=5Fsizeof=5F=5F_methods_of_builtin_?= =?utf-8?q?types_now_use_dynamic_basic_size=2E?= Message-ID: <20151219180827.32113.42716@psf.io> https://hg.python.org/cpython/rev/4a47e998c40a changeset: 99632:4a47e998c40a parent: 99630:a8f24e26abc7 parent: 99631:71d6755145ae user: Serhiy Storchaka date: Sat Dec 19 20:07:11 2015 +0200 summary: Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. This allows sys.getsize() to work correctly with their subclasses with __slots__ defined. files: Lib/test/test_sys.py | 30 ++++++++++++++++++++++++ Misc/NEWS | 4 +++ Modules/_collectionsmodule.c | 2 +- Modules/_decimal/_decimal.c | 2 +- Modules/_elementtree.c | 2 +- Modules/_io/bufferedio.c | 2 +- Modules/_io/bytesio.c | 2 +- Modules/_pickle.c | 4 +- Modules/_struct.c | 2 +- Modules/arraymodule.c | 2 +- Modules/itertoolsmodule.c | 8 +++--- Modules/mmapmodule.c | 2 +- Modules/parsermodule.c | 2 +- Objects/bytearrayobject.c | 2 +- Objects/codeobject.c | 2 +- Objects/dictobject.c | 2 +- Objects/listobject.c | 2 +- Objects/odictobject.c | 2 - Objects/setobject.c | 2 +- 19 files changed, 54 insertions(+), 22 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1112,6 +1112,36 @@ # weakcallableproxy check(weakref.proxy(int), size('2Pn2P')) + def check_slots(self, obj, base, extra): + expected = sys.getsizeof(base) + struct.calcsize(extra) + if gc.is_tracked(obj) and not gc.is_tracked(base): + expected += struct.calcsize('2Pn') # PyGC_Head + self.assertEqual(sys.getsizeof(obj), expected) + + def test_slots(self): + # check all subclassable types defined in Objects/ that allow + # non-empty __slots__ + check = self.check_slots + class BA(bytearray): + __slots__ = 'a', 'b', 'c' + check(BA(), bytearray(), '3P') + class D(dict): + __slots__ = 'a', 'b', 'c' + check(D(x=[]), {'x': []}, '3P') + class L(list): + __slots__ = 'a', 'b', 'c' + check(L(), [], '3P') + class S(set): + __slots__ = 'a', 'b', 'c' + check(S(), set(), '3P') + class FS(frozenset): + __slots__ = 'a', 'b', 'c' + check(FS(), frozenset(), '3P') + from collections import OrderedDict + class OD(OrderedDict): + __slots__ = 'a', 'b', 'c' + check(OD(x=[]), OrderedDict(x=[]), '3P') + def test_pythontypes(self): # check all types defined in Python/ size = test.support.calcobjsize diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,10 @@ Core and Builtins ----------------- +- Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. + This allows sys.getsize() to work correctly with their subclasses with + __slots__ defined. + - Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. - Issue #5319: New Py_FinalizeEx() API allowing Python to set an exit status diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1476,7 +1476,7 @@ Py_ssize_t res; Py_ssize_t blocks; - res = sizeof(dequeobject); + res = _PyObject_SIZE(Py_TYPE(deque)); blocks = (size_t)(deque->leftindex + Py_SIZE(deque) + BLOCKLEN - 1) / BLOCKLEN; assert(deque->leftindex + Py_SIZE(deque) - 1 == (blocks - 1) * BLOCKLEN + deque->rightindex); diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -4529,7 +4529,7 @@ { Py_ssize_t res; - res = sizeof(PyDecObject); + res = _PyObject_SIZE(Py_TYPE(v)); if (mpd_isdynamic_data(MPD(v))) { res += MPD(v)->alloc * sizeof(mpd_uint_t); } diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -847,7 +847,7 @@ _elementtree_Element___sizeof___impl(ElementObject *self) /*[clinic end generated code: output=bf73867721008000 input=70f4b323d55a17c1]*/ { - Py_ssize_t result = sizeof(ElementObject); + Py_ssize_t result = _PyObject_SIZE(Py_TYPE(self)); if (self->extra) { result += sizeof(ElementObjectExtra); if (self->extra->children != self->extra->_children) diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -423,7 +423,7 @@ { Py_ssize_t res; - res = sizeof(buffered); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->buffer) res += self->buffer_size; return PyLong_FromSsize_t(res); diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -991,7 +991,7 @@ { Py_ssize_t res; - res = sizeof(bytesio); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->buf && !SHARED_BUF(self)) res += _PySys_GetSizeOf(self->buf); return PyLong_FromSsize_t(res); diff --git a/Modules/_pickle.c b/Modules/_pickle.c --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -4087,7 +4087,7 @@ { Py_ssize_t res, s; - res = sizeof(PicklerObject); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->memo != NULL) { res += sizeof(PyMemoTable); res += self->memo->mt_allocated * sizeof(PyMemoEntry); @@ -6509,7 +6509,7 @@ { Py_ssize_t res; - res = sizeof(UnpicklerObject); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->memo != NULL) res += self->memo_size * sizeof(PyObject *); if (self->marks != NULL) diff --git a/Modules/_struct.c b/Modules/_struct.c --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1924,7 +1924,7 @@ Py_ssize_t size; formatcode *code; - size = sizeof(PyStructObject) + sizeof(formatcode); + size = _PyObject_SIZE(Py_TYPE(self)) + sizeof(formatcode); for (code = self->s_codes; code->fmtdef != NULL; code++) size += sizeof(formatcode); return PyLong_FromSsize_t(size); diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1743,7 +1743,7 @@ /*[clinic end generated code: output=d8e1c61ebbe3eaed input=805586565bf2b3c6]*/ { Py_ssize_t res; - res = sizeof(arrayobject) + self->allocated * self->ob_descr->itemsize; + res = _PyObject_SIZE(Py_TYPE(self)) + self->allocated * self->ob_descr->itemsize; return PyLong_FromSsize_t(res); } diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -2109,7 +2109,7 @@ { Py_ssize_t res; - res = sizeof(productobject); + res = _PyObject_SIZE(Py_TYPE(lz)); res += PyTuple_GET_SIZE(lz->pools) * sizeof(Py_ssize_t); return PyLong_FromSsize_t(res); } @@ -2440,7 +2440,7 @@ { Py_ssize_t res; - res = sizeof(combinationsobject); + res = _PyObject_SIZE(Py_TYPE(co)); res += co->r * sizeof(Py_ssize_t); return PyLong_FromSsize_t(res); } @@ -2781,7 +2781,7 @@ { Py_ssize_t res; - res = sizeof(cwrobject); + res = _PyObject_SIZE(Py_TYPE(co)); res += co->r * sizeof(Py_ssize_t); return PyLong_FromSsize_t(res); } @@ -3129,7 +3129,7 @@ { Py_ssize_t res; - res = sizeof(permutationsobject); + res = _PyObject_SIZE(Py_TYPE(po)); res += PyTuple_GET_SIZE(po->pool) * sizeof(Py_ssize_t); res += po->r * sizeof(Py_ssize_t); return PyLong_FromSsize_t(res); diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -719,7 +719,7 @@ { Py_ssize_t res; - res = sizeof(mmap_object); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->tagname) res += strlen(self->tagname) + 1; return PyLong_FromSsize_t(res); diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -397,7 +397,7 @@ { Py_ssize_t res; - res = sizeof(PyST_Object) + _PyNode_SizeOf(st->st_node); + res = _PyObject_SIZE(Py_TYPE(st)) + _PyNode_SizeOf(st->st_node); return PyLong_FromSsize_t(res); } diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -2904,7 +2904,7 @@ { Py_ssize_t res; - res = sizeof(PyByteArrayObject) + self->ob_alloc * sizeof(char); + res = _PyObject_SIZE(Py_TYPE(self)) + self->ob_alloc * sizeof(char); return PyLong_FromSsize_t(res); } diff --git a/Objects/codeobject.c b/Objects/codeobject.c --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -384,7 +384,7 @@ { Py_ssize_t res; - res = sizeof(PyCodeObject); + res = _PyObject_SIZE(Py_TYPE(co)); if (co->co_cell2arg != NULL && co->co_cellvars != NULL) res += PyTuple_GET_SIZE(co->co_cellvars) * sizeof(unsigned char); return PyLong_FromSsize_t(res); diff --git a/Objects/dictobject.c b/Objects/dictobject.c --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2563,7 +2563,7 @@ Py_ssize_t size, res; size = DK_SIZE(mp->ma_keys); - res = sizeof(PyDictObject); + res = _PyObject_SIZE(Py_TYPE(mp)); if (mp->ma_values) res += size * sizeof(PyObject*); /* If the dictionary is split, the keys portion is accounted-for diff --git a/Objects/listobject.c b/Objects/listobject.c --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2324,7 +2324,7 @@ { Py_ssize_t res; - res = sizeof(PyListObject) + self->allocated * sizeof(void*); + res = _PyObject_SIZE(Py_TYPE(self)) + self->allocated * sizeof(void*); return PyLong_FromSsize_t(res); } diff --git a/Objects/odictobject.c b/Objects/odictobject.c --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -951,8 +951,6 @@ if (res == -1 && PyErr_Occurred()) return NULL; - res += sizeof(PyODictObject) - sizeof(PyDictObject); - /* instance dict */ pylong = _PyDict_SizeOf((PyDictObject *)od->od_inst_dict); if (pylong == NULL) diff --git a/Objects/setobject.c b/Objects/setobject.c --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -2003,7 +2003,7 @@ { Py_ssize_t res; - res = sizeof(PySetObject); + res = _PyObject_SIZE(Py_TYPE(so)); if (so->table != so->smalltable) res = res + (so->mask + 1) * sizeof(setentry); return PyLong_FromSsize_t(res); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 19 13:08:27 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Dec 2015 18:08:27 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NDIx?= =?utf-8?q?=3A_=5F=5Fsizeof=5F=5F_methods_of_builtin_types_now_use_dynamic?= =?utf-8?q?_basic_size=2E?= Message-ID: <20151219180827.90156.60208@psf.io> https://hg.python.org/cpython/rev/71d6755145ae changeset: 99631:71d6755145ae branch: 3.5 parent: 99628:e4f3e3ccd06f user: Serhiy Storchaka date: Sat Dec 19 20:05:25 2015 +0200 summary: Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. This allows sys.getsize() to work correctly with their subclasses with __slots__ defined. files: Lib/test/test_sys.py | 30 ++++++++++++++++++++++++ Misc/NEWS | 4 +++ Modules/_collectionsmodule.c | 2 +- Modules/_decimal/_decimal.c | 2 +- Modules/_elementtree.c | 2 +- Modules/_io/bufferedio.c | 2 +- Modules/_io/bytesio.c | 2 +- Modules/_pickle.c | 4 +- Modules/_struct.c | 2 +- Modules/arraymodule.c | 2 +- Modules/itertoolsmodule.c | 8 +++--- Modules/mmapmodule.c | 2 +- Modules/parsermodule.c | 2 +- Objects/bytearrayobject.c | 2 +- Objects/codeobject.c | 2 +- Objects/dictobject.c | 2 +- Objects/listobject.c | 2 +- Objects/odictobject.c | 2 - Objects/setobject.c | 2 +- 19 files changed, 54 insertions(+), 22 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1112,6 +1112,36 @@ # weakcallableproxy check(weakref.proxy(int), size('2Pn2P')) + def check_slots(self, obj, base, extra): + expected = sys.getsizeof(base) + struct.calcsize(extra) + if gc.is_tracked(obj) and not gc.is_tracked(base): + expected += struct.calcsize('2Pn') # PyGC_Head + self.assertEqual(sys.getsizeof(obj), expected) + + def test_slots(self): + # check all subclassable types defined in Objects/ that allow + # non-empty __slots__ + check = self.check_slots + class BA(bytearray): + __slots__ = 'a', 'b', 'c' + check(BA(), bytearray(), '3P') + class D(dict): + __slots__ = 'a', 'b', 'c' + check(D(x=[]), {'x': []}, '3P') + class L(list): + __slots__ = 'a', 'b', 'c' + check(L(), [], '3P') + class S(set): + __slots__ = 'a', 'b', 'c' + check(S(), set(), '3P') + class FS(frozenset): + __slots__ = 'a', 'b', 'c' + check(FS(), frozenset(), '3P') + from collections import OrderedDict + class OD(OrderedDict): + __slots__ = 'a', 'b', 'c' + check(OD(x=[]), OrderedDict(x=[]), '3P') + def test_pythontypes(self): # check all types defined in Python/ size = test.support.calcobjsize diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,10 @@ Core and Builtins ----------------- +- Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. + This allows sys.getsize() to work correctly with their subclasses with + __slots__ defined. + - Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. - Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1443,7 +1443,7 @@ Py_ssize_t res; Py_ssize_t blocks; - res = sizeof(dequeobject); + res = _PyObject_SIZE(Py_TYPE(deque)); blocks = (deque->leftindex + Py_SIZE(deque) + BLOCKLEN - 1) / BLOCKLEN; assert(deque->leftindex + Py_SIZE(deque) - 1 == (blocks - 1) * BLOCKLEN + deque->rightindex); diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -4529,7 +4529,7 @@ { Py_ssize_t res; - res = sizeof(PyDecObject); + res = _PyObject_SIZE(Py_TYPE(v)); if (mpd_isdynamic_data(MPD(v))) { res += MPD(v)->alloc * sizeof(mpd_uint_t); } diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -847,7 +847,7 @@ _elementtree_Element___sizeof___impl(ElementObject *self) /*[clinic end generated code: output=bf73867721008000 input=70f4b323d55a17c1]*/ { - Py_ssize_t result = sizeof(ElementObject); + Py_ssize_t result = _PyObject_SIZE(Py_TYPE(self)); if (self->extra) { result += sizeof(ElementObjectExtra); if (self->extra->children != self->extra->_children) diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -423,7 +423,7 @@ { Py_ssize_t res; - res = sizeof(buffered); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->buffer) res += self->buffer_size; return PyLong_FromSsize_t(res); diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -991,7 +991,7 @@ { Py_ssize_t res; - res = sizeof(bytesio); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->buf && !SHARED_BUF(self)) res += _PySys_GetSizeOf(self->buf); return PyLong_FromSsize_t(res); diff --git a/Modules/_pickle.c b/Modules/_pickle.c --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -4015,7 +4015,7 @@ { Py_ssize_t res, s; - res = sizeof(PicklerObject); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->memo != NULL) { res += sizeof(PyMemoTable); res += self->memo->mt_allocated * sizeof(PyMemoEntry); @@ -6418,7 +6418,7 @@ { Py_ssize_t res; - res = sizeof(UnpicklerObject); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->memo != NULL) res += self->memo_size * sizeof(PyObject *); if (self->marks != NULL) diff --git a/Modules/_struct.c b/Modules/_struct.c --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1924,7 +1924,7 @@ Py_ssize_t size; formatcode *code; - size = sizeof(PyStructObject) + sizeof(formatcode); + size = _PyObject_SIZE(Py_TYPE(self)) + sizeof(formatcode); for (code = self->s_codes; code->fmtdef != NULL; code++) size += sizeof(formatcode); return PyLong_FromSsize_t(size); diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1743,7 +1743,7 @@ /*[clinic end generated code: output=d8e1c61ebbe3eaed input=805586565bf2b3c6]*/ { Py_ssize_t res; - res = sizeof(arrayobject) + self->allocated * self->ob_descr->itemsize; + res = _PyObject_SIZE(Py_TYPE(self)) + self->allocated * self->ob_descr->itemsize; return PyLong_FromSsize_t(res); } diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -2089,7 +2089,7 @@ { Py_ssize_t res; - res = sizeof(productobject); + res = _PyObject_SIZE(Py_TYPE(lz)); res += PyTuple_GET_SIZE(lz->pools) * sizeof(Py_ssize_t); return PyLong_FromSsize_t(res); } @@ -2420,7 +2420,7 @@ { Py_ssize_t res; - res = sizeof(combinationsobject); + res = _PyObject_SIZE(Py_TYPE(co)); res += co->r * sizeof(Py_ssize_t); return PyLong_FromSsize_t(res); } @@ -2761,7 +2761,7 @@ { Py_ssize_t res; - res = sizeof(cwrobject); + res = _PyObject_SIZE(Py_TYPE(co)); res += co->r * sizeof(Py_ssize_t); return PyLong_FromSsize_t(res); } @@ -3110,7 +3110,7 @@ { Py_ssize_t res; - res = sizeof(permutationsobject); + res = _PyObject_SIZE(Py_TYPE(po)); res += PyTuple_GET_SIZE(po->pool) * sizeof(Py_ssize_t); res += po->r * sizeof(Py_ssize_t); return PyLong_FromSsize_t(res); diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -719,7 +719,7 @@ { Py_ssize_t res; - res = sizeof(mmap_object); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->tagname) res += strlen(self->tagname) + 1; return PyLong_FromSsize_t(res); diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -397,7 +397,7 @@ { Py_ssize_t res; - res = sizeof(PyST_Object) + _PyNode_SizeOf(st->st_node); + res = _PyObject_SIZE(Py_TYPE(st)) + _PyNode_SizeOf(st->st_node); return PyLong_FromSsize_t(res); } diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -2974,7 +2974,7 @@ { Py_ssize_t res; - res = sizeof(PyByteArrayObject) + self->ob_alloc * sizeof(char); + res = _PyObject_SIZE(Py_TYPE(self)) + self->ob_alloc * sizeof(char); return PyLong_FromSsize_t(res); } diff --git a/Objects/codeobject.c b/Objects/codeobject.c --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -384,7 +384,7 @@ { Py_ssize_t res; - res = sizeof(PyCodeObject); + res = _PyObject_SIZE(Py_TYPE(co)); if (co->co_cell2arg != NULL && co->co_cellvars != NULL) res += PyTuple_GET_SIZE(co->co_cellvars) * sizeof(unsigned char); return PyLong_FromSsize_t(res); diff --git a/Objects/dictobject.c b/Objects/dictobject.c --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2560,7 +2560,7 @@ Py_ssize_t size, res; size = DK_SIZE(mp->ma_keys); - res = sizeof(PyDictObject); + res = _PyObject_SIZE(Py_TYPE(mp)); if (mp->ma_values) res += size * sizeof(PyObject*); /* If the dictionary is split, the keys portion is accounted-for diff --git a/Objects/listobject.c b/Objects/listobject.c --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2324,7 +2324,7 @@ { Py_ssize_t res; - res = sizeof(PyListObject) + self->allocated * sizeof(void*); + res = _PyObject_SIZE(Py_TYPE(self)) + self->allocated * sizeof(void*); return PyLong_FromSsize_t(res); } diff --git a/Objects/odictobject.c b/Objects/odictobject.c --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -951,8 +951,6 @@ if (res == -1 && PyErr_Occurred()) return NULL; - res += sizeof(PyODictObject) - sizeof(PyDictObject); - /* instance dict */ pylong = _PyDict_SizeOf((PyDictObject *)od->od_inst_dict); if (pylong == NULL) diff --git a/Objects/setobject.c b/Objects/setobject.c --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1940,7 +1940,7 @@ { Py_ssize_t res; - res = sizeof(PySetObject); + res = _PyObject_SIZE(Py_TYPE(so)); if (so->table != so->smalltable) res = res + (so->mask + 1) * sizeof(setentry); return PyLong_FromSsize_t(res); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 19 15:51:24 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Dec 2015 20:51:24 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Use_correct_Py?= =?utf-8?q?GC=5FHead_size_in_tests_for_issue_=2325421=2E?= Message-ID: <20151219205124.73368.4268@psf.io> https://hg.python.org/cpython/rev/ab97ff838e11 changeset: 99635:ab97ff838e11 branch: 2.7 parent: 99633:be3998aed1e7 user: Serhiy Storchaka date: Sat Dec 19 22:49:29 2015 +0200 summary: Use correct PyGC_Head size in tests for issue #25421. files: Lib/test/test_sys.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -760,7 +760,7 @@ def check_slots(self, obj, base, extra): expected = sys.getsizeof(base) + struct.calcsize(extra) if gc.is_tracked(obj) and not gc.is_tracked(base): - expected += struct.calcsize('3P') # PyGC_Head + expected += self.gc_headsize self.assertEqual(sys.getsizeof(obj), expected) def test_slots(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 19 15:51:24 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Dec 2015 20:51:24 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Use_correct_Py?= =?utf-8?q?GC=5FHead_size_in_tests_for_issue_=2325421=2E?= Message-ID: <20151219205124.32115.18704@psf.io> https://hg.python.org/cpython/rev/a1388dbdd293 changeset: 99634:a1388dbdd293 branch: 3.5 parent: 99631:71d6755145ae user: Serhiy Storchaka date: Sat Dec 19 22:49:29 2015 +0200 summary: Use correct PyGC_Head size in tests for issue #25421. files: Lib/test/test_sys.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1115,7 +1115,7 @@ def check_slots(self, obj, base, extra): expected = sys.getsizeof(base) + struct.calcsize(extra) if gc.is_tracked(obj) and not gc.is_tracked(base): - expected += struct.calcsize('2Pn') # PyGC_Head + expected += self.gc_headsize self.assertEqual(sys.getsizeof(obj), expected) def test_slots(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 19 15:51:24 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 19 Dec 2015 20:51:24 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Use_correct_PyGC=5FHead_size_in_tests_for_issue_=2325421?= =?utf-8?q?=2E?= Message-ID: <20151219205124.83195.47820@psf.io> https://hg.python.org/cpython/rev/5115f39cc59f changeset: 99636:5115f39cc59f parent: 99632:4a47e998c40a parent: 99634:a1388dbdd293 user: Serhiy Storchaka date: Sat Dec 19 22:51:00 2015 +0200 summary: Use correct PyGC_Head size in tests for issue #25421. files: Lib/test/test_sys.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1115,7 +1115,7 @@ def check_slots(self, obj, base, extra): expected = sys.getsizeof(base) + struct.calcsize(extra) if gc.is_tracked(obj) and not gc.is_tracked(base): - expected += struct.calcsize('2Pn') # PyGC_Head + expected += self.gc_headsize self.assertEqual(sys.getsizeof(obj), expected) def test_slots(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 20 02:44:42 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 20 Dec 2015 07:44:42 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Create_a_file_?= =?utf-8?q?in_SizeofTest_only_if_needed=2E?= Message-ID: <20151220074442.7704.81015@psf.io> https://hg.python.org/cpython/rev/f3a095ad52fe changeset: 99637:f3a095ad52fe branch: 2.7 parent: 99635:ab97ff838e11 user: Serhiy Storchaka date: Sun Dec 20 09:36:55 2015 +0200 summary: Create a file in SizeofTest only if needed. files: Lib/test/test_sys.py | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -484,11 +484,6 @@ self.longdigit = sys.long_info.sizeof_digit import _testcapi self.gc_headsize = _testcapi.SIZEOF_PYGC_HEAD - self.file = open(test.test_support.TESTFN, 'wb') - - def tearDown(self): - self.file.close() - test.test_support.unlink(test.test_support.TESTFN) check_sizeof = test.test_support.check_sizeof @@ -613,7 +608,12 @@ # enumerate check(enumerate([]), size('l3P')) # file - check(self.file, size('4P2i4P3i3P3i')) + f = file(test.test_support.TESTFN, 'wb') + try: + check(f, size('4P2i4P3i3P3i')) + finally: + f.close() + test.test_support.unlink(test.test_support.TESTFN) # float check(float(0), size('d')) # sys.floatinfo @@ -793,7 +793,12 @@ check(_ast.AST(), size('')) # imp.NullImporter import imp - check(imp.NullImporter(self.file.name), size('')) + f = open(test.test_support.TESTFN, 'wb') + try: + check(imp.NullImporter(f.name), size('')) + finally: + f.close() + test.test_support.unlink(test.test_support.TESTFN) try: raise TypeError except TypeError: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 20 02:44:43 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 20 Dec 2015 07:44:43 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogRG9uJ3QgY3JlYXRl?= =?utf-8?q?_non-needed_file=2E?= Message-ID: <20151220074442.57602.64627@psf.io> https://hg.python.org/cpython/rev/ad25fdb6c521 changeset: 99638:ad25fdb6c521 branch: 3.5 parent: 99634:a1388dbdd293 user: Serhiy Storchaka date: Sun Dec 20 09:37:52 2015 +0200 summary: Don't create non-needed file. files: Lib/test/test_sys.py | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -814,11 +814,6 @@ self.longdigit = sys.int_info.sizeof_digit import _testcapi self.gc_headsize = _testcapi.SIZEOF_PYGC_HEAD - self.file = open(test.support.TESTFN, 'wb') - - def tearDown(self): - self.file.close() - test.support.unlink(test.support.TESTFN) check_sizeof = test.support.check_sizeof -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 20 02:44:42 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 20 Dec 2015 07:44:42 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Don=27t_create_non-needed_file=2E?= Message-ID: <20151220074442.57616.68055@psf.io> https://hg.python.org/cpython/rev/6e114c4023f5 changeset: 99639:6e114c4023f5 parent: 99636:5115f39cc59f parent: 99638:ad25fdb6c521 user: Serhiy Storchaka date: Sun Dec 20 09:38:31 2015 +0200 summary: Don't create non-needed file. files: Lib/test/test_sys.py | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -814,11 +814,6 @@ self.longdigit = sys.int_info.sizeof_digit import _testcapi self.gc_headsize = _testcapi.SIZEOF_PYGC_HEAD - self.file = open(test.support.TESTFN, 'wb') - - def tearDown(self): - self.file.close() - test.support.unlink(test.support.TESTFN) check_sizeof = test.support.check_sizeof -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sun Dec 20 03:42:21 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 20 Dec 2015 08:42:21 +0000 Subject: [Python-checkins] Daily reference leaks (5115f39cc59f): sum=4 Message-ID: <20151220084221.7692.66565@psf.io> results for 5115f39cc59f on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflog78Nf_6', '--timeout', '7200'] From python-checkins at python.org Sun Dec 20 04:40:37 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 20 Dec 2015 09:40:37 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Fixed_sizeof_tests_for_dict_and_type_=28they_were_passed?= =?utf-8?q?_by_accident=29=2E?= Message-ID: <20151220094037.19158.78949@psf.io> https://hg.python.org/cpython/rev/72016e8df85a changeset: 99641:72016e8df85a parent: 99639:6e114c4023f5 parent: 99640:5895cb9fc8d0 user: Serhiy Storchaka date: Sun Dec 20 11:39:47 2015 +0200 summary: Fixed sizeof tests for dict and type (they were passed by accident). Added tests for dict views iterators. files: Lib/test/test_sys.py | 33 +++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -864,6 +864,7 @@ def test_objecttypes(self): # check all types defined in Objects/ + calcsize = struct.calcsize size = test.support.calcobjsize vsize = test.support.calcvobjsize check = self.check_sizeof @@ -915,17 +916,23 @@ # method-wrapper (descriptor object) check({}.__iter__, size('2P')) # dict - check({}, size('n2P' + '2nPn' + 8*'n2P')) + check({}, size('n2P') + calcsize('2nPn') + 8*calcsize('n2P')) longdict = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8} - check(longdict, size('n2P' + '2nPn') + 16*struct.calcsize('n2P')) - # dictionary-keyiterator + check(longdict, size('n2P') + calcsize('2nPn') + 16*calcsize('n2P')) + # dictionary-keyview check({}.keys(), size('P')) - # dictionary-valueiterator + # dictionary-valueview check({}.values(), size('P')) - # dictionary-itemiterator + # dictionary-itemview check({}.items(), size('P')) # dictionary iterator check(iter({}), size('P2nPn')) + # dictionary-keyiterator + check(iter({}.keys()), size('P2nPn')) + # dictionary-valueiterator + check(iter({}.values()), size('P2nPn')) + # dictionary-itemiterator + check(iter({}.items()), size('P2nPn')) # dictproxy class C(object): pass check(C.__dict__, size('P')) @@ -1044,8 +1051,8 @@ check(set(sample), s) check(frozenset(sample), s) else: - check(set(sample), s + newsize*struct.calcsize('nP')) - check(frozenset(sample), s + newsize*struct.calcsize('nP')) + check(set(sample), s + newsize*calcsize('nP')) + check(frozenset(sample), s + newsize*calcsize('nP')) # setiterator check(iter(set()), size('P3n')) # slice @@ -1059,11 +1066,15 @@ # static type: PyTypeObject s = vsize('P2n15Pl4Pn9Pn11PIP') check(int, s) - # (PyTypeObject + PyAsyncMethods + PyNumberMethods + PyMappingMethods + - # PySequenceMethods + PyBufferProcs + 4P) - s = vsize('P2n17Pl4Pn9Pn11PIP') + struct.calcsize('34P 3P 3P 10P 2P 4P') + s = vsize('P2n15Pl4Pn9Pn11PIP' # PyTypeObject + '3P' # PyAsyncMethods + '36P' # PyNumberMethods + '3P' # PyMappingMethods + '10P' # PySequenceMethods + '2P' # PyBufferProcs + '4P') # Separate block for PyDictKeysObject with 4 entries - s += struct.calcsize("2nPn") + 4*struct.calcsize("n2P") + s += calcsize("2nPn") + 4*calcsize("n2P") # class class newstyleclass(object): pass check(newstyleclass, s) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 20 04:40:37 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 20 Dec 2015 09:40:37 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fixed_sizeof_t?= =?utf-8?q?ests_for_dict_and_type_=28they_were_passed_by_accident=29=2E?= Message-ID: <20151220094037.57622.3302@psf.io> https://hg.python.org/cpython/rev/5895cb9fc8d0 changeset: 99640:5895cb9fc8d0 branch: 3.5 parent: 99638:ad25fdb6c521 user: Serhiy Storchaka date: Sun Dec 20 11:39:14 2015 +0200 summary: Fixed sizeof tests for dict and type (they were passed by accident). Added tests for dict views iterators. files: Lib/test/test_sys.py | 33 +++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -864,6 +864,7 @@ def test_objecttypes(self): # check all types defined in Objects/ + calcsize = struct.calcsize size = test.support.calcobjsize vsize = test.support.calcvobjsize check = self.check_sizeof @@ -915,17 +916,23 @@ # method-wrapper (descriptor object) check({}.__iter__, size('2P')) # dict - check({}, size('n2P' + '2nPn' + 8*'n2P')) + check({}, size('n2P') + calcsize('2nPn') + 8*calcsize('n2P')) longdict = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8} - check(longdict, size('n2P' + '2nPn') + 16*struct.calcsize('n2P')) - # dictionary-keyiterator + check(longdict, size('n2P') + calcsize('2nPn') + 16*calcsize('n2P')) + # dictionary-keyview check({}.keys(), size('P')) - # dictionary-valueiterator + # dictionary-valueview check({}.values(), size('P')) - # dictionary-itemiterator + # dictionary-itemview check({}.items(), size('P')) # dictionary iterator check(iter({}), size('P2nPn')) + # dictionary-keyiterator + check(iter({}.keys()), size('P2nPn')) + # dictionary-valueiterator + check(iter({}.values()), size('P2nPn')) + # dictionary-itemiterator + check(iter({}.items()), size('P2nPn')) # dictproxy class C(object): pass check(C.__dict__, size('P')) @@ -1044,8 +1051,8 @@ check(set(sample), s) check(frozenset(sample), s) else: - check(set(sample), s + newsize*struct.calcsize('nP')) - check(frozenset(sample), s + newsize*struct.calcsize('nP')) + check(set(sample), s + newsize*calcsize('nP')) + check(frozenset(sample), s + newsize*calcsize('nP')) # setiterator check(iter(set()), size('P3n')) # slice @@ -1059,11 +1066,15 @@ # static type: PyTypeObject s = vsize('P2n15Pl4Pn9Pn11PIP') check(int, s) - # (PyTypeObject + PyAsyncMethods + PyNumberMethods + PyMappingMethods + - # PySequenceMethods + PyBufferProcs + 4P) - s = vsize('P2n17Pl4Pn9Pn11PIP') + struct.calcsize('34P 3P 3P 10P 2P 4P') + s = vsize('P2n15Pl4Pn9Pn11PIP' # PyTypeObject + '3P' # PyAsyncMethods + '36P' # PyNumberMethods + '3P' # PyMappingMethods + '10P' # PySequenceMethods + '2P' # PyBufferProcs + '4P') # Separate block for PyDictKeysObject with 4 entries - s += struct.calcsize("2nPn") + 4*struct.calcsize("n2P") + s += calcsize("2nPn") + 4*calcsize("n2P") # class class newstyleclass(object): pass check(newstyleclass, s) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 20 04:40:37 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 20 Dec 2015 09:40:37 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fixed_sizeof_t?= =?utf-8?q?ests_for_dict_and_type_=28they_were_passed_by_accident=29=2E?= Message-ID: <20151220094037.57604.54764@psf.io> https://hg.python.org/cpython/rev/b87fe3e4a3d8 changeset: 99642:b87fe3e4a3d8 branch: 2.7 parent: 99637:f3a095ad52fe user: Serhiy Storchaka date: Sun Dec 20 11:40:00 2015 +0200 summary: Fixed sizeof tests for dict and type (they were passed by accident). Added tests for dict views. files: Lib/test/test_sys.py | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -527,6 +527,7 @@ def test_objecttypes(self): # check all types defined in Objects/ + calcsize = struct.calcsize size = test.test_support.calcobjsize vsize = test.test_support.calcvobjsize check = self.check_sizeof @@ -590,9 +591,17 @@ # method-wrapper (descriptor object) check({}.__iter__, size('2P')) # dict - check({}, size('3P2P' + 8*'P2P')) + check({}, size('3P2P') + 8*calcsize('P2P')) x = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8} - check(x, size('3P2P' + 8*'P2P') + 16*struct.calcsize('P2P')) + check(x, size('3P2P') + 8*calcsize('P2P') + 16*calcsize('P2P')) + # dictionary-keyview + check({}.viewkeys(), size('P')) + # dictionary-valueview + check({}.viewvalues(), size('P')) + # dictionary-itemview + check({}.viewitems(), size('P')) + # dictionary iterator + check(iter({}), size('P2PPP')) # dictionary-keyiterator check({}.iterkeys(), size('P2PPP')) # dictionary-valueiterator @@ -710,16 +719,16 @@ check(set(sample), s) check(frozenset(sample), s) else: - check(set(sample), s + newsize*struct.calcsize('lP')) - check(frozenset(sample), s + newsize*struct.calcsize('lP')) + check(set(sample), s + newsize*calcsize('lP')) + check(frozenset(sample), s + newsize*calcsize('lP')) # setiterator check(iter(set()), size('P3P')) # slice check(slice(1), size('3P')) # str vh = test.test_support._vheader - check('', struct.calcsize(vh + 'lic')) - check('abc', struct.calcsize(vh + 'lic') + 3) + check('', calcsize(vh + 'lic')) + check('abc', calcsize(vh + 'lic') + 3) # super check(super(int), size('3P')) # tuple @@ -728,9 +737,12 @@ # tupleiterator check(iter(()), size('lP')) # type - # (PyTypeObject + PyNumberMethods + PyMappingMethods + - # PySequenceMethods + PyBufferProcs) - s = vsize('P2P15Pl4PP9PP11PI') + struct.calcsize('41P 10P 3P 6P') + s = vsize('P2P15Pl4PP9PP11PI' # PyTypeObject + '39P' # PyNumberMethods + '3P' # PyMappingMethods + '10P' # PySequenceMethods + '6P' # PyBufferProcs + '2P') class newstyleclass(object): pass check(newstyleclass, s) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 20 11:04:17 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 20 Dec 2015 16:04:17 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NzY2?= =?utf-8?q?=3A_Special_method_=5F=5Fbytes=5F=5F=28=29_now_works_in_str_sub?= =?utf-8?q?classes=2E?= Message-ID: <20151220160416.16764.71283@psf.io> https://hg.python.org/cpython/rev/1e54adef4064 changeset: 99643:1e54adef4064 branch: 3.5 parent: 99640:5895cb9fc8d0 user: Serhiy Storchaka date: Sun Dec 20 16:36:34 2015 +0200 summary: Issue #25766: Special method __bytes__() now works in str subclasses. files: Lib/test/test_bytes.py | 6 ++++++ Misc/NEWS | 2 ++ Objects/bytesobject.c | 18 ++++++++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -779,6 +779,12 @@ def __index__(self): return 42 self.assertEqual(bytes(A()), b'a') + # Issue #25766 + class A(str): + def __bytes__(self): + return b'abc' + self.assertEqual(bytes(A('\u20ac')), b'abc') + self.assertEqual(bytes(A('\u20ac'), 'iso8859-15'), b'\xa4') # Issue #24731 class A: def __bytes__(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #25766: Special method __bytes__() now works in str subclasses. + - Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. This allows sys.getsize() to work correctly with their subclasses with __slots__ defined. diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -3175,11 +3175,11 @@ return PyBytes_FromStringAndSize(NULL, 0); } - if (PyUnicode_Check(x)) { + if (encoding != NULL) { /* Encode via the codec registry */ - if (encoding == NULL) { + if (!PyUnicode_Check(x)) { PyErr_SetString(PyExc_TypeError, - "string argument without an encoding"); + "encoding without a string argument"); return NULL; } new = PyUnicode_AsEncodedString(x, encoding, errors); @@ -3189,10 +3189,11 @@ return new; } - /* If it's not unicode, there can't be encoding or errors */ - if (encoding != NULL || errors != NULL) { + if (errors != NULL) { PyErr_SetString(PyExc_TypeError, - "encoding or errors without a string argument"); + PyUnicode_Check(x) ? + "string argument without an encoding" : + "errors without a string argument"); return NULL; } @@ -3217,6 +3218,11 @@ else if (PyErr_Occurred()) return NULL; + if (PyUnicode_Check(x)) { + PyErr_SetString(PyExc_TypeError, + "string argument without an encoding"); + return NULL; + } /* Is it an integer? */ size = PyNumber_AsSsize_t(x, PyExc_OverflowError); if (size == -1 && PyErr_Occurred()) { -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 20 11:04:20 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 20 Dec 2015 16:04:20 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogSXNzdWUgIzI1NzY2OiBTcGVjaWFsIG1ldGhvZCBfX2J5dGVzX18oKSBu?= =?utf-8?q?ow_works_in_str_subclasses=2E?= Message-ID: <20151220160417.73378.17267@psf.io> https://hg.python.org/cpython/rev/af0b95fb1c19 changeset: 99644:af0b95fb1c19 parent: 99641:72016e8df85a parent: 99643:1e54adef4064 user: Serhiy Storchaka date: Sun Dec 20 16:37:21 2015 +0200 summary: Issue #25766: Special method __bytes__() now works in str subclasses. files: Lib/test/test_bytes.py | 6 ++++++ Misc/NEWS | 2 ++ Objects/bytesobject.c | 18 ++++++++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -793,6 +793,12 @@ def __index__(self): return 42 self.assertEqual(bytes(A()), b'a') + # Issue #25766 + class A(str): + def __bytes__(self): + return b'abc' + self.assertEqual(bytes(A('\u20ac')), b'abc') + self.assertEqual(bytes(A('\u20ac'), 'iso8859-15'), b'\xa4') # Issue #24731 class A: def __bytes__(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #25766: Special method __bytes__() now works in str subclasses. + - Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. This allows sys.getsize() to work correctly with their subclasses with __slots__ defined. diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -3320,11 +3320,11 @@ return PyBytes_FromStringAndSize(NULL, 0); } - if (PyUnicode_Check(x)) { + if (encoding != NULL) { /* Encode via the codec registry */ - if (encoding == NULL) { + if (!PyUnicode_Check(x)) { PyErr_SetString(PyExc_TypeError, - "string argument without an encoding"); + "encoding without a string argument"); return NULL; } new = PyUnicode_AsEncodedString(x, encoding, errors); @@ -3334,10 +3334,11 @@ return new; } - /* If it's not unicode, there can't be encoding or errors */ - if (encoding != NULL || errors != NULL) { + if (errors != NULL) { PyErr_SetString(PyExc_TypeError, - "encoding or errors without a string argument"); + PyUnicode_Check(x) ? + "string argument without an encoding" : + "errors without a string argument"); return NULL; } @@ -3362,6 +3363,11 @@ else if (PyErr_Occurred()) return NULL; + if (PyUnicode_Check(x)) { + PyErr_SetString(PyExc_TypeError, + "string argument without an encoding"); + return NULL; + } /* Is it an integer? */ size = PyNumber_AsSsize_t(x, PyExc_OverflowError); if (size == -1 && PyErr_Occurred()) { -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 01:47:27 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 21 Dec 2015 06:47:27 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Rebuild_pydoc_?= =?utf-8?q?topics_for_Python_3=2E4=2E4_final=2E?= Message-ID: <20151221064727.19156.32138@psf.io> https://hg.python.org/cpython/rev/8bf80a9e98fa changeset: 99646:8bf80a9e98fa branch: 3.4 user: Larry Hastings date: Sat Dec 19 19:28:52 2015 -0800 summary: Rebuild pydoc topics for Python 3.4.4 final. files: Lib/pydoc_data/topics.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py --- a/Lib/pydoc_data/topics.py +++ b/Lib/pydoc_data/topics.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Autogenerated by Sphinx on Sun Dec 6 05:51:21 2015 +# Autogenerated by Sphinx on Sat Dec 19 19:27:32 2015 topics = {'assert': u'\nThe "assert" statement\n**********************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, "assert expression", is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, "assert expression1, expression2", is equivalent to\n\n if __debug__:\n if not expression1: raise AssertionError(expression2)\n\nThese equivalences assume that "__debug__" and "AssertionError" refer\nto the built-in variables with those names. In the current\nimplementation, the built-in variable "__debug__" is "True" under\nnormal circumstances, "False" when optimization is requested (command\nline option -O). The current code generator emits no code for an\nassert statement when optimization is requested at compile time. Note\nthat it is unnecessary to include the source code for the expression\nthat failed in the error message; it will be displayed as part of the\nstack trace.\n\nAssignments to "__debug__" are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n', 'assignment': u'\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n | "*" target\n\n(See section *Primaries* for the syntax definitions for\n*attributeref*, *subscription*, and *slicing*.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list, optionally enclosed in\nparentheses or square brackets, is recursively defined as follows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The\n object must be an iterable with the same number of items as there\n are targets in the target list, and the items are assigned, from\n left to right, to the corresponding targets.\n\n * If the target list contains one target prefixed with an\n asterisk, called a "starred" target: The object must be a sequence\n with at least as many items as there are targets in the target\n list, minus one. The first items of the sequence are assigned,\n from left to right, to the targets before the starred target. The\n final items of the sequence are assigned to the targets after the\n starred target. A list of the remaining items in the sequence is\n then assigned to the starred target (the list can be empty).\n\n * Else: The object must be a sequence with the same number of\n items as there are targets in the target list, and the items are\n assigned, from left to right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a "global" or "nonlocal" statement\n in the current code block: the name is bound to the object in the\n current local namespace.\n\n * Otherwise: the name is bound to the object in the global\n namespace or the outer namespace determined by "nonlocal",\n respectively.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in\n square brackets: The object must be an iterable with the same number\n of items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, "TypeError" is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily "AttributeError").\n\n Note: If the object is a class instance and the attribute reference\n occurs on both sides of the assignment operator, the RHS expression,\n "a.x" can access either an instance attribute or (if no instance\n attribute exists) a class attribute. The LHS target "a.x" is always\n set as an instance attribute, creating it if necessary. Thus, the\n two occurrences of "a.x" do not necessarily refer to the same\n attribute: if the RHS expression refers to a class attribute, the\n LHS creates a new instance attribute as the target of the\n assignment:\n\n class Cls:\n x = 3 # class variable\n inst = Cls()\n inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x as 3\n\n This description does not necessarily apply to descriptor\n attributes, such as properties created with "property()".\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield an integer. If it is negative, the sequence\'s\n length is added to it. The resulting value must be a nonnegative\n integer less than the sequence\'s length, and the sequence is asked\n to assign the assigned object to its item with that index. If the\n index is out of range, "IndexError" is raised (assignment to a\n subscripted sequence cannot add new items to a list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n For user-defined objects, the "__setitem__()" method is called with\n appropriate arguments.\n\n* If the target is a slicing: The primary expression in the\n reference is evaluated. It should yield a mutable sequence object\n (such as a list). The assigned object should be a sequence object\n of the same type. Next, the lower and upper bound expressions are\n evaluated, insofar they are present; defaults are zero and the\n sequence\'s length. The bounds should evaluate to integers. If\n either bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the target\n sequence allows it.\n\n**CPython implementation detail:** In the current implementation, the\nsyntax for targets is taken to be the same as for expressions, and\ninvalid syntax is rejected during the code generation phase, causing\nless detailed error messages.\n\nAlthough the definition of assignment implies that overlaps between\nthe left-hand side and the right-hand side are \'simultanenous\' (for\nexample "a, b = b, a" swaps two variables), overlaps *within* the\ncollection of assigned-to variables occur left-to-right, sometimes\nresulting in confusion. For instance, the following program prints\n"[0, 2]":\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2 # i is updated, then x[i] is updated\n print(x)\n\nSee also: **PEP 3132** - Extended Iterable Unpacking\n\n The specification for the "*target" feature.\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions of the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like "x += 1" can be rewritten as\n"x = x + 1" to achieve a similar, but not exactly equal effect. In the\naugmented version, "x" is only evaluated once. Also, when possible,\nthe actual operation is performed *in-place*, meaning that rather than\ncreating a new object and assigning that to the target, the old object\nis modified instead.\n\nUnlike normal assignments, augmented assignments evaluate the left-\nhand side *before* evaluating the right-hand side. For example, "a[i]\n+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs\nthe addition, and lastly, it writes the result back to "a[i]".\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n', 'atom-identifiers': u'\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a "NameError" exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name, with leading underscores removed and a single underscore\ninserted, in front of the name. For example, the identifier "__spam"\noccurring in a class named "Ham" will be transformed to "_Ham__spam".\nThis transformation is independent of the syntactical context in which\nthe identifier is used. If the transformed name is extremely long\n(longer than 255 characters), implementation defined truncation may\nhappen. If the class name consists only of underscores, no\ntransformation is done.\n', -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 01:47:27 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 21 Dec 2015 06:47:27 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogRml4ZXMgIzI1ODQ0?= =?utf-8?q?=3A_Corrected_=3D/=3D=3D_typo_potentially_leading_to_crash_in_l?= =?utf-8?q?auncher=2E?= Message-ID: <20151221064727.83225.13240@psf.io> https://hg.python.org/cpython/rev/48b3cac0dbcd changeset: 99645:48b3cac0dbcd branch: 3.4 parent: 99495:04a1f9fd0802 user: Vinay Sajip date: Sun Dec 13 09:41:29 2015 +0000 summary: Fixes #25844: Corrected =/== typo potentially leading to crash in launcher. files: PC/launcher.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -114,7 +114,7 @@ if (result >= BUFSIZE) { /* Large environment variable. Accept some leakage */ wchar_t *buf2 = (wchar_t*)malloc(sizeof(wchar_t) * (result+1)); - if (buf2 = NULL) { + if (buf2 == NULL) { error(RC_NO_MEMORY, L"Could not allocate environment buffer"); } GetEnvironmentVariableW(key, buf2, result); @@ -1219,7 +1219,7 @@ * is no version specification. */ debug(L"searching PATH for python executable\n"); - cmd = find_on_path(L"python"); + cmd = find_on_path(PYTHON_EXECUTABLE); debug(L"Python on path: %s\n", cmd ? cmd->value : L""); if (cmd) { debug(L"located python on PATH: %s\n", cmd->value); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 01:47:28 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 21 Dec 2015 06:47:28 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Post-release_t?= =?utf-8?q?ouchups_for_Python_3=2E4=2E4_final=2E?= Message-ID: <20151221064728.73366.45587@psf.io> https://hg.python.org/cpython/rev/69e46c228d4a changeset: 99649:69e46c228d4a branch: 3.4 user: Larry Hastings date: Sun Dec 20 22:42:47 2015 -0800 summary: Post-release touchups for Python 3.4.4 final. files: Include/patchlevel.h | 2 +- Misc/NEWS | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -23,7 +23,7 @@ #define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "3.4.4" +#define PY_VERSION "3.4.4+" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -2,6 +2,18 @@ Python News +++++++++++ +What's New in Python 3.4.5? +=========================== + +Release date: tba + +Core and Builtins +----------------- + +Library +------- + + What's New in Python 3.4.4? =========================== -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 01:47:27 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 21 Dec 2015 06:47:27 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Added_tag_v3?= =?utf-8?q?=2E4=2E4_for_changeset_737efcadf5a6?= Message-ID: <20151221064727.7706.92427@psf.io> https://hg.python.org/cpython/rev/39a314d76f2b changeset: 99648:39a314d76f2b branch: 3.4 user: Larry Hastings date: Sat Dec 19 19:31:20 2015 -0800 summary: Added tag v3.4.4 for changeset 737efcadf5a6 files: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -145,3 +145,4 @@ 69dd528ca6255a66c37cc5cf680e8357d108b036 v3.4.3rc1 b4cbecbc0781e89a309d03b60a1f75f8499250e6 v3.4.3 04f3f725896c6961212c3a12e8ac25be6958f4fa v3.4.4rc1 +737efcadf5a678b184e0fa431aae11276bf06648 v3.4.4 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 01:47:27 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 21 Dec 2015 06:47:27 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Release_bump_f?= =?utf-8?q?or_Python_3=2E4=2E4_final=2E?= Message-ID: <20151221064727.90152.86843@psf.io> https://hg.python.org/cpython/rev/737efcadf5a6 changeset: 99647:737efcadf5a6 branch: 3.4 tag: v3.4.4 user: Larry Hastings date: Sat Dec 19 19:31:10 2015 -0800 summary: Release bump for Python 3.4.4 final. files: Include/patchlevel.h | 6 +++--- Misc/NEWS | 7 +++---- README | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -19,11 +19,11 @@ #define PY_MAJOR_VERSION 3 #define PY_MINOR_VERSION 4 #define PY_MICRO_VERSION 4 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "3.4.4rc1+" +#define PY_VERSION "3.4.4" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -7,12 +7,11 @@ Release date: 2015/12/20 -Core and Builtins ------------------ - -Library +Windows ------- +- Issue #25844: Corrected =/== typo potentially leading to crash in launcher. + What's New in Python 3.4.4rc1? ============================== diff --git a/README b/README --- a/README +++ b/README @@ -1,4 +1,4 @@ -This is Python version 3.4.3 +This is Python version 3.4.4 ============================ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 01:47:28 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 21 Dec 2015 06:47:28 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNCk6?= =?utf-8?q?_Merge=2E?= Message-ID: <20151221064728.19130.83143@psf.io> https://hg.python.org/cpython/rev/73ad9db1dce6 changeset: 99650:73ad9db1dce6 branch: 3.4 parent: 99627:42963dd81600 parent: 99649:69e46c228d4a user: Larry Hastings date: Sun Dec 20 22:44:06 2015 -0800 summary: Merge. files: .hgtags | 1 + Include/patchlevel.h | 6 +++--- Lib/pydoc_data/topics.py | 2 +- Misc/NEWS | 19 +++++++++++++++---- README | 2 +- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -145,3 +145,4 @@ 69dd528ca6255a66c37cc5cf680e8357d108b036 v3.4.3rc1 b4cbecbc0781e89a309d03b60a1f75f8499250e6 v3.4.3 04f3f725896c6961212c3a12e8ac25be6958f4fa v3.4.4rc1 +737efcadf5a678b184e0fa431aae11276bf06648 v3.4.4 diff --git a/Include/patchlevel.h b/Include/patchlevel.h --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -19,11 +19,11 @@ #define PY_MAJOR_VERSION 3 #define PY_MINOR_VERSION 4 #define PY_MICRO_VERSION 4 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "3.4.4rc1+" +#define PY_VERSION "3.4.4+" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py --- a/Lib/pydoc_data/topics.py +++ b/Lib/pydoc_data/topics.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Autogenerated by Sphinx on Sun Dec 6 05:51:21 2015 +# Autogenerated by Sphinx on Sat Dec 19 19:27:32 2015 topics = {'assert': u'\nThe "assert" statement\n**********************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, "assert expression", is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, "assert expression1, expression2", is equivalent to\n\n if __debug__:\n if not expression1: raise AssertionError(expression2)\n\nThese equivalences assume that "__debug__" and "AssertionError" refer\nto the built-in variables with those names. In the current\nimplementation, the built-in variable "__debug__" is "True" under\nnormal circumstances, "False" when optimization is requested (command\nline option -O). The current code generator emits no code for an\nassert statement when optimization is requested at compile time. Note\nthat it is unnecessary to include the source code for the expression\nthat failed in the error message; it will be displayed as part of the\nstack trace.\n\nAssignments to "__debug__" are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n', 'assignment': u'\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n | "*" target\n\n(See section *Primaries* for the syntax definitions for\n*attributeref*, *subscription*, and *slicing*.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list, optionally enclosed in\nparentheses or square brackets, is recursively defined as follows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The\n object must be an iterable with the same number of items as there\n are targets in the target list, and the items are assigned, from\n left to right, to the corresponding targets.\n\n * If the target list contains one target prefixed with an\n asterisk, called a "starred" target: The object must be a sequence\n with at least as many items as there are targets in the target\n list, minus one. The first items of the sequence are assigned,\n from left to right, to the targets before the starred target. The\n final items of the sequence are assigned to the targets after the\n starred target. A list of the remaining items in the sequence is\n then assigned to the starred target (the list can be empty).\n\n * Else: The object must be a sequence with the same number of\n items as there are targets in the target list, and the items are\n assigned, from left to right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a "global" or "nonlocal" statement\n in the current code block: the name is bound to the object in the\n current local namespace.\n\n * Otherwise: the name is bound to the object in the global\n namespace or the outer namespace determined by "nonlocal",\n respectively.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in\n square brackets: The object must be an iterable with the same number\n of items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, "TypeError" is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily "AttributeError").\n\n Note: If the object is a class instance and the attribute reference\n occurs on both sides of the assignment operator, the RHS expression,\n "a.x" can access either an instance attribute or (if no instance\n attribute exists) a class attribute. The LHS target "a.x" is always\n set as an instance attribute, creating it if necessary. Thus, the\n two occurrences of "a.x" do not necessarily refer to the same\n attribute: if the RHS expression refers to a class attribute, the\n LHS creates a new instance attribute as the target of the\n assignment:\n\n class Cls:\n x = 3 # class variable\n inst = Cls()\n inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x as 3\n\n This description does not necessarily apply to descriptor\n attributes, such as properties created with "property()".\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield an integer. If it is negative, the sequence\'s\n length is added to it. The resulting value must be a nonnegative\n integer less than the sequence\'s length, and the sequence is asked\n to assign the assigned object to its item with that index. If the\n index is out of range, "IndexError" is raised (assignment to a\n subscripted sequence cannot add new items to a list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n For user-defined objects, the "__setitem__()" method is called with\n appropriate arguments.\n\n* If the target is a slicing: The primary expression in the\n reference is evaluated. It should yield a mutable sequence object\n (such as a list). The assigned object should be a sequence object\n of the same type. Next, the lower and upper bound expressions are\n evaluated, insofar they are present; defaults are zero and the\n sequence\'s length. The bounds should evaluate to integers. If\n either bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the target\n sequence allows it.\n\n**CPython implementation detail:** In the current implementation, the\nsyntax for targets is taken to be the same as for expressions, and\ninvalid syntax is rejected during the code generation phase, causing\nless detailed error messages.\n\nAlthough the definition of assignment implies that overlaps between\nthe left-hand side and the right-hand side are \'simultanenous\' (for\nexample "a, b = b, a" swaps two variables), overlaps *within* the\ncollection of assigned-to variables occur left-to-right, sometimes\nresulting in confusion. For instance, the following program prints\n"[0, 2]":\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2 # i is updated, then x[i] is updated\n print(x)\n\nSee also: **PEP 3132** - Extended Iterable Unpacking\n\n The specification for the "*target" feature.\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions of the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like "x += 1" can be rewritten as\n"x = x + 1" to achieve a similar, but not exactly equal effect. In the\naugmented version, "x" is only evaluated once. Also, when possible,\nthe actual operation is performed *in-place*, meaning that rather than\ncreating a new object and assigning that to the target, the old object\nis modified instead.\n\nUnlike normal assignments, augmented assignments evaluate the left-\nhand side *before* evaluating the right-hand side. For example, "a[i]\n+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs\nthe addition, and lastly, it writes the result back to "a[i]".\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n', 'atom-identifiers': u'\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a "NameError" exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name, with leading underscores removed and a single underscore\ninserted, in front of the name. For example, the identifier "__spam"\noccurring in a class named "Ham" will be transformed to "_Ham__spam".\nThis transformation is independent of the syntactical context in which\nthe identifier is used. If the transformed name is extremely long\n(longer than 255 characters), implementation defined truncation may\nhappen. If the class name consists only of underscores, no\ntransformation is done.\n', diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -2,17 +2,28 @@ Python News +++++++++++ +What's New in Python 3.4.5? +=========================== + +Release date: tba + +Core and Builtins +----------------- + +Library +------- + + What's New in Python 3.4.4? =========================== Release date: 2015/12/20 -Core and Builtins ------------------ - -Library +Windows ------- +- Issue #25844: Corrected =/== typo potentially leading to crash in launcher. + What's New in Python 3.4.4rc1? ============================== diff --git a/README b/README --- a/README +++ b/README @@ -1,4 +1,4 @@ -This is Python version 3.4.3 +This is Python version 3.4.4 ============================ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 01:47:28 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 21 Dec 2015 06:47:28 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Merge_3=2E4=2E4_from_3=2E4_to_3=2E5=2E?= Message-ID: <20151221064728.16760.22611@psf.io> https://hg.python.org/cpython/rev/74d1f24de99e changeset: 99651:74d1f24de99e branch: 3.5 parent: 99643:1e54adef4064 parent: 99650:73ad9db1dce6 user: Larry Hastings date: Sun Dec 20 22:46:30 2015 -0800 summary: Merge 3.4.4 from 3.4 to 3.5. files: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -145,6 +145,7 @@ 69dd528ca6255a66c37cc5cf680e8357d108b036 v3.4.3rc1 b4cbecbc0781e89a309d03b60a1f75f8499250e6 v3.4.3 04f3f725896c6961212c3a12e8ac25be6958f4fa v3.4.4rc1 +737efcadf5a678b184e0fa431aae11276bf06648 v3.4.4 5d4b6a57d5fd7564bf73f3db0e46fe5eeb00bcd8 v3.5.0a1 0337bd7ebcb6559d69679bc7025059ad1ce4f432 v3.5.0a2 82656e28b5e5c4ae48d8dd8b5f0d7968908a82b6 v3.5.0a3 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 01:47:28 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 21 Dec 2015 06:47:28 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_from_3=2E5_to_default=2E?= Message-ID: <20151221064728.2924.41561@psf.io> https://hg.python.org/cpython/rev/e1418fc70e82 changeset: 99652:e1418fc70e82 parent: 99644:af0b95fb1c19 parent: 99651:74d1f24de99e user: Larry Hastings date: Sun Dec 20 22:47:04 2015 -0800 summary: Merge from 3.5 to default. files: .hgtags | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -145,6 +145,7 @@ 69dd528ca6255a66c37cc5cf680e8357d108b036 v3.4.3rc1 b4cbecbc0781e89a309d03b60a1f75f8499250e6 v3.4.3 04f3f725896c6961212c3a12e8ac25be6958f4fa v3.4.4rc1 +737efcadf5a678b184e0fa431aae11276bf06648 v3.4.4 5d4b6a57d5fd7564bf73f3db0e46fe5eeb00bcd8 v3.5.0a1 0337bd7ebcb6559d69679bc7025059ad1ce4f432 v3.5.0a2 82656e28b5e5c4ae48d8dd8b5f0d7968908a82b6 v3.5.0a3 -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 01:48:25 2015 From: python-checkins at python.org (larry.hastings) Date: Mon, 21 Dec 2015 06:48:25 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Update_3=2E4_release_schedule?= =?utf-8?q?_to_note_the_release_of_3=2E4=2E4=2E?= Message-ID: <20151221064825.32107.51234@psf.io> https://hg.python.org/peps/rev/0c55bcc4eb0f changeset: 6142:0c55bcc4eb0f user: Larry Hastings date: Sun Dec 20 22:48:22 2015 -0800 summary: Update 3.4 release schedule to note the release of 3.4.4. files: pep-0429.txt | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pep-0429.txt b/pep-0429.txt --- a/pep-0429.txt +++ b/pep-0429.txt @@ -72,11 +72,11 @@ ------------------------ - 3.4.4 candidate 1: December 6, 2015 - +- 3.4.4 final: December 20, 2015 Planned future releases: -- 3.4.4 final: December 20, 2015 +- tba Features for 3.4 -- Repository URL: https://hg.python.org/peps From solipsis at pitrou.net Mon Dec 21 03:42:23 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 21 Dec 2015 08:42:23 +0000 Subject: [Python-checkins] Daily reference leaks (af0b95fb1c19): sum=2 Message-ID: <20151221084223.6435.85912@psf.io> results for af0b95fb1c19 on branch "default" -------------------------------------------- test_collections leaked [-2, 0, 0] references, sum=-2 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogauQVQL', '--timeout', '7200'] From python-checkins at python.org Mon Dec 21 04:13:31 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Dec 2015 09:13:31 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1OTAy?= =?utf-8?q?=3A_Fixed_various_refcount_issues_in_ElementTree_iteration=2E?= Message-ID: <20151221091331.7686.48743@psf.io> https://hg.python.org/cpython/rev/00b6a13cfd70 changeset: 99653:00b6a13cfd70 branch: 3.5 parent: 99651:74d1f24de99e user: Serhiy Storchaka date: Mon Dec 21 11:09:48 2015 +0200 summary: Issue #25902: Fixed various refcount issues in ElementTree iteration. files: Lib/test/test_xml_etree.py | 51 +++++++++++++ Lib/xml/etree/ElementTree.py | 10 +- Misc/NEWS | 2 + Modules/_elementtree.c | 90 +++++++++++++++-------- 4 files changed, 117 insertions(+), 36 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1666,6 +1666,57 @@ ET.register_namespace('test10777', 'http://myuri/') ET.register_namespace('test10777', 'http://myuri/') + def test_lost_text(self): + # Issue #25902: Borrowed text can disappear + class Text: + def __bool__(self): + e.text = 'changed' + return True + + e = ET.Element('tag') + e.text = Text() + i = e.itertext() + t = next(i) + self.assertIsInstance(t, Text) + self.assertIsInstance(e.text, str) + self.assertEqual(e.text, 'changed') + + def test_lost_tail(self): + # Issue #25902: Borrowed tail can disappear + class Text: + def __bool__(self): + e[0].tail = 'changed' + return True + + e = ET.Element('root') + e.append(ET.Element('tag')) + e[0].tail = Text() + i = e.itertext() + t = next(i) + self.assertIsInstance(t, Text) + self.assertIsInstance(e[0].tail, str) + self.assertEqual(e[0].tail, 'changed') + + def test_lost_elem(self): + # Issue #25902: Borrowed element can disappear + class Tag: + def __eq__(self, other): + e[0] = ET.Element('changed') + next(i) + return True + + e = ET.Element('root') + e.append(ET.Element(Tag())) + e.append(ET.Element('tag')) + i = e.iter('tag') + try: + t = next(i) + except ValueError: + self.skipTest('generators are not reentrant') + self.assertIsInstance(t.tag, Tag) + self.assertIsInstance(e[0].tag, str) + self.assertEqual(e[0].tag, 'changed') + # -------------------------------------------------------------------- diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -428,12 +428,14 @@ tag = self.tag if not isinstance(tag, str) and tag is not None: return - if self.text: - yield self.text + t = self.text + if t: + yield t for e in self: yield from e.itertext() - if e.tail: - yield e.tail + t = e.tail + if t: + yield t def SubElement(parent, tag, attrib={}, **extra): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -28,6 +28,8 @@ Library ------- +- Issue #25902: Fixed various refcount issues in ElementTree iteration. + - Issue #25717: Restore the previous behaviour of tolerating most fstat() errors when opening files. This was a regression in 3.5a1, and stopped anonymous temporary files from working in special cases. diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2072,6 +2072,7 @@ ElementObject *cur_parent; Py_ssize_t child_index; int rc; + ElementObject *elem; while (1) { /* Handle the case reached in the beginning and end of iteration, where @@ -2085,38 +2086,47 @@ PyErr_SetNone(PyExc_StopIteration); return NULL; } else { + elem = it->root_element; it->parent_stack = parent_stack_push_new(it->parent_stack, - it->root_element); + elem); if (!it->parent_stack) { PyErr_NoMemory(); return NULL; } + Py_INCREF(elem); it->root_done = 1; rc = (it->sought_tag == Py_None); if (!rc) { - rc = PyObject_RichCompareBool(it->root_element->tag, + rc = PyObject_RichCompareBool(elem->tag, it->sought_tag, Py_EQ); - if (rc < 0) + if (rc < 0) { + Py_DECREF(elem); return NULL; + } } if (rc) { if (it->gettext) { - PyObject *text = element_get_text(it->root_element); - if (!text) + PyObject *text = element_get_text(elem); + if (!text) { + Py_DECREF(elem); return NULL; + } + Py_INCREF(text); + Py_DECREF(elem); rc = PyObject_IsTrue(text); + if (rc > 0) + return text; + Py_DECREF(text); if (rc < 0) return NULL; - if (rc) { - Py_INCREF(text); - return text; - } } else { - Py_INCREF(it->root_element); - return (PyObject *)it->root_element; + return (PyObject *)elem; } } + else { + Py_DECREF(elem); + } } } @@ -2126,54 +2136,68 @@ cur_parent = it->parent_stack->parent; child_index = it->parent_stack->child_index; if (cur_parent->extra && child_index < cur_parent->extra->length) { - ElementObject *child = (ElementObject *) - cur_parent->extra->children[child_index]; + elem = (ElementObject *)cur_parent->extra->children[child_index]; it->parent_stack->child_index++; it->parent_stack = parent_stack_push_new(it->parent_stack, - child); + elem); if (!it->parent_stack) { PyErr_NoMemory(); return NULL; } + Py_INCREF(elem); if (it->gettext) { - PyObject *text = element_get_text(child); - if (!text) + PyObject *text = element_get_text(elem); + if (!text) { + Py_DECREF(elem); return NULL; + } + Py_INCREF(text); + Py_DECREF(elem); rc = PyObject_IsTrue(text); + if (rc > 0) + return text; + Py_DECREF(text); if (rc < 0) return NULL; - if (rc) { - Py_INCREF(text); - return text; - } } else { rc = (it->sought_tag == Py_None); if (!rc) { - rc = PyObject_RichCompareBool(child->tag, + rc = PyObject_RichCompareBool(elem->tag, it->sought_tag, Py_EQ); - if (rc < 0) + if (rc < 0) { + Py_DECREF(elem); return NULL; + } } if (rc) { - Py_INCREF(child); - return (PyObject *)child; + return (PyObject *)elem; } + Py_DECREF(elem); } } else { PyObject *tail; - ParentLocator *next = it->parent_stack->next; + ParentLocator *next; if (it->gettext) { + Py_INCREF(cur_parent); tail = element_get_tail(cur_parent); - if (!tail) + if (!tail) { + Py_DECREF(cur_parent); return NULL; + } + Py_INCREF(tail); + Py_DECREF(cur_parent); } - else + else { tail = Py_None; - Py_XDECREF(it->parent_stack->parent); + Py_INCREF(tail); + } + next = it->parent_stack->next; + cur_parent = it->parent_stack->parent; PyObject_Free(it->parent_stack); it->parent_stack = next; + Py_XDECREF(cur_parent); /* Note that extra condition on it->parent_stack->parent here; * this is because itertext() is supposed to only return *inner* @@ -2181,12 +2205,14 @@ */ if (it->parent_stack->parent) { rc = PyObject_IsTrue(tail); + if (rc > 0) + return tail; + Py_DECREF(tail); if (rc < 0) return NULL; - if (rc) { - Py_INCREF(tail); - return tail; - } + } + else { + Py_DECREF(tail); } } } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 04:13:37 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Dec 2015 09:13:37 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325902=3A_Fixed_various_refcount_issues_in_Eleme?= =?utf-8?q?ntTree_iteration=2E?= Message-ID: <20151221091337.19130.57011@psf.io> https://hg.python.org/cpython/rev/e09cb2af3092 changeset: 99654:e09cb2af3092 parent: 99652:e1418fc70e82 parent: 99653:00b6a13cfd70 user: Serhiy Storchaka date: Mon Dec 21 11:11:12 2015 +0200 summary: Issue #25902: Fixed various refcount issues in ElementTree iteration. files: Lib/test/test_xml_etree.py | 51 +++++++++++++ Lib/xml/etree/ElementTree.py | 10 +- Misc/NEWS | 2 + Modules/_elementtree.c | 90 +++++++++++++++-------- 4 files changed, 117 insertions(+), 36 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1668,6 +1668,57 @@ ET.register_namespace('test10777', 'http://myuri/') ET.register_namespace('test10777', 'http://myuri/') + def test_lost_text(self): + # Issue #25902: Borrowed text can disappear + class Text: + def __bool__(self): + e.text = 'changed' + return True + + e = ET.Element('tag') + e.text = Text() + i = e.itertext() + t = next(i) + self.assertIsInstance(t, Text) + self.assertIsInstance(e.text, str) + self.assertEqual(e.text, 'changed') + + def test_lost_tail(self): + # Issue #25902: Borrowed tail can disappear + class Text: + def __bool__(self): + e[0].tail = 'changed' + return True + + e = ET.Element('root') + e.append(ET.Element('tag')) + e[0].tail = Text() + i = e.itertext() + t = next(i) + self.assertIsInstance(t, Text) + self.assertIsInstance(e[0].tail, str) + self.assertEqual(e[0].tail, 'changed') + + def test_lost_elem(self): + # Issue #25902: Borrowed element can disappear + class Tag: + def __eq__(self, other): + e[0] = ET.Element('changed') + next(i) + return True + + e = ET.Element('root') + e.append(ET.Element(Tag())) + e.append(ET.Element('tag')) + i = e.iter('tag') + try: + t = next(i) + except ValueError: + self.skipTest('generators are not reentrant') + self.assertIsInstance(t.tag, Tag) + self.assertIsInstance(e[0].tag, str) + self.assertEqual(e[0].tag, 'changed') + # -------------------------------------------------------------------- diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -429,12 +429,14 @@ tag = self.tag if not isinstance(tag, str) and tag is not None: return - if self.text: - yield self.text + t = self.text + if t: + yield t for e in self: yield from e.itertext() - if e.tail: - yield e.tail + t = e.tail + if t: + yield t def SubElement(parent, tag, attrib={}, **extra): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -115,6 +115,8 @@ Library ------- +- Issue #25902: Fixed various refcount issues in ElementTree iteration. + - Issue #22227: The TarFile iterator is reimplemented using generator. This implementation is simpler that using class. diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2070,6 +2070,7 @@ ElementObject *cur_parent; Py_ssize_t child_index; int rc; + ElementObject *elem; while (1) { /* Handle the case reached in the beginning and end of iteration, where @@ -2083,38 +2084,47 @@ PyErr_SetNone(PyExc_StopIteration); return NULL; } else { + elem = it->root_element; it->parent_stack = parent_stack_push_new(it->parent_stack, - it->root_element); + elem); if (!it->parent_stack) { PyErr_NoMemory(); return NULL; } + Py_INCREF(elem); it->root_done = 1; rc = (it->sought_tag == Py_None); if (!rc) { - rc = PyObject_RichCompareBool(it->root_element->tag, + rc = PyObject_RichCompareBool(elem->tag, it->sought_tag, Py_EQ); - if (rc < 0) + if (rc < 0) { + Py_DECREF(elem); return NULL; + } } if (rc) { if (it->gettext) { - PyObject *text = element_get_text(it->root_element); - if (!text) + PyObject *text = element_get_text(elem); + if (!text) { + Py_DECREF(elem); return NULL; + } + Py_INCREF(text); + Py_DECREF(elem); rc = PyObject_IsTrue(text); + if (rc > 0) + return text; + Py_DECREF(text); if (rc < 0) return NULL; - if (rc) { - Py_INCREF(text); - return text; - } } else { - Py_INCREF(it->root_element); - return (PyObject *)it->root_element; + return (PyObject *)elem; } } + else { + Py_DECREF(elem); + } } } @@ -2124,54 +2134,68 @@ cur_parent = it->parent_stack->parent; child_index = it->parent_stack->child_index; if (cur_parent->extra && child_index < cur_parent->extra->length) { - ElementObject *child = (ElementObject *) - cur_parent->extra->children[child_index]; + elem = (ElementObject *)cur_parent->extra->children[child_index]; it->parent_stack->child_index++; it->parent_stack = parent_stack_push_new(it->parent_stack, - child); + elem); if (!it->parent_stack) { PyErr_NoMemory(); return NULL; } + Py_INCREF(elem); if (it->gettext) { - PyObject *text = element_get_text(child); - if (!text) + PyObject *text = element_get_text(elem); + if (!text) { + Py_DECREF(elem); return NULL; + } + Py_INCREF(text); + Py_DECREF(elem); rc = PyObject_IsTrue(text); + if (rc > 0) + return text; + Py_DECREF(text); if (rc < 0) return NULL; - if (rc) { - Py_INCREF(text); - return text; - } } else { rc = (it->sought_tag == Py_None); if (!rc) { - rc = PyObject_RichCompareBool(child->tag, + rc = PyObject_RichCompareBool(elem->tag, it->sought_tag, Py_EQ); - if (rc < 0) + if (rc < 0) { + Py_DECREF(elem); return NULL; + } } if (rc) { - Py_INCREF(child); - return (PyObject *)child; + return (PyObject *)elem; } + Py_DECREF(elem); } } else { PyObject *tail; - ParentLocator *next = it->parent_stack->next; + ParentLocator *next; if (it->gettext) { + Py_INCREF(cur_parent); tail = element_get_tail(cur_parent); - if (!tail) + if (!tail) { + Py_DECREF(cur_parent); return NULL; + } + Py_INCREF(tail); + Py_DECREF(cur_parent); } - else + else { tail = Py_None; - Py_XDECREF(it->parent_stack->parent); + Py_INCREF(tail); + } + next = it->parent_stack->next; + cur_parent = it->parent_stack->parent; PyObject_Free(it->parent_stack); it->parent_stack = next; + Py_XDECREF(cur_parent); /* Note that extra condition on it->parent_stack->parent here; * this is because itertext() is supposed to only return *inner* @@ -2179,12 +2203,14 @@ */ if (it->parent_stack->parent) { rc = PyObject_IsTrue(tail); + if (rc > 0) + return tail; + Py_DECREF(tail); if (rc < 0) return NULL; - if (rc) { - Py_INCREF(tail); - return tail; - } + } + else { + Py_DECREF(tail); } } } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 05:44:24 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Dec 2015 10:44:24 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325873=3A_Optimize?= =?utf-8?q?d_iterating_ElementTree=2E?= Message-ID: <20151221104424.16758.64419@psf.io> https://hg.python.org/cpython/rev/5a5d5268afd5 changeset: 99655:5a5d5268afd5 user: Serhiy Storchaka date: Mon Dec 21 12:43:54 2015 +0200 summary: Issue #25873: Optimized iterating ElementTree. Iterating elements Element.iter() is now 40% faster, iterating text Element.itertext() is now up to 2.5 times faster. files: Misc/NEWS | 4 + Modules/_elementtree.c | 261 +++++++++++----------------- 2 files changed, 106 insertions(+), 159 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -115,6 +115,10 @@ Library ------- +- Issue #25873: Optimized iterating ElementTree. Iterating elements + Element.iter() is now 40% faster, iterating text Element.itertext() + is now up to 2.5 times faster. + - Issue #25902: Fixed various refcount issues in ElementTree iteration. - Issue #22227: The TarFile iterator is reimplemented using generator. diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1986,22 +1986,22 @@ * pre-order traversal. To keep track of which sub-element should be returned * next, a stack of parents is maintained. This is a standard stack-based * iterative pre-order traversal of a tree. - * The stack is managed using a single-linked list starting at parent_stack. - * Each stack node contains the saved parent to which we should return after + * The stack is managed using a continuous array. + * Each stack item contains the saved parent to which we should return after * the current one is exhausted, and the next child to examine in that parent. */ typedef struct ParentLocator_t { ElementObject *parent; Py_ssize_t child_index; - struct ParentLocator_t *next; } ParentLocator; typedef struct { PyObject_HEAD ParentLocator *parent_stack; + Py_ssize_t parent_stack_used; + Py_ssize_t parent_stack_size; ElementObject *root_element; PyObject *sought_tag; - int root_done; int gettext; } ElementIterObject; @@ -2009,13 +2009,11 @@ static void elementiter_dealloc(ElementIterObject *it) { - ParentLocator *p = it->parent_stack; - while (p) { - ParentLocator *temp = p; - Py_XDECREF(p->parent); - p = p->next; - PyObject_Free(temp); - } + Py_ssize_t i = it->parent_stack_used; + it->parent_stack_used = 0; + while (i--) + Py_XDECREF(it->parent_stack[i].parent); + PyMem_Free(it->parent_stack); Py_XDECREF(it->sought_tag); Py_XDECREF(it->root_element); @@ -2027,11 +2025,9 @@ static int elementiter_traverse(ElementIterObject *it, visitproc visit, void *arg) { - ParentLocator *p = it->parent_stack; - while (p) { - Py_VISIT(p->parent); - p = p->next; - } + Py_ssize_t i = it->parent_stack_used; + while (i--) + Py_VISIT(it->parent_stack[i].parent); Py_VISIT(it->root_element); Py_VISIT(it->sought_tag); @@ -2040,17 +2036,25 @@ /* Helper function for elementiter_next. Add a new parent to the parent stack. */ -static ParentLocator * -parent_stack_push_new(ParentLocator *stack, ElementObject *parent) +static int +parent_stack_push_new(ElementIterObject *it, ElementObject *parent) { - ParentLocator *new_node = PyObject_Malloc(sizeof(ParentLocator)); - if (new_node) { - new_node->parent = parent; - Py_INCREF(parent); - new_node->child_index = 0; - new_node->next = stack; + ParentLocator *item; + + if (it->parent_stack_used >= it->parent_stack_size) { + Py_ssize_t new_size = it->parent_stack_size * 2; /* never overflow */ + ParentLocator *parent_stack = it->parent_stack; + PyMem_Resize(parent_stack, ParentLocator, new_size); + if (parent_stack == NULL) + return -1; + it->parent_stack = parent_stack; + it->parent_stack_size = new_size; } - return new_node; + item = it->parent_stack + it->parent_stack_used++; + Py_INCREF(parent); + item->parent = parent; + item->child_index = 0; + return 0; } static PyObject * @@ -2067,151 +2071,91 @@ * - itertext() also has to handle tail, after finishing with all the * children of a node. */ - ElementObject *cur_parent; - Py_ssize_t child_index; int rc; ElementObject *elem; + PyObject *text; while (1) { /* Handle the case reached in the beginning and end of iteration, where - * the parent stack is empty. The root_done flag gives us indication - * whether we've just started iterating (so root_done is 0), in which - * case the root is returned. If root_done is 1 and we're here, the + * the parent stack is empty. If root_element is NULL and we're here, the * iterator is exhausted. */ - if (!it->parent_stack->parent) { - if (it->root_done) { + if (!it->parent_stack_used) { + if (!it->root_element) { PyErr_SetNone(PyExc_StopIteration); return NULL; - } else { - elem = it->root_element; - it->parent_stack = parent_stack_push_new(it->parent_stack, - elem); - if (!it->parent_stack) { - PyErr_NoMemory(); - return NULL; - } - - Py_INCREF(elem); - it->root_done = 1; - rc = (it->sought_tag == Py_None); - if (!rc) { - rc = PyObject_RichCompareBool(elem->tag, - it->sought_tag, Py_EQ); - if (rc < 0) { - Py_DECREF(elem); - return NULL; - } - } - if (rc) { - if (it->gettext) { - PyObject *text = element_get_text(elem); - if (!text) { - Py_DECREF(elem); - return NULL; - } - Py_INCREF(text); - Py_DECREF(elem); - rc = PyObject_IsTrue(text); - if (rc > 0) - return text; - Py_DECREF(text); - if (rc < 0) - return NULL; - } else { - return (PyObject *)elem; - } - } - else { - Py_DECREF(elem); - } } + + elem = it->root_element; /* steals a reference */ + it->root_element = NULL; } - - /* See if there are children left to traverse in the current parent. If - * yes, visit the next child. If not, pop the stack and try again. - */ - cur_parent = it->parent_stack->parent; - child_index = it->parent_stack->child_index; - if (cur_parent->extra && child_index < cur_parent->extra->length) { - elem = (ElementObject *)cur_parent->extra->children[child_index]; - it->parent_stack->child_index++; - it->parent_stack = parent_stack_push_new(it->parent_stack, - elem); - if (!it->parent_stack) { - PyErr_NoMemory(); - return NULL; - } - - Py_INCREF(elem); - if (it->gettext) { - PyObject *text = element_get_text(elem); - if (!text) { - Py_DECREF(elem); - return NULL; - } - Py_INCREF(text); - Py_DECREF(elem); - rc = PyObject_IsTrue(text); - if (rc > 0) - return text; - Py_DECREF(text); - if (rc < 0) - return NULL; - } else { - rc = (it->sought_tag == Py_None); - if (!rc) { - rc = PyObject_RichCompareBool(elem->tag, - it->sought_tag, Py_EQ); - if (rc < 0) { - Py_DECREF(elem); - return NULL; - } - } - if (rc) { - return (PyObject *)elem; + else { + /* See if there are children left to traverse in the current parent. If + * yes, visit the next child. If not, pop the stack and try again. + */ + ParentLocator *item = &it->parent_stack[it->parent_stack_used - 1]; + Py_ssize_t child_index = item->child_index; + ElementObjectExtra *extra; + elem = item->parent; + extra = elem->extra; + if (!extra || child_index >= extra->length) { + it->parent_stack_used--; + /* Note that extra condition on it->parent_stack_used here; + * this is because itertext() is supposed to only return *inner* + * text, not text following the element it began iteration with. + */ + if (it->gettext && it->parent_stack_used) { + text = element_get_tail(elem); + goto gettext; } Py_DECREF(elem); + continue; } + + elem = (ElementObject *)extra->children[child_index]; + item->child_index++; + Py_INCREF(elem); + } + + if (parent_stack_push_new(it, elem) < 0) { + Py_DECREF(elem); + PyErr_NoMemory(); + return NULL; + } + if (it->gettext) { + text = element_get_text(elem); + goto gettext; + } + + if (it->sought_tag == Py_None) + return (PyObject *)elem; + + rc = PyObject_RichCompareBool(elem->tag, it->sought_tag, Py_EQ); + if (rc > 0) + return (PyObject *)elem; + + Py_DECREF(elem); + if (rc < 0) + return NULL; + continue; + +gettext: + if (!text) { + Py_DECREF(elem); + return NULL; + } + if (text == Py_None) { + Py_DECREF(elem); } else { - PyObject *tail; - ParentLocator *next; - if (it->gettext) { - Py_INCREF(cur_parent); - tail = element_get_tail(cur_parent); - if (!tail) { - Py_DECREF(cur_parent); - return NULL; - } - Py_INCREF(tail); - Py_DECREF(cur_parent); - } - else { - tail = Py_None; - Py_INCREF(tail); - } - next = it->parent_stack->next; - cur_parent = it->parent_stack->parent; - PyObject_Free(it->parent_stack); - it->parent_stack = next; - Py_XDECREF(cur_parent); - - /* Note that extra condition on it->parent_stack->parent here; - * this is because itertext() is supposed to only return *inner* - * text, not text following the element it began iteration with. - */ - if (it->parent_stack->parent) { - rc = PyObject_IsTrue(tail); - if (rc > 0) - return tail; - Py_DECREF(tail); - if (rc < 0) - return NULL; - } - else { - Py_DECREF(tail); - } + Py_INCREF(text); + Py_DECREF(elem); + rc = PyObject_IsTrue(text); + if (rc > 0) + return text; + Py_DECREF(text); + if (rc < 0) + return NULL; } } @@ -2263,6 +2207,7 @@ 0, /* tp_new */ }; +#define INIT_PARENT_STACK_SIZE 8 static PyObject * create_elementiter(ElementObject *self, PyObject *tag, int gettext) @@ -2275,22 +2220,20 @@ Py_INCREF(tag); it->sought_tag = tag; - it->root_done = 0; it->gettext = gettext; Py_INCREF(self); it->root_element = self; PyObject_GC_Track(it); - it->parent_stack = PyObject_Malloc(sizeof(ParentLocator)); + it->parent_stack = PyMem_New(ParentLocator, INIT_PARENT_STACK_SIZE); if (it->parent_stack == NULL) { Py_DECREF(it); PyErr_NoMemory(); return NULL; } - it->parent_stack->parent = NULL; - it->parent_stack->child_index = 0; - it->parent_stack->next = NULL; + it->parent_stack_used = 0; + it->parent_stack_size = INIT_PARENT_STACK_SIZE; return (PyObject *)it; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 05:57:53 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 21 Dec 2015 10:57:53 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325869=3A_Optimize?= =?utf-8?q?d_deepcopying_ElementTree=3B_it_is_now_20_times_faster=2E?= Message-ID: <20151221105753.2906.13585@psf.io> https://hg.python.org/cpython/rev/090c3e3a648d changeset: 99656:090c3e3a648d user: Serhiy Storchaka date: Mon Dec 21 12:57:27 2015 +0200 summary: Issue #25869: Optimized deepcopying ElementTree; it is now 20 times faster. files: Misc/NEWS | 2 + Modules/_elementtree.c | 78 ++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 24 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -115,6 +115,8 @@ Library ------- +- Issue #25869: Optimized deepcopying ElementTree; it is now 20 times faster. + - Issue #25873: Optimized iterating ElementTree. Iterating elements Element.iter() is now 40% faster, iterating text Element.itertext() is now up to 2.5 times faster. diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -129,30 +129,6 @@ /* helpers */ LOCAL(PyObject*) -deepcopy(PyObject* object, PyObject* memo) -{ - /* do a deep copy of the given object */ - PyObject* args; - PyObject* result; - elementtreestate *st = ET_STATE_GLOBAL; - - if (!st->deepcopy_obj) { - PyErr_SetString( - PyExc_RuntimeError, - "deepcopy helper not found" - ); - return NULL; - } - - args = PyTuple_Pack(2, object, memo); - if (!args) - return NULL; - result = PyObject_CallObject(st->deepcopy_obj, args); - Py_DECREF(args); - return result; -} - -LOCAL(PyObject*) list_join(PyObject* list) { /* join list elements (destroying the list in the process) */ @@ -748,6 +724,9 @@ return (PyObject*) element; } +/* Helper for a deep copy. */ +LOCAL(PyObject *) deepcopy(PyObject *, PyObject *); + /*[clinic input] _elementtree.Element.__deepcopy__ @@ -838,6 +817,57 @@ return NULL; } +LOCAL(PyObject *) +deepcopy(PyObject *object, PyObject *memo) +{ + /* do a deep copy of the given object */ + PyObject *args; + PyObject *result; + elementtreestate *st; + + /* Fast paths */ + if (object == Py_None || PyUnicode_CheckExact(object)) { + Py_INCREF(object); + return object; + } + + if (Py_REFCNT(object) == 1) { + if (PyDict_CheckExact(object)) { + PyObject *key, *value; + Py_ssize_t pos = 0; + int simple = 1; + while (PyDict_Next(object, &pos, &key, &value)) { + if (!PyUnicode_CheckExact(key) || !PyUnicode_CheckExact(value)) { + simple = 0; + break; + } + } + if (simple) + return PyDict_Copy(object); + /* Fall through to general case */ + } + else if (Element_CheckExact(object)) { + return _elementtree_Element___deepcopy__((ElementObject *)object, memo); + } + } + + /* General case */ + st = ET_STATE_GLOBAL; + if (!st->deepcopy_obj) { + PyErr_SetString(PyExc_RuntimeError, + "deepcopy helper not found"); + return NULL; + } + + args = PyTuple_Pack(2, object, memo); + if (!args) + return NULL; + result = PyObject_CallObject(st->deepcopy_obj, args); + Py_DECREF(args); + return result; +} + + /*[clinic input] _elementtree.Element.__sizeof__ -> Py_ssize_t -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Mon Dec 21 09:29:33 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 21 Dec 2015 14:29:33 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-21 Message-ID: Results for project Python default, build date 2015-12-21 03:09:06 +0000 commit: af0b95fb1c195b0b24816df0017666b1b59e7bc3 revision date: 2015-12-20 14:37:21 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.48% -1.93% 9.50% 16.12% :-| pybench 0.11% 0.23% -1.37% 6.20% :-( regex_v8 2.97% -0.05% -4.18% 3.43% :-( nbody 0.24% -2.35% -1.09% 8.66% :-| json_dump_v2 0.27% 0.58% -1.14% 10.30% :-| normal_startup 0.98% -0.00% -1.36% 4.66% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Mon Dec 21 09:32:45 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 21 Dec 2015 14:32:45 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-21 Message-ID: Results for project Python 2.7, build date 2015-12-21 04:00:51 +0000 commit: b87fe3e4a3d87e855e8e640da0d9a99ec3b7bd95 revision date: 2015-12-20 09:40:00 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.43% 2.35% 4.33% 3.53% :-) pybench 0.14% 0.24% 6.25% 4.95% :-( regex_v8 1.06% 0.39% -2.14% 10.50% :-) nbody 0.32% -0.37% 7.27% 2.52% :-) json_dump_v2 0.26% 3.81% 5.40% 8.03% :-( normal_startup 1.75% -0.09% -5.39% 2.30% :-| ssbench 0.19% -0.09% 1.36% 0.83% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Mon Dec 21 15:18:05 2015 From: python-checkins at python.org (zach.ware) Date: Mon, 21 Dec 2015 20:18:05 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1ODI3?= =?utf-8?q?=3A_Add_support_for_ICC_to_configure?= Message-ID: <20151221201805.7676.40816@psf.io> https://hg.python.org/cpython/rev/d7b5c2f99a99 changeset: 99657:d7b5c2f99a99 branch: 2.7 parent: 99642:b87fe3e4a3d8 user: Zachary Ware date: Mon Dec 21 11:43:03 2015 -0600 summary: Issue #25827: Add support for ICC to configure files: .gitignore | 1 + .hgignore | 1 + Makefile.pre.in | 1 + Misc/NEWS | 3 ++ configure | 44 +++++++++++++++++++++++++++++++++++++ configure.ac | 29 ++++++++++++++++++++++++ 6 files changed, 79 insertions(+), 0 deletions(-) diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ *.gc?? *.profclang? *.profraw +*.dyn Doc/build/ Doc/tools/docutils/ Doc/tools/jinja2/ diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -48,6 +48,7 @@ *.gc?? *.profclang? *.profraw +*.dyn Lib/distutils/command/*.pdb Lib/lib2to3/*.pickle Lib/test/data/* diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1354,6 +1354,7 @@ profile-removal: find . -name '*.gc??' -exec rm -f {} ';' find . -name '*.profclang?' -exec rm -f {} ';' + find . -name '*.dyn' -exec rm -f {} ';' clobber: clean profile-removal -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -64,6 +64,9 @@ Build ----- +- Issue #25827: Add support for building with ICC to ``configure``, including + a new ``--with-icc`` flag. + - Issue #25696: Fix installation of Python on UNIX with make -j9. - Issue #25798: Update OS X 10.5+ 32-bit-only installer to build diff --git a/configure b/configure --- a/configure +++ b/configure @@ -789,6 +789,7 @@ with_framework_name enable_framework with_gcc +with_icc with_cxx_main with_suffix enable_shared @@ -1469,6 +1470,7 @@ specify an alternate name of the framework built with --enable-framework --without-gcc never use gcc + --with-icc build with icc --with-cxx-main= compile main() and link python executable with C++ compiler @@ -3480,6 +3482,29 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $without_gcc" >&5 $as_echo "$without_gcc" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-icc" >&5 +$as_echo_n "checking for --with-icc... " >&6; } + +# Check whether --with-icc was given. +if test "${with_icc+set}" = set; then : + withval=$with_icc; + case $withval in + no) CC=${CC:-cc} + with_icc=no;; + yes) CC=icc + CXX=icpc + with_icc=yes;; + *) CC=$withval + with_icc=$withval;; + esac +else + + with_icc=no +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_icc" >&5 +$as_echo "$with_icc" >&6; } + # If the user switches compilers, we can't believe the cache if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC" then @@ -6188,6 +6213,13 @@ ;; esac +# ICC needs -fp-model strict or floats behave badly +case "$CC" in +*icc*) + BASECFLAGS="$BASECFLAGS -fp-model strict" + ;; +esac + if test "$Py_DEBUG" = 'true'; then : else @@ -6334,6 +6366,12 @@ # Enable PGO flags. + + + + + + # Extract the first word of "llvm-profdata", so it can be a program name with args. set dummy llvm-profdata; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -6405,6 +6443,12 @@ ;; esac ;; + *icc*) + PGO_PROF_GEN_FLAG="-prof-gen" + PGO_PROF_USE_FLAG="-prof-use" + LLVM_PROF_MERGER="true" + LLVM_PROF_FILE="" + ;; esac diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -573,6 +573,22 @@ esac]) AC_MSG_RESULT($without_gcc) +AC_MSG_CHECKING(for --with-icc) +AC_ARG_WITH(icc, + AS_HELP_STRING([--with-icc], [build with icc]), +[ + case $withval in + no) CC=${CC:-cc} + with_icc=no;; + yes) CC=icc + CXX=icpc + with_icc=yes;; + *) CC=$withval + with_icc=$withval;; + esac], [ + with_icc=no]) +AC_MSG_RESULT($with_icc) + # If the user switches compilers, we can't believe the cache if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC" then @@ -1266,6 +1282,13 @@ ;; esac +# ICC needs -fp-model strict or floats behave badly +case "$CC" in +*icc*) + BASECFLAGS="$BASECFLAGS -fp-model strict" + ;; +esac + if test "$Py_DEBUG" = 'true'; then : else @@ -1394,6 +1417,12 @@ ;; esac ;; + *icc*) + PGO_PROF_GEN_FLAG="-prof-gen" + PGO_PROF_USE_FLAG="-prof-use" + LLVM_PROF_MERGER="true" + LLVM_PROF_FILE="" + ;; esac -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 15:18:11 2015 From: python-checkins at python.org (zach.ware) Date: Mon, 21 Dec 2015 20:18:11 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODI3?= =?utf-8?q?=3A_Add_support_for_ICC_to_configure?= Message-ID: <20151221201805.22352.90400@psf.io> https://hg.python.org/cpython/rev/c5e419464585 changeset: 99658:c5e419464585 branch: 3.5 parent: 99653:00b6a13cfd70 user: Zachary Ware date: Mon Dec 21 12:09:17 2015 -0600 summary: Issue #25827: Add support for ICC to configure files: .gitignore | 1 + .hgignore | 1 + Makefile.pre.in | 1 + Misc/NEWS | 3 + configure | 151 ++++++++++++++++++++++++++++++++++++ configure.ac | 39 +++++++++ 6 files changed, 196 insertions(+), 0 deletions(-) diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ *.gc?? *.profclang? *.profraw +*.dyn .gdb_history Doc/build/ Doc/venv/ diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -53,6 +53,7 @@ *.gc?? *.profclang? *.profraw +*.dyn Lib/distutils/command/*.pdb Lib/lib2to3/*.pickle Lib/test/data/* diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1592,6 +1592,7 @@ profile-removal: find . -name '*.gc??' -exec rm -f {} ';' find . -name '*.profclang?' -exec rm -f {} ';' + find . -name '*.dyn' -exec rm -f {} ';' rm -f $(COVERAGE_INFO) rm -rf $(COVERAGE_REPORT) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -92,6 +92,9 @@ Build ----- +- Issue #25827: Add support for building with ICC to ``configure``, including + a new ``--with-icc`` flag. + - Issue #25696: Fix installation of Python on UNIX with make -j9. - Issue #25798: Update OS X 10.5 installer to use OpenSSL 1.0.2e. diff --git a/configure b/configure --- a/configure +++ b/configure @@ -801,6 +801,7 @@ with_framework_name enable_framework with_gcc +with_icc with_cxx_main with_suffix enable_shared @@ -1480,6 +1481,7 @@ specify an alternate name of the framework built with --enable-framework --without-gcc never use gcc + --with-icc build with icc --with-cxx-main= compile main() and link python executable with C++ compiler @@ -3549,6 +3551,29 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $without_gcc" >&5 $as_echo "$without_gcc" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-icc" >&5 +$as_echo_n "checking for --with-icc... " >&6; } + +# Check whether --with-icc was given. +if test "${with_icc+set}" = set; then : + withval=$with_icc; + case $withval in + no) CC=${CC:-cc} + with_icc=no;; + yes) CC=icc + CXX=icpc + with_icc=yes;; + *) CC=$withval + with_icc=$withval;; + esac +else + + with_icc=no +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_icc" >&5 +$as_echo "$with_icc" >&6; } + # If the user switches compilers, we can't believe the cache if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC" then @@ -4941,6 +4966,104 @@ CXX="$ac_cv_path_CXX" fi ;; + icc|*/icc) if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}icpc", so it can be a program name with args. +set dummy ${ac_tool_prefix}icpc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $CXX in + [\\/]* | ?:[\\/]*) + ac_cv_path_CXX="$CXX" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in notfound +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +CXX=$ac_cv_path_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_CXX"; then + ac_pt_CXX=$CXX + # Extract the first word of "icpc", so it can be a program name with args. +set dummy icpc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_CXX in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_CXX="$ac_pt_CXX" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in notfound +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_CXX="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_CXX=$ac_cv_path_ac_pt_CXX +if test -n "$ac_pt_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_CXX" >&5 +$as_echo "$ac_pt_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_CXX" = x; then + CXX="icpc" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_pt_CXX + fi +else + CXX="$ac_cv_path_CXX" +fi + ;; esac if test "$CXX" = "notfound" then @@ -6438,6 +6561,12 @@ # Enable PGO flags. + + + + + + # Extract the first word of "llvm-profdata", so it can be a program name with args. set dummy llvm-profdata; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -6509,6 +6638,12 @@ ;; esac ;; + *icc*) + PGO_PROF_GEN_FLAG="-prof-gen" + PGO_PROF_USE_FLAG="-prof-use" + LLVM_PROF_MERGER="true" + LLVM_PROF_FILE="" + ;; esac # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be @@ -6655,6 +6790,13 @@ BASECFLAGS="$BASECFLAGS -fno-strict-aliasing" fi + # ICC doesn't recognize the option, but only emits a warning + ## XXX does it emit an unused result warning and can it be disabled? + case "$CC" in + *icc*) + ac_cv_disable_unused_result_warning=no + ;; + *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can turn off $CC unused result warning" >&5 $as_echo_n "checking if we can turn off $CC unused result warning... " >&6; } ac_save_cc="$CC" @@ -6692,6 +6834,8 @@ CC="$ac_save_cc" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_disable_unused_result_warning" >&5 $as_echo "$ac_cv_disable_unused_result_warning" >&6; } + ;; + esac if test $ac_cv_disable_unused_result_warning = yes then @@ -6981,6 +7125,13 @@ ;; esac +# ICC needs -fp-model strict or floats behave badly +case "$CC" in +*icc*) + CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict" + ;; +esac + if test "$Py_DEBUG" = 'true'; then : else diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -593,6 +593,22 @@ esac]) AC_MSG_RESULT($without_gcc) +AC_MSG_CHECKING(for --with-icc) +AC_ARG_WITH(icc, + AS_HELP_STRING([--with-icc], [build with icc]), +[ + case $withval in + no) CC=${CC:-cc} + with_icc=no;; + yes) CC=icc + CXX=icpc + with_icc=yes;; + *) CC=$withval + with_icc=$withval;; + esac], [ + with_icc=no]) +AC_MSG_RESULT($with_icc) + # If the user switches compilers, we can't believe the cache if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC" then @@ -699,6 +715,7 @@ gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;; cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;; clang|*/clang) AC_PATH_TOOL(CXX, [clang++], [clang++], [notfound]) ;; + icc|*/icc) AC_PATH_TOOL(CXX, [icpc], [icpc], [notfound]) ;; esac if test "$CXX" = "notfound" then @@ -1259,6 +1276,12 @@ ;; esac ;; + *icc*) + PGO_PROF_GEN_FLAG="-prof-gen" + PGO_PROF_USE_FLAG="-prof-use" + LLVM_PROF_MERGER="true" + LLVM_PROF_FILE="" + ;; esac # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be @@ -1370,6 +1393,13 @@ BASECFLAGS="$BASECFLAGS -fno-strict-aliasing" fi + # ICC doesn't recognize the option, but only emits a warning + ## XXX does it emit an unused result warning and can it be disabled? + case "$CC" in + *icc*) + ac_cv_disable_unused_result_warning=no + ;; + *) AC_MSG_CHECKING(if we can turn off $CC unused result warning) ac_save_cc="$CC" CC="$CC -Wunused-result -Werror" @@ -1386,6 +1416,8 @@ CFLAGS="$save_CFLAGS" CC="$ac_save_cc" AC_MSG_RESULT($ac_cv_disable_unused_result_warning) + ;; + esac if test $ac_cv_disable_unused_result_warning = yes then @@ -1608,6 +1640,13 @@ ;; esac +# ICC needs -fp-model strict or floats behave badly +case "$CC" in +*icc*) + CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict" + ;; +esac + if test "$Py_DEBUG" = 'true'; then : else -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 21 15:18:13 2015 From: python-checkins at python.org (zach.ware) Date: Mon, 21 Dec 2015 20:18:13 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325827=3A_Merge_with_3=2E5?= Message-ID: <20151221201806.22362.2659@psf.io> https://hg.python.org/cpython/rev/29ea3827cfaa changeset: 99659:29ea3827cfaa parent: 99656:090c3e3a648d parent: 99658:c5e419464585 user: Zachary Ware date: Mon Dec 21 14:17:12 2015 -0600 summary: Issue #25827: Merge with 3.5 files: .gitignore | 1 + .hgignore | 1 + Makefile.pre.in | 1 + Misc/NEWS | 3 + configure | 151 ++++++++++++++++++++++++++++++++++++ configure.ac | 39 +++++++++ 6 files changed, 196 insertions(+), 0 deletions(-) diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ *.gc?? *.profclang? *.profraw +*.dyn .gdb_history Doc/build/ Doc/venv/ diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -53,6 +53,7 @@ *.gc?? *.profclang? *.profraw +*.dyn Lib/distutils/command/*.pdb Lib/lib2to3/*.pickle Lib/test/data/* diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1593,6 +1593,7 @@ profile-removal: find . -name '*.gc??' -exec rm -f {} ';' find . -name '*.profclang?' -exec rm -f {} ';' + find . -name '*.dyn' -exec rm -f {} ';' rm -f $(COVERAGE_INFO) rm -rf $(COVERAGE_REPORT) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -509,6 +509,9 @@ Build ----- +- Issue #25827: Add support for building with ICC to ``configure``, including + a new ``--with-icc`` flag. + - Issue #25696: Fix installation of Python on UNIX with make -j9. - Issue #24986: It is now possible to build Python on Windows without errors diff --git a/configure b/configure --- a/configure +++ b/configure @@ -801,6 +801,7 @@ with_framework_name enable_framework with_gcc +with_icc with_cxx_main with_suffix enable_shared @@ -1480,6 +1481,7 @@ specify an alternate name of the framework built with --enable-framework --without-gcc never use gcc + --with-icc build with icc --with-cxx-main= compile main() and link python executable with C++ compiler @@ -3549,6 +3551,29 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $without_gcc" >&5 $as_echo "$without_gcc" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-icc" >&5 +$as_echo_n "checking for --with-icc... " >&6; } + +# Check whether --with-icc was given. +if test "${with_icc+set}" = set; then : + withval=$with_icc; + case $withval in + no) CC=${CC:-cc} + with_icc=no;; + yes) CC=icc + CXX=icpc + with_icc=yes;; + *) CC=$withval + with_icc=$withval;; + esac +else + + with_icc=no +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_icc" >&5 +$as_echo "$with_icc" >&6; } + # If the user switches compilers, we can't believe the cache if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC" then @@ -4941,6 +4966,104 @@ CXX="$ac_cv_path_CXX" fi ;; + icc|*/icc) if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}icpc", so it can be a program name with args. +set dummy ${ac_tool_prefix}icpc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $CXX in + [\\/]* | ?:[\\/]*) + ac_cv_path_CXX="$CXX" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in notfound +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +CXX=$ac_cv_path_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_CXX"; then + ac_pt_CXX=$CXX + # Extract the first word of "icpc", so it can be a program name with args. +set dummy icpc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_CXX in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_CXX="$ac_pt_CXX" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in notfound +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_CXX="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_CXX=$ac_cv_path_ac_pt_CXX +if test -n "$ac_pt_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_CXX" >&5 +$as_echo "$ac_pt_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_CXX" = x; then + CXX="icpc" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_pt_CXX + fi +else + CXX="$ac_cv_path_CXX" +fi + ;; esac if test "$CXX" = "notfound" then @@ -6438,6 +6561,12 @@ # Enable PGO flags. + + + + + + # Extract the first word of "llvm-profdata", so it can be a program name with args. set dummy llvm-profdata; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -6509,6 +6638,12 @@ ;; esac ;; + *icc*) + PGO_PROF_GEN_FLAG="-prof-gen" + PGO_PROF_USE_FLAG="-prof-use" + LLVM_PROF_MERGER="true" + LLVM_PROF_FILE="" + ;; esac # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be @@ -6655,6 +6790,13 @@ BASECFLAGS="$BASECFLAGS -fno-strict-aliasing" fi + # ICC doesn't recognize the option, but only emits a warning + ## XXX does it emit an unused result warning and can it be disabled? + case "$CC" in + *icc*) + ac_cv_disable_unused_result_warning=no + ;; + *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can turn off $CC unused result warning" >&5 $as_echo_n "checking if we can turn off $CC unused result warning... " >&6; } ac_save_cc="$CC" @@ -6692,6 +6834,8 @@ CC="$ac_save_cc" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_disable_unused_result_warning" >&5 $as_echo "$ac_cv_disable_unused_result_warning" >&6; } + ;; + esac if test $ac_cv_disable_unused_result_warning = yes then @@ -6981,6 +7125,13 @@ ;; esac +# ICC needs -fp-model strict or floats behave badly +case "$CC" in +*icc*) + CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict" + ;; +esac + if test "$Py_DEBUG" = 'true'; then : else diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -593,6 +593,22 @@ esac]) AC_MSG_RESULT($without_gcc) +AC_MSG_CHECKING(for --with-icc) +AC_ARG_WITH(icc, + AS_HELP_STRING([--with-icc], [build with icc]), +[ + case $withval in + no) CC=${CC:-cc} + with_icc=no;; + yes) CC=icc + CXX=icpc + with_icc=yes;; + *) CC=$withval + with_icc=$withval;; + esac], [ + with_icc=no]) +AC_MSG_RESULT($with_icc) + # If the user switches compilers, we can't believe the cache if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC" then @@ -699,6 +715,7 @@ gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;; cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;; clang|*/clang) AC_PATH_TOOL(CXX, [clang++], [clang++], [notfound]) ;; + icc|*/icc) AC_PATH_TOOL(CXX, [icpc], [icpc], [notfound]) ;; esac if test "$CXX" = "notfound" then @@ -1259,6 +1276,12 @@ ;; esac ;; + *icc*) + PGO_PROF_GEN_FLAG="-prof-gen" + PGO_PROF_USE_FLAG="-prof-use" + LLVM_PROF_MERGER="true" + LLVM_PROF_FILE="" + ;; esac # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be @@ -1370,6 +1393,13 @@ BASECFLAGS="$BASECFLAGS -fno-strict-aliasing" fi + # ICC doesn't recognize the option, but only emits a warning + ## XXX does it emit an unused result warning and can it be disabled? + case "$CC" in + *icc*) + ac_cv_disable_unused_result_warning=no + ;; + *) AC_MSG_CHECKING(if we can turn off $CC unused result warning) ac_save_cc="$CC" CC="$CC -Wunused-result -Werror" @@ -1386,6 +1416,8 @@ CFLAGS="$save_CFLAGS" CC="$ac_save_cc" AC_MSG_RESULT($ac_cv_disable_unused_result_warning) + ;; + esac if test $ac_cv_disable_unused_result_warning = yes then @@ -1608,6 +1640,13 @@ ;; esac +# ICC needs -fp-model strict or floats behave badly +case "$CC" in +*icc*) + CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict" + ;; +esac + if test "$Py_DEBUG" = 'true'; then : else -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 22 01:22:46 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Dec 2015 06:22:46 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325914=3A_Fixed_and_simplified_OrderedDict=2E=5F?= =?utf-8?b?X3NpemVvZl9fLg==?= Message-ID: <20151222062246.7698.12942@psf.io> https://hg.python.org/cpython/rev/624316fbb39d changeset: 99661:624316fbb39d parent: 99659:29ea3827cfaa parent: 99660:0a2ea08fcebe user: Serhiy Storchaka date: Tue Dec 22 08:22:05 2015 +0200 summary: Issue #25914: Fixed and simplified OrderedDict.__sizeof__. files: Include/dictobject.h | 2 +- Lib/test/test_ordered_dict.py | 32 +++++++++++++++++++++++ Misc/NEWS | 2 + Objects/dictobject.c | 12 ++++++-- Objects/odictobject.c | 22 +--------------- 5 files changed, 45 insertions(+), 25 deletions(-) diff --git a/Include/dictobject.h b/Include/dictobject.h --- a/Include/dictobject.h +++ b/Include/dictobject.h @@ -98,7 +98,7 @@ PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp); PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp); Py_ssize_t _PyDict_KeysSize(PyDictKeysObject *keys); -PyObject *_PyDict_SizeOf(PyDictObject *); +Py_ssize_t _PyDict_SizeOf(PyDictObject *); PyObject *_PyDict_Pop(PyDictObject *, PyObject *, PyObject *); PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *); #define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL) diff --git a/Lib/test/test_ordered_dict.py b/Lib/test/test_ordered_dict.py --- a/Lib/test/test_ordered_dict.py +++ b/Lib/test/test_ordered_dict.py @@ -2,6 +2,7 @@ import copy import pickle from random import randrange, shuffle +import struct import sys import unittest from collections.abc import MutableMapping @@ -604,6 +605,37 @@ module = c_coll OrderedDict = c_coll.OrderedDict + check_sizeof = support.check_sizeof + + @support.cpython_only + def test_sizeof_exact(self): + OrderedDict = self.OrderedDict + calcsize = struct.calcsize + size = support.calcobjsize + check = self.check_sizeof + + basicsize = size('n2P' + '3PnPn2P') + calcsize('2nPn') + entrysize = calcsize('n2P') + calcsize('P') + nodesize = calcsize('Pn2P') + + od = OrderedDict() + check(od, basicsize + 8*entrysize) + od.x = 1 + check(od, basicsize + 8*entrysize) + od.update([(i, i) for i in range(3)]) + check(od, basicsize + 8*entrysize + 3*nodesize) + od.update([(i, i) for i in range(3, 10)]) + check(od, basicsize + 16*entrysize + 10*nodesize) + + check(od.keys(), size('P')) + check(od.items(), size('P')) + check(od.values(), size('P')) + + itersize = size('iP2n2P') + check(iter(od), itersize) + check(iter(od.keys()), itersize) + check(iter(od.items()), itersize) + check(iter(od.values()), itersize) def test_key_change_during_iteration(self): OrderedDict = self.OrderedDict diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -115,6 +115,8 @@ Library ------- +- Issue #25914: Fixed and simplified OrderedDict.__sizeof__. + - Issue #25869: Optimized deepcopying ElementTree; it is now 20 times faster. - Issue #25873: Optimized iterating ElementTree. Iterating elements diff --git a/Objects/dictobject.c b/Objects/dictobject.c --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2557,7 +2557,7 @@ static PyObject *dictiter_new(PyDictObject *, PyTypeObject *); -PyObject * +Py_ssize_t _PyDict_SizeOf(PyDictObject *mp) { Py_ssize_t size, res; @@ -2570,7 +2570,7 @@ in the type object. */ if (mp->ma_keys->dk_refcnt == 1) res += sizeof(PyDictKeysObject) + (size-1) * sizeof(PyDictKeyEntry); - return PyLong_FromSsize_t(res); + return res; } Py_ssize_t @@ -2579,6 +2579,12 @@ return sizeof(PyDictKeysObject) + (DK_SIZE(keys)-1) * sizeof(PyDictKeyEntry); } +PyObject * +dict_sizeof(PyDictObject *mp) +{ + return PyLong_FromSsize_t(_PyDict_SizeOf(mp)); +} + PyDoc_STRVAR(getitem__doc__, "x.__getitem__(y) <==> x[y]"); PyDoc_STRVAR(sizeof__doc__, @@ -2626,7 +2632,7 @@ DICT___CONTAINS___METHODDEF {"__getitem__", (PyCFunction)dict_subscript, METH_O | METH_COEXIST, getitem__doc__}, - {"__sizeof__", (PyCFunction)_PyDict_SizeOf, METH_NOARGS, + {"__sizeof__", (PyCFunction)dict_sizeof, METH_NOARGS, sizeof__doc__}, {"get", (PyCFunction)dict_get, METH_VARARGS, get__doc__}, diff --git a/Objects/odictobject.c b/Objects/odictobject.c --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -940,27 +940,7 @@ static PyObject * odict_sizeof(PyODictObject *od) { - PyObject *pylong; - Py_ssize_t res, temp; - - pylong = _PyDict_SizeOf((PyDictObject *)od); - if (pylong == NULL) - return NULL; - res = PyLong_AsSsize_t(pylong); - Py_DECREF(pylong); - if (res == -1 && PyErr_Occurred()) - return NULL; - - /* instance dict */ - pylong = _PyDict_SizeOf((PyDictObject *)od->od_inst_dict); - if (pylong == NULL) - return NULL; - temp = PyLong_AsSsize_t(pylong); - Py_DECREF(pylong); - if (temp == -1 && PyErr_Occurred()) - return NULL; - res += temp; - + Py_ssize_t res = _PyDict_SizeOf((PyDictObject *)od); res += sizeof(_ODictNode *) * _odict_FAST_SIZE(od); /* od_fast_nodes */ if (!_odict_EMPTY(od)) { res += sizeof(_ODictNode) * PyODict_SIZE(od); /* linked-list */ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 22 01:22:51 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Dec 2015 06:22:51 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1OTE0?= =?utf-8?q?=3A_Fixed_and_simplified_OrderedDict=2E=5F=5Fsizeof=5F=5F=2E?= Message-ID: <20151222062246.98555.75414@psf.io> https://hg.python.org/cpython/rev/0a2ea08fcebe changeset: 99660:0a2ea08fcebe branch: 3.5 parent: 99658:c5e419464585 user: Serhiy Storchaka date: Tue Dec 22 08:16:18 2015 +0200 summary: Issue #25914: Fixed and simplified OrderedDict.__sizeof__. files: Include/dictobject.h | 2 +- Lib/test/test_ordered_dict.py | 32 +++++++++++++++++++++++ Misc/NEWS | 2 + Objects/dictobject.c | 12 ++++++-- Objects/odictobject.c | 22 +--------------- 5 files changed, 45 insertions(+), 25 deletions(-) diff --git a/Include/dictobject.h b/Include/dictobject.h --- a/Include/dictobject.h +++ b/Include/dictobject.h @@ -98,7 +98,7 @@ PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp); PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp); Py_ssize_t _PyDict_KeysSize(PyDictKeysObject *keys); -PyObject *_PyDict_SizeOf(PyDictObject *); +Py_ssize_t _PyDict_SizeOf(PyDictObject *); PyObject *_PyDict_Pop(PyDictObject *, PyObject *, PyObject *); PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *); #define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL) diff --git a/Lib/test/test_ordered_dict.py b/Lib/test/test_ordered_dict.py --- a/Lib/test/test_ordered_dict.py +++ b/Lib/test/test_ordered_dict.py @@ -2,6 +2,7 @@ import copy import pickle from random import randrange, shuffle +import struct import sys import unittest from collections.abc import MutableMapping @@ -596,6 +597,37 @@ module = c_coll OrderedDict = c_coll.OrderedDict + check_sizeof = support.check_sizeof + + @support.cpython_only + def test_sizeof_exact(self): + OrderedDict = self.OrderedDict + calcsize = struct.calcsize + size = support.calcobjsize + check = self.check_sizeof + + basicsize = size('n2P' + '3PnPn2P') + calcsize('2nPn') + entrysize = calcsize('n2P') + calcsize('P') + nodesize = calcsize('Pn2P') + + od = OrderedDict() + check(od, basicsize + 8*entrysize) + od.x = 1 + check(od, basicsize + 8*entrysize) + od.update([(i, i) for i in range(3)]) + check(od, basicsize + 8*entrysize + 3*nodesize) + od.update([(i, i) for i in range(3, 10)]) + check(od, basicsize + 16*entrysize + 10*nodesize) + + check(od.keys(), size('P')) + check(od.items(), size('P')) + check(od.values(), size('P')) + + itersize = size('iP2n2P') + check(iter(od), itersize) + check(iter(od.keys()), itersize) + check(iter(od.items()), itersize) + check(iter(od.values()), itersize) def test_key_change_during_iteration(self): OrderedDict = self.OrderedDict diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -28,6 +28,8 @@ Library ------- +- Issue #25914: Fixed and simplified OrderedDict.__sizeof__. + - Issue #25902: Fixed various refcount issues in ElementTree iteration. - Issue #25717: Restore the previous behaviour of tolerating most fstat() diff --git a/Objects/dictobject.c b/Objects/dictobject.c --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2554,7 +2554,7 @@ static PyObject *dictiter_new(PyDictObject *, PyTypeObject *); -PyObject * +Py_ssize_t _PyDict_SizeOf(PyDictObject *mp) { Py_ssize_t size, res; @@ -2567,7 +2567,7 @@ in the type object. */ if (mp->ma_keys->dk_refcnt == 1) res += sizeof(PyDictKeysObject) + (size-1) * sizeof(PyDictKeyEntry); - return PyLong_FromSsize_t(res); + return res; } Py_ssize_t @@ -2576,6 +2576,12 @@ return sizeof(PyDictKeysObject) + (DK_SIZE(keys)-1) * sizeof(PyDictKeyEntry); } +PyObject * +dict_sizeof(PyDictObject *mp) +{ + return PyLong_FromSsize_t(_PyDict_SizeOf(mp)); +} + PyDoc_STRVAR(getitem__doc__, "x.__getitem__(y) <==> x[y]"); PyDoc_STRVAR(sizeof__doc__, @@ -2623,7 +2629,7 @@ DICT___CONTAINS___METHODDEF {"__getitem__", (PyCFunction)dict_subscript, METH_O | METH_COEXIST, getitem__doc__}, - {"__sizeof__", (PyCFunction)_PyDict_SizeOf, METH_NOARGS, + {"__sizeof__", (PyCFunction)dict_sizeof, METH_NOARGS, sizeof__doc__}, {"get", (PyCFunction)dict_get, METH_VARARGS, get__doc__}, diff --git a/Objects/odictobject.c b/Objects/odictobject.c --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -940,27 +940,7 @@ static PyObject * odict_sizeof(PyODictObject *od) { - PyObject *pylong; - Py_ssize_t res, temp; - - pylong = _PyDict_SizeOf((PyDictObject *)od); - if (pylong == NULL) - return NULL; - res = PyLong_AsSsize_t(pylong); - Py_DECREF(pylong); - if (res == -1 && PyErr_Occurred()) - return NULL; - - /* instance dict */ - pylong = _PyDict_SizeOf((PyDictObject *)od->od_inst_dict); - if (pylong == NULL) - return NULL; - temp = PyLong_AsSsize_t(pylong); - Py_DECREF(pylong); - if (temp == -1 && PyErr_Occurred()) - return NULL; - res += temp; - + Py_ssize_t res = _PyDict_SizeOf((PyDictObject *)od); res += sizeof(_ODictNode *) * _odict_FAST_SIZE(od); /* od_fast_nodes */ if (!_odict_EMPTY(od)) { res += sizeof(_ODictNode) * PyODict_SIZE(od); /* linked-list */ -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Tue Dec 22 03:44:39 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 22 Dec 2015 08:44:39 +0000 Subject: [Python-checkins] Daily reference leaks (29ea3827cfaa): sum=4 Message-ID: <20151222084439.16746.76917@psf.io> results for 29ea3827cfaa on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogxRhuKr', '--timeout', '7200'] From lp_benchmark_robot at intel.com Tue Dec 22 09:15:56 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 22 Dec 2015 14:15:56 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-22 Message-ID: <6f5a3fc1-2e3e-4117-b4eb-56a008ed6a76@irsmsx102.ger.corp.intel.com> Results for project Python default, build date 2015-12-22 03:09:16 +0000 commit: 29ea3827cfaa1df5693cd00363d14ffc81ca586a revision date: 2015-12-21 20:17:12 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.48% 0.62% 10.06% 14.52% :-| pybench 0.10% 0.06% -1.30% 5.83% :-( regex_v8 2.69% 0.17% -4.00% 3.85% :-| nbody 0.41% -0.18% -1.28% 10.05% :-| json_dump_v2 0.24% 0.30% -0.83% 9.66% :-| normal_startup 0.78% -0.27% -1.75% 4.78% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Tue Dec 22 09:17:57 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 22 Dec 2015 14:17:57 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-22 Message-ID: <4a73378c-613f-4b98-80e4-0e81f7f87ec3@irsmsx102.ger.corp.intel.com> Results for project Python 2.7, build date 2015-12-22 04:01:01 +0000 commit: d7b5c2f99a99414eb8698f38444de4b6f5463eb2 revision date: 2015-12-21 17:43:03 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.45% -0.49% 3.86% 5.58% :-) pybench 0.15% 0.08% 6.33% 3.74% :-( regex_v8 1.05% -0.11% -2.25% 10.71% :-) nbody 0.57% 1.55% 8.71% 1.90% :-) json_dump_v2 0.22% 0.13% 5.52% 9.61% :-( normal_startup 1.86% 0.17% -5.21% 1.90% :-| ssbench 0.07% -0.03% 1.34% 0.77% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Tue Dec 22 17:09:23 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Dec 2015 22:09:23 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325860=3A_os=2Efwalk=28=29_no_longer_skips_remai?= =?utf-8?q?ning_directories_when_error?= Message-ID: <20151222220922.11666.92714@psf.io> https://hg.python.org/cpython/rev/a85675dabb8f changeset: 99663:a85675dabb8f parent: 99661:624316fbb39d parent: 99662:767262c149ca user: Serhiy Storchaka date: Wed Dec 23 00:09:01 2015 +0200 summary: Issue #25860: os.fwalk() no longer skips remaining directories when error occurs. Original patch by Samson Lee. files: Lib/os.py | 2 +- Lib/test/test_os.py | 31 ++++++++++++++++++++----------- Misc/NEWS | 3 +++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Lib/os.py b/Lib/os.py --- a/Lib/os.py +++ b/Lib/os.py @@ -514,7 +514,7 @@ except OSError as err: if onerror is not None: onerror(err) - return + continue try: if follow_symlinks or path.samestat(orig_st, stat(dirfd)): dirpath = path.join(toppath, name) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -790,12 +790,8 @@ # Wrapper to hide minor differences between os.walk and os.fwalk # to tests both functions with the same code base - def walk(self, directory, topdown=True, follow_symlinks=False): - walk_it = os.walk(directory, - topdown=topdown, - followlinks=follow_symlinks) - for root, dirs, files in walk_it: - yield (root, dirs, files) + def walk(self, directory, **kwargs): + return os.walk(directory, **kwargs) def setUp(self): join = os.path.join @@ -925,16 +921,29 @@ os.remove(dirname) os.rmdir(support.TESTFN) + def test_walk_bad_dir(self): + # Walk top-down. + errors = [] + walk_it = self.walk(self.walk_path, onerror=errors.append) + root, dirs, files = next(walk_it) + self.assertFalse(errors) + dir1 = dirs[0] + dir1new = dir1 + '.new' + os.rename(os.path.join(root, dir1), os.path.join(root, dir1new)) + roots = [r for r, d, f in walk_it] + self.assertTrue(errors) + self.assertNotIn(os.path.join(root, dir1), roots) + self.assertNotIn(os.path.join(root, dir1new), roots) + for dir2 in dirs[1:]: + self.assertIn(os.path.join(root, dir2), roots) + @unittest.skipUnless(hasattr(os, 'fwalk'), "Test needs os.fwalk()") class FwalkTests(WalkTests): """Tests for os.fwalk().""" - def walk(self, directory, topdown=True, follow_symlinks=False): - walk_it = os.fwalk(directory, - topdown=topdown, - follow_symlinks=follow_symlinks) - for root, dirs, files, root_fd in walk_it: + def walk(self, directory, **kwargs): + for root, dirs, files, root_fd in os.fwalk(directory, **kwargs): yield (root, dirs, files) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -115,6 +115,9 @@ Library ------- +- Issue #25860: os.fwalk() no longer skips remaining directories when error + occurs. Original patch by Samson Lee. + - Issue #25914: Fixed and simplified OrderedDict.__sizeof__. - Issue #25869: Optimized deepcopying ElementTree; it is now 20 times faster. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 22 17:09:23 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Dec 2015 22:09:23 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODYw?= =?utf-8?q?=3A_os=2Efwalk=28=29_no_longer_skips_remaining_directories_when?= =?utf-8?q?_error?= Message-ID: <20151222220922.70429.62750@psf.io> https://hg.python.org/cpython/rev/767262c149ca changeset: 99662:767262c149ca branch: 3.5 parent: 99660:0a2ea08fcebe user: Serhiy Storchaka date: Wed Dec 23 00:08:24 2015 +0200 summary: Issue #25860: os.fwalk() no longer skips remaining directories when error occurs. Original patch by Samson Lee. files: Lib/os.py | 2 +- Lib/test/test_os.py | 31 ++++++++++++++++++++----------- Misc/NEWS | 3 +++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Lib/os.py b/Lib/os.py --- a/Lib/os.py +++ b/Lib/os.py @@ -514,7 +514,7 @@ except OSError as err: if onerror is not None: onerror(err) - return + continue try: if follow_symlinks or path.samestat(orig_st, stat(dirfd)): dirpath = path.join(toppath, name) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -791,12 +791,8 @@ # Wrapper to hide minor differences between os.walk and os.fwalk # to tests both functions with the same code base - def walk(self, directory, topdown=True, follow_symlinks=False): - walk_it = os.walk(directory, - topdown=topdown, - followlinks=follow_symlinks) - for root, dirs, files in walk_it: - yield (root, dirs, files) + def walk(self, directory, **kwargs): + return os.walk(directory, **kwargs) def setUp(self): join = os.path.join @@ -926,16 +922,29 @@ os.remove(dirname) os.rmdir(support.TESTFN) + def test_walk_bad_dir(self): + # Walk top-down. + errors = [] + walk_it = self.walk(self.walk_path, onerror=errors.append) + root, dirs, files = next(walk_it) + self.assertFalse(errors) + dir1 = dirs[0] + dir1new = dir1 + '.new' + os.rename(os.path.join(root, dir1), os.path.join(root, dir1new)) + roots = [r for r, d, f in walk_it] + self.assertTrue(errors) + self.assertNotIn(os.path.join(root, dir1), roots) + self.assertNotIn(os.path.join(root, dir1new), roots) + for dir2 in dirs[1:]: + self.assertIn(os.path.join(root, dir2), roots) + @unittest.skipUnless(hasattr(os, 'fwalk'), "Test needs os.fwalk()") class FwalkTests(WalkTests): """Tests for os.fwalk().""" - def walk(self, directory, topdown=True, follow_symlinks=False): - walk_it = os.fwalk(directory, - topdown=topdown, - follow_symlinks=follow_symlinks) - for root, dirs, files, root_fd in walk_it: + def walk(self, directory, **kwargs): + for root, dirs, files, root_fd in os.fwalk(directory, **kwargs): yield (root, dirs, files) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -28,6 +28,9 @@ Library ------- +- Issue #25860: os.fwalk() no longer skips remaining directories when error + occurs. Original patch by Samson Lee. + - Issue #25914: Fixed and simplified OrderedDict.__sizeof__. - Issue #25902: Fixed various refcount issues in ElementTree iteration. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 22 17:38:10 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Dec 2015 22:38:10 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODYw?= =?utf-8?q?=3A_Fixed_test_failure_caused_by_inconsistency_of_os=2Ewalk=28?= =?utf-8?q?=29_and?= Message-ID: <20151222223810.28362.80624@psf.io> https://hg.python.org/cpython/rev/7995a81236b6 changeset: 99664:7995a81236b6 branch: 3.5 parent: 99662:767262c149ca user: Serhiy Storchaka date: Wed Dec 23 00:37:34 2015 +0200 summary: Issue #25860: Fixed test failure caused by inconsistency of os.walk() and os.fwalk() parameter names. files: Lib/test/test_os.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -792,6 +792,8 @@ # Wrapper to hide minor differences between os.walk and os.fwalk # to tests both functions with the same code base def walk(self, directory, **kwargs): + if 'follow_symlinks' in kwargs: + kwargs['followlinks'] = kwargs.pop('follow_symlinks') return os.walk(directory, **kwargs) def setUp(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 22 17:38:14 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 22 Dec 2015 22:38:14 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325860=3A_Fixed_test_failure_caused_by_inconsist?= =?utf-8?q?ency_of_os=2Ewalk=28=29_and?= Message-ID: <20151222223810.124872.52743@psf.io> https://hg.python.org/cpython/rev/dcf9e9ae5393 changeset: 99665:dcf9e9ae5393 parent: 99663:a85675dabb8f parent: 99664:7995a81236b6 user: Serhiy Storchaka date: Wed Dec 23 00:37:50 2015 +0200 summary: Issue #25860: Fixed test failure caused by inconsistency of os.walk() and os.fwalk() parameter names. files: Lib/test/test_os.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -791,6 +791,8 @@ # Wrapper to hide minor differences between os.walk and os.fwalk # to tests both functions with the same code base def walk(self, directory, **kwargs): + if 'follow_symlinks' in kwargs: + kwargs['followlinks'] = kwargs.pop('follow_symlinks') return os.walk(directory, **kwargs) def setUp(self): -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Wed Dec 23 03:47:44 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 23 Dec 2015 08:47:44 +0000 Subject: [Python-checkins] Daily reference leaks (dcf9e9ae5393): sum=4 Message-ID: <20151223084743.22761.30414@psf.io> results for dcf9e9ae5393 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogXOuchu', '--timeout', '7200'] From lp_benchmark_robot at intel.com Wed Dec 23 10:26:35 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 23 Dec 2015 15:26:35 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-23 Message-ID: Results for project Python default, build date 2015-12-23 13:12:03 +0000 commit: dcf9e9ae53936e779b99b2d120f2f004f902bc62 previous commit: 29ea3827cfaa1df5693cd00363d14ffc81ca586a revision date: 2015-12-22 22:37:50 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.43% 0.69% 10.68% 15.49% :-| pybench 0.10% -0.16% -1.46% 6.00% :-( regex_v8 2.71% 0.08% -3.91% 3.48% :-) nbody 0.13% 2.74% 1.50% 7.04% :-| json_dump_v2 0.26% -0.70% -1.54% 11.82% :-( normal_startup 0.97% -0.13% -2.12% 5.53% ---------------------------------------------------------------------------------- Note: Benchmark results are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Wed Dec 23 10:27:17 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 23 Dec 2015 15:27:17 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-23 Message-ID: <088484eb-472e-46ab-89a8-4f1a7741e427@irsmsx103.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python 2.7, build date 2015-12-23 13:14:32 +0000 commit: d7b5c2f99a99414eb8698f38444de4b6f5463eb2 previous commit: b87fe3e4a3d87e855e8e640da0d9a99ec3b7bd95 revision date: 2015-12-21 17:43:03 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.45% -0.49% 3.86% 5.58% :-) pybench 0.15% 0.08% 6.33% 3.74% :-( regex_v8 1.05% -0.11% -2.25% 10.71% :-) nbody 0.57% 1.55% 8.71% 1.90% :-) json_dump_v2 0.22% 0.13% 5.52% 9.61% :-( normal_startup 1.86% 0.17% -5.21% 1.90% :-| ssbench 0.07% -0.03% 1.34% 0.77% ---------------------------------------------------------------------------------- Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. * Relative Standard Deviation (Standard Deviation/Average) Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Wed Dec 23 21:20:21 2015 From: python-checkins at python.org (r.david.murray) Date: Thu, 24 Dec 2015 02:20:21 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge=3A_=231753718=3A_clarify_RFC_compliance_and_bytes/?= =?utf-8?q?string_argument_types=2E?= Message-ID: <20151224022021.105550.17176@psf.io> https://hg.python.org/cpython/rev/92760d2edc9e changeset: 99667:92760d2edc9e parent: 99665:dcf9e9ae5393 parent: 99666:105bf5dd93b8 user: R David Murray date: Wed Dec 23 21:19:53 2015 -0500 summary: Merge: #1753718: clarify RFC compliance and bytes/string argument types. files: Doc/library/base64.rst | 128 ++++++++++++++++------------ 1 files changed, 71 insertions(+), 57 deletions(-) diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -21,13 +21,19 @@ POST request. The encoding algorithm is not the same as the :program:`uuencode` program. -There are two :rfc:`3548` interfaces provided by this module. The modern -interface supports encoding and decoding ASCII byte string objects using all -three :rfc:`3548` defined alphabets (normal, URL-safe, and filesystem-safe). -Additionally, the decoding functions of the modern interface also accept -Unicode strings containing only ASCII characters. The legacy interface provides -for encoding and decoding to and from file-like objects as well as byte -strings, but only using the Base64 standard alphabet. +There are two interfaces provided by this module. The modern interface +supports encoding :term:`bytes-like objects ` to ASCII +:class:`bytes`, and decoding :term:`bytes-like objects ` or +strings containing ASCII to :class:`bytes`. All three :rfc:`3548` defined +alphabets (normal, URL-safe, and filesystem-safe) are supported. + +The legacy interface does not support decoding from strings, but it does +provide functions for encoding and decoding to and from :term:`file objects +`. It only supports the Base64 standard alphabet, and it adds +newlines every 76 characters as per :rfc:`2045`. Note that if you are looking +for :rfc:`2045` support you probably want to be looking at the :mod:`email` +package instead. + .. versionchanged:: 3.3 ASCII-only Unicode strings are now accepted by the decoding functions of @@ -41,26 +47,26 @@ .. function:: b64encode(s, altchars=None) - Encode a byte string using Base64. + Encode the :term:`bytes-like object` *s* using Base64 and return the encoded + :class:`bytes`. - *s* is the string to encode. Optional *altchars* must be a string of at least + Optional *altchars* must be a :term:`bytes-like object` of at least length 2 (additional characters are ignored) which specifies an alternative alphabet for the ``+`` and ``/`` characters. This allows an application to e.g. generate URL or filesystem safe Base64 strings. The default is ``None``, for which the standard Base64 alphabet is used. - The encoded byte string is returned. - .. function:: b64decode(s, altchars=None, validate=False) - Decode a Base64 encoded byte string. + Decode the Base64 encoded :term:`bytes-like object` or ASCII string + *s* and return the decoded :class:`bytes`. - *s* is the byte string to decode. Optional *altchars* must be a string of + Optional *altchars* must be a :term:`bytes-like object` or ASCII string of at least length 2 (additional characters are ignored) which specifies the alternative alphabet used instead of the ``+`` and ``/`` characters. - The decoded string is returned. A :exc:`binascii.Error` exception is raised + A :exc:`binascii.Error` exception is raised if *s* is incorrectly padded. If *validate* is ``False`` (the default), non-base64-alphabet characters are @@ -71,38 +77,44 @@ .. function:: standard_b64encode(s) - Encode byte string *s* using the standard Base64 alphabet. + Encode :term:`bytes-like object` *s* using the standard Base64 alphabet + and return the encoded :class:`bytes`. .. function:: standard_b64decode(s) - Decode byte string *s* using the standard Base64 alphabet. + Decode :term:`bytes-like object` or ASCII string *s* using the standard + Base64 alphabet and return the decoded :class:`bytes`. .. function:: urlsafe_b64encode(s) - Encode byte string *s* using a URL-safe alphabet, which substitutes ``-`` instead of - ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet. The result + Encode :term:`bytes-like object` *s* using a URL-safe alphabet, which + substitutes ``-`` instead of ``+`` and ``_`` instead of ``/`` in the + standard Base64 alphabet, and return the encoded :class:`bytes`. The result can still contain ``=``. .. function:: urlsafe_b64decode(s) - Decode byte string *s* using a URL-safe alphabet, which substitutes ``-`` instead of - ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet. + Decode :term:`bytes-like object` or ASCII string *s* using a URL-safe + alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of + ``/`` in the standard Base64 alphabet, and return the decoded + :class:`bytes`. .. function:: b32encode(s) - Encode a byte string using Base32. *s* is the string to encode. The encoded string - is returned. + Encode the :term:`bytes-like object` *s* using Base32 and return the + encoded :class:`bytes`. .. function:: b32decode(s, casefold=False, map01=None) - Decode a Base32 encoded byte string. + Decode the Base32 encoded :term:`bytes-like object` or ASCII string *s* and + return the decoded :class:`bytes`. - *s* is the byte string to decode. Optional *casefold* is a flag specifying + Optional *casefold* is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is ``False``. @@ -113,46 +125,45 @@ digit 0 is always mapped to the letter O). For security purposes the default is ``None``, so that 0 and 1 are not allowed in the input. - The decoded byte string is returned. A :exc:`binascii.Error` is raised if *s* is + A :exc:`binascii.Error` is raised if *s* is incorrectly padded or if there are non-alphabet characters present in the - string. + input. .. function:: b16encode(s) - Encode a byte string using Base16. - - *s* is the string to encode. The encoded byte string is returned. + Encode the :term:`bytes-like object` *s* using Base16 and return the + encoded :class:`bytes`. .. function:: b16decode(s, casefold=False) - Decode a Base16 encoded byte string. + Decode the Base16 encoded :term:`bytes-like object` or ASCII string *s* and + return the decoded :class:`bytes`. - *s* is the string to decode. Optional *casefold* is a flag specifying whether a + Optional *casefold* is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is ``False``. - The decoded byte string is returned. A :exc:`TypeError` is raised if *s* were + A :exc:`TypeError` is raised if *s* is incorrectly padded or if there are non-alphabet characters present in the - string. + input. .. function:: a85encode(s, *, foldspaces=False, wrapcol=0, pad=False, adobe=False) - Encode a byte string using Ascii85. - - *s* is the string to encode. The encoded byte string is returned. + Encode the :term:`bytes-like object` *s* using Ascii85 and return the + encoded :class:`bytes`. *foldspaces* is an optional flag that uses the special short sequence 'y' instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This feature is not supported by the "standard" Ascii85 encoding. - *wrapcol* controls whether the output should have newline (``'\n'``) + *wrapcol* controls whether the output should have newline (``b'\n'``) characters added to it. If this is non-zero, each output line will be at most this many characters long. - *pad* controls whether the input string is padded to a multiple of 4 + *pad* controls whether the input is padded to a multiple of 4 before encoding. Note that the ``btoa`` implementation always pads. *adobe* controls whether the encoded byte sequence is framed with ``<~`` @@ -163,9 +174,8 @@ .. function:: a85decode(s, *, foldspaces=False, adobe=False, ignorechars=b' \\t\\n\\r\\v') - Decode an Ascii85 encoded byte string. - - *s* is the byte string to decode. + Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *s* and + return the decoded :class:`bytes`. *foldspaces* is a flag that specifies whether the 'y' short sequence should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). @@ -174,7 +184,8 @@ *adobe* controls whether the input sequence is in Adobe Ascii85 format (i.e. is framed with <~ and ~>). - *ignorechars* should be a byte string containing characters to ignore + *ignorechars* should be a :term:`bytes-like object` or ASCII string + containing characters to ignore from the input. This should only contain whitespace characters, and by default contains all whitespace characters in ASCII. @@ -183,18 +194,19 @@ .. function:: b85encode(s, pad=False) - Encode a byte string using base85, as used in e.g. git-style binary - diffs. + Encode the :term:`bytes-like object` *s* using base85 (as used in e.g. + git-style binary diffs) and return the encoded :class:`bytes`. - If *pad* is true, the input is padded with "\\0" so its length is a - multiple of 4 characters before encoding. + If *pad* is true, the input is padded with ``b'\0'`` so its length is a + multiple of 4 bytes before encoding. .. versionadded:: 3.4 .. function:: b85decode(b) - Decode base85-encoded byte string. Padding is implicitly removed, if + Decode the base85-encoded :term:`bytes-like object` or ASCII string *b* and + return the decoded :class:`bytes`. Padding is implicitly removed, if necessary. .. versionadded:: 3.4 @@ -214,15 +226,15 @@ Decode the contents of the binary *input* file and write the resulting binary data to the *output* file. *input* and *output* must be :term:`file objects - `. *input* will be read until ``input.read()`` returns an empty - bytes object. + `. *input* will be read until ``input.readline()`` returns an + empty bytes object. .. function:: decodebytes(s) decodestring(s) - Decode the byte string *s*, which must contain one or more lines of base64 - encoded data, and return a byte string containing the resulting binary data. + Decode the :term:`bytes-like object` *s*, which must contain one or more + lines of base64 encoded data, and return the decoded :class:`bytes`. ``decodestring`` is a deprecated alias. .. versionadded:: 3.1 @@ -233,17 +245,19 @@ Encode the contents of the binary *input* file and write the resulting base64 encoded data to the *output* file. *input* and *output* must be :term:`file objects `. *input* will be read until ``input.read()`` returns - an empty bytes object. :func:`encode` returns the encoded data plus a trailing - newline character (``b'\n'``). + an empty bytes object. :func:`encode` inserts a newline character (``b'\n'``) + after every 76 bytes of the output, as well as ensuring that the output + always ends with a newline, as per :rfc:`2045` (MIME). .. function:: encodebytes(s) encodestring(s) - Encode the byte string *s*, which can contain arbitrary binary data, and - return a byte string containing one or more lines of base64-encoded data. - :func:`encodebytes` returns a string containing one or more lines of - base64-encoded data always including an extra trailing newline (``b'\n'``). + Encode the :term:`bytes-like object` *s*, which can contain arbitrary binary + data, and return :class:`bytes` containing the base64-encoded data, with newlines + (``b'\n'``) inserted after every 76 bytes of output, and ensuring that + there is a trailing newline, as per :rfc:`2045` (MIME). + ``encodestring`` is a deprecated alias. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 23 21:20:21 2015 From: python-checkins at python.org (r.david.murray) Date: Thu, 24 Dec 2015 02:20:21 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogIzE3NTM3MTg6IGNs?= =?utf-8?q?arify_RFC_compliance_and_bytes/string_argument_types=2E?= Message-ID: <20151224022020.70419.94871@psf.io> https://hg.python.org/cpython/rev/105bf5dd93b8 changeset: 99666:105bf5dd93b8 branch: 3.5 parent: 99664:7995a81236b6 user: R David Murray date: Wed Dec 23 21:17:17 2015 -0500 summary: #1753718: clarify RFC compliance and bytes/string argument types. Patch includes contributions by Isobel Hooper, incorporating suggestions from Paul Winkler. Reviewed by Martin Panter. In addition to accepting the corrections for the RFC compliance wording, I went through and corrected all the argument and return types, and made the pattern of how the arguments and return types are documented consistent. So, this patch also addresses #20782, though I had forgotten about that issue and its patch. files: Doc/library/base64.rst | 128 ++++++++++++++++------------ 1 files changed, 71 insertions(+), 57 deletions(-) diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -21,13 +21,19 @@ POST request. The encoding algorithm is not the same as the :program:`uuencode` program. -There are two :rfc:`3548` interfaces provided by this module. The modern -interface supports encoding and decoding ASCII byte string objects using all -three :rfc:`3548` defined alphabets (normal, URL-safe, and filesystem-safe). -Additionally, the decoding functions of the modern interface also accept -Unicode strings containing only ASCII characters. The legacy interface provides -for encoding and decoding to and from file-like objects as well as byte -strings, but only using the Base64 standard alphabet. +There are two interfaces provided by this module. The modern interface +supports encoding :term:`bytes-like objects ` to ASCII +:class:`bytes`, and decoding :term:`bytes-like objects ` or +strings containing ASCII to :class:`bytes`. All three :rfc:`3548` defined +alphabets (normal, URL-safe, and filesystem-safe) are supported. + +The legacy interface does not support decoding from strings, but it does +provide functions for encoding and decoding to and from :term:`file objects +`. It only supports the Base64 standard alphabet, and it adds +newlines every 76 characters as per :rfc:`2045`. Note that if you are looking +for :rfc:`2045` support you probably want to be looking at the :mod:`email` +package instead. + .. versionchanged:: 3.3 ASCII-only Unicode strings are now accepted by the decoding functions of @@ -41,26 +47,26 @@ .. function:: b64encode(s, altchars=None) - Encode a byte string using Base64. + Encode the :term:`bytes-like object` *s* using Base64 and return the encoded + :class:`bytes`. - *s* is the string to encode. Optional *altchars* must be a string of at least + Optional *altchars* must be a :term:`bytes-like object` of at least length 2 (additional characters are ignored) which specifies an alternative alphabet for the ``+`` and ``/`` characters. This allows an application to e.g. generate URL or filesystem safe Base64 strings. The default is ``None``, for which the standard Base64 alphabet is used. - The encoded byte string is returned. - .. function:: b64decode(s, altchars=None, validate=False) - Decode a Base64 encoded byte string. + Decode the Base64 encoded :term:`bytes-like object` or ASCII string + *s* and return the decoded :class:`bytes`. - *s* is the byte string to decode. Optional *altchars* must be a string of + Optional *altchars* must be a :term:`bytes-like object` or ASCII string of at least length 2 (additional characters are ignored) which specifies the alternative alphabet used instead of the ``+`` and ``/`` characters. - The decoded string is returned. A :exc:`binascii.Error` exception is raised + A :exc:`binascii.Error` exception is raised if *s* is incorrectly padded. If *validate* is ``False`` (the default), non-base64-alphabet characters are @@ -71,38 +77,44 @@ .. function:: standard_b64encode(s) - Encode byte string *s* using the standard Base64 alphabet. + Encode :term:`bytes-like object` *s* using the standard Base64 alphabet + and return the encoded :class:`bytes`. .. function:: standard_b64decode(s) - Decode byte string *s* using the standard Base64 alphabet. + Decode :term:`bytes-like object` or ASCII string *s* using the standard + Base64 alphabet and return the decoded :class:`bytes`. .. function:: urlsafe_b64encode(s) - Encode byte string *s* using a URL-safe alphabet, which substitutes ``-`` instead of - ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet. The result + Encode :term:`bytes-like object` *s* using a URL-safe alphabet, which + substitutes ``-`` instead of ``+`` and ``_`` instead of ``/`` in the + standard Base64 alphabet, and return the encoded :class:`bytes`. The result can still contain ``=``. .. function:: urlsafe_b64decode(s) - Decode byte string *s* using a URL-safe alphabet, which substitutes ``-`` instead of - ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet. + Decode :term:`bytes-like object` or ASCII string *s* using a URL-safe + alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of + ``/`` in the standard Base64 alphabet, and return the decoded + :class:`bytes`. .. function:: b32encode(s) - Encode a byte string using Base32. *s* is the string to encode. The encoded string - is returned. + Encode the :term:`bytes-like object` *s* using Base32 and return the + encoded :class:`bytes`. .. function:: b32decode(s, casefold=False, map01=None) - Decode a Base32 encoded byte string. + Decode the Base32 encoded :term:`bytes-like object` or ASCII string *s* and + return the decoded :class:`bytes`. - *s* is the byte string to decode. Optional *casefold* is a flag specifying + Optional *casefold* is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is ``False``. @@ -113,46 +125,45 @@ digit 0 is always mapped to the letter O). For security purposes the default is ``None``, so that 0 and 1 are not allowed in the input. - The decoded byte string is returned. A :exc:`binascii.Error` is raised if *s* is + A :exc:`binascii.Error` is raised if *s* is incorrectly padded or if there are non-alphabet characters present in the - string. + input. .. function:: b16encode(s) - Encode a byte string using Base16. - - *s* is the string to encode. The encoded byte string is returned. + Encode the :term:`bytes-like object` *s* using Base16 and return the + encoded :class:`bytes`. .. function:: b16decode(s, casefold=False) - Decode a Base16 encoded byte string. + Decode the Base16 encoded :term:`bytes-like object` or ASCII string *s* and + return the decoded :class:`bytes`. - *s* is the string to decode. Optional *casefold* is a flag specifying whether a + Optional *casefold* is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is ``False``. - The decoded byte string is returned. A :exc:`TypeError` is raised if *s* were + A :exc:`TypeError` is raised if *s* is incorrectly padded or if there are non-alphabet characters present in the - string. + input. .. function:: a85encode(s, *, foldspaces=False, wrapcol=0, pad=False, adobe=False) - Encode a byte string using Ascii85. - - *s* is the string to encode. The encoded byte string is returned. + Encode the :term:`bytes-like object` *s* using Ascii85 and return the + encoded :class:`bytes`. *foldspaces* is an optional flag that uses the special short sequence 'y' instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This feature is not supported by the "standard" Ascii85 encoding. - *wrapcol* controls whether the output should have newline (``'\n'``) + *wrapcol* controls whether the output should have newline (``b'\n'``) characters added to it. If this is non-zero, each output line will be at most this many characters long. - *pad* controls whether the input string is padded to a multiple of 4 + *pad* controls whether the input is padded to a multiple of 4 before encoding. Note that the ``btoa`` implementation always pads. *adobe* controls whether the encoded byte sequence is framed with ``<~`` @@ -163,9 +174,8 @@ .. function:: a85decode(s, *, foldspaces=False, adobe=False, ignorechars=b' \\t\\n\\r\\v') - Decode an Ascii85 encoded byte string. - - *s* is the byte string to decode. + Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *s* and + return the decoded :class:`bytes`. *foldspaces* is a flag that specifies whether the 'y' short sequence should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). @@ -174,7 +184,8 @@ *adobe* controls whether the input sequence is in Adobe Ascii85 format (i.e. is framed with <~ and ~>). - *ignorechars* should be a byte string containing characters to ignore + *ignorechars* should be a :term:`bytes-like object` or ASCII string + containing characters to ignore from the input. This should only contain whitespace characters, and by default contains all whitespace characters in ASCII. @@ -183,18 +194,19 @@ .. function:: b85encode(s, pad=False) - Encode a byte string using base85, as used in e.g. git-style binary - diffs. + Encode the :term:`bytes-like object` *s* using base85 (as used in e.g. + git-style binary diffs) and return the encoded :class:`bytes`. - If *pad* is true, the input is padded with "\\0" so its length is a - multiple of 4 characters before encoding. + If *pad* is true, the input is padded with ``b'\0'`` so its length is a + multiple of 4 bytes before encoding. .. versionadded:: 3.4 .. function:: b85decode(b) - Decode base85-encoded byte string. Padding is implicitly removed, if + Decode the base85-encoded :term:`bytes-like object` or ASCII string *b* and + return the decoded :class:`bytes`. Padding is implicitly removed, if necessary. .. versionadded:: 3.4 @@ -214,15 +226,15 @@ Decode the contents of the binary *input* file and write the resulting binary data to the *output* file. *input* and *output* must be :term:`file objects - `. *input* will be read until ``input.read()`` returns an empty - bytes object. + `. *input* will be read until ``input.readline()`` returns an + empty bytes object. .. function:: decodebytes(s) decodestring(s) - Decode the byte string *s*, which must contain one or more lines of base64 - encoded data, and return a byte string containing the resulting binary data. + Decode the :term:`bytes-like object` *s*, which must contain one or more + lines of base64 encoded data, and return the decoded :class:`bytes`. ``decodestring`` is a deprecated alias. .. versionadded:: 3.1 @@ -233,17 +245,19 @@ Encode the contents of the binary *input* file and write the resulting base64 encoded data to the *output* file. *input* and *output* must be :term:`file objects `. *input* will be read until ``input.read()`` returns - an empty bytes object. :func:`encode` returns the encoded data plus a trailing - newline character (``b'\n'``). + an empty bytes object. :func:`encode` inserts a newline character (``b'\n'``) + after every 76 bytes of the output, as well as ensuring that the output + always ends with a newline, as per :rfc:`2045` (MIME). .. function:: encodebytes(s) encodestring(s) - Encode the byte string *s*, which can contain arbitrary binary data, and - return a byte string containing one or more lines of base64-encoded data. - :func:`encodebytes` returns a string containing one or more lines of - base64-encoded data always including an extra trailing newline (``b'\n'``). + Encode the :term:`bytes-like object` *s*, which can contain arbitrary binary + data, and return :class:`bytes` containing the base64-encoded data, with newlines + (``b'\n'``) inserted after every 76 bytes of output, and ensuring that + there is a trailing newline, as per :rfc:`2045` (MIME). + ``encodestring`` is a deprecated alias. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 24 03:40:34 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 24 Dec 2015 08:40:34 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzIwNDQw?= =?utf-8?q?=3A_Massive_replacing_unsafe_attribute_setting_code_with_specia?= =?utf-8?q?l?= Message-ID: <20151224084033.3387.53508@psf.io> https://hg.python.org/cpython/rev/23296440b654 changeset: 99668:23296440b654 branch: 2.7 parent: 99657:d7b5c2f99a99 user: Serhiy Storchaka date: Thu Dec 24 10:35:35 2015 +0200 summary: Issue #20440: Massive replacing unsafe attribute setting code with special macro Py_SETREF. files: Include/object.h | 23 ++++++++++++++++ Misc/NEWS | 3 ++ Modules/_bsddb.c | 15 +++------- Modules/_csv.c | 6 +-- Modules/_ctypes/_ctypes.c | 33 ++++++++---------------- Modules/_curses_panel.c | 5 +-- Modules/_json.c | 3 +- Modules/_sqlite/connection.c | 13 +++----- Modules/_sqlite/cursor.c | 13 +++----- Modules/_sre.c | 3 +- Modules/_ssl.c | 3 +- Modules/bz2module.c | 5 +-- Modules/cPickle.c | 24 +++++----------- Modules/cdmodule.c | 6 +-- Modules/itertoolsmodule.c | 3 +- Modules/signalmodule.c | 3 +- Modules/zlibmodule.c | 6 +-- Objects/descrobject.c | 3 +- Objects/exceptions.c | 8 ++--- Objects/fileobject.c | 6 +-- Objects/frameobject.c | 3 +- Objects/funcobject.c | 9 ++---- Objects/stringobject.c | 6 +-- Objects/typeobject.c | 6 +-- Objects/unicodeobject.c | 3 +- Python/_warnings.c | 3 +- Python/ceval.c | 3 +- Python/compile.c | 5 +-- 28 files changed, 94 insertions(+), 128 deletions(-) diff --git a/Include/object.h b/Include/object.h --- a/Include/object.h +++ b/Include/object.h @@ -824,6 +824,29 @@ #define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0) #define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0) +/* Safely decref `op` and set `op` to `op2`. + * + * As in case of Py_CLEAR "the obvious" code can be deadly: + * + * Py_XDECREF(op); + * op = op2; + * + * The safe way is: + * + * Py_SETREF(op, op2); + * + * That arranges to set `op` to `op2` _before_ decref'ing, so that any code + * triggered as a side-effect of `op` getting torn down no longer believes + * `op` points to a valid object. + */ + +#define Py_SETREF(op, op2) \ + do { \ + PyObject *_py_tmp = (PyObject *)(op); \ + (op) = (op2); \ + Py_XDECREF(_py_tmp); \ + } while (0) + /* These are provided as conveniences to Python runtime embedders, so that they can have object code that is not dependent on Python compilation flags. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #20440: Massive replacing unsafe attribute setting code with special + macro Py_SETREF. + - Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. This allows sys.getsize() to work correctly with their subclasses with __slots__ defined. diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -1607,9 +1607,8 @@ } /* Save a reference to the callback in the secondary DB. */ - Py_XDECREF(secondaryDB->associateCallback); Py_XINCREF(callback); - secondaryDB->associateCallback = callback; + Py_SETREF(secondaryDB->associateCallback, callback); secondaryDB->primaryDBType = _DB_get_type(self); /* PyEval_InitThreads is called here due to a quirk in python 1.5 @@ -2498,9 +2497,8 @@ DB_set_private(DBObject* self, PyObject* private_obj) { /* We can set the private field even if db is closed */ - Py_DECREF(self->private_obj); Py_INCREF(private_obj); - self->private_obj = private_obj; + Py_SETREF(self->private_obj, private_obj); RETURN_NONE(); } @@ -6998,9 +6996,8 @@ DBEnv_set_private(DBEnvObject* self, PyObject* private_obj) { /* We can set the private field even if dbenv is closed */ - Py_DECREF(self->private_obj); Py_INCREF(private_obj); - self->private_obj = private_obj; + Py_SETREF(self->private_obj, private_obj); RETURN_NONE(); } @@ -7253,9 +7250,8 @@ return NULL; } - Py_XDECREF(self->event_notifyCallback); Py_INCREF(notifyFunc); - self->event_notifyCallback = notifyFunc; + Py_SETREF(self->event_notifyCallback, notifyFunc); /* This is to workaround a problem with un-initialized threads (see comment in DB_associate) */ @@ -7413,9 +7409,8 @@ MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); - Py_DECREF(self->rep_transport); Py_INCREF(rep_transport); - self->rep_transport = rep_transport; + Py_SETREF(self->rep_transport, rep_transport); RETURN_NONE(); } diff --git a/Modules/_csv.c b/Modules/_csv.c --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -276,9 +276,8 @@ return -1; } else { - Py_XDECREF(*target); Py_INCREF(src); - *target = src; + Py_SETREF(*target, src); } } return 0; @@ -770,8 +769,7 @@ static int parse_reset(ReaderObj *self) { - Py_XDECREF(self->fields); - self->fields = PyList_New(0); + Py_SETREF(self->fields, PyList_New(0)); if (self->fields == NULL) return -1; self->field_len = 0; diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -424,8 +424,7 @@ Py_DECREF((PyObject *)dict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)dict; + Py_SETREF(result->tp_dict, (PyObject *)dict); dict->format = _ctypes_alloc_format_string(NULL, "B"); if (dict->format == NULL) { Py_DECREF(result); @@ -903,8 +902,7 @@ return -1; } Py_INCREF(proto); - Py_XDECREF(stgdict->proto); - stgdict->proto = proto; + Py_SETREF(stgdict->proto, proto); return 0; } @@ -994,8 +992,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); return (PyObject *)result; } @@ -1460,8 +1457,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); /* Special case for character arrays. A permanent annoyance: char arrays are also strings! @@ -1884,8 +1880,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); return (PyObject *)result; } @@ -2393,8 +2388,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); if (-1 == make_funcptrtype_dict(stgdict)) { Py_DECREF(result); @@ -2536,8 +2530,7 @@ } ob = PyCData_GetContainer(target); if (ob->b_objects == NULL || !PyDict_CheckExact(ob->b_objects)) { - Py_XDECREF(ob->b_objects); - ob->b_objects = keep; /* refcount consumed */ + Py_SETREF(ob->b_objects, keep); /* refcount consumed */ return 0; } key = unique_key(target, index); @@ -3059,9 +3052,8 @@ "the errcheck attribute must be callable"); return -1; } - Py_XDECREF(self->errcheck); Py_XINCREF(ob); - self->errcheck = ob; + Py_SETREF(self->errcheck, ob); return 0; } @@ -3090,9 +3082,8 @@ return -1; } Py_XDECREF(self->checker); - Py_XDECREF(self->restype); Py_INCREF(ob); - self->restype = ob; + Py_SETREF(self->restype, ob); self->checker = PyObject_GetAttrString(ob, "_check_retval_"); if (self->checker == NULL) PyErr_Clear(); @@ -3130,11 +3121,9 @@ converters = converters_from_argtypes(ob); if (!converters) return -1; - Py_XDECREF(self->converters); - self->converters = converters; - Py_XDECREF(self->argtypes); + Py_SETREF(self->converters, converters); Py_INCREF(ob); - self->argtypes = ob; + Py_SETREF(self->argtypes, ob); } return 0; } diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -283,9 +283,8 @@ PyErr_SetString(PyCursesError, "replace_panel() returned ERR"); return NULL; } - Py_DECREF(po->wo); - po->wo = temp; - Py_INCREF(po->wo); + Py_INCREF(temp); + Py_SETREF(po->wo, temp); Py_INCREF(Py_None); return Py_None; } diff --git a/Modules/_json.c b/Modules/_json.c --- a/Modules/_json.c +++ b/Modules/_json.c @@ -1717,8 +1717,7 @@ } else if (PyUnicode_Check(s->encoding)) { PyObject *tmp = PyUnicode_AsEncodedString(s->encoding, NULL, NULL); - Py_DECREF(s->encoding); - s->encoding = tmp; + Py_SETREF(s->encoding, tmp); } if (s->encoding == NULL) goto bail; diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -228,8 +228,8 @@ node = node->next; } - Py_DECREF(self->statement_cache); - self->statement_cache = (pysqlite_Cache*)PyObject_CallFunction((PyObject*)&pysqlite_CacheType, "O", self); + Py_SETREF(self->statement_cache, + (pysqlite_Cache *)PyObject_CallFunction((PyObject *)&pysqlite_CacheType, "O", self)); Py_DECREF(self); self->statement_cache->decref_factory = 0; } @@ -346,9 +346,8 @@ _pysqlite_drop_unused_cursor_references(self); if (cursor && self->row_factory != Py_None) { - Py_XDECREF(((pysqlite_Cursor*)cursor)->row_factory); Py_INCREF(self->row_factory); - ((pysqlite_Cursor*)cursor)->row_factory = self->row_factory; + Py_SETREF(((pysqlite_Cursor *)cursor)->row_factory, self->row_factory); } return cursor; @@ -816,8 +815,7 @@ } } - Py_DECREF(self->statements); - self->statements = new_list; + Py_SETREF(self->statements, new_list); } static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self) @@ -848,8 +846,7 @@ } } - Py_DECREF(self->cursors); - self->cursors = new_list; + Py_SETREF(self->cursors, new_list); } PyObject* pysqlite_connection_create_function(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -172,8 +172,7 @@ return 0; } - Py_XDECREF(self->row_cast_map); - self->row_cast_map = PyList_New(0); + Py_SETREF(self->row_cast_map, PyList_New(0)); for (i = 0; i < sqlite3_column_count(self->statement->st); i++) { converter = NULL; @@ -544,9 +543,8 @@ } /* reset description and rowcount */ - Py_DECREF(self->description); Py_INCREF(Py_None); - self->description = Py_None; + Py_SETREF(self->description, Py_None); self->rowcount = -1L; func_args = PyTuple_New(1); @@ -571,8 +569,8 @@ } if (self->statement->in_use) { - Py_DECREF(self->statement); - self->statement = PyObject_New(pysqlite_Statement, &pysqlite_StatementType); + Py_SETREF(self->statement, + PyObject_New(pysqlite_Statement, &pysqlite_StatementType)); if (!self->statement) { goto error; } @@ -683,8 +681,7 @@ numcols = sqlite3_column_count(self->statement->st); Py_END_ALLOW_THREADS - Py_DECREF(self->description); - self->description = PyTuple_New(numcols); + Py_SETREF(self->description, PyTuple_New(numcols)); if (!self->description) { goto error; } diff --git a/Modules/_sre.c b/Modules/_sre.c --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -2054,8 +2054,7 @@ if (!copy) return 0; - Py_DECREF(*object); - *object = copy; + Py_SETREF(*object, copy); return 1; /* success */ } diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1467,8 +1467,7 @@ return -1; #else Py_INCREF(value); - Py_DECREF(self->ctx); - self->ctx = (PySSLContext *) value; + Py_SETREF(self->ctx, (PySSLContext *)value); SSL_set_SSL_CTX(self->ssl, self->ctx->ctx); #endif } else { diff --git a/Modules/bz2module.c b/Modules/bz2module.c --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -1953,9 +1953,8 @@ self->running = 0; input_left += bzs->avail_in; if (input_left != 0) { - Py_DECREF(self->unused_data); - self->unused_data = - PyString_FromStringAndSize(bzs->next_in, input_left); + Py_SETREF(self->unused_data, + PyString_FromStringAndSize(bzs->next_in, input_left)); if (self->unused_data == NULL) goto error; } diff --git a/Modules/cPickle.c b/Modules/cPickle.c --- a/Modules/cPickle.c +++ b/Modules/cPickle.c @@ -689,8 +689,7 @@ } if (! str) return -1; - Py_XDECREF(self->last_string); - self->last_string = str; + Py_SETREF(self->last_string, str); if (! (*s = PyString_AsString(str))) return -1; @@ -716,8 +715,7 @@ if ((str_size = PyString_Size(str)) < 0) return -1; - Py_XDECREF(self->last_string); - self->last_string = str; + Py_SETREF(self->last_string, str); if (! (*s = PyString_AsString(str))) return -1; @@ -3228,9 +3226,8 @@ "attribute deletion is not supported"); return -1; } - Py_XDECREF(p->pers_func); Py_INCREF(v); - p->pers_func = v; + Py_SETREF(p->pers_func, v); return 0; } @@ -3242,9 +3239,8 @@ "attribute deletion is not supported"); return -1; } - Py_XDECREF(p->inst_pers_func); Py_INCREF(v); - p->inst_pers_func = v; + Py_SETREF(p->inst_pers_func, v); return 0; } @@ -3270,9 +3266,8 @@ PyErr_SetString(PyExc_TypeError, "memo must be a dictionary"); return -1; } - Py_XDECREF(p->memo); Py_INCREF(v); - p->memo = v; + Py_SETREF(p->memo, v); return 0; } @@ -5667,16 +5662,14 @@ { if (!strcmp(name, "persistent_load")) { - Py_XDECREF(self->pers_func); - self->pers_func = value; Py_XINCREF(value); + Py_SETREF(self->pers_func, value); return 0; } if (!strcmp(name, "find_global")) { - Py_XDECREF(self->find_class); - self->find_class = value; Py_XINCREF(value); + Py_SETREF(self->find_class, value); return 0; } @@ -5692,9 +5685,8 @@ "memo must be a dictionary"); return -1; } - Py_XDECREF(self->memo); - self->memo = value; Py_INCREF(value); + Py_SETREF(self->memo, value); return 0; } diff --git a/Modules/cdmodule.c b/Modules/cdmodule.c --- a/Modules/cdmodule.c +++ b/Modules/cdmodule.c @@ -628,12 +628,10 @@ CDsetcallback(self->ob_cdparser, (CDDATATYPES) type, CD_callback, (void *) self); #endif - Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallback); Py_INCREF(func); - self->ob_cdcallbacks[type].ob_cdcallback = func; - Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallbackarg); + Py_SETREF(self->ob_cdcallbacks[type].ob_cdcallback, func); Py_INCREF(funcarg); - self->ob_cdcallbacks[type].ob_cdcallbackarg = funcarg; + Py_SETREF(self->ob_cdcallbacks[type].ob_cdcallbackarg, funcarg); /* if (type == cd_audio) { diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -494,8 +494,7 @@ link = teedataobject_jumplink(to->dataobj); if (link == NULL) return NULL; - Py_DECREF(to->dataobj); - to->dataobj = (teedataobject *)link; + Py_SETREF(to->dataobj, (teedataobject *)link); to->index = 0; } value = teedataobject_getitem(to->dataobj, to->index); diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -621,8 +621,7 @@ if (Handlers[SIGINT].func == DefaultHandler) { /* Install default int handler */ Py_INCREF(IntHandler); - Py_DECREF(Handlers[SIGINT].func); - Handlers[SIGINT].func = IntHandler; + Py_SETREF(Handlers[SIGINT].func, IntHandler); old_siginthandler = PyOS_setsig(SIGINT, signal_handler); } diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -491,8 +491,7 @@ PyString_AS_STRING(self->unused_data), old_size); Py_MEMCPY(PyString_AS_STRING(new_data) + old_size, self->zst.next_in, self->zst.avail_in); - Py_DECREF(self->unused_data); - self->unused_data = new_data; + Py_SETREF(self->unused_data, new_data); self->zst.avail_in = 0; } } @@ -504,8 +503,7 @@ (char *)self->zst.next_in, self->zst.avail_in); if (new_data == NULL) return -1; - Py_DECREF(self->unconsumed_tail); - self->unconsumed_tail = new_data; + Py_SETREF(self->unconsumed_tail, new_data); } return 0; } diff --git a/Objects/descrobject.c b/Objects/descrobject.c --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1332,8 +1332,7 @@ PyObject *get_doc = PyObject_GetAttrString(get, "__doc__"); if (get_doc) { if (Py_TYPE(self) == &PyProperty_Type) { - Py_XDECREF(prop->prop_doc); - prop->prop_doc = get_doc; + Py_SETREF(prop->prop_doc, get_doc); } else { /* If this is a property subclass, put __doc__ diff --git a/Objects/exceptions.c b/Objects/exceptions.c --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -58,9 +58,8 @@ if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds)) return -1; - Py_DECREF(self->args); - self->args = args; - Py_INCREF(self->args); + Py_INCREF(args); + Py_SETREF(self->args, args); if (PyTuple_GET_SIZE(self->args) == 1) { Py_CLEAR(self->message); @@ -627,8 +626,7 @@ if (!subslice) return -1; - Py_DECREF(self->args); /* replacing args */ - self->args = subslice; + Py_SETREF(self->args, subslice); } return 0; } diff --git a/Objects/fileobject.c b/Objects/fileobject.c --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -574,10 +574,8 @@ oerrors = Py_None; Py_INCREF(Py_None); } - Py_DECREF(file->f_encoding); - file->f_encoding = str; - Py_DECREF(file->f_errors); - file->f_errors = oerrors; + Py_SETREF(file->f_encoding, str); + Py_SETREF(file->f_errors, oerrors); return 1; } diff --git a/Objects/frameobject.c b/Objects/frameobject.c --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -859,8 +859,7 @@ } } else if (values[j] != value) { Py_XINCREF(value); - Py_XDECREF(values[j]); - values[j] = value; + Py_SETREF(values[j], value); } Py_XDECREF(value); } diff --git a/Objects/funcobject.c b/Objects/funcobject.c --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -116,8 +116,7 @@ PyErr_SetString(PyExc_SystemError, "non-tuple default args"); return -1; } - Py_XDECREF(((PyFunctionObject *) op) -> func_defaults); - ((PyFunctionObject *) op) -> func_defaults = defaults; + Py_SETREF(((PyFunctionObject *)op)->func_defaults, defaults); return 0; } @@ -149,8 +148,7 @@ closure->ob_type->tp_name); return -1; } - Py_XDECREF(((PyFunctionObject *) op) -> func_closure); - ((PyFunctionObject *) op) -> func_closure = closure; + Py_SETREF(((PyFunctionObject *)op)->func_closure, closure); return 0; } @@ -430,8 +428,7 @@ if (name != Py_None) { Py_INCREF(name); - Py_DECREF(newfunc->func_name); - newfunc->func_name = name; + Py_SETREF(newfunc->func_name, name); } if (defaults != Py_None) { Py_INCREF(defaults); diff --git a/Objects/stringobject.c b/Objects/stringobject.c --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -3865,8 +3865,7 @@ return; } v = string_concat((PyStringObject *) *pv, w); - Py_DECREF(*pv); - *pv = v; + Py_SETREF(*pv, v); } void @@ -4751,8 +4750,7 @@ t = PyDict_GetItem(interned, (PyObject *)s); if (t) { Py_INCREF(t); - Py_DECREF(*p); - *p = t; + Py_SETREF(*p, t); return; } diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -166,9 +166,8 @@ are borrowed reference */ for (i = 0; i < (1 << MCACHE_SIZE_EXP); i++) { method_cache[i].value = NULL; - Py_XDECREF(method_cache[i].name); - method_cache[i].name = Py_None; Py_INCREF(Py_None); + Py_SETREF(method_cache[i].name, Py_None); } /* mark all version tags as invalid */ PyType_Modified(&PyBaseObject_Type); @@ -2527,8 +2526,7 @@ method_cache[h].version = type->tp_version_tag; method_cache[h].value = res; /* borrowed */ Py_INCREF(name); - Py_DECREF(method_cache[h].name); - method_cache[h].name = name; + Py_SETREF(method_cache[h].name, name); } return res; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -436,8 +436,7 @@ return -1; Py_UNICODE_COPY(w->str, v->str, length < v->length ? length : v->length); - Py_DECREF(*unicode); - *unicode = w; + Py_SETREF(*unicode, w); return 0; } diff --git a/Python/_warnings.c b/Python/_warnings.c --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -528,8 +528,7 @@ goto handle_error; } else if (!is_true) { - Py_DECREF(*filename); - *filename = PyString_FromString("__main__"); + Py_SETREF(*filename, PyString_FromString("__main__")); if (*filename == NULL) goto handle_error; } diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4360,8 +4360,7 @@ Py_INCREF(self); func = PyMethod_GET_FUNCTION(func); Py_INCREF(func); - Py_DECREF(*pfunc); - *pfunc = self; + Py_SETREF(*pfunc, self); na++; n++; } else diff --git a/Python/compile.c b/Python/compile.c --- a/Python/compile.c +++ b/Python/compile.c @@ -1455,9 +1455,8 @@ if (!compiler_enter_scope(c, s->v.ClassDef.name, (void *)s, s->lineno)) return 0; - Py_XDECREF(c->u->u_private); - c->u->u_private = s->v.ClassDef.name; - Py_INCREF(c->u->u_private); + Py_INCREF(s->v.ClassDef.name); + Py_SETREF(c->u->u_private, s->v.ClassDef.name); str = PyString_InternFromString("__name__"); if (!str || !compiler_nameop(c, str, Load)) { Py_XDECREF(str); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 24 03:40:34 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 24 Dec 2015 08:40:34 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIwNDQw?= =?utf-8?q?=3A_Massive_replacing_unsafe_attribute_setting_code_with_specia?= =?utf-8?q?l?= Message-ID: <20151224084034.9624.58769@psf.io> https://hg.python.org/cpython/rev/fd36d72f6030 changeset: 99669:fd36d72f6030 branch: 3.5 parent: 99666:105bf5dd93b8 user: Serhiy Storchaka date: Thu Dec 24 10:35:59 2015 +0200 summary: Issue #20440: Massive replacing unsafe attribute setting code with special macro Py_SETREF. files: Include/object.h | 26 +++++++++++++++ Misc/NEWS | 3 + Modules/_csv.c | 6 +-- Modules/_ctypes/_ctypes.c | 41 ++++++++--------------- Modules/_curses_panel.c | 5 +- Modules/_io/bytesio.c | 3 +- Modules/_sqlite/connection.c | 13 ++---- Modules/_sqlite/cursor.c | 13 ++---- Modules/_sre.c | 3 +- Modules/_ssl.c | 6 +-- Modules/faulthandler.c | 9 +--- Modules/itertoolsmodule.c | 3 +- Modules/signalmodule.c | 3 +- Modules/zipimport.c | 3 +- Modules/zlibmodule.c | 6 +-- Objects/bytesobject.c | 3 +- Objects/descrobject.c | 3 +- Objects/exceptions.c | 3 +- Objects/frameobject.c | 3 +- Objects/funcobject.c | 15 ++----- Objects/moduleobject.c | 3 +- Objects/rangeobject.c | 3 +- Objects/typeobject.c | 9 +--- Objects/unicodeobject.c | 12 ++---- Parser/tokenizer.c | 3 +- Python/_warnings.c | 3 +- Python/ceval.c | 6 +-- Python/compile.c | 3 +- 28 files changed, 92 insertions(+), 120 deletions(-) diff --git a/Include/object.h b/Include/object.h --- a/Include/object.h +++ b/Include/object.h @@ -846,6 +846,32 @@ Py_DECREF(_py_xdecref_tmp); \ } while (0) +#ifndef Py_LIMITED_API +/* Safely decref `op` and set `op` to `op2`. + * + * As in case of Py_CLEAR "the obvious" code can be deadly: + * + * Py_XDECREF(op); + * op = op2; + * + * The safe way is: + * + * Py_SETREF(op, op2); + * + * That arranges to set `op` to `op2` _before_ decref'ing, so that any code + * triggered as a side-effect of `op` getting torn down no longer believes + * `op` points to a valid object. + */ + +#define Py_SETREF(op, op2) \ + do { \ + PyObject *_py_tmp = (PyObject *)(op); \ + (op) = (op2); \ + Py_XDECREF(_py_tmp); \ + } while (0) + +#endif /* ifndef Py_LIMITED_API */ + /* These are provided as conveniences to Python runtime embedders, so that they can have object code that is not dependent on Python compilation flags. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #20440: Massive replacing unsafe attribute setting code with special + macro Py_SETREF. + - Issue #25766: Special method __bytes__() now works in str subclasses. - Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. diff --git a/Modules/_csv.c b/Modules/_csv.c --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -276,9 +276,8 @@ else { if (PyUnicode_READY(src) == -1) return -1; - Py_XDECREF(*target); Py_INCREF(src); - *target = src; + Py_SETREF(*target, src); } } return 0; @@ -784,8 +783,7 @@ static int parse_reset(ReaderObj *self) { - Py_XDECREF(self->fields); - self->fields = PyList_New(0); + Py_SETREF(self->fields, PyList_New(0)); if (self->fields == NULL) return -1; self->field_len = 0; diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -391,8 +391,7 @@ Py_DECREF((PyObject *)dict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)dict; + Py_SETREF(result->tp_dict, (PyObject *)dict); dict->format = _ctypes_alloc_format_string(NULL, "B"); if (dict->format == NULL) { Py_DECREF(result); @@ -871,8 +870,7 @@ return -1; } Py_INCREF(proto); - Py_XDECREF(stgdict->proto); - stgdict->proto = proto; + Py_SETREF(stgdict->proto, proto); return 0; } @@ -962,8 +960,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); return (PyObject *)result; } @@ -1406,8 +1403,7 @@ /* replace the class dict by our updated spam dict */ if (-1 == PyDict_Update((PyObject *)stgdict, result->tp_dict)) goto error; - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; /* steal the reference */ + Py_SETREF(result->tp_dict, (PyObject *)stgdict); /* steal the reference */ stgdict = NULL; /* Special case for character arrays. @@ -1820,8 +1816,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); return (PyObject *)result; } @@ -1949,8 +1944,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); /* Install from_param class methods in ctypes base classes. Overrides the PyCSimpleType_from_param generic method. @@ -2313,8 +2307,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); if (-1 == make_funcptrtype_dict(stgdict)) { Py_DECREF(result); @@ -2458,8 +2451,7 @@ return -1; } if (ob->b_objects == NULL || !PyDict_CheckExact(ob->b_objects)) { - Py_XDECREF(ob->b_objects); - ob->b_objects = keep; /* refcount consumed */ + Py_SETREF(ob->b_objects, keep); /* refcount consumed */ return 0; } key = unique_key(target, index); @@ -2962,9 +2954,8 @@ "the errcheck attribute must be callable"); return -1; } - Py_XDECREF(self->errcheck); Py_XINCREF(ob); - self->errcheck = ob; + Py_SETREF(self->errcheck, ob); return 0; } @@ -2993,9 +2984,8 @@ return -1; } Py_XDECREF(self->checker); - Py_XDECREF(self->restype); Py_INCREF(ob); - self->restype = ob; + Py_SETREF(self->restype, ob); self->checker = PyObject_GetAttrString(ob, "_check_retval_"); if (self->checker == NULL) PyErr_Clear(); @@ -3033,11 +3023,9 @@ converters = converters_from_argtypes(ob); if (!converters) return -1; - Py_XDECREF(self->converters); - self->converters = converters; - Py_XDECREF(self->argtypes); + Py_SETREF(self->converters, converters); Py_INCREF(ob); - self->argtypes = ob; + Py_SETREF(self->argtypes, ob); } return 0; } @@ -5164,9 +5152,8 @@ return -1; bself = (PyBaseExceptionObject *)self; - Py_DECREF(bself->args); - bself->args = args; - Py_INCREF(bself->args); + Py_INCREF(args); + Py_SETREF(bself->args, args); return 0; } diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -312,9 +312,8 @@ PyErr_SetString(_curses_panelstate_global->PyCursesError, "replace_panel() returned ERR"); return NULL; } - Py_DECREF(po->wo); - po->wo = temp; - Py_INCREF(po->wo); + Py_INCREF(temp); + Py_SETREF(po->wo, temp); Py_INCREF(Py_None); return Py_None; } diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -969,8 +969,7 @@ if (initvalue && initvalue != Py_None) { if (PyBytes_CheckExact(initvalue)) { Py_INCREF(initvalue); - Py_XDECREF(self->buf); - self->buf = initvalue; + Py_SETREF(self->buf, initvalue); self->string_size = PyBytes_GET_SIZE(initvalue); } else { diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -204,8 +204,8 @@ node = node->next; } - Py_DECREF(self->statement_cache); - self->statement_cache = (pysqlite_Cache*)PyObject_CallFunction((PyObject*)&pysqlite_CacheType, "O", self); + Py_SETREF(self->statement_cache, + (pysqlite_Cache *)PyObject_CallFunction((PyObject *)&pysqlite_CacheType, "O", self)); Py_DECREF(self); self->statement_cache->decref_factory = 0; } @@ -318,9 +318,8 @@ _pysqlite_drop_unused_cursor_references(self); if (cursor && self->row_factory != Py_None) { - Py_XDECREF(((pysqlite_Cursor*)cursor)->row_factory); Py_INCREF(self->row_factory); - ((pysqlite_Cursor*)cursor)->row_factory = self->row_factory; + Py_SETREF(((pysqlite_Cursor *)cursor)->row_factory, self->row_factory); } return cursor; @@ -795,8 +794,7 @@ } } - Py_DECREF(self->statements); - self->statements = new_list; + Py_SETREF(self->statements, new_list); } static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self) @@ -827,8 +825,7 @@ } } - Py_DECREF(self->cursors); - self->cursors = new_list; + Py_SETREF(self->cursors, new_list); } PyObject* pysqlite_connection_create_function(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -170,8 +170,7 @@ return 0; } - Py_XDECREF(self->row_cast_map); - self->row_cast_map = PyList_New(0); + Py_SETREF(self->row_cast_map, PyList_New(0)); for (i = 0; i < sqlite3_column_count(self->statement->st); i++) { converter = NULL; @@ -510,9 +509,8 @@ goto error; /* reset description and rowcount */ - Py_DECREF(self->description); Py_INCREF(Py_None); - self->description = Py_None; + Py_SETREF(self->description, Py_None); self->rowcount = -1L; func_args = PyTuple_New(1); @@ -537,8 +535,8 @@ } if (self->statement->in_use) { - Py_DECREF(self->statement); - self->statement = PyObject_New(pysqlite_Statement, &pysqlite_StatementType); + Py_SETREF(self->statement, + PyObject_New(pysqlite_Statement, &pysqlite_StatementType)); if (!self->statement) { goto error; } @@ -654,8 +652,7 @@ numcols = sqlite3_column_count(self->statement->st); Py_END_ALLOW_THREADS - Py_DECREF(self->description); - self->description = PyTuple_New(numcols); + Py_SETREF(self->description, PyTuple_New(numcols)); if (!self->description) { goto error; } diff --git a/Modules/_sre.c b/Modules/_sre.c --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -756,8 +756,7 @@ if (!copy) return 0; - Py_DECREF(*object); - *object = copy; + Py_SETREF(*object, copy); return 1; /* success */ } diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1589,8 +1589,7 @@ return -1; #else Py_INCREF(value); - Py_DECREF(self->ctx); - self->ctx = (PySSLContext *) value; + Py_SETREF(self->ctx, (PySSLContext *)value); SSL_set_SSL_CTX(self->ssl, self->ctx->ctx); #endif } else { @@ -1647,8 +1646,7 @@ static int PySSL_set_owner(PySSLSocket *self, PyObject *value, void *c) { - Py_XDECREF(self->owner); - self->owner = PyWeakref_NewRef(value, NULL); + Py_SETREF(self->owner, PyWeakref_NewRef(value, NULL)); if (self->owner == NULL) return -1; return 0; diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -380,9 +380,8 @@ if (tstate == NULL) return NULL; - Py_XDECREF(fatal_error.file); Py_XINCREF(file); - fatal_error.file = file; + Py_SETREF(fatal_error.file, file); fatal_error.fd = fd; fatal_error.all_threads = all_threads; fatal_error.interp = tstate->interp; @@ -599,9 +598,8 @@ /* Cancel previous thread, if running */ cancel_dump_traceback_later(); - Py_XDECREF(thread.file); Py_XINCREF(file); - thread.file = file; + Py_SETREF(thread.file, file); thread.fd = fd; thread.timeout_us = timeout_us; thread.repeat = repeat; @@ -778,9 +776,8 @@ user->previous = previous; } - Py_XDECREF(user->file); Py_XINCREF(file); - user->file = file; + Py_SETREF(user->file, file); user->fd = fd; user->all_threads = all_threads; user->chain = chain; diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -636,8 +636,7 @@ link = teedataobject_jumplink(to->dataobj); if (link == NULL) return NULL; - Py_DECREF(to->dataobj); - to->dataobj = (teedataobject *)link; + Py_SETREF(to->dataobj, (teedataobject *)link); to->index = 0; } value = teedataobject_getitem(to->dataobj, to->index); diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -1266,8 +1266,7 @@ if (Handlers[SIGINT].func == DefaultHandler) { /* Install default int handler */ Py_INCREF(IntHandler); - Py_DECREF(Handlers[SIGINT].func); - Handlers[SIGINT].func = IntHandler; + Py_SETREF(Handlers[SIGINT].func, IntHandler); old_siginthandler = PyOS_setsig(SIGINT, signal_handler); } diff --git a/Modules/zipimport.c b/Modules/zipimport.c --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -155,8 +155,7 @@ tmp = PyUnicode_FromFormat("%U%c", self->prefix, SEP); if (tmp == NULL) goto error; - Py_DECREF(self->prefix); - self->prefix = tmp; + Py_SETREF(self->prefix, tmp); } } else diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -667,8 +667,7 @@ PyBytes_AS_STRING(self->unused_data), old_size); Py_MEMCPY(PyBytes_AS_STRING(new_data) + old_size, self->zst.next_in, self->zst.avail_in); - Py_DECREF(self->unused_data); - self->unused_data = new_data; + Py_SETREF(self->unused_data, new_data); self->zst.avail_in = 0; } } @@ -680,8 +679,7 @@ (char *)self->zst.next_in, self->zst.avail_in); if (new_data == NULL) return -1; - Py_DECREF(self->unconsumed_tail); - self->unconsumed_tail = new_data; + Py_SETREF(self->unconsumed_tail, new_data); } return 0; } diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -3520,8 +3520,7 @@ /* Multiple references, need to create new object */ PyObject *v; v = bytes_concat(*pv, w); - Py_DECREF(*pv); - *pv = v; + Py_SETREF(*pv, v); } } diff --git a/Objects/descrobject.c b/Objects/descrobject.c --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1509,8 +1509,7 @@ PyObject *get_doc = _PyObject_GetAttrId(get, &PyId___doc__); if (get_doc) { if (Py_TYPE(self) == &PyProperty_Type) { - Py_XDECREF(prop->prop_doc); - prop->prop_doc = get_doc; + Py_SETREF(prop->prop_doc, get_doc); } else { /* If this is a property subclass, put __doc__ diff --git a/Objects/exceptions.c b/Objects/exceptions.c --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -236,8 +236,7 @@ } Py_XINCREF(tb); - Py_XDECREF(self->traceback); - self->traceback = tb; + Py_SETREF(self->traceback, tb); return 0; } diff --git a/Objects/frameobject.c b/Objects/frameobject.c --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -857,8 +857,7 @@ } } else if (values[j] != value) { Py_XINCREF(value); - Py_XDECREF(values[j]); - values[j] = value; + Py_SETREF(values[j], value); } Py_XDECREF(value); } diff --git a/Objects/funcobject.c b/Objects/funcobject.c --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -127,8 +127,7 @@ PyErr_SetString(PyExc_SystemError, "non-tuple default args"); return -1; } - Py_XDECREF(((PyFunctionObject *) op) -> func_defaults); - ((PyFunctionObject *) op) -> func_defaults = defaults; + Py_SETREF(((PyFunctionObject *)op)->func_defaults, defaults); return 0; } @@ -159,8 +158,7 @@ "non-dict keyword only default args"); return -1; } - Py_XDECREF(((PyFunctionObject *)op) -> func_kwdefaults); - ((PyFunctionObject *) op) -> func_kwdefaults = defaults; + Py_SETREF(((PyFunctionObject *)op)->func_kwdefaults, defaults); return 0; } @@ -192,8 +190,7 @@ closure->ob_type->tp_name); return -1; } - Py_XDECREF(((PyFunctionObject *) op) -> func_closure); - ((PyFunctionObject *) op) -> func_closure = closure; + Py_SETREF(((PyFunctionObject *)op)->func_closure, closure); return 0; } @@ -224,8 +221,7 @@ "non-dict annotations"); return -1; } - Py_XDECREF(((PyFunctionObject *)op) -> func_annotations); - ((PyFunctionObject *) op) -> func_annotations = annotations; + Py_SETREF(((PyFunctionObject *)op)->func_annotations, annotations); return 0; } @@ -531,8 +527,7 @@ if (name != Py_None) { Py_INCREF(name); - Py_DECREF(newfunc->func_name); - newfunc->func_name = name; + Py_SETREF(newfunc->func_name, name); } if (defaults != Py_None) { Py_INCREF(defaults); diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -69,8 +69,7 @@ return -1; if (PyUnicode_CheckExact(name)) { Py_INCREF(name); - Py_XDECREF(mod->md_name); - mod->md_name = name; + Py_SETREF(mod->md_name, name); } return 0; diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -1066,8 +1066,7 @@ result = PyNumber_Add(r->start, product); Py_DECREF(product); if (result) { - Py_DECREF(r->index); - r->index = new_index; + Py_SETREF(r->index, new_index); } else { Py_DECREF(new_index); diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -315,9 +315,8 @@ are borrowed reference */ for (i = 0; i < (1 << MCACHE_SIZE_EXP); i++) { method_cache[i].value = NULL; - Py_XDECREF(method_cache[i].name); - method_cache[i].name = Py_None; Py_INCREF(Py_None); + Py_SETREF(method_cache[i].name, Py_None); } /* mark all version tags as invalid */ PyType_Modified(&PyBaseObject_Type); @@ -462,8 +461,7 @@ et = (PyHeapTypeObject*)type; Py_INCREF(value); - Py_DECREF(et->ht_qualname); - et->ht_qualname = value; + Py_SETREF(et->ht_qualname, value); return 0; } @@ -2910,8 +2908,7 @@ else method_cache_misses++; #endif - Py_DECREF(method_cache[h].name); - method_cache[h].name = name; + Py_SETREF(method_cache[h].name, name); } return res; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1665,8 +1665,7 @@ _Py_INCREF_UNICODE_EMPTY(); if (!unicode_empty) return -1; - Py_DECREF(*p_unicode); - *p_unicode = unicode_empty; + Py_SETREF(*p_unicode, unicode_empty); return 0; } @@ -1674,8 +1673,7 @@ PyObject *copy = resize_copy(unicode, length); if (copy == NULL) return -1; - Py_DECREF(*p_unicode); - *p_unicode = copy; + Py_SETREF(*p_unicode, copy); return 0; } @@ -13322,8 +13320,7 @@ return -1; _PyUnicode_FastCopyCharacters(newbuffer, 0, writer->buffer, 0, writer->pos); - Py_DECREF(writer->buffer); - writer->buffer = newbuffer; + Py_SETREF(writer->buffer, newbuffer); } _PyUnicodeWriter_Update(writer); return 0; @@ -15009,8 +15006,7 @@ if (t) { Py_INCREF(t); - Py_DECREF(*p); - *p = t; + Py_SETREF(*p, t); return; } diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -524,9 +524,8 @@ if (stream == NULL) goto cleanup; - Py_XDECREF(tok->decoding_readline); readline = _PyObject_GetAttrId(stream, &PyId_readline); - tok->decoding_readline = readline; + Py_SETREF(tok->decoding_readline, readline); if (pos > 0) { if (PyObject_CallObject(readline, NULL) == NULL) { readline = NULL; diff --git a/Python/_warnings.c b/Python/_warnings.c --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -680,8 +680,7 @@ goto handle_error; } else if (!is_true) { - Py_DECREF(*filename); - *filename = PyUnicode_FromString("__main__"); + Py_SETREF(*filename, PyUnicode_FromString("__main__")); if (*filename == NULL) goto handle_error; } diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3214,8 +3214,7 @@ Py_INCREF(self); func = PyMethod_GET_FUNCTION(func); Py_INCREF(func); - Py_DECREF(*pfunc); - *pfunc = self; + Py_SETREF(*pfunc, self); na++; /* n++; */ } else @@ -4670,8 +4669,7 @@ Py_INCREF(self); func = PyMethod_GET_FUNCTION(func); Py_INCREF(func); - Py_DECREF(*pfunc); - *pfunc = self; + Py_SETREF(*pfunc, self); na++; n++; } else diff --git a/Python/compile.c b/Python/compile.c --- a/Python/compile.c +++ b/Python/compile.c @@ -1795,8 +1795,7 @@ { /* use the class name for name mangling */ Py_INCREF(s->v.ClassDef.name); - Py_XDECREF(c->u->u_private); - c->u->u_private = s->v.ClassDef.name; + Py_SETREF(c->u->u_private, s->v.ClassDef.name); /* load (global) __name__ ... */ str = PyUnicode_InternFromString("__name__"); if (!str || !compiler_nameop(c, str, Load)) { -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 24 03:40:34 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 24 Dec 2015 08:40:34 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2320440=3A_Massive_replacing_unsafe_attribute_set?= =?utf-8?q?ting_code_with_special?= Message-ID: <20151224084034.21394.33304@psf.io> https://hg.python.org/cpython/rev/c4e8751ce637 changeset: 99670:c4e8751ce637 parent: 99667:92760d2edc9e parent: 99669:fd36d72f6030 user: Serhiy Storchaka date: Thu Dec 24 10:39:57 2015 +0200 summary: Issue #20440: Massive replacing unsafe attribute setting code with special macro Py_SETREF. files: Include/object.h | 26 +++++++++++++++ Misc/NEWS | 3 + Modules/_csv.c | 6 +-- Modules/_ctypes/_ctypes.c | 41 ++++++++--------------- Modules/_curses_panel.c | 5 +- Modules/_io/bytesio.c | 3 +- Modules/_sqlite/connection.c | 13 ++---- Modules/_sqlite/cursor.c | 13 ++---- Modules/_sre.c | 3 +- Modules/_ssl.c | 6 +-- Modules/faulthandler.c | 9 +--- Modules/itertoolsmodule.c | 3 +- Modules/signalmodule.c | 3 +- Modules/zipimport.c | 3 +- Modules/zlibmodule.c | 6 +-- Objects/bytesobject.c | 3 +- Objects/descrobject.c | 3 +- Objects/exceptions.c | 3 +- Objects/frameobject.c | 3 +- Objects/funcobject.c | 15 ++----- Objects/moduleobject.c | 3 +- Objects/rangeobject.c | 3 +- Objects/typeobject.c | 9 +--- Objects/unicodeobject.c | 12 ++---- Parser/tokenizer.c | 3 +- Python/_warnings.c | 3 +- Python/ceval.c | 6 +-- Python/compile.c | 3 +- 28 files changed, 92 insertions(+), 120 deletions(-) diff --git a/Include/object.h b/Include/object.h --- a/Include/object.h +++ b/Include/object.h @@ -846,6 +846,32 @@ Py_DECREF(_py_xdecref_tmp); \ } while (0) +#ifndef Py_LIMITED_API +/* Safely decref `op` and set `op` to `op2`. + * + * As in case of Py_CLEAR "the obvious" code can be deadly: + * + * Py_XDECREF(op); + * op = op2; + * + * The safe way is: + * + * Py_SETREF(op, op2); + * + * That arranges to set `op` to `op2` _before_ decref'ing, so that any code + * triggered as a side-effect of `op` getting torn down no longer believes + * `op` points to a valid object. + */ + +#define Py_SETREF(op, op2) \ + do { \ + PyObject *_py_tmp = (PyObject *)(op); \ + (op) = (op2); \ + Py_XDECREF(_py_tmp); \ + } while (0) + +#endif /* ifndef Py_LIMITED_API */ + /* These are provided as conveniences to Python runtime embedders, so that they can have object code that is not dependent on Python compilation flags. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #20440: Massive replacing unsafe attribute setting code with special + macro Py_SETREF. + - Issue #25766: Special method __bytes__() now works in str subclasses. - Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. diff --git a/Modules/_csv.c b/Modules/_csv.c --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -276,9 +276,8 @@ else { if (PyUnicode_READY(src) == -1) return -1; - Py_XDECREF(*target); Py_INCREF(src); - *target = src; + Py_SETREF(*target, src); } } return 0; @@ -784,8 +783,7 @@ static int parse_reset(ReaderObj *self) { - Py_XDECREF(self->fields); - self->fields = PyList_New(0); + Py_SETREF(self->fields, PyList_New(0)); if (self->fields == NULL) return -1; self->field_len = 0; diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -391,8 +391,7 @@ Py_DECREF((PyObject *)dict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)dict; + Py_SETREF(result->tp_dict, (PyObject *)dict); dict->format = _ctypes_alloc_format_string(NULL, "B"); if (dict->format == NULL) { Py_DECREF(result); @@ -871,8 +870,7 @@ return -1; } Py_INCREF(proto); - Py_XDECREF(stgdict->proto); - stgdict->proto = proto; + Py_SETREF(stgdict->proto, proto); return 0; } @@ -962,8 +960,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); return (PyObject *)result; } @@ -1406,8 +1403,7 @@ /* replace the class dict by our updated spam dict */ if (-1 == PyDict_Update((PyObject *)stgdict, result->tp_dict)) goto error; - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; /* steal the reference */ + Py_SETREF(result->tp_dict, (PyObject *)stgdict); /* steal the reference */ stgdict = NULL; /* Special case for character arrays. @@ -1820,8 +1816,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); return (PyObject *)result; } @@ -1949,8 +1944,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); /* Install from_param class methods in ctypes base classes. Overrides the PyCSimpleType_from_param generic method. @@ -2313,8 +2307,7 @@ Py_DECREF((PyObject *)stgdict); return NULL; } - Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + Py_SETREF(result->tp_dict, (PyObject *)stgdict); if (-1 == make_funcptrtype_dict(stgdict)) { Py_DECREF(result); @@ -2458,8 +2451,7 @@ return -1; } if (ob->b_objects == NULL || !PyDict_CheckExact(ob->b_objects)) { - Py_XDECREF(ob->b_objects); - ob->b_objects = keep; /* refcount consumed */ + Py_SETREF(ob->b_objects, keep); /* refcount consumed */ return 0; } key = unique_key(target, index); @@ -2962,9 +2954,8 @@ "the errcheck attribute must be callable"); return -1; } - Py_XDECREF(self->errcheck); Py_XINCREF(ob); - self->errcheck = ob; + Py_SETREF(self->errcheck, ob); return 0; } @@ -2993,9 +2984,8 @@ return -1; } Py_XDECREF(self->checker); - Py_XDECREF(self->restype); Py_INCREF(ob); - self->restype = ob; + Py_SETREF(self->restype, ob); self->checker = PyObject_GetAttrString(ob, "_check_retval_"); if (self->checker == NULL) PyErr_Clear(); @@ -3033,11 +3023,9 @@ converters = converters_from_argtypes(ob); if (!converters) return -1; - Py_XDECREF(self->converters); - self->converters = converters; - Py_XDECREF(self->argtypes); + Py_SETREF(self->converters, converters); Py_INCREF(ob); - self->argtypes = ob; + Py_SETREF(self->argtypes, ob); } return 0; } @@ -5164,9 +5152,8 @@ return -1; bself = (PyBaseExceptionObject *)self; - Py_DECREF(bself->args); - bself->args = args; - Py_INCREF(bself->args); + Py_INCREF(args); + Py_SETREF(bself->args, args); return 0; } diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -312,9 +312,8 @@ PyErr_SetString(_curses_panelstate_global->PyCursesError, "replace_panel() returned ERR"); return NULL; } - Py_DECREF(po->wo); - po->wo = temp; - Py_INCREF(po->wo); + Py_INCREF(temp); + Py_SETREF(po->wo, temp); Py_INCREF(Py_None); return Py_None; } diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -969,8 +969,7 @@ if (initvalue && initvalue != Py_None) { if (PyBytes_CheckExact(initvalue)) { Py_INCREF(initvalue); - Py_XDECREF(self->buf); - self->buf = initvalue; + Py_SETREF(self->buf, initvalue); self->string_size = PyBytes_GET_SIZE(initvalue); } else { diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -204,8 +204,8 @@ node = node->next; } - Py_DECREF(self->statement_cache); - self->statement_cache = (pysqlite_Cache*)PyObject_CallFunction((PyObject*)&pysqlite_CacheType, "O", self); + Py_SETREF(self->statement_cache, + (pysqlite_Cache *)PyObject_CallFunction((PyObject *)&pysqlite_CacheType, "O", self)); Py_DECREF(self); self->statement_cache->decref_factory = 0; } @@ -318,9 +318,8 @@ _pysqlite_drop_unused_cursor_references(self); if (cursor && self->row_factory != Py_None) { - Py_XDECREF(((pysqlite_Cursor*)cursor)->row_factory); Py_INCREF(self->row_factory); - ((pysqlite_Cursor*)cursor)->row_factory = self->row_factory; + Py_SETREF(((pysqlite_Cursor *)cursor)->row_factory, self->row_factory); } return cursor; @@ -795,8 +794,7 @@ } } - Py_DECREF(self->statements); - self->statements = new_list; + Py_SETREF(self->statements, new_list); } static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self) @@ -827,8 +825,7 @@ } } - Py_DECREF(self->cursors); - self->cursors = new_list; + Py_SETREF(self->cursors, new_list); } PyObject* pysqlite_connection_create_function(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -170,8 +170,7 @@ return 0; } - Py_XDECREF(self->row_cast_map); - self->row_cast_map = PyList_New(0); + Py_SETREF(self->row_cast_map, PyList_New(0)); for (i = 0; i < sqlite3_column_count(self->statement->st); i++) { converter = NULL; @@ -510,9 +509,8 @@ goto error; /* reset description and rowcount */ - Py_DECREF(self->description); Py_INCREF(Py_None); - self->description = Py_None; + Py_SETREF(self->description, Py_None); self->rowcount = -1L; func_args = PyTuple_New(1); @@ -537,8 +535,8 @@ } if (self->statement->in_use) { - Py_DECREF(self->statement); - self->statement = PyObject_New(pysqlite_Statement, &pysqlite_StatementType); + Py_SETREF(self->statement, + PyObject_New(pysqlite_Statement, &pysqlite_StatementType)); if (!self->statement) { goto error; } @@ -654,8 +652,7 @@ numcols = sqlite3_column_count(self->statement->st); Py_END_ALLOW_THREADS - Py_DECREF(self->description); - self->description = PyTuple_New(numcols); + Py_SETREF(self->description, PyTuple_New(numcols)); if (!self->description) { goto error; } diff --git a/Modules/_sre.c b/Modules/_sre.c --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -753,8 +753,7 @@ if (!copy) return 0; - Py_DECREF(*object); - *object = copy; + Py_SETREF(*object, copy); return 1; /* success */ } diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1589,8 +1589,7 @@ return -1; #else Py_INCREF(value); - Py_DECREF(self->ctx); - self->ctx = (PySSLContext *) value; + Py_SETREF(self->ctx, (PySSLContext *)value); SSL_set_SSL_CTX(self->ssl, self->ctx->ctx); #endif } else { @@ -1647,8 +1646,7 @@ static int PySSL_set_owner(PySSLSocket *self, PyObject *value, void *c) { - Py_XDECREF(self->owner); - self->owner = PyWeakref_NewRef(value, NULL); + Py_SETREF(self->owner, PyWeakref_NewRef(value, NULL)); if (self->owner == NULL) return -1; return 0; diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -380,9 +380,8 @@ if (tstate == NULL) return NULL; - Py_XDECREF(fatal_error.file); Py_XINCREF(file); - fatal_error.file = file; + Py_SETREF(fatal_error.file, file); fatal_error.fd = fd; fatal_error.all_threads = all_threads; fatal_error.interp = tstate->interp; @@ -599,9 +598,8 @@ /* Cancel previous thread, if running */ cancel_dump_traceback_later(); - Py_XDECREF(thread.file); Py_XINCREF(file); - thread.file = file; + Py_SETREF(thread.file, file); thread.fd = fd; thread.timeout_us = timeout_us; thread.repeat = repeat; @@ -778,9 +776,8 @@ user->previous = previous; } - Py_XDECREF(user->file); Py_XINCREF(file); - user->file = file; + Py_SETREF(user->file, file); user->fd = fd; user->all_threads = all_threads; user->chain = chain; diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -634,8 +634,7 @@ link = teedataobject_jumplink(to->dataobj); if (link == NULL) return NULL; - Py_DECREF(to->dataobj); - to->dataobj = (teedataobject *)link; + Py_SETREF(to->dataobj, (teedataobject *)link); to->index = 0; } value = teedataobject_getitem(to->dataobj, to->index); diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -1266,8 +1266,7 @@ if (Handlers[SIGINT].func == DefaultHandler) { /* Install default int handler */ Py_INCREF(IntHandler); - Py_DECREF(Handlers[SIGINT].func); - Handlers[SIGINT].func = IntHandler; + Py_SETREF(Handlers[SIGINT].func, IntHandler); old_siginthandler = PyOS_setsig(SIGINT, signal_handler); } diff --git a/Modules/zipimport.c b/Modules/zipimport.c --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -155,8 +155,7 @@ tmp = PyUnicode_FromFormat("%U%c", self->prefix, SEP); if (tmp == NULL) goto error; - Py_DECREF(self->prefix); - self->prefix = tmp; + Py_SETREF(self->prefix, tmp); } } else diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -667,8 +667,7 @@ PyBytes_AS_STRING(self->unused_data), old_size); Py_MEMCPY(PyBytes_AS_STRING(new_data) + old_size, self->zst.next_in, self->zst.avail_in); - Py_DECREF(self->unused_data); - self->unused_data = new_data; + Py_SETREF(self->unused_data, new_data); self->zst.avail_in = 0; } } @@ -680,8 +679,7 @@ (char *)self->zst.next_in, self->zst.avail_in); if (new_data == NULL) return -1; - Py_DECREF(self->unconsumed_tail); - self->unconsumed_tail = new_data; + Py_SETREF(self->unconsumed_tail, new_data); } return 0; } diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -3688,8 +3688,7 @@ /* Multiple references, need to create new object */ PyObject *v; v = bytes_concat(*pv, w); - Py_DECREF(*pv); - *pv = v; + Py_SETREF(*pv, v); } } diff --git a/Objects/descrobject.c b/Objects/descrobject.c --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1509,8 +1509,7 @@ PyObject *get_doc = _PyObject_GetAttrId(get, &PyId___doc__); if (get_doc) { if (Py_TYPE(self) == &PyProperty_Type) { - Py_XDECREF(prop->prop_doc); - prop->prop_doc = get_doc; + Py_SETREF(prop->prop_doc, get_doc); } else { /* If this is a property subclass, put __doc__ diff --git a/Objects/exceptions.c b/Objects/exceptions.c --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -236,8 +236,7 @@ } Py_XINCREF(tb); - Py_XDECREF(self->traceback); - self->traceback = tb; + Py_SETREF(self->traceback, tb); return 0; } diff --git a/Objects/frameobject.c b/Objects/frameobject.c --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -857,8 +857,7 @@ } } else if (values[j] != value) { Py_XINCREF(value); - Py_XDECREF(values[j]); - values[j] = value; + Py_SETREF(values[j], value); } Py_XDECREF(value); } diff --git a/Objects/funcobject.c b/Objects/funcobject.c --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -127,8 +127,7 @@ PyErr_SetString(PyExc_SystemError, "non-tuple default args"); return -1; } - Py_XDECREF(((PyFunctionObject *) op) -> func_defaults); - ((PyFunctionObject *) op) -> func_defaults = defaults; + Py_SETREF(((PyFunctionObject *)op)->func_defaults, defaults); return 0; } @@ -159,8 +158,7 @@ "non-dict keyword only default args"); return -1; } - Py_XDECREF(((PyFunctionObject *)op) -> func_kwdefaults); - ((PyFunctionObject *) op) -> func_kwdefaults = defaults; + Py_SETREF(((PyFunctionObject *)op)->func_kwdefaults, defaults); return 0; } @@ -192,8 +190,7 @@ closure->ob_type->tp_name); return -1; } - Py_XDECREF(((PyFunctionObject *) op) -> func_closure); - ((PyFunctionObject *) op) -> func_closure = closure; + Py_SETREF(((PyFunctionObject *)op)->func_closure, closure); return 0; } @@ -224,8 +221,7 @@ "non-dict annotations"); return -1; } - Py_XDECREF(((PyFunctionObject *)op) -> func_annotations); - ((PyFunctionObject *) op) -> func_annotations = annotations; + Py_SETREF(((PyFunctionObject *)op)->func_annotations, annotations); return 0; } @@ -531,8 +527,7 @@ if (name != Py_None) { Py_INCREF(name); - Py_DECREF(newfunc->func_name); - newfunc->func_name = name; + Py_SETREF(newfunc->func_name, name); } if (defaults != Py_None) { Py_INCREF(defaults); diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -69,8 +69,7 @@ return -1; if (PyUnicode_CheckExact(name)) { Py_INCREF(name); - Py_XDECREF(mod->md_name); - mod->md_name = name; + Py_SETREF(mod->md_name, name); } return 0; diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -1066,8 +1066,7 @@ result = PyNumber_Add(r->start, product); Py_DECREF(product); if (result) { - Py_DECREF(r->index); - r->index = new_index; + Py_SETREF(r->index, new_index); } else { Py_DECREF(new_index); diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -315,9 +315,8 @@ are borrowed reference */ for (i = 0; i < (1 << MCACHE_SIZE_EXP); i++) { method_cache[i].value = NULL; - Py_XDECREF(method_cache[i].name); - method_cache[i].name = Py_None; Py_INCREF(Py_None); + Py_SETREF(method_cache[i].name, Py_None); } /* mark all version tags as invalid */ PyType_Modified(&PyBaseObject_Type); @@ -462,8 +461,7 @@ et = (PyHeapTypeObject*)type; Py_INCREF(value); - Py_DECREF(et->ht_qualname); - et->ht_qualname = value; + Py_SETREF(et->ht_qualname, value); return 0; } @@ -2918,8 +2916,7 @@ else method_cache_misses++; #endif - Py_DECREF(method_cache[h].name); - method_cache[h].name = name; + Py_SETREF(method_cache[h].name, name); } return res; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1828,8 +1828,7 @@ _Py_INCREF_UNICODE_EMPTY(); if (!unicode_empty) return -1; - Py_DECREF(*p_unicode); - *p_unicode = unicode_empty; + Py_SETREF(*p_unicode, unicode_empty); return 0; } @@ -1837,8 +1836,7 @@ PyObject *copy = resize_copy(unicode, length); if (copy == NULL) return -1; - Py_DECREF(*p_unicode); - *p_unicode = copy; + Py_SETREF(*p_unicode, copy); return 0; } @@ -13543,8 +13541,7 @@ return -1; _PyUnicode_FastCopyCharacters(newbuffer, 0, writer->buffer, 0, writer->pos); - Py_DECREF(writer->buffer); - writer->buffer = newbuffer; + Py_SETREF(writer->buffer, newbuffer); } _PyUnicodeWriter_Update(writer); return 0; @@ -15261,8 +15258,7 @@ if (t) { Py_INCREF(t); - Py_DECREF(*p); - *p = t; + Py_SETREF(*p, t); return; } diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -524,9 +524,8 @@ if (stream == NULL) goto cleanup; - Py_XDECREF(tok->decoding_readline); readline = _PyObject_GetAttrId(stream, &PyId_readline); - tok->decoding_readline = readline; + Py_SETREF(tok->decoding_readline, readline); if (pos > 0) { if (PyObject_CallObject(readline, NULL) == NULL) { readline = NULL; diff --git a/Python/_warnings.c b/Python/_warnings.c --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -680,8 +680,7 @@ goto handle_error; } else if (!is_true) { - Py_DECREF(*filename); - *filename = PyUnicode_FromString("__main__"); + Py_SETREF(*filename, PyUnicode_FromString("__main__")); if (*filename == NULL) goto handle_error; } diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3221,8 +3221,7 @@ Py_INCREF(self); func = PyMethod_GET_FUNCTION(func); Py_INCREF(func); - Py_DECREF(*pfunc); - *pfunc = self; + Py_SETREF(*pfunc, self); na++; /* n++; */ } else @@ -4734,8 +4733,7 @@ Py_INCREF(self); func = PyMethod_GET_FUNCTION(func); Py_INCREF(func); - Py_DECREF(*pfunc); - *pfunc = self; + Py_SETREF(*pfunc, self); na++; n++; } else diff --git a/Python/compile.c b/Python/compile.c --- a/Python/compile.c +++ b/Python/compile.c @@ -1800,8 +1800,7 @@ { /* use the class name for name mangling */ Py_INCREF(s->v.ClassDef.name); - Py_XDECREF(c->u->u_private); - c->u->u_private = s->v.ClassDef.name; + Py_SETREF(c->u->u_private, s->v.ClassDef.name); /* load (global) __name__ ... */ str = PyUnicode_InternFromString("__name__"); if (!str || !compiler_nameop(c, str, Load)) { -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Thu Dec 24 03:48:57 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 24 Dec 2015 08:48:57 +0000 Subject: [Python-checkins] Daily reference leaks (92760d2edc9e): sum=4 Message-ID: <20151224084857.21219.40968@psf.io> results for 92760d2edc9e on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogxOz39J', '--timeout', '7200'] From python-checkins at python.org Thu Dec 24 04:53:55 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 24 Dec 2015 09:53:55 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI0MTAz?= =?utf-8?q?=3A_Fixed_possible_use_after_free_in_ElementTree=2EXMLPullParse?= =?utf-8?q?r=2E?= Message-ID: <20151224095355.77235.12645@psf.io> https://hg.python.org/cpython/rev/ed62cf0cf256 changeset: 99672:ed62cf0cf256 branch: 3.5 parent: 99669:fd36d72f6030 user: Serhiy Storchaka date: Thu Dec 24 11:51:57 2015 +0200 summary: Issue #24103: Fixed possible use after free in ElementTree.XMLPullParser. files: Misc/NEWS | 2 + Modules/_elementtree.c | 32 ++++++++++++----------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -31,6 +31,8 @@ Library ------- +- Issue #24103: Fixed possible use after free in ElementTree.XMLPullParser. + - Issue #25860: os.fwalk() no longer skips remaining directories when error occurs. Original patch by Samson Lee. diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -3598,7 +3598,7 @@ /*[clinic end generated code: output=1440092922b13ed1 input=59db9742910c6174]*/ { /* activate element event reporting */ - Py_ssize_t i, seqlen; + Py_ssize_t i; TreeBuilderObject *target; PyObject *events_seq; @@ -3614,8 +3614,7 @@ target = (TreeBuilderObject*) self->target; Py_INCREF(events_queue); - Py_XDECREF(target->events); - target->events = events_queue; + Py_SETREF(target->events, events_queue); /* clear out existing events */ Py_CLEAR(target->start_event_obj); @@ -3634,46 +3633,41 @@ return NULL; } - seqlen = PySequence_Size(events_seq); - for (i = 0; i < seqlen; ++i) { + for (i = 0; i < PySequence_Size(events_seq); ++i) { PyObject *event_name_obj = PySequence_Fast_GET_ITEM(events_seq, i); char *event_name = NULL; if (PyUnicode_Check(event_name_obj)) { - event_name = _PyUnicode_AsString(event_name_obj); + event_name = PyUnicode_AsUTF8(event_name_obj); } else if (PyBytes_Check(event_name_obj)) { event_name = PyBytes_AS_STRING(event_name_obj); } - if (event_name == NULL) { Py_DECREF(events_seq); PyErr_Format(PyExc_ValueError, "invalid events sequence"); return NULL; - } else if (strcmp(event_name, "start") == 0) { - Py_INCREF(event_name_obj); - target->start_event_obj = event_name_obj; + } + + Py_INCREF(event_name_obj); + if (strcmp(event_name, "start") == 0) { + Py_SETREF(target->start_event_obj, event_name_obj); } else if (strcmp(event_name, "end") == 0) { - Py_INCREF(event_name_obj); - Py_XDECREF(target->end_event_obj); - target->end_event_obj = event_name_obj; + Py_SETREF(target->end_event_obj, event_name_obj); } else if (strcmp(event_name, "start-ns") == 0) { - Py_INCREF(event_name_obj); - Py_XDECREF(target->start_ns_event_obj); - target->start_ns_event_obj = event_name_obj; + Py_SETREF(target->start_ns_event_obj, event_name_obj); EXPAT(SetNamespaceDeclHandler)( self->parser, (XML_StartNamespaceDeclHandler) expat_start_ns_handler, (XML_EndNamespaceDeclHandler) expat_end_ns_handler ); } else if (strcmp(event_name, "end-ns") == 0) { - Py_INCREF(event_name_obj); - Py_XDECREF(target->end_ns_event_obj); - target->end_ns_event_obj = event_name_obj; + Py_SETREF(target->end_ns_event_obj, event_name_obj); EXPAT(SetNamespaceDeclHandler)( self->parser, (XML_StartNamespaceDeclHandler) expat_start_ns_handler, (XML_EndNamespaceDeclHandler) expat_end_ns_handler ); } else { + Py_DECREF(event_name_obj); Py_DECREF(events_seq); PyErr_Format(PyExc_ValueError, "unknown event '%s'", event_name); return NULL; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 24 04:53:55 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 24 Dec 2015 09:53:55 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI0MTAz?= =?utf-8?q?=3A_Fixed_possible_use_after_free_in_ElementTree=2Eiterparse=28?= =?utf-8?b?KS4=?= Message-ID: <20151224095355.105554.47344@psf.io> https://hg.python.org/cpython/rev/deda5b5160d2 changeset: 99671:deda5b5160d2 branch: 2.7 parent: 99668:23296440b654 user: Serhiy Storchaka date: Thu Dec 24 11:51:24 2015 +0200 summary: Issue #24103: Fixed possible use after free in ElementTree.iterparse(). files: Misc/NEWS | 2 ++ Modules/_elementtree.c | 20 +++++++------------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -29,6 +29,8 @@ Library ------- +- Issue #24103: Fixed possible use after free in ElementTree.iterparse(). + - Issue #20954: _args_from_interpreter_flags used by multiprocessing and some tests no longer behaves incorrectly in the presence of the PYTHONHASHSEED environment variable. diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2751,8 +2751,7 @@ target = (TreeBuilderObject*) self->target; Py_INCREF(events); - Py_XDECREF(target->events); - target->events = events; + Py_SETREF(target->events, events); /* clear out existing events */ Py_CLEAR(target->start_event_obj); @@ -2774,33 +2773,28 @@ char* event; if (!PyString_Check(item)) goto error; + Py_INCREF(item); event = PyString_AS_STRING(item); if (strcmp(event, "start") == 0) { - Py_INCREF(item); - target->start_event_obj = item; + Py_SETREF(target->start_event_obj, item); } else if (strcmp(event, "end") == 0) { - Py_INCREF(item); - Py_XDECREF(target->end_event_obj); - target->end_event_obj = item; + Py_SETREF(target->end_event_obj, item); } else if (strcmp(event, "start-ns") == 0) { - Py_INCREF(item); - Py_XDECREF(target->start_ns_event_obj); - target->start_ns_event_obj = item; + Py_SETREF(target->start_ns_event_obj, item); EXPAT(SetNamespaceDeclHandler)( self->parser, (XML_StartNamespaceDeclHandler) expat_start_ns_handler, (XML_EndNamespaceDeclHandler) expat_end_ns_handler ); } else if (strcmp(event, "end-ns") == 0) { - Py_INCREF(item); - Py_XDECREF(target->end_ns_event_obj); - target->end_ns_event_obj = item; + Py_SETREF(target->end_ns_event_obj, item); EXPAT(SetNamespaceDeclHandler)( self->parser, (XML_StartNamespaceDeclHandler) expat_start_ns_handler, (XML_EndNamespaceDeclHandler) expat_end_ns_handler ); } else { + Py_DECREF(item); PyErr_Format( PyExc_ValueError, "unknown event '%s'", event -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 24 04:53:55 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 24 Dec 2015 09:53:55 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2324103=3A_Fixed_possible_use_after_free_in_Eleme?= =?utf-8?q?ntTree=2EXMLPullParser=2E?= Message-ID: <20151224095355.21378.61322@psf.io> https://hg.python.org/cpython/rev/8a14af800f96 changeset: 99673:8a14af800f96 parent: 99670:c4e8751ce637 parent: 99672:ed62cf0cf256 user: Serhiy Storchaka date: Thu Dec 24 11:53:16 2015 +0200 summary: Issue #24103: Fixed possible use after free in ElementTree.XMLPullParser. files: Misc/NEWS | 2 + Modules/_elementtree.c | 32 ++++++++++++----------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -118,6 +118,8 @@ Library ------- +- Issue #24103: Fixed possible use after free in ElementTree.XMLPullParser. + - Issue #25860: os.fwalk() no longer skips remaining directories when error occurs. Original patch by Samson Lee. diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -3581,7 +3581,7 @@ /*[clinic end generated code: output=1440092922b13ed1 input=abf90830a1c3b0fc]*/ { /* activate element event reporting */ - Py_ssize_t i, seqlen; + Py_ssize_t i; TreeBuilderObject *target; PyObject *events_append, *events_seq; @@ -3599,8 +3599,7 @@ events_append = PyObject_GetAttrString(events_queue, "append"); if (events_append == NULL) return NULL; - Py_XDECREF(target->events_append); - target->events_append = events_append; + Py_SETREF(target->events_append, events_append); /* clear out existing events */ Py_CLEAR(target->start_event_obj); @@ -3619,46 +3618,41 @@ return NULL; } - seqlen = PySequence_Size(events_seq); - for (i = 0; i < seqlen; ++i) { + for (i = 0; i < PySequence_Size(events_seq); ++i) { PyObject *event_name_obj = PySequence_Fast_GET_ITEM(events_seq, i); char *event_name = NULL; if (PyUnicode_Check(event_name_obj)) { - event_name = _PyUnicode_AsString(event_name_obj); + event_name = PyUnicode_AsUTF8(event_name_obj); } else if (PyBytes_Check(event_name_obj)) { event_name = PyBytes_AS_STRING(event_name_obj); } - if (event_name == NULL) { Py_DECREF(events_seq); PyErr_Format(PyExc_ValueError, "invalid events sequence"); return NULL; - } else if (strcmp(event_name, "start") == 0) { - Py_INCREF(event_name_obj); - target->start_event_obj = event_name_obj; + } + + Py_INCREF(event_name_obj); + if (strcmp(event_name, "start") == 0) { + Py_SETREF(target->start_event_obj, event_name_obj); } else if (strcmp(event_name, "end") == 0) { - Py_INCREF(event_name_obj); - Py_XDECREF(target->end_event_obj); - target->end_event_obj = event_name_obj; + Py_SETREF(target->end_event_obj, event_name_obj); } else if (strcmp(event_name, "start-ns") == 0) { - Py_INCREF(event_name_obj); - Py_XDECREF(target->start_ns_event_obj); - target->start_ns_event_obj = event_name_obj; + Py_SETREF(target->start_ns_event_obj, event_name_obj); EXPAT(SetNamespaceDeclHandler)( self->parser, (XML_StartNamespaceDeclHandler) expat_start_ns_handler, (XML_EndNamespaceDeclHandler) expat_end_ns_handler ); } else if (strcmp(event_name, "end-ns") == 0) { - Py_INCREF(event_name_obj); - Py_XDECREF(target->end_ns_event_obj); - target->end_ns_event_obj = event_name_obj; + Py_SETREF(target->end_ns_event_obj, event_name_obj); EXPAT(SetNamespaceDeclHandler)( self->parser, (XML_StartNamespaceDeclHandler) expat_start_ns_handler, (XML_EndNamespaceDeclHandler) expat_end_ns_handler ); } else { + Py_DECREF(event_name_obj); Py_DECREF(events_seq); PyErr_Format(PyExc_ValueError, "unknown event '%s'", event_name); return NULL; -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Thu Dec 24 07:55:33 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 24 Dec 2015 12:55:33 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-24 Message-ID: Results for project Python default, build date 2015-12-24 03:04:45 +0000 commit: 92760d2edc9ec8407f844320bfe4988e8ca8e1de previous commit: dcf9e9ae53936e779b99b2d120f2f004f902bc62 revision date: 2015-12-24 02:19:53 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.43% -0.18% 10.53% 14.90% :-| pybench 0.12% -0.07% -1.53% 5.96% :-( regex_v8 2.77% -0.01% -3.92% 4.65% :-| nbody 0.61% 0.05% 1.55% 3.24% :-| json_dump_v2 0.27% 0.12% -1.42% 11.07% :-| normal_startup 1.07% -0.00% -1.90% 5.15% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) Note: Benchmark results are measured in seconds. Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Thu Dec 24 07:56:35 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 24 Dec 2015 12:56:35 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-24 Message-ID: <7dd408e7-694e-47ef-8f87-2733aa6d1fad@irsmsx101.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python 2.7, build date 2015-12-24 03:58:09 +0000 commit: d7b5c2f99a99414eb8698f38444de4b6f5463eb2 previous commit: b87fe3e4a3d87e855e8e640da0d9a99ec3b7bd95 revision date: 2015-12-21 17:43:03 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.45% -0.49% 3.86% 5.58% :-) pybench 0.15% 0.08% 6.33% 3.74% :-( regex_v8 1.05% -0.11% -2.25% 10.71% :-) nbody 0.57% 1.55% 8.71% 1.90% :-) json_dump_v2 0.22% 0.13% 5.52% 9.61% :-( normal_startup 1.86% 0.17% -5.21% 1.90% :-| ssbench 0.07% -0.03% 1.34% 0.77% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From solipsis at pitrou.net Fri Dec 25 03:54:15 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 25 Dec 2015 08:54:15 +0000 Subject: [Python-checkins] Daily reference leaks (8a14af800f96): sum=4 Message-ID: <20151225084412.3381.89227@psf.io> results for 8a14af800f96 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogj1uHER', '--timeout', '7200'] From python-checkins at python.org Fri Dec 25 12:54:53 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Dec 2015 17:54:53 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325923=3A_Added_th?= =?utf-8?q?e_const_qualifier_to_static_constant_arrays=2E?= Message-ID: <20151225175453.21402.25962@psf.io> https://hg.python.org/cpython/rev/3cb3e224b692 changeset: 99674:3cb3e224b692 user: Serhiy Storchaka date: Fri Dec 25 19:53:18 2015 +0200 summary: Issue #25923: Added the const qualifier to static constant arrays. files: Include/py_curses.h | 4 ++-- Include/pymath.h | 2 +- Modules/_csv.c | 8 ++++---- Modules/_ctypes/_ctypes.c | 14 +++++++------- Modules/_ctypes/callproc.c | 16 ++++++++-------- Modules/_curses_panel.c | 2 +- Modules/_datetimemodule.c | 20 ++++++++++---------- Modules/_dbmmodule.c | 8 ++++---- Modules/_gdbmmodule.c | 2 +- Modules/_io/textio.c | 4 ++-- Modules/_randommodule.c | 2 +- Modules/_sqlite/connection.c | 2 +- Modules/_sqlite/cursor.c | 4 ++-- Modules/_sqlite/module.c | 4 ++-- Modules/_sre.c | 2 +- Modules/_struct.c | 4 ++-- Modules/_testbuffer.c | 2 +- Modules/_testcapimodule.c | 4 ++-- Modules/arraymodule.c | 18 +++++++++--------- Modules/audioop.c | 20 +++++++++++--------- Modules/binascii.c | 14 +++++++------- Modules/getaddrinfo.c | 2 +- Modules/getpath.c | 4 ++-- Modules/main.c | 14 +++++++------- Modules/parsermodule.c | 4 ++-- Modules/posixmodule.c | 10 +++++----- Modules/selectmodule.c | 2 +- Modules/timemodule.c | 4 ++-- Modules/unicodedata.c | 4 ++-- Objects/object.c | 2 +- Objects/structseq.c | 6 +++--- Objects/typeobject.c | 2 +- Objects/unicodeobject.c | 12 ++++++------ Parser/parsetok.c | 4 ++-- Parser/pgen.c | 2 +- Python/ast.c | 4 ++-- Python/dtoa.c | 4 ++-- Python/formatter_unicode.c | 2 +- Python/import.c | 6 +++--- Python/importdl.c | 4 ++-- Python/mystrtoul.c | 6 +++--- Python/pystrtod.c | 9 +++++---- Python/pythonrun.c | 4 ++-- Python/sysmodule.c | 6 ++++-- 44 files changed, 139 insertions(+), 134 deletions(-) diff --git a/Include/py_curses.h b/Include/py_curses.h --- a/Include/py_curses.h +++ b/Include/py_curses.h @@ -103,8 +103,8 @@ #endif /* general error messages */ -static char *catchall_ERR = "curses function returned ERR"; -static char *catchall_NULL = "curses function returned NULL"; +static const char catchall_ERR[] = "curses function returned ERR"; +static const char catchall_NULL[] = "curses function returned NULL"; /* Function Prototype Macros - They are ugly but very, very useful. ;-) diff --git a/Include/pymath.h b/Include/pymath.h --- a/Include/pymath.h +++ b/Include/pymath.h @@ -169,7 +169,7 @@ #pragma float_control (pop) #define Py_NAN __icc_nan() #else /* ICC_NAN_RELAXED as default for Intel Compiler */ - static union { unsigned char buf[8]; double __icc_nan; } __nan_store = {0,0,0,0,0,0,0xf8,0x7f}; + static const union { unsigned char buf[8]; double __icc_nan; } __nan_store = {0,0,0,0,0,0,0xf8,0x7f}; #define Py_NAN (__nan_store.__icc_nan) #endif /* ICC_NAN_STRICT */ #endif /* __INTEL_COMPILER */ diff --git a/Modules/_csv.c b/Modules/_csv.c --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -60,10 +60,10 @@ typedef struct { QuoteStyle style; - char *name; + const char *name; } StyleDesc; -static StyleDesc quote_styles[] = { +static const StyleDesc quote_styles[] = { { QUOTE_MINIMAL, "QUOTE_MINIMAL" }, { QUOTE_ALL, "QUOTE_ALL" }, { QUOTE_NONNUMERIC, "QUOTE_NONNUMERIC" }, @@ -286,7 +286,7 @@ static int dialect_check_quoting(int quoting) { - StyleDesc *qs; + const StyleDesc *qs; for (qs = quote_styles; qs->name; qs++) { if ((int)qs->style == quoting) @@ -1633,7 +1633,7 @@ PyInit__csv(void) { PyObject *module; - StyleDesc *style; + const StyleDesc *style; if (PyType_Ready(&Dialect_Type) < 0) return NULL; diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -435,7 +435,7 @@ return StructUnionType_new(type, args, kwds, 0); } -static char from_address_doc[] = +static const char from_address_doc[] = "C.from_address(integer) -> C instance\naccess a C instance at the specified address"; static PyObject * @@ -453,7 +453,7 @@ return PyCData_AtAddress(type, buf); } -static char from_buffer_doc[] = +static const char from_buffer_doc[] = "C.from_buffer(object, offset=0) -> C instance\ncreate a C instance from a writeable buffer"; static int @@ -524,7 +524,7 @@ return result; } -static char from_buffer_copy_doc[] = +static const char from_buffer_copy_doc[] = "C.from_buffer_copy(object, offset=0) -> C instance\ncreate a C instance from a readable buffer"; static PyObject * @@ -566,7 +566,7 @@ return result; } -static char in_dll_doc[] = +static const char in_dll_doc[] = "C.in_dll(dll, name) -> C instance\naccess a C instance in a dll"; static PyObject * @@ -623,7 +623,7 @@ return PyCData_AtAddress(type, address); } -static char from_param_doc[] = +static const char from_param_doc[] = "Convert a Python object into a function call parameter."; static PyObject * @@ -1481,7 +1481,7 @@ */ -static char *SIMPLE_TYPE_CHARS = "cbBhHiIlLdfuzZqQPXOv?g"; +static const char SIMPLE_TYPE_CHARS[] = "cbBhHiIlLdfuzZqQPXOv?g"; static PyObject * c_wchar_p_from_param(PyObject *type, PyObject *value) @@ -5118,7 +5118,7 @@ #ifdef MS_WIN32 -static char comerror_doc[] = "Raised when a COM method call failed."; +static const char comerror_doc[] = "Raised when a COM method call failed."; int comerror_init(PyObject *self, PyObject *args, PyObject *kwds) diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1201,7 +1201,7 @@ #ifdef MS_WIN32 -static char format_error_doc[] = +static const char format_error_doc[] = "FormatError([integer]) -> string\n\ \n\ Convert a win32 error code into a string. If the error code is not\n\ @@ -1225,7 +1225,7 @@ return result; } -static char load_library_doc[] = +static const char load_library_doc[] = "LoadLibrary(name) -> handle\n\ \n\ Load an executable (usually a DLL), and return a handle to it.\n\ @@ -1254,7 +1254,7 @@ #endif } -static char free_library_doc[] = +static const char free_library_doc[] = "FreeLibrary(handle) -> void\n\ \n\ Free the handle of an executable previously loaded by LoadLibrary.\n"; @@ -1269,7 +1269,7 @@ return Py_None; } -static char copy_com_pointer_doc[] = +static const char copy_com_pointer_doc[] = "CopyComPointer(src, dst) -> HRESULT value\n"; static PyObject * @@ -1439,7 +1439,7 @@ /***************************************************************** * functions */ -static char sizeof_doc[] = +static const char sizeof_doc[] = "sizeof(C type) -> integer\n" "sizeof(C instance) -> integer\n" "Return the size in bytes of a C instance"; @@ -1460,7 +1460,7 @@ return NULL; } -static char alignment_doc[] = +static const char alignment_doc[] = "alignment(C type) -> integer\n" "alignment(C instance) -> integer\n" "Return the alignment requirements of a C instance"; @@ -1483,7 +1483,7 @@ return NULL; } -static char byref_doc[] = +static const char byref_doc[] = "byref(C instance[, offset=0]) -> byref-object\n" "Return a pointer lookalike to a C instance, only usable\n" "as function argument"; @@ -1527,7 +1527,7 @@ return (PyObject *)parg; } -static char addressof_doc[] = +static const char addressof_doc[] = "addressof(C instance) -> integer\n" "Return the address of the C instance internal buffer"; diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -6,7 +6,7 @@ /* Release Number */ -static char *PyCursesVersion = "2.1"; +static const char PyCursesVersion[] = "2.1"; /* Includes */ diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -184,12 +184,12 @@ * and the number of days before that month in the same year. These * are correct for non-leap years only. */ -static int _days_in_month[] = { +static const int _days_in_month[] = { 0, /* unused; this vector uses 1-based indexing */ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; -static int _days_before_month[] = { +static const int _days_before_month[] = { 0, /* unused; this vector uses 1-based indexing */ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; @@ -1009,10 +1009,10 @@ static PyObject * format_ctime(PyDateTime_Date *date, int hours, int minutes, int seconds) { - static const char *DayNames[] = { + static const char * const DayNames[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; - static const char *MonthNames[] = { + static const char * const MonthNames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; @@ -2307,7 +2307,7 @@ {NULL, NULL}, }; -static char delta_doc[] = +static const char delta_doc[] = PyDoc_STR("Difference between two datetime values."); static PyNumberMethods delta_as_number = { @@ -2886,7 +2886,7 @@ {NULL, NULL} }; -static char date_doc[] = +static const char date_doc[] = PyDoc_STR("date(year, month, day) --> date object"); static PyNumberMethods date_as_number = { @@ -3155,7 +3155,7 @@ {NULL, NULL} }; -static char tzinfo_doc[] = +static const char tzinfo_doc[] = PyDoc_STR("Abstract base class for time zone info objects."); static PyTypeObject PyDateTime_TZInfoType = { @@ -3387,7 +3387,7 @@ {NULL, NULL} }; -static char timezone_doc[] = +static const char timezone_doc[] = PyDoc_STR("Fixed offset from UTC implementation of tzinfo."); static PyTypeObject PyDateTime_TimeZoneType = { @@ -3877,7 +3877,7 @@ {NULL, NULL} }; -static char time_doc[] = +static const char time_doc[] = PyDoc_STR("time([hour[, minute[, second[, microsecond[, tzinfo]]]]]) --> a time object\n\ \n\ All arguments are optional. tzinfo may be None, or an instance of\n\ @@ -5065,7 +5065,7 @@ {NULL, NULL} }; -static char datetime_doc[] = +static const char datetime_doc[] = PyDoc_STR("datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])\n\ \n\ The year, month and day arguments are required. tzinfo may be None, or an\n\ diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c --- a/Modules/_dbmmodule.c +++ b/Modules/_dbmmodule.c @@ -14,16 +14,16 @@ */ #if defined(HAVE_NDBM_H) #include -static char *which_dbm = "GNU gdbm"; /* EMX port of GDBM */ +static const char which_dbm[] = "GNU gdbm"; /* EMX port of GDBM */ #elif defined(HAVE_GDBM_NDBM_H) #include -static char *which_dbm = "GNU gdbm"; +static const char which_dbm[] = "GNU gdbm"; #elif defined(HAVE_GDBM_DASH_NDBM_H) #include -static char *which_dbm = "GNU gdbm"; +static const char which_dbm[] = "GNU gdbm"; #elif defined(HAVE_BERKDB_H) #include -static char *which_dbm = "Berkeley DB"; +static const char which_dbm[] = "Berkeley DB"; #else #error "No ndbm.h available!" #endif diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c --- a/Modules/_gdbmmodule.c +++ b/Modules/_gdbmmodule.c @@ -615,7 +615,7 @@ return newdbmobject(name, iflags, mode); } -static char dbmmodule_open_flags[] = "rwcn" +static const char dbmmodule_open_flags[] = "rwcn" #ifdef GDBM_FAST "f" #endif diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -772,7 +772,7 @@ encodefunc_t encodefunc; } encodefuncentry; -static encodefuncentry encodefuncs[] = { +static const encodefuncentry encodefuncs[] = { {"ascii", (encodefunc_t) ascii_encode}, {"iso8859-1", (encodefunc_t) latin1_encode}, {"utf-8", (encodefunc_t) utf8_encode}, @@ -1022,7 +1022,7 @@ goto error; } else if (PyUnicode_Check(res)) { - encodefuncentry *e = encodefuncs; + const encodefuncentry *e = encodefuncs; while (e->name != NULL) { if (!PyUnicode_CompareWithASCIIString(res, e->name)) { self->encodefunc = e->encodefunc; diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -99,7 +99,7 @@ genrand_int32(RandomObject *self) { PY_UINT32_T y; - static PY_UINT32_T mag01[2]={0x0U, MATRIX_A}; + static const PY_UINT32_T mag01[2] = {0x0U, MATRIX_A}; /* mag01[x] = x * MATRIX_A for x=0,1 */ PY_UINT32_T *mt; diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1622,7 +1622,7 @@ Py_RETURN_FALSE; } -static char connection_doc[] = +static const char connection_doc[] = PyDoc_STR("SQLite database connection object."); static PyGetSetDef connection_getset[] = { diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -27,7 +27,7 @@ PyObject* pysqlite_cursor_iternext(pysqlite_Cursor* self); -static char* errmsg_fetch_across_rollback = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from."; +static const char errmsg_fetch_across_rollback[] = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from."; static pysqlite_StatementKind detect_statement_type(const char* statement) { @@ -1050,7 +1050,7 @@ {NULL} }; -static char cursor_doc[] = +static const char cursor_doc[] = PyDoc_STR("SQLite database cursor class."); PyTypeObject pysqlite_CursorType = { diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c --- a/Modules/_sqlite/module.c +++ b/Modules/_sqlite/module.c @@ -261,13 +261,13 @@ }; struct _IntConstantPair { - char* constant_name; + const char *constant_name; int constant_value; }; typedef struct _IntConstantPair IntConstantPair; -static IntConstantPair _int_constants[] = { +static const IntConstantPair _int_constants[] = { {"PARSE_DECLTYPES", PARSE_DECLTYPES}, {"PARSE_COLNAMES", PARSE_COLNAMES}, diff --git a/Modules/_sre.c b/Modules/_sre.c --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -35,7 +35,7 @@ * other compatibility work. */ -static char copyright[] = +static const char copyright[] = " SRE 2.2.2 Copyright (c) 1997-2002 by Secret Labs AB "; #define PY_SSIZE_T_CLEAN diff --git a/Modules/_struct.c b/Modules/_struct.c --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -723,7 +723,7 @@ return 0; } -static formatdef native_table[] = { +static const formatdef native_table[] = { {'x', sizeof(char), 0, NULL}, {'b', sizeof(char), 0, nu_byte, np_byte}, {'B', sizeof(char), 0, nu_ubyte, np_ubyte}, @@ -2280,7 +2280,7 @@ /* Check endian and swap in faster functions */ { - formatdef *native = native_table; + const formatdef *native = native_table; formatdef *other, *ptr; #if PY_LITTLE_ENDIAN other = lilendian_table; diff --git a/Modules/_testbuffer.c b/Modules/_testbuffer.c --- a/Modules/_testbuffer.c +++ b/Modules/_testbuffer.c @@ -13,7 +13,7 @@ PyObject *calcsize = NULL; /* cache simple format string */ -static const char *simple_fmt = "B"; +static const char simple_fmt[] = "B"; PyObject *simple_format = NULL; #define SIMPLE_FORMAT(fmt) (fmt == NULL || strcmp(fmt, "B") == 0) #define FIX_FORMAT(fmt) (fmt == NULL ? "B" : fmt) diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -887,7 +887,7 @@ getargs_keywords(PyObject *self, PyObject *args, PyObject *kwargs) { static char *keywords[] = {"arg1","arg2","arg3","arg4","arg5", NULL}; - static char *fmt="(ii)i|(i(ii))(iii)i"; + static const char fmt[] = "(ii)i|(i(ii))(iii)i"; int int_args[10]={-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, fmt, keywords, @@ -3769,7 +3769,7 @@ "T_LONGLONG", "T_ULONGLONG", #endif NULL}; - static char *fmt = "|bbBhHiIlknfds#" + static const char fmt[] = "|bbBhHiIlknfds#" #ifdef HAVE_LONG_LONG "LK" #endif diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -31,7 +31,7 @@ int itemsize; PyObject * (*getitem)(struct arrayobject *, Py_ssize_t); int (*setitem)(struct arrayobject *, Py_ssize_t, PyObject *); - char *formats; + const char *formats; int is_integer_type; int is_signed; }; @@ -40,7 +40,7 @@ PyObject_VAR_HEAD char *ob_item; Py_ssize_t allocated; - struct arraydescr *ob_descr; + const struct arraydescr *ob_descr; PyObject *weakreflist; /* List of weak references */ int ob_exports; /* Number of exported buffers */ } arrayobject; @@ -511,7 +511,7 @@ * Don't forget to update typecode_to_mformat_code() if you add a new * typecode. */ -static struct arraydescr descriptors[] = { +static const struct arraydescr descriptors[] = { {'b', 1, b_getitem, b_setitem, "b", 1, 1}, {'B', 1, BB_getitem, BB_setitem, "B", 1, 0}, {'u', sizeof(Py_UNICODE), u_getitem, u_setitem, "u", 0, 0}, @@ -539,7 +539,7 @@ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=ad43d37e942a8854]*/ static PyObject * -newarrayobject(PyTypeObject *type, Py_ssize_t size, struct arraydescr *descr) +newarrayobject(PyTypeObject *type, Py_ssize_t size, const struct arraydescr *descr) { arrayobject *op; size_t nbytes; @@ -1946,7 +1946,7 @@ { PyObject *converted_items; PyObject *result; - struct arraydescr *descr; + const struct arraydescr *descr; if (!PyType_Check(arraytype)) { PyErr_Format(PyExc_TypeError, @@ -2084,7 +2084,7 @@ Py_ssize_t itemcount = Py_SIZE(items) / mf_descr.size; const unsigned char *memstr = (unsigned char *)PyBytes_AS_STRING(items); - struct arraydescr *descr; + const struct arraydescr *descr; /* If possible, try to pack array's items using a data type * that fits better. This may result in an array with narrower @@ -2554,7 +2554,7 @@ view->format = NULL; view->internal = NULL; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { - view->format = self->ob_descr->formats; + view->format = (char *)self->ob_descr->formats; #ifdef Py_UNICODE_WIDE if (self->ob_descr->typecode == 'u') { view->format = "w"; @@ -2595,7 +2595,7 @@ { int c; PyObject *initial = NULL, *it = NULL; - struct arraydescr *descr; + const struct arraydescr *descr; if (type == &Arraytype && !_PyArg_NoKeywords("array.array()", kwds)) return NULL; @@ -2987,7 +2987,7 @@ char buffer[Py_ARRAY_LENGTH(descriptors)], *p; PyObject *typecodes; Py_ssize_t size = 0; - struct arraydescr *descr; + const struct arraydescr *descr; if (PyType_Ready(&Arraytype) < 0) return -1; diff --git a/Modules/audioop.c b/Modules/audioop.c --- a/Modules/audioop.c +++ b/Modules/audioop.c @@ -51,13 +51,15 @@ #define SEG_SHIFT (4) /* Left shift for segment number. */ #define SEG_MASK (0x70) /* Segment field mask. */ -static PyInt16 seg_aend[8] = {0x1F, 0x3F, 0x7F, 0xFF, - 0x1FF, 0x3FF, 0x7FF, 0xFFF}; -static PyInt16 seg_uend[8] = {0x3F, 0x7F, 0xFF, 0x1FF, - 0x3FF, 0x7FF, 0xFFF, 0x1FFF}; +static const PyInt16 seg_aend[8] = { + 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF +}; +static const PyInt16 seg_uend[8] = { + 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF +}; static PyInt16 -search(PyInt16 val, PyInt16 *table, int size) +search(PyInt16 val, const PyInt16 *table, int size) { int i; @@ -70,7 +72,7 @@ #define st_ulaw2linear16(uc) (_st_ulaw2linear16[uc]) #define st_alaw2linear16(uc) (_st_alaw2linear16[uc]) -static PyInt16 _st_ulaw2linear16[256] = { +static const PyInt16 _st_ulaw2linear16[256] = { -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956, -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764, -15996, -15484, -14972, -14460, -13948, @@ -176,7 +178,7 @@ } -static PyInt16 _st_alaw2linear16[256] = { +static const PyInt16 _st_alaw2linear16[256] = { -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784, -2752, -2624, -3008, -2880, -2240, @@ -270,12 +272,12 @@ /* End of code taken from sox */ /* Intel ADPCM step variation table */ -static int indexTable[16] = { +static const int indexTable[16] = { -1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8, }; -static int stepsizeTable[89] = { +static const int stepsizeTable[89] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, diff --git a/Modules/binascii.c b/Modules/binascii.c --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -74,7 +74,7 @@ #define SKIP 0x7E #define FAIL 0x7D -static unsigned char table_a2b_hqx[256] = { +static const unsigned char table_a2b_hqx[256] = { /* ^@ ^A ^B ^C ^D ^E ^F ^G */ /* 0*/ FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, /* \b \t \n ^K ^L \r ^N ^O */ @@ -125,10 +125,10 @@ FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, }; -static unsigned char table_b2a_hqx[] = +static const unsigned char table_b2a_hqx[] = "!\"#$%&'()*+,-012345689 at ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr"; -static char table_a2b_base64[] = { +static const char table_a2b_base64[] = { -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63, @@ -144,12 +144,12 @@ /* Max binary chunk size; limited only by available memory */ #define BASE64_MAXBIN ((PY_SSIZE_T_MAX - 3) / 2) -static unsigned char table_b2a_base64[] = +static const unsigned char table_b2a_base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static unsigned short crctab_hqx[256] = { +static const unsigned short crctab_hqx[256] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, @@ -977,7 +977,7 @@ using byte-swap instructions. ********************************************************************/ -static unsigned int crc_32_tab[256] = { +static const unsigned int crc_32_tab[256] = { 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, @@ -1201,7 +1201,7 @@ return binascii_a2b_hex_impl(module, hexstr); } -static int table_hex[128] = { +static const int table_hex[128] = { -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, diff --git a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c --- a/Modules/getaddrinfo.c +++ b/Modules/getaddrinfo.c @@ -136,7 +136,7 @@ struct addrinfo *, int); static int str_isnumber(const char *); -static char *ai_errlist[] = { +static const char * const ai_errlist[] = { "success.", "address family for hostname not supported.", /* EAI_ADDRFAMILY */ "temporary failure in name resolution.", /* EAI_AGAIN */ diff --git a/Modules/getpath.c b/Modules/getpath.c --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -477,8 +477,8 @@ { extern wchar_t *Py_GetProgramName(void); - static wchar_t delimiter[2] = {DELIM, '\0'}; - static wchar_t separator[2] = {SEP, '\0'}; + static const wchar_t delimiter[2] = {DELIM, '\0'}; + static const wchar_t separator[2] = {SEP, '\0'}; char *_rtpypath = Py_GETENV("PYTHONPATH"); /* XXX use wide version on Windows */ wchar_t *rtpypath = NULL; wchar_t *home = Py_GetPythonHome(); diff --git a/Modules/main.c b/Modules/main.c --- a/Modules/main.c +++ b/Modules/main.c @@ -42,11 +42,11 @@ #define PROGRAM_OPTS BASE_OPTS /* Short usage message (with %s for argv0) */ -static char *usage_line = +static const char usage_line[] = "usage: %ls [option] ... [-c cmd | -m mod | file | -] [arg] ...\n"; /* Long usage message, split into parts < 512 bytes */ -static char *usage_1 = "\ +static const char usage_1[] = "\ Options and arguments (and corresponding environment variables):\n\ -b : issue warnings about str(bytes_instance), str(bytearray_instance)\n\ and comparing bytes/bytearray with str. (-bb: issue errors)\n\ @@ -56,7 +56,7 @@ -E : ignore PYTHON* environment variables (such as PYTHONPATH)\n\ -h : print this help message and exit (also --help)\n\ "; -static char *usage_2 = "\ +static const char usage_2[] = "\ -i : inspect interactively after running script; forces a prompt even\n\ if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\ -I : isolate Python from the user's environment (implies -E and -s)\n\ @@ -67,7 +67,7 @@ -s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\ -S : don't imply 'import site' on initialization\n\ "; -static char *usage_3 = "\ +static const char usage_3[] = "\ -u : unbuffered binary stdout and stderr, stdin always buffered;\n\ also PYTHONUNBUFFERED=x\n\ see man page for details on internal buffering relating to '-u'\n\ @@ -79,7 +79,7 @@ -x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ -X opt : set implementation-specific option\n\ "; -static char *usage_4 = "\ +static const char usage_4[] = "\ file : program read from script file\n\ - : program read from stdin (default; interactive mode if a tty)\n\ arg ...: arguments passed to program in sys.argv[1:]\n\n\ @@ -88,14 +88,14 @@ PYTHONPATH : '%c'-separated list of directories prefixed to the\n\ default module search path. The result is sys.path.\n\ "; -static char *usage_5 = +static const char usage_5[] = "PYTHONHOME : alternate directory (or %c).\n" " The default module search path uses %s.\n" "PYTHONCASEOK : ignore case in 'import' statements (Windows).\n" "PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n" "PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.\n\ "; -static char *usage_6 = "\ +static const char usage_6[] = "\ PYTHONHASHSEED: if this variable is set to 'random', a random value is used\n\ to seed the hashes of str, bytes and datetime objects. It can also be\n\ set to an integer in the range [0,4294967295] to get hash values with a\n\ diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -53,7 +53,7 @@ /* String constants used to initialize module attributes. * */ -static char parser_copyright_string[] = +static const char parser_copyright_string[] = "Copyright 1995-1996 by Virginia Polytechnic Institute & State\n\ University, Blacksburg, Virginia, USA, and Fred L. Drake, Jr., Reston,\n\ Virginia, USA. Portions copyright 1991-1995 by Stichting Mathematisch\n\ @@ -63,7 +63,7 @@ PyDoc_STRVAR(parser_doc_string, "This is an interface to Python's internal parser."); -static char parser_version_string[] = "0.5"; +static const char parser_version_string[] = "0.5"; typedef PyObject* (*SeqMaker) (Py_ssize_t length); diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9479,7 +9479,7 @@ * sufficiently pervasive that it's not worth the loss of readability. */ struct constdef { - char *name; + const char *name; int value; }; @@ -10822,7 +10822,7 @@ for (i = 0; ; i++) { void *ptr; ssize_t result; - static Py_ssize_t buffer_sizes[] = {128, XATTR_SIZE_MAX, 0}; + static const Py_ssize_t buffer_sizes[] = {128, XATTR_SIZE_MAX, 0}; Py_ssize_t buffer_size = buffer_sizes[i]; if (!buffer_size) { path_error(path); @@ -10988,7 +10988,7 @@ for (i = 0; ; i++) { char *start, *trace, *end; ssize_t length; - static Py_ssize_t buffer_sizes[] = { 256, XATTR_LIST_MAX, 0 }; + static const Py_ssize_t buffer_sizes[] = { 256, XATTR_LIST_MAX, 0 }; Py_ssize_t buffer_size = buffer_sizes[i]; if (!buffer_size) { /* ERANGE */ @@ -12821,7 +12821,7 @@ }; -static char *have_functions[] = { +static const char * const have_functions[] = { #ifdef HAVE_FACCESSAT "HAVE_FACCESSAT", @@ -12956,7 +12956,7 @@ { PyObject *m, *v; PyObject *list; - char **trace; + const char * const *trace; #if defined(HAVE_SYMLINK) && defined(MS_WINDOWS) win32_can_symlink = enable_symlink(); diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -1842,7 +1842,7 @@ PyObject *pfd; static char *kwlist[] = {"ident", "filter", "flags", "fflags", "data", "udata", NULL}; - static char *fmt = "O|hHI" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent"; + static const char fmt[] = "O|hHI" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent"; EV_SET(&(self->e), 0, EVFILT_READ, EV_ADD, 0, 0, 0); /* defaults */ diff --git a/Modules/timemodule.c b/Modules/timemodule.c --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -732,10 +732,10 @@ { /* Inspired by Open Group reference implementation available at * http://pubs.opengroup.org/onlinepubs/009695399/functions/asctime.html */ - static char wday_name[7][4] = { + static const char wday_name[7][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; - static char mon_name[12][4] = { + static const char mon_name[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -884,7 +884,7 @@ return h; } -static char *hangul_syllables[][3] = { +static const char * const hangul_syllables[][3] = { { "G", "A", "" }, { "GG", "AE", "G" }, { "N", "YA", "GG" }, @@ -1057,7 +1057,7 @@ int i, len1; *len = -1; for (i = 0; i < count; i++) { - char *s = hangul_syllables[i][column]; + const char *s = hangul_syllables[i][column]; len1 = Py_SAFE_DOWNCAST(strlen(s), size_t, int); if (len1 <= *len) continue; diff --git a/Objects/object.c b/Objects/object.c --- a/Objects/object.c +++ b/Objects/object.c @@ -644,7 +644,7 @@ /* Map rich comparison operators to their swapped version, e.g. LT <--> GT */ int _Py_SwappedOp[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; -static char *opstrings[] = {"<", "<=", "==", "!=", ">", ">="}; +static const char * const opstrings[] = {"<", "<=", "==", "!=", ">", ">="}; /* Perform a rich comparison, raising TypeError when the requested comparison operator is not supported. */ diff --git a/Objects/structseq.c b/Objects/structseq.c --- a/Objects/structseq.c +++ b/Objects/structseq.c @@ -4,9 +4,9 @@ #include "Python.h" #include "structmember.h" -static char visible_length_key[] = "n_sequence_fields"; -static char real_length_key[] = "n_fields"; -static char unnamed_fields_key[] = "n_unnamed_fields"; +static const char visible_length_key[] = "n_sequence_fields"; +static const char real_length_key[] = "n_fields"; +static const char unnamed_fields_key[] = "n_unnamed_fields"; /* Fields with this name have only a field index, not a field name. They are only allowed for indices < n_visible_fields. */ diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2690,7 +2690,7 @@ return NULL; } -static short slotoffsets[] = { +static const short slotoffsets[] = { -1, /* invalid slot */ #include "typeslots.inc" }; diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -272,7 +272,7 @@ const char *reason); /* Same for linebreaks */ -static unsigned char ascii_linebreak[] = { +static const unsigned char ascii_linebreak[] = { 0, 0, 0, 0, 0, 0, 0, 0, /* 0x000A, * LINE FEED */ /* 0x000B, * LINE TABULATION */ @@ -4135,7 +4135,7 @@ Py_ssize_t *endinpos, PyObject **exceptionObject, const char **inptr, PyObject **output, Py_ssize_t *outpos) { - static char *argparse = "O!n;decoding error handler must return (str, int) tuple"; + static const char *argparse = "O!n;decoding error handler must return (str, int) tuple"; PyObject *restuple = NULL; PyObject *repunicode = NULL; @@ -4243,7 +4243,7 @@ Py_ssize_t *endinpos, PyObject **exceptionObject, const char **inptr, _PyUnicodeWriter *writer /* PyObject **output, Py_ssize_t *outpos */) { - static char *argparse = "O!n;decoding error handler must return (str, int) tuple"; + static const char *argparse = "O!n;decoding error handler must return (str, int) tuple"; PyObject *restuple = NULL; PyObject *repunicode = NULL; @@ -6560,7 +6560,7 @@ Py_ssize_t startpos, Py_ssize_t endpos, Py_ssize_t *newpos) { - static char *argparse = "On;encoding error handler must return (str/bytes, int) tuple"; + static const char *argparse = "On;encoding error handler must return (str/bytes, int) tuple"; Py_ssize_t len; PyObject *restuple; PyObject *resunicode; @@ -8572,7 +8572,7 @@ Py_ssize_t startpos, Py_ssize_t endpos, Py_ssize_t *newpos) { - static char *argparse = "O!n;translating error handler must return (str, int) tuple"; + static const char *argparse = "O!n;translating error handler must return (str, int) tuple"; Py_ssize_t i_newpos; PyObject *restuple; @@ -12156,7 +12156,7 @@ #define BOTHSTRIP 2 /* Arrays indexed by above */ -static const char *stripformat[] = {"|O:lstrip", "|O:rstrip", "|O:strip"}; +static const char * const stripformat[] = {"|O:lstrip", "|O:rstrip", "|O:strip"}; #define STRIPNAME(i) (stripformat[i]+3) diff --git a/Parser/parsetok.c b/Parser/parsetok.c --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -161,10 +161,10 @@ #ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD #if 0 -static char with_msg[] = +static const char with_msg[] = "%s:%d: Warning: 'with' will become a reserved keyword in Python 2.6\n"; -static char as_msg[] = +static const char as_msg[] = "%s:%d: Warning: 'as' will become a reserved keyword in Python 2.6\n"; static void diff --git a/Parser/pgen.c b/Parser/pgen.c --- a/Parser/pgen.c +++ b/Parser/pgen.c @@ -134,7 +134,7 @@ #ifdef Py_DEBUG -static char REQNFMT[] = "metacompile: less than %d children\n"; +static const char REQNFMT[] = "metacompile: less than %d children\n"; #define REQN(i, count) do { \ if (i < count) { \ diff --git a/Python/ast.c b/Python/ast.c --- a/Python/ast.c +++ b/Python/ast.c @@ -870,7 +870,7 @@ } } -static const char* FORBIDDEN[] = { +static const char * const FORBIDDEN[] = { "None", "True", "False", @@ -887,7 +887,7 @@ return 1; } if (full_checks) { - const char **p; + const char * const *p; for (p = FORBIDDEN; *p; p++) { if (PyUnicode_CompareWithASCIIString(name, *p) == 0) { ast_error(c, n, "assignment to keyword"); diff --git a/Python/dtoa.c b/Python/dtoa.c --- a/Python/dtoa.c +++ b/Python/dtoa.c @@ -747,7 +747,7 @@ { Bigint *b1, *p5, *p51; int i; - static int p05[3] = { 5, 25, 125 }; + static const int p05[3] = { 5, 25, 125 }; if ((i = k & 3)) { b = multadd(b, p05[i-1], 0); @@ -803,7 +803,7 @@ { Bigint *b1, *p5, *p51; int i; - static int p05[3] = { 5, 25, 125 }; + static const int p05[3] = { 5, 25, 125 }; if ((i = k & 3)) { b = multadd(b, p05[i-1], 0); diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -656,7 +656,7 @@ return 0; } -static char no_grouping[1] = {CHAR_MAX}; +static const char no_grouping[1] = {CHAR_MAX}; /* Find the decimal point character(s?), thousands_separator(s?), and grouping description, either for the current locale if type is diff --git a/Python/import.c b/Python/import.c --- a/Python/import.c +++ b/Python/import.c @@ -320,7 +320,7 @@ /* List of names to clear in sys */ -static char* sys_deletes[] = { +static const char * const sys_deletes[] = { "path", "argv", "ps1", "ps2", "last_type", "last_value", "last_traceback", "path_hooks", "path_importer_cache", "meta_path", @@ -330,7 +330,7 @@ NULL }; -static char* sys_files[] = { +static const char * const sys_files[] = { "stdin", "__stdin__", "stdout", "__stdout__", "stderr", "__stderr__", @@ -347,7 +347,7 @@ PyInterpreterState *interp = PyThreadState_GET()->interp; PyObject *modules = interp->modules; PyObject *weaklist = NULL; - char **p; + const char * const *p; if (modules == NULL) return; /* Already done */ diff --git a/Python/importdl.c b/Python/importdl.c --- a/Python/importdl.c +++ b/Python/importdl.c @@ -23,8 +23,8 @@ const char *pathname, FILE *fp); #endif -static const char *ascii_only_prefix = "PyInit"; -static const char *nonascii_prefix = "PyInitU"; +static const char * const ascii_only_prefix = "PyInit"; +static const char * const nonascii_prefix = "PyInitU"; /* Get the variable part of a module's export symbol name. * Returns a bytes instance. For non-ASCII-named modules, the name is diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c --- a/Python/mystrtoul.c +++ b/Python/mystrtoul.c @@ -17,7 +17,7 @@ * smallmax[base] is the largest unsigned long i such that * i * base doesn't overflow unsigned long. */ -static unsigned long smallmax[] = { +static const unsigned long smallmax[] = { 0, /* bases 0 and 1 are invalid */ 0, ULONG_MAX / 2, @@ -62,14 +62,14 @@ * Note that this is pessimistic if sizeof(long) > 4. */ #if SIZEOF_LONG == 4 -static int digitlimit[] = { +static const int digitlimit[] = { 0, 0, 32, 20, 16, 13, 12, 11, 10, 10, /* 0 - 9 */ 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, /* 10 - 19 */ 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, /* 20 - 29 */ 6, 6, 6, 6, 6, 6, 6}; /* 30 - 36 */ #elif SIZEOF_LONG == 8 /* [int(math.floor(math.log(2**64, i))) for i in range(2, 37)] */ -static int digitlimit[] = { +static const int digitlimit[] = { 0, 0, 64, 40, 32, 27, 24, 22, 21, 20, /* 0 - 9 */ 19, 18, 17, 17, 16, 16, 16, 15, 15, 15, /* 10 - 19 */ 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, /* 20 - 29 */ diff --git a/Python/pystrtod.c b/Python/pystrtod.c --- a/Python/pystrtod.c +++ b/Python/pystrtod.c @@ -881,12 +881,12 @@ #define OFS_E 2 /* The lengths of these are known to the code below, so don't change them */ -static char *lc_float_strings[] = { +static const char * const lc_float_strings[] = { "inf", "nan", "e", }; -static char *uc_float_strings[] = { +static const char * const uc_float_strings[] = { "INF", "NAN", "E", @@ -925,7 +925,8 @@ format_float_short(double d, char format_code, int mode, int precision, int always_add_sign, int add_dot_0_if_integer, - int use_alt_formatting, char **float_strings, int *type) + int use_alt_formatting, const char * const *float_strings, + int *type) { char *buf = NULL; char *p = NULL; @@ -1176,7 +1177,7 @@ int flags, int *type) { - char **float_strings = lc_float_strings; + const char * const *float_strings = lc_float_strings; int mode; /* Validate format_code, and map upper and lower case. Compute the diff --git a/Python/pythonrun.c b/Python/pythonrun.c --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -785,11 +785,11 @@ PyErr_Clear(); } -static const char *cause_message = +static const char cause_message[] = "\nThe above exception was the direct cause " "of the following exception:\n\n"; -static const char *context_message = +static const char context_message[] = "\nDuring handling of the above exception, " "another exception occurred:\n\n"; diff --git a/Python/sysmodule.c b/Python/sysmodule.c --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -346,8 +346,10 @@ static int trace_init(void) { - static char *whatnames[7] = {"call", "exception", "line", "return", - "c_call", "c_exception", "c_return"}; + static const char * const whatnames[7] = { + "call", "exception", "line", "return", + "c_call", "c_exception", "c_return" + }; PyObject *name; int i; for (i = 0; i < 7; ++i) { -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 25 13:02:32 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Dec 2015 18:02:32 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325923=3A_Added_mo?= =?utf-8?q?re_const_qualifiers_to_signatures_of_static_and_private?= Message-ID: <20151225180232.3371.19220@psf.io> https://hg.python.org/cpython/rev/80d1faa9735d changeset: 99675:80d1faa9735d user: Serhiy Storchaka date: Fri Dec 25 20:01:53 2015 +0200 summary: Issue #25923: Added more const qualifiers to signatures of static and private functions. files: Include/bytes_methods.h | 6 +- Include/pythonrun.h | 8 +- Misc/coverity_model.c | 2 +- Modules/_ctypes/_ctypes.c | 4 +- Modules/_ctypes/callbacks.c | 2 +- Modules/_ctypes/callproc.c | 2 +- Modules/_ctypes/ctypes.h | 2 +- Modules/_curses_panel.c | 2 +- Modules/_datetimemodule.c | 2 +- Modules/_io/_iomodule.h | 2 +- Modules/_io/bufferedio.c | 2 +- Modules/_io/fileio.c | 4 +- Modules/_io/textio.c | 20 ++++---- Modules/_json.c | 4 +- Modules/_localemodule.c | 2 +- Modules/_pickle.c | 2 +- Modules/_posixsubprocess.c | 2 +- Modules/_scproxy.c | 2 +- Modules/_sre.c | 2 +- Modules/_ssl.c | 4 +- Modules/_struct.c | 6 +- Modules/_testmultiphase.c | 2 +- Modules/_tkinter.c | 8 +- Modules/_winapi.c | 4 +- Modules/binascii.c | 44 +++++++++++------- Modules/gcmodule.c | 2 +- Modules/getaddrinfo.c | 2 +- Modules/main.c | 2 +- Modules/mathmodule.c | 4 +- Modules/parsermodule.c | 10 ++-- Modules/posixmodule.c | 43 ++++++++++------- Modules/pyexpat.c | 6 +- Modules/socketmodule.c | 4 +- Modules/timemodule.c | 2 +- Modules/xxlimited.c | 2 +- Modules/xxmodule.c | 2 +- Modules/zipimport.c | 2 +- Modules/zlibmodule.c | 2 +- Objects/bytearrayobject.c | 8 +- Objects/bytes_methods.c | 6 +- Objects/bytesobject.c | 2 +- Objects/descrobject.c | 2 +- Objects/dictobject.c | 2 +- Objects/memoryobject.c | 4 +- Objects/typeobject.c | 10 ++-- Objects/unicodeobject.c | 6 +- Objects/weakrefobject.c | 2 +- Parser/pgen.c | 4 +- Parser/pgenmain.c | 4 +- Parser/tokenizer.c | 6 +- Python/_warnings.c | 2 +- Python/ceval.c | 4 +- Python/dtoa.c | 2 +- Python/dynload_win.c | 2 +- Python/getargs.c | 58 ++++++++++++------------ Python/marshal.c | 34 +++++++------ Python/modsupport.c | 4 +- Python/pylifecycle.c | 4 +- Python/pythonrun.c | 8 +- Python/symtable.c | 4 +- 60 files changed, 210 insertions(+), 191 deletions(-) diff --git a/Include/bytes_methods.h b/Include/bytes_methods.h --- a/Include/bytes_methods.h +++ b/Include/bytes_methods.h @@ -17,9 +17,9 @@ /* These store their len sized answer in the given preallocated *result arg. */ extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len); extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len); -extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len); -extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len); -extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len); +extern void _Py_bytes_title(char *result, const char *s, Py_ssize_t len); +extern void _Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len); +extern void _Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len); /* The maketrans() static method. */ extern PyObject* _Py_bytes_maketrans(Py_buffer *frm, Py_buffer *to); diff --git a/Include/pythonrun.h b/Include/pythonrun.h --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -66,8 +66,8 @@ const char *filename, /* decoded from the filesystem encoding */ const char* enc, int start, - char *ps1, - char *ps2, + const char *ps1, + const char *ps2, PyCompilerFlags *flags, int *errcode, PyArena *arena); @@ -76,8 +76,8 @@ PyObject *filename, const char* enc, int start, - char *ps1, - char *ps2, + const char *ps1, + const char *ps2, PyCompilerFlags *flags, int *errcode, PyArena *arena); diff --git a/Misc/coverity_model.c b/Misc/coverity_model.c --- a/Misc/coverity_model.c +++ b/Misc/coverity_model.c @@ -94,7 +94,7 @@ } /* Parser/pgenmain.c */ -grammar *getgrammar(char *filename) +grammar *getgrammar(const char *filename) { grammar *g; __coverity_tainted_data_sink__(filename); diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -3195,7 +3195,7 @@ } static int -_get_name(PyObject *obj, char **pname) +_get_name(PyObject *obj, const char **pname) { #ifdef MS_WIN32 if (PyLong_Check(obj)) { @@ -3223,7 +3223,7 @@ static PyObject * PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds) { - char *name; + const char *name; int (* address)(void); PyObject *ftuple; PyObject *dll; diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -77,7 +77,7 @@ /**************************************************************/ static void -PrintError(char *msg, ...) +PrintError(const char *msg, ...) { char buf[512]; PyObject *f = PySys_GetObject("stderr"); diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -928,7 +928,7 @@ * Raise a new exception 'exc_class', adding additional text to the original * exception string. */ -void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...) +void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...) { va_list vargs; PyObject *tp, *v, *tb, *s, *cls_str, *msg_str; diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h --- a/Modules/_ctypes/ctypes.h +++ b/Modules/_ctypes/ctypes.h @@ -327,7 +327,7 @@ PyCData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, Py_ssize_t index, Py_ssize_t size, char *ptr); -extern void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...); +extern void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...); struct basespec { CDataObject *base; diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -56,7 +56,7 @@ */ static PyObject * -PyCursesCheckERR(int code, char *fname) +PyCursesCheckERR(int code, const char *fname) { if (code != ERR) { Py_INCREF(Py_None); diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -873,7 +873,7 @@ * this returns NULL. Else result is returned. */ static PyObject * -call_tzinfo_method(PyObject *tzinfo, char *name, PyObject *tzinfoarg) +call_tzinfo_method(PyObject *tzinfo, const char *name, PyObject *tzinfoarg) { PyObject *offset; diff --git a/Modules/_io/_iomodule.h b/Modules/_io/_iomodule.h --- a/Modules/_io/_iomodule.h +++ b/Modules/_io/_iomodule.h @@ -60,7 +60,7 @@ * Otherwise, the line ending is specified by readnl, a str object */ extern Py_ssize_t _PyIO_find_line_ending( int translated, int universal, PyObject *readnl, - int kind, char *start, char *end, Py_ssize_t *consumed); + int kind, const char *start, const char *end, Py_ssize_t *consumed); /* Return 1 if an EnvironmentError with errno == EINTR is set (and then clears the error indicator), 0 otherwise. diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -659,7 +659,7 @@ /* Sets the current error to BlockingIOError */ static void -_set_BlockingIOError(char *msg, Py_ssize_t written) +_set_BlockingIOError(const char *msg, Py_ssize_t written) { PyObject *err; PyErr_Clear(); diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -540,7 +540,7 @@ } static PyObject * -err_mode(char *action) +err_mode(const char *action) { _PyIO_State *state = IO_STATE(); if (state != NULL) @@ -1043,7 +1043,7 @@ } #endif /* HAVE_FTRUNCATE */ -static char * +static const char * mode_string(fileio *self) { if (self->created) { diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -1648,8 +1648,8 @@ /* NOTE: `end` must point to the real end of the Py_UCS4 storage, that is to the NUL character. Otherwise the function will produce incorrect results. */ -static char * -find_control_char(int kind, char *s, char *end, Py_UCS4 ch) +static const char * +find_control_char(int kind, const char *s, const char *end, Py_UCS4 ch) { if (kind == PyUnicode_1BYTE_KIND) { assert(ch < 256); @@ -1669,13 +1669,13 @@ Py_ssize_t _PyIO_find_line_ending( int translated, int universal, PyObject *readnl, - int kind, char *start, char *end, Py_ssize_t *consumed) + int kind, const char *start, const char *end, Py_ssize_t *consumed) { Py_ssize_t len = ((char*)end - (char*)start)/kind; if (translated) { /* Newlines are already translated, only search for \n */ - char *pos = find_control_char(kind, start, end, '\n'); + const char *pos = find_control_char(kind, start, end, '\n'); if (pos != NULL) return (pos - start)/kind + 1; else { @@ -1687,7 +1687,7 @@ /* Universal newline search. Find any of \r, \r\n, \n * The decoder ensures that \r\n are not split in two pieces */ - char *s = start; + const char *s = start; for (;;) { Py_UCS4 ch; /* Fast path for non-control chars. The loop always ends @@ -1717,21 +1717,21 @@ /* Assume that readnl is an ASCII character. */ assert(PyUnicode_KIND(readnl) == PyUnicode_1BYTE_KIND); if (readnl_len == 1) { - char *pos = find_control_char(kind, start, end, nl[0]); + const char *pos = find_control_char(kind, start, end, nl[0]); if (pos != NULL) return (pos - start)/kind + 1; *consumed = len; return -1; } else { - char *s = start; - char *e = end - (readnl_len - 1)*kind; - char *pos; + const char *s = start; + const char *e = end - (readnl_len - 1)*kind; + const char *pos; if (e < s) e = s; while (s < e) { Py_ssize_t i; - char *pos = find_control_char(kind, s, end, nl[0]); + const char *pos = find_control_char(kind, s, end, nl[0]); if (pos == NULL || pos >= e) break; for (i = 1; i < readnl_len; i++) { diff --git a/Modules/_json.c b/Modules/_json.c --- a/Modules/_json.c +++ b/Modules/_json.c @@ -112,7 +112,7 @@ static PyObject * _encoded_const(PyObject *obj); static void -raise_errmsg(char *msg, PyObject *s, Py_ssize_t end); +raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end); static PyObject * encoder_encode_string(PyEncoderObject *s, PyObject *obj); static PyObject * @@ -323,7 +323,7 @@ } static void -raise_errmsg(char *msg, PyObject *s, Py_ssize_t end) +raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end) { /* Use JSONDecodeError exception to raise a nice looking ValueError subclass */ static PyObject *JSONDecodeError = NULL; diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -49,7 +49,7 @@ /* the grouping is terminated by either 0 or CHAR_MAX */ static PyObject* -copy_grouping(char* s) +copy_grouping(const char* s) { int i; PyObject *result, *val = NULL; diff --git a/Modules/_pickle.c b/Modules/_pickle.c --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -2187,7 +2187,7 @@ } static int -write_utf8(PicklerObject *self, char *data, Py_ssize_t size) +write_utf8(PicklerObject *self, const char *data, Py_ssize_t size) { char header[9]; Py_ssize_t len; diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -72,7 +72,7 @@ /* Convert ASCII to a positive int, no libc call. no overflow. -1 on error. */ static int -_pos_int_from_ascii(char *name) +_pos_int_from_ascii(const char *name) { int num = 0; while (*name >= '0' && *name <= '9') { diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c --- a/Modules/_scproxy.c +++ b/Modules/_scproxy.c @@ -130,7 +130,7 @@ } static int -set_proxy(PyObject* proxies, char* proto, CFDictionaryRef proxyDict, +set_proxy(PyObject* proxies, const char* proto, CFDictionaryRef proxyDict, CFStringRef enabledKey, CFStringRef hostKey, CFStringRef portKey) { diff --git a/Modules/_sre.c b/Modules/_sre.c --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -714,7 +714,7 @@ } static PyObject* -call(char* module, char* function, PyObject* args) +call(const char* module, const char* function, PyObject* args) { PyObject* name; PyObject* mod; diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -378,7 +378,7 @@ } static PyObject * -PySSL_SetError(PySSLSocket *obj, int ret, char *filename, int lineno) +PySSL_SetError(PySSLSocket *obj, int ret, const char *filename, int lineno) { PyObject *type = PySSLErrorObject; char *errstr = NULL; @@ -460,7 +460,7 @@ } static PyObject * -_setSSLError (char *errstr, int errcode, char *filename, int lineno) { +_setSSLError (const char *errstr, int errcode, const char *filename, int lineno) { if (errstr == NULL) errcode = ERR_peek_last_error(); diff --git a/Modules/_struct.c b/Modules/_struct.c --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1189,7 +1189,7 @@ static const formatdef * -whichtable(char **pfmt) +whichtable(const char **pfmt) { const char *fmt = (*pfmt)++; /* May be backed out of later */ switch (*fmt) { @@ -1268,7 +1268,7 @@ fmt = PyBytes_AS_STRING(self->s_format); - f = whichtable((char **)&fmt); + f = whichtable(&fmt); s = fmt; size = 0; @@ -1457,7 +1457,7 @@ } static PyObject * -s_unpack_internal(PyStructObject *soself, char *startfrom) { +s_unpack_internal(PyStructObject *soself, const char *startfrom) { formatcode *code; Py_ssize_t i = 0; PyObject *result = PyTuple_New(soself->s_len); diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c --- a/Modules/_testmultiphase.c +++ b/Modules/_testmultiphase.c @@ -61,7 +61,7 @@ } static int -Example_setattr(ExampleObject *self, char *name, PyObject *v) +Example_setattr(ExampleObject *self, const char *name, PyObject *v) { if (self->x_attr == NULL) { self->x_attr = PyDict_New(); diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -841,7 +841,7 @@ Py_DECREF(tp); } -static char* +static const char * PyTclObject_TclString(PyObject *self) { return Tcl_GetString(((PyTclObject*)self)->value); @@ -1726,7 +1726,7 @@ varname_converter(PyObject *in, void *_out) { char *s; - char **out = (char**)_out; + const char **out = (const char**)_out; if (PyBytes_Check(in)) { if (PyBytes_Size(in) > INT_MAX) { PyErr_SetString(PyExc_OverflowError, "bytes object is too long"); @@ -1846,7 +1846,7 @@ static PyObject * SetVar(PyObject *self, PyObject *args, int flags) { - char *name1, *name2; + const char *name1, *name2; PyObject *newValue; PyObject *res = NULL; Tcl_Obj *newval, *ok; @@ -1915,7 +1915,7 @@ static PyObject * GetVar(PyObject *self, PyObject *args, int flags) { - char *name1, *name2=NULL; + const char *name1, *name2=NULL; PyObject *res = NULL; Tcl_Obj *tres; diff --git a/Modules/_winapi.c b/Modules/_winapi.c --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -675,7 +675,7 @@ /* helpers for createprocess */ static unsigned long -getulong(PyObject* obj, char* name) +getulong(PyObject* obj, const char* name) { PyObject* value; unsigned long ret; @@ -691,7 +691,7 @@ } static HANDLE -gethandle(PyObject* obj, char* name) +gethandle(PyObject* obj, const char* name) { PyObject* value; HANDLE ret; diff --git a/Modules/binascii.c b/Modules/binascii.c --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -256,7 +256,8 @@ binascii_a2b_uu_impl(PyModuleDef *module, Py_buffer *data) /*[clinic end generated code: output=5779f39b0b48459f input=7cafeaf73df63d1c]*/ { - unsigned char *ascii_data, *bin_data; + const unsigned char *ascii_data; + unsigned char *bin_data; int leftbits = 0; unsigned char this_ch; unsigned int leftchar = 0; @@ -342,7 +343,8 @@ binascii_b2a_uu_impl(PyModuleDef *module, Py_buffer *data) /*[clinic end generated code: output=181021b69bb9a414 input=00fdf458ce8b465b]*/ { - unsigned char *ascii_data, *bin_data; + unsigned char *ascii_data; + const unsigned char *bin_data; int leftbits = 0; unsigned char this_ch; unsigned int leftchar = 0; @@ -389,7 +391,7 @@ static int -binascii_find_valid(unsigned char *s, Py_ssize_t slen, int num) +binascii_find_valid(const unsigned char *s, Py_ssize_t slen, int num) { /* Finds & returns the (num+1)th ** valid character for base64, or -1 if none. @@ -426,7 +428,8 @@ binascii_a2b_base64_impl(PyModuleDef *module, Py_buffer *data) /*[clinic end generated code: output=3e351b702bed56d2 input=5872acf6e1cac243]*/ { - unsigned char *ascii_data, *bin_data; + const unsigned char *ascii_data; + unsigned char *bin_data; int leftbits = 0; unsigned char this_ch; unsigned int leftchar = 0; @@ -522,7 +525,8 @@ binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data, int newline) /*[clinic end generated code: output=19e1dd719a890b50 input=7b2ea6fa38d8924c]*/ { - unsigned char *ascii_data, *bin_data; + unsigned char *ascii_data; + const unsigned char *bin_data; int leftbits = 0; unsigned char this_ch; unsigned int leftchar = 0; @@ -589,7 +593,8 @@ binascii_a2b_hqx_impl(PyModuleDef *module, Py_buffer *data) /*[clinic end generated code: output=60bcdbbd28b105cd input=0d914c680e0eed55]*/ { - unsigned char *ascii_data, *bin_data; + const unsigned char *ascii_data; + unsigned char *bin_data; int leftbits = 0; unsigned char this_ch; unsigned int leftchar = 0; @@ -667,7 +672,8 @@ binascii_rlecode_hqx_impl(PyModuleDef *module, Py_buffer *data) /*[clinic end generated code: output=0905da344dbf0648 input=e1f1712447a82b09]*/ { - unsigned char *in_data, *out_data; + const unsigned char *in_data; + unsigned char *out_data; unsigned char ch; Py_ssize_t in, inend, len; _PyBytesWriter writer; @@ -728,7 +734,8 @@ binascii_b2a_hqx_impl(PyModuleDef *module, Py_buffer *data) /*[clinic end generated code: output=5a987810d5e3cdbb input=9596ebe019fe12ba]*/ { - unsigned char *ascii_data, *bin_data; + unsigned char *ascii_data; + const unsigned char *bin_data; int leftbits = 0; unsigned char this_ch; unsigned int leftchar = 0; @@ -782,7 +789,8 @@ binascii_rledecode_hqx_impl(PyModuleDef *module, Py_buffer *data) /*[clinic end generated code: output=f7afd89b789946ab input=54cdd49fc014402c]*/ { - unsigned char *in_data, *out_data; + const unsigned char *in_data; + unsigned char *out_data; unsigned char in_byte, in_repeat; Py_ssize_t in_len; _PyBytesWriter writer; @@ -899,7 +907,7 @@ binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc) /*[clinic end generated code: output=167c2dac62625717 input=add8c53712ccceda]*/ { - unsigned char *bin_data; + const unsigned char *bin_data; Py_ssize_t len; crc &= 0xffff; @@ -1050,7 +1058,7 @@ #ifdef USE_ZLIB_CRC32 /* This was taken from zlibmodule.c PyZlib_crc32 (but is PY_SSIZE_T_CLEAN) */ { - Byte *buf; + const Byte *buf; Py_ssize_t len; int signed_val; @@ -1061,7 +1069,7 @@ } #else /* USE_ZLIB_CRC32 */ { /* By Jim Ahlstrom; All rights transferred to CNRI */ - unsigned char *bin_data; + const unsigned char *bin_data; Py_ssize_t len; unsigned int result; @@ -1144,7 +1152,7 @@ binascii_a2b_hex_impl(PyModuleDef *module, Py_buffer *hexstr) /*[clinic end generated code: output=d61da452b5c6d290 input=9e1e7f2f94db24fd]*/ { - char* argbuf; + const char* argbuf; Py_ssize_t arglen; PyObject *retval; char* retbuf; @@ -1232,7 +1240,8 @@ { Py_ssize_t in, out; char ch; - unsigned char *ascii_data, *odata; + const unsigned char *ascii_data; + unsigned char *odata; Py_ssize_t datalen = 0; PyObject *rv; @@ -1338,13 +1347,14 @@ /*[clinic end generated code: output=a87ca9ccb94e2a9f input=7f2a9aaa008e92b2]*/ { Py_ssize_t in, out; - unsigned char *databuf, *odata; + const unsigned char *databuf; + unsigned char *odata; Py_ssize_t datalen = 0, odatalen = 0; PyObject *rv; unsigned int linelen = 0; unsigned char ch; int crlf = 0; - unsigned char *p; + const unsigned char *p; databuf = data->buf; datalen = data->len; @@ -1353,7 +1363,7 @@ /* XXX: this function has the side effect of converting all of * the end of lines to be the same depending on this detection * here */ - p = (unsigned char *) memchr(databuf, '\n', datalen); + p = (const unsigned char *) memchr(databuf, '\n', datalen); if ((p != NULL) && (p > databuf) && (*(p-1) == '\r')) crlf = 1; diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -738,7 +738,7 @@ } static void -debug_cycle(char *msg, PyObject *op) +debug_cycle(const char *msg, PyObject *op) { PySys_FormatStderr("gc: %s <%s %p>\n", msg, Py_TYPE(op)->tp_name, op); diff --git a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c --- a/Modules/getaddrinfo.c +++ b/Modules/getaddrinfo.c @@ -198,7 +198,7 @@ #define ERR(err) { error = (err); goto bad; } -char * +const char * gai_strerror(int ecode) { if (ecode < 0 || ecode > EAI_MAX) diff --git a/Modules/main.c b/Modules/main.c --- a/Modules/main.c +++ b/Modules/main.c @@ -103,7 +103,7 @@ "; static int -usage(int exitcode, wchar_t* program) +usage(int exitcode, const wchar_t* program) { FILE *f = exitcode ? stderr : stdout; diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -876,7 +876,7 @@ } static PyObject * -math_2(PyObject *args, double (*func) (double, double), char *funcname) +math_2(PyObject *args, double (*func) (double, double), const char *funcname) { PyObject *ox, *oy; double x, y, r; @@ -1673,7 +1673,7 @@ in that int is larger than PY_SSIZE_T_MAX. */ static PyObject* -loghelper(PyObject* arg, double (*func)(double), char *funcname) +loghelper(PyObject* arg, double (*func)(double), const char *funcname) { /* If it is int, do it ourselves. */ if (PyLong_Check(arg)) { diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -578,13 +578,13 @@ } -/* err_string(char* message) +/* err_string(const char* message) * * Sets the error string for an exception of type ParserError. * */ static void -err_string(char *message) +err_string(const char *message) { PyErr_SetString(parser_error, message); } @@ -597,7 +597,7 @@ * */ static PyObject* -parser_do_parse(PyObject *args, PyObject *kw, char *argspec, int type) +parser_do_parse(PyObject *args, PyObject *kw, const char *argspec, int type) { char* string = 0; PyObject* res = 0; @@ -984,7 +984,7 @@ /* * Validation routines used within the validation section: */ -static int validate_terminal(node *terminal, int type, char *string); +static int validate_terminal(node *terminal, int type, const char *string); #define validate_ampersand(ch) validate_terminal(ch, AMPER, "&") #define validate_circumflex(ch) validate_terminal(ch, CIRCUMFLEX, "^") @@ -1082,7 +1082,7 @@ static int -validate_terminal(node *terminal, int type, char *string) +validate_terminal(node *terminal, int type, const char *string) { int res = (validate_ntype(terminal, type) && ((string == 0) || (strcmp(string, STR(terminal)) == 0))); diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -949,7 +949,8 @@ } static void -argument_unavailable_error(char *function_name, char *argument_name) { +argument_unavailable_error(const char *function_name, const char *argument_name) +{ PyErr_Format(PyExc_NotImplementedError, "%s%s%s unavailable on this platform", (function_name != NULL) ? function_name : "", @@ -972,7 +973,8 @@ } static int -fd_specified(char *function_name, int fd) { +fd_specified(const char *function_name, int fd) +{ if (fd == -1) return 0; @@ -981,7 +983,8 @@ } static int -follow_symlinks_specified(char *function_name, int follow_symlinks) { +follow_symlinks_specified(const char *function_name, int follow_symlinks) +{ if (follow_symlinks) return 0; @@ -990,7 +993,8 @@ } static int -path_and_dir_fd_invalid(char *function_name, path_t *path, int dir_fd) { +path_and_dir_fd_invalid(const char *function_name, path_t *path, int dir_fd) +{ if (!path->narrow && !path->wide && (dir_fd != DEFAULT_DIR_FD)) { PyErr_Format(PyExc_ValueError, "%s: can't specify dir_fd without matching path", @@ -1001,7 +1005,8 @@ } static int -dir_fd_and_fd_invalid(char *function_name, int dir_fd, int fd) { +dir_fd_and_fd_invalid(const char *function_name, int dir_fd, int fd) +{ if ((dir_fd != DEFAULT_DIR_FD) && (fd != -1)) { PyErr_Format(PyExc_ValueError, "%s: can't specify both dir_fd and fd", @@ -1012,8 +1017,9 @@ } static int -fd_and_follow_symlinks_invalid(char *function_name, int fd, - int follow_symlinks) { +fd_and_follow_symlinks_invalid(const char *function_name, int fd, + int follow_symlinks) +{ if ((fd > 0) && (!follow_symlinks)) { PyErr_Format(PyExc_ValueError, "%s: cannot use fd and follow_symlinks together", @@ -1024,8 +1030,9 @@ } static int -dir_fd_and_follow_symlinks_invalid(char *function_name, int dir_fd, - int follow_symlinks) { +dir_fd_and_follow_symlinks_invalid(const char *function_name, int dir_fd, + int follow_symlinks) +{ if ((dir_fd != DEFAULT_DIR_FD) && (!follow_symlinks)) { PyErr_Format(PyExc_ValueError, "%s: cannot use dir_fd and follow_symlinks together", @@ -1220,7 +1227,7 @@ #ifdef MS_WINDOWS static PyObject * -win32_error(char* function, const char* filename) +win32_error(const char* function, const char* filename) { /* XXX We should pass the function name along in the future. (winreg.c also wants to pass the function name.) @@ -1235,7 +1242,7 @@ } static PyObject * -win32_error_object(char* function, PyObject* filename) +win32_error_object(const char* function, PyObject* filename) { /* XXX - see win32_error for comments on 'function' */ errno = GetLastError(); @@ -2100,7 +2107,7 @@ static PyObject * -posix_do_stat(char *function_name, path_t *path, +posix_do_stat(const char *function_name, path_t *path, int dir_fd, int follow_symlinks) { STRUCT_STAT st; @@ -4561,7 +4568,7 @@ #if defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMENSAT) static int -utime_dir_fd(utime_t *ut, int dir_fd, char *path, int follow_symlinks) +utime_dir_fd(utime_t *ut, int dir_fd, const char *path, int follow_symlinks) { #ifdef HAVE_UTIMENSAT int flags = follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW; @@ -4610,7 +4617,7 @@ #ifdef UTIME_HAVE_NOFOLLOW_SYMLINKS static int -utime_nofollow_symlinks(utime_t *ut, char *path) +utime_nofollow_symlinks(utime_t *ut, const char *path) { #ifdef HAVE_UTIMENSAT UTIME_TO_TIMESPEC; @@ -4626,7 +4633,7 @@ #ifndef MS_WINDOWS static int -utime_default(utime_t *ut, char *path) +utime_default(utime_t *ut, const char *path) { #ifdef HAVE_UTIMENSAT UTIME_TO_TIMESPEC; @@ -7323,7 +7330,7 @@ /* Return True if the path at src relative to dest is a directory */ static int -_check_dirA(char *src, char *dest) +_check_dirA(const char *src, char *dest) { WIN32_FILE_ATTRIBUTE_DATA src_info; char dest_parent[MAX_PATH]; @@ -11835,7 +11842,7 @@ #else /* POSIX */ static char * -join_path_filename(char *path_narrow, char* filename, Py_ssize_t filename_len) +join_path_filename(const char *path_narrow, const char* filename, Py_ssize_t filename_len) { Py_ssize_t path_len; Py_ssize_t size; @@ -11867,7 +11874,7 @@ } static PyObject * -DirEntry_from_posix_info(path_t *path, char *name, Py_ssize_t name_len, +DirEntry_from_posix_info(path_t *path, const char *name, Py_ssize_t name_len, ino_t d_ino #ifdef HAVE_DIRENT_D_TYPE , unsigned char d_type diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -91,7 +91,7 @@ * false on an exception. */ static int -set_error_attr(PyObject *err, char *name, int value) +set_error_attr(PyObject *err, const char *name, int value) { PyObject *v = PyLong_FromLong(value); @@ -218,7 +218,7 @@ } static PyObject* -call_with_frame(char *funcname, int lineno, PyObject* func, PyObject* args, +call_with_frame(const char *funcname, int lineno, PyObject* func, PyObject* args, xmlparseobject *self) { PyObject *res; @@ -766,7 +766,7 @@ { PyObject *str; Py_ssize_t len; - char *ptr; + const char *ptr; str = PyObject_CallFunction(meth, "n", buf_size); if (str == NULL) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -904,7 +904,7 @@ an error occurred; then an exception is raised. */ static int -setipaddr(char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int af) +setipaddr(const char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int af) { struct addrinfo hints, *res; int error; @@ -1085,7 +1085,7 @@ an error occurred. */ static int -setbdaddr(char *name, bdaddr_t *bdaddr) +setbdaddr(const char *name, bdaddr_t *bdaddr) { unsigned int b0, b1, b2, b3, b4, b5; char ch; diff --git a/Modules/timemodule.c b/Modules/timemodule.c --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -311,7 +311,7 @@ Returns non-zero on success (parallels PyArg_ParseTuple). */ static int -parse_time_t_args(PyObject *args, char *format, time_t *pwhen) +parse_time_t_args(PyObject *args, const char *format, time_t *pwhen) { PyObject *ot = NULL; time_t whent; diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c --- a/Modules/xxlimited.c +++ b/Modules/xxlimited.c @@ -89,7 +89,7 @@ } static int -Xxo_setattr(XxoObject *self, char *name, PyObject *v) +Xxo_setattr(XxoObject *self, const char *name, PyObject *v) { if (self->x_attr == NULL) { self->x_attr = PyDict_New(); diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c --- a/Modules/xxmodule.c +++ b/Modules/xxmodule.c @@ -76,7 +76,7 @@ } static int -Xxo_setattr(XxoObject *self, char *name, PyObject *v) +Xxo_setattr(XxoObject *self, const char *name, PyObject *v) { if (self->x_attr == NULL) { self->x_attr = PyDict_New(); diff --git a/Modules/zipimport.c b/Modules/zipimport.c --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -815,7 +815,7 @@ 4 bytes, encoded as little endian. This partially reimplements marshal.c:r_long() */ static long -get_long(unsigned char *buf) { +get_long(const unsigned char *buf) { long x; x = buf[0]; x |= (long)buf[1] << 8; diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -53,7 +53,7 @@ } compobject; static void -zlib_error(z_stream zst, int err, char *msg) +zlib_error(z_stream zst, int err, const char *msg) { const char *zmsg = Z_NULL; /* In case of a version mismatch, zst.msg won't be initialized. diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -2576,8 +2576,8 @@ /* XXX These two helpers could be optimized if argsize == 1 */ static Py_ssize_t -lstrip_helper(char *myptr, Py_ssize_t mysize, - void *argptr, Py_ssize_t argsize) +lstrip_helper(const char *myptr, Py_ssize_t mysize, + const void *argptr, Py_ssize_t argsize) { Py_ssize_t i = 0; while (i < mysize && memchr(argptr, (unsigned char) myptr[i], argsize)) @@ -2586,8 +2586,8 @@ } static Py_ssize_t -rstrip_helper(char *myptr, Py_ssize_t mysize, - void *argptr, Py_ssize_t argsize) +rstrip_helper(const char *myptr, Py_ssize_t mysize, + const void *argptr, Py_ssize_t argsize) { Py_ssize_t i = mysize - 1; while (i >= 0 && memchr(argptr, (unsigned char) myptr[i], argsize)) diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c --- a/Objects/bytes_methods.c +++ b/Objects/bytes_methods.c @@ -277,7 +277,7 @@ characters, all remaining cased characters have lowercase."); void -_Py_bytes_title(char *result, char *s, Py_ssize_t len) +_Py_bytes_title(char *result, const char *s, Py_ssize_t len) { Py_ssize_t i; int previous_is_cased = 0; @@ -306,7 +306,7 @@ and the rest lower-cased."); void -_Py_bytes_capitalize(char *result, char *s, Py_ssize_t len) +_Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len) { Py_ssize_t i; @@ -336,7 +336,7 @@ to lowercase ASCII and vice versa."); void -_Py_bytes_swapcase(char *result, char *s, Py_ssize_t len) +_Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len) { Py_ssize_t i; diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -308,7 +308,7 @@ { Py_ssize_t i; - p = va_arg(vargs, char*); + p = va_arg(vargs, const char*); i = strlen(p); if (prec > 0 && i > prec) i = prec; diff --git a/Objects/descrobject.c b/Objects/descrobject.c --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -22,7 +22,7 @@ } static PyObject * -descr_repr(PyDescrObject *descr, char *format) +descr_repr(PyDescrObject *descr, const char *format) { PyObject *name = NULL; if (descr->d_name != NULL && PyUnicode_Check(descr->d_name)) diff --git a/Objects/dictobject.c b/Objects/dictobject.c --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -1925,7 +1925,7 @@ } static int -dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, char *methname) +dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, const char *methname) { PyObject *arg = NULL; int result = 0; diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1133,7 +1133,7 @@ return -1; } -Py_LOCAL_INLINE(char *) +Py_LOCAL_INLINE(const char *) get_native_fmtstr(const char *fmt) { int at = 0; @@ -1221,7 +1221,7 @@ goto out; } - view->format = get_native_fmtstr(PyBytes_AS_STRING(asciifmt)); + view->format = (char *)get_native_fmtstr(PyBytes_AS_STRING(asciifmt)); if (view->format == NULL) { /* NOT_REACHED: get_native_fmtchar() already validates the format. */ PyErr_SetString(PyExc_RuntimeError, diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -564,7 +564,7 @@ static PyTypeObject *best_base(PyObject *); static int mro_internal(PyTypeObject *, PyObject **); Py_LOCAL_INLINE(int) type_is_subtype_base_chain(PyTypeObject *, PyTypeObject *); -static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, char *); +static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, const char *); static int add_subclass(PyTypeObject*, PyTypeObject*); static int add_all_subclasses(PyTypeObject *type, PyObject *bases); static void remove_subclass(PyTypeObject *, PyTypeObject *); @@ -1435,7 +1435,7 @@ as lookup_method to cache the interned name string object. */ static PyObject * -call_method(PyObject *o, _Py_Identifier *nameid, char *format, ...) +call_method(PyObject *o, _Py_Identifier *nameid, const char *format, ...) { va_list va; PyObject *args, *func = 0, *retval; @@ -1471,7 +1471,7 @@ /* Clone of call_method() that returns NotImplemented when the lookup fails. */ static PyObject * -call_maybe(PyObject *o, _Py_Identifier *nameid, char *format, ...) +call_maybe(PyObject *o, _Py_Identifier *nameid, const char *format, ...) { va_list va; PyObject *args, *func = 0, *retval; @@ -3609,7 +3609,7 @@ } static int -compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, char* attr) +compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, const char* attr) { PyTypeObject *newbase, *oldbase; @@ -5348,7 +5348,7 @@ /* Helper to check for object.__setattr__ or __delattr__ applied to a type. This is called the Carlo Verre hack after its discoverer. */ static int -hackcheck(PyObject *self, setattrofunc func, char *what) +hackcheck(PyObject *self, setattrofunc func, const char *what) { PyTypeObject *type = Py_TYPE(self); while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -6986,7 +6986,7 @@ # define WC_ERR_INVALID_CHARS 0x0080 #endif -static char* +static const char* code_page_name(UINT code_page, PyObject **obj) { *obj = NULL; @@ -7094,7 +7094,7 @@ PyObject *errorHandler = NULL; PyObject *exc = NULL; PyObject *encoding_obj = NULL; - char *encoding; + const char *encoding; DWORD err; int ret = -1; @@ -7438,7 +7438,7 @@ PyObject *errorHandler = NULL; PyObject *exc = NULL; PyObject *encoding_obj = NULL; - char *encoding; + const char *encoding; Py_ssize_t newpos, newoutsize; PyObject *rep; int ret = -1; diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -265,7 +265,7 @@ } static int -parse_weakref_init_args(char *funcname, PyObject *args, PyObject *kwargs, +parse_weakref_init_args(const char *funcname, PyObject *args, PyObject *kwargs, PyObject **obp, PyObject **callbackp) { /* XXX Should check that kwargs == NULL or is empty. */ diff --git a/Parser/pgen.c b/Parser/pgen.c --- a/Parser/pgen.c +++ b/Parser/pgen.c @@ -379,7 +379,7 @@ /* Forward */ static void printssdfa(int xx_nstates, ss_state *xx_state, int nbits, - labellist *ll, char *msg); + labellist *ll, const char *msg); static void simplify(int xx_nstates, ss_state *xx_state); static void convert(dfa *d, int xx_nstates, ss_state *xx_state); @@ -494,7 +494,7 @@ static void printssdfa(int xx_nstates, ss_state *xx_state, int nbits, - labellist *ll, char *msg) + labellist *ll, const char *msg) { int i, ibit, iarc; ss_state *yy; diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c --- a/Parser/pgenmain.c +++ b/Parser/pgenmain.c @@ -27,7 +27,7 @@ int Py_IgnoreEnvironmentFlag; /* Forward */ -grammar *getgrammar(char *filename); +grammar *getgrammar(const char *filename); void Py_Exit(int) _Py_NO_RETURN; @@ -76,7 +76,7 @@ } grammar * -getgrammar(char *filename) +getgrammar(const char *filename) { FILE *fp; node *n; diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -202,8 +202,8 @@ } -static char * -get_normal_name(char *s) /* for utf-8 and latin-1 */ +static const char * +get_normal_name(const char *s) /* for utf-8 and latin-1 */ { char buf[13]; int i; @@ -264,7 +264,7 @@ if (begin < t) { char* r = new_string(begin, t - begin, tok); - char* q; + const char* q; if (!r) return 0; q = get_normal_name(r); diff --git a/Python/_warnings.c b/Python/_warnings.c --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -921,7 +921,7 @@ #undef PyErr_Warn PyAPI_FUNC(int) -PyErr_Warn(PyObject *category, char *text) +PyErr_Warn(PyObject *category, const char *text) { return PyErr_WarnEx(category, text, 1); } diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -125,7 +125,7 @@ #ifdef LLTRACE static int lltrace; -static int prtrace(PyObject *, char *); +static int prtrace(PyObject *, const char *); #endif static int call_trace(Py_tracefunc, PyObject *, PyThreadState *, PyFrameObject *, @@ -4308,7 +4308,7 @@ #ifdef LLTRACE static int -prtrace(PyObject *v, char *str) +prtrace(PyObject *v, const char *str) { printf("%s ", str); if (PyObject_Print(v, stdout, 0) != 0) diff --git a/Python/dtoa.c b/Python/dtoa.c --- a/Python/dtoa.c +++ b/Python/dtoa.c @@ -2315,7 +2315,7 @@ } static char * -nrv_alloc(char *s, char **rve, int n) +nrv_alloc(const char *s, char **rve, int n) { char *rv, *t; diff --git a/Python/dynload_win.c b/Python/dynload_win.c --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -41,7 +41,7 @@ /* Case insensitive string compare, to avoid any dependencies on particular C RTL implementations */ -static int strcasecmp (char *string1, char *string2) +static int strcasecmp (const char *string1, const char *string2) { int first, second; diff --git a/Python/getargs.c b/Python/getargs.c --- a/Python/getargs.c +++ b/Python/getargs.c @@ -20,12 +20,12 @@ #ifdef HAVE_DECLSPEC_DLL /* Export functions */ -PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, char *, ...); -PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, char *, ...); +PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, const char *, ...); +PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...); PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *, const char *, char **, ...); PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...); -PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, char *, va_list); +PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, const char *, va_list); PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *, const char *, char **, va_list); #endif @@ -56,18 +56,18 @@ /* Forward */ static int vgetargs1(PyObject *, const char *, va_list *, int); static void seterror(Py_ssize_t, const char *, int *, const char *, const char *); -static char *convertitem(PyObject *, const char **, va_list *, int, int *, - char *, size_t, freelist_t *); -static char *converttuple(PyObject *, const char **, va_list *, int, - int *, char *, size_t, int, freelist_t *); -static char *convertsimple(PyObject *, const char **, va_list *, int, char *, - size_t, freelist_t *); -static Py_ssize_t convertbuffer(PyObject *, void **p, char **); -static int getbuffer(PyObject *, Py_buffer *, char**); +static const char *convertitem(PyObject *, const char **, va_list *, int, int *, + char *, size_t, freelist_t *); +static const char *converttuple(PyObject *, const char **, va_list *, int, + int *, char *, size_t, int, freelist_t *); +static const char *convertsimple(PyObject *, const char **, va_list *, int, + char *, size_t, freelist_t *); +static Py_ssize_t convertbuffer(PyObject *, void **p, const char **); +static int getbuffer(PyObject *, Py_buffer *, const char**); static int vgetargskeywords(PyObject *, PyObject *, const char *, char **, va_list *, int); -static char *skipitem(const char **, va_list *, int); +static const char *skipitem(const char **, va_list *, int); int PyArg_Parse(PyObject *args, const char *format, ...) @@ -82,7 +82,7 @@ } int -_PyArg_Parse_SizeT(PyObject *args, char *format, ...) +_PyArg_Parse_SizeT(PyObject *args, const char *format, ...) { int retval; va_list va; @@ -107,7 +107,7 @@ } int -_PyArg_ParseTuple_SizeT(PyObject *args, char *format, ...) +_PyArg_ParseTuple_SizeT(PyObject *args, const char *format, ...) { int retval; va_list va; @@ -130,7 +130,7 @@ } int -_PyArg_VaParse_SizeT(PyObject *args, char *format, va_list va) +_PyArg_VaParse_SizeT(PyObject *args, const char *format, va_list va) { va_list lva; @@ -208,7 +208,7 @@ int endfmt = 0; const char *formatsave = format; Py_ssize_t i, len; - char *msg; + const char *msg; int compat = flags & FLAG_COMPAT; freelistentry_t static_entries[STATIC_FREELIST_ENTRIES]; freelist_t freelist; @@ -416,7 +416,7 @@ and msgbuf is returned. */ -static char * +static const char * converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags, int *levels, char *msgbuf, size_t bufsize, int toplevel, freelist_t *freelist) @@ -474,7 +474,7 @@ format = *p_format; for (i = 0; i < n; i++) { - char *msg; + const char *msg; PyObject *item; item = PySequence_GetItem(arg, i); if (item == NULL) { @@ -501,11 +501,11 @@ /* Convert a single item. */ -static char * +static const char * convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags, int *levels, char *msgbuf, size_t bufsize, freelist_t *freelist) { - char *msg; + const char *msg; const char *format = *p_format; if (*format == '(' /* ')' */) { @@ -530,7 +530,7 @@ /* Format an error message generated by convertsimple(). */ -static char * +static const char * converterr(const char *expected, PyObject *arg, char *msgbuf, size_t bufsize) { assert(expected != NULL); @@ -566,7 +566,7 @@ When you add new format codes, please don't forget poor skipitem() below. */ -static char * +static const char * convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, char *msgbuf, size_t bufsize, freelist_t *freelist) { @@ -851,7 +851,7 @@ case 'y': {/* any bytes-like object */ void **p = (void **)va_arg(*p_va, char **); - char *buf; + const char *buf; Py_ssize_t count; if (*format == '*') { if (getbuffer(arg, (Py_buffer*)p, &buf) < 0) @@ -898,7 +898,7 @@ PyBuffer_FillInfo(p, arg, sarg, len, 1, 0); } else { /* any bytes-like object */ - char *buf; + const char *buf; if (getbuffer(arg, p, &buf) < 0) return converterr(buf, arg, msgbuf, bufsize); } @@ -928,7 +928,7 @@ } else { /* read-only bytes-like object */ /* XXX Really? */ - char *buf; + const char *buf; Py_ssize_t count = convertbuffer(arg, p, &buf); if (count < 0) return converterr(buf, arg, msgbuf, bufsize); @@ -1275,7 +1275,7 @@ } static Py_ssize_t -convertbuffer(PyObject *arg, void **p, char **errmsg) +convertbuffer(PyObject *arg, void **p, const char **errmsg) { PyBufferProcs *pb = Py_TYPE(arg)->tp_as_buffer; Py_ssize_t count; @@ -1297,7 +1297,7 @@ } static int -getbuffer(PyObject *arg, Py_buffer *view, char **errmsg) +getbuffer(PyObject *arg, Py_buffer *view, const char **errmsg) { if (PyObject_GetBuffer(arg, view, PyBUF_SIMPLE) != 0) { *errmsg = "bytes-like object"; @@ -1629,7 +1629,7 @@ } -static char * +static const char * skipitem(const char **p_format, va_list *p_va, int flags) { const char *format = *p_format; @@ -1722,7 +1722,7 @@ case '(': /* bypass tuple, not handled at all previously */ { - char *msg; + const char *msg; for (;;) { if (*format==')') break; diff --git a/Python/marshal.c b/Python/marshal.c --- a/Python/marshal.c +++ b/Python/marshal.c @@ -643,7 +643,7 @@ PyObject *refs; /* a list */ } RFILE; -static char * +static const char * r_string(Py_ssize_t n, RFILE *p) { Py_ssize_t read = -1; @@ -729,7 +729,7 @@ c = getc(p->fp); } else { - char *ptr = r_string(1, p); + const char *ptr = r_string(1, p); if (ptr != NULL) c = *(unsigned char *) ptr; } @@ -740,9 +740,9 @@ r_short(RFILE *p) { short x = -1; - unsigned char *buffer; + const unsigned char *buffer; - buffer = (unsigned char *) r_string(2, p); + buffer = (const unsigned char *) r_string(2, p); if (buffer != NULL) { x = buffer[0]; x |= buffer[1] << 8; @@ -756,9 +756,9 @@ r_long(RFILE *p) { long x = -1; - unsigned char *buffer; + const unsigned char *buffer; - buffer = (unsigned char *) r_string(4, p); + buffer = (const unsigned char *) r_string(4, p); if (buffer != NULL) { x = buffer[0]; x |= (long)buffer[1] << 8; @@ -978,7 +978,8 @@ case TYPE_FLOAT: { - char buf[256], *ptr; + char buf[256]; + const char *ptr; double dx; n = r_byte(p); if (n == EOF) { @@ -1001,9 +1002,9 @@ case TYPE_BINARY_FLOAT: { - unsigned char *buf; + const unsigned char *buf; double x; - buf = (unsigned char *) r_string(8, p); + buf = (const unsigned char *) r_string(8, p); if (buf == NULL) break; x = _PyFloat_Unpack8(buf, 1); @@ -1016,7 +1017,8 @@ case TYPE_COMPLEX: { - char buf[256], *ptr; + char buf[256]; + const char *ptr; Py_complex c; n = r_byte(p); if (n == EOF) { @@ -1053,15 +1055,15 @@ case TYPE_BINARY_COMPLEX: { - unsigned char *buf; + const unsigned char *buf; Py_complex c; - buf = (unsigned char *) r_string(8, p); + buf = (const unsigned char *) r_string(8, p); if (buf == NULL) break; c.real = _PyFloat_Unpack8(buf, 1); if (c.real == -1.0 && PyErr_Occurred()) break; - buf = (unsigned char *) r_string(8, p); + buf = (const unsigned char *) r_string(8, p); if (buf == NULL) break; c.imag = _PyFloat_Unpack8(buf, 1); @@ -1074,7 +1076,7 @@ case TYPE_STRING: { - char *ptr; + const char *ptr; n = r_long(p); if (PyErr_Occurred()) break; @@ -1119,7 +1121,7 @@ } _read_ascii: { - char *ptr; + const char *ptr; ptr = r_string(n, p); if (ptr == NULL) break; @@ -1137,7 +1139,7 @@ is_interned = 1; case TYPE_UNICODE: { - char *buffer; + const char *buffer; n = r_long(p); if (PyErr_Occurred()) diff --git a/Python/modsupport.c b/Python/modsupport.c --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -301,7 +301,7 @@ case 'U': /* XXX deprecated alias */ { PyObject *v; - char *str = va_arg(*p_va, char *); + const char *str = va_arg(*p_va, const char *); Py_ssize_t n; if (**p_format == '#') { ++*p_format; @@ -334,7 +334,7 @@ case 'y': { PyObject *v; - char *str = va_arg(*p_va, char *); + const char *str = va_arg(*p_va, const char *); Py_ssize_t n; if (**p_format == '#') { ++*p_format; diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1004,8 +1004,8 @@ /* returns Py_None if the fd is not valid */ static PyObject* create_stdio(PyObject* io, - int fd, int write_mode, char* name, - char* encoding, char* errors) + int fd, int write_mode, const char* name, + const char* encoding, const char* errors) { PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res; const char* mode; diff --git a/Python/pythonrun.c b/Python/pythonrun.c --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1138,8 +1138,8 @@ mod_ty PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc, - int start, char *ps1, - char *ps2, PyCompilerFlags *flags, int *errcode, + int start, const char *ps1, + const char *ps2, PyCompilerFlags *flags, int *errcode, PyArena *arena) { mod_ty mod; @@ -1171,8 +1171,8 @@ mod_ty PyParser_ASTFromFile(FILE *fp, const char *filename_str, const char* enc, - int start, char *ps1, - char *ps2, PyCompilerFlags *flags, int *errcode, + int start, const char *ps1, + const char *ps2, PyCompilerFlags *flags, int *errcode, PyArena *arena) { mod_ty mod; diff --git a/Python/symtable.c b/Python/symtable.c --- a/Python/symtable.c +++ b/Python/symtable.c @@ -160,7 +160,7 @@ }; static int symtable_analyze(struct symtable *st); -static int symtable_warn(struct symtable *st, char *msg, int lineno); +static int symtable_warn(struct symtable *st, const char *msg, int lineno); static int symtable_enter_block(struct symtable *st, identifier name, _Py_block_ty block, void *ast, int lineno, int col_offset); @@ -903,7 +903,7 @@ static int -symtable_warn(struct symtable *st, char *msg, int lineno) +symtable_warn(struct symtable *st, const char *msg, int lineno) { PyObject *message = PyUnicode_FromString(msg); if (message == NULL) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 25 14:06:48 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Dec 2015 19:06:48 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIyOTk1?= =?utf-8?q?=3A_Instances_of_extension_types_with_a_state_that_aren=27t?= Message-ID: <20151225190648.77229.24509@psf.io> https://hg.python.org/cpython/rev/0cd2de69fb66 changeset: 99676:0cd2de69fb66 branch: 3.5 parent: 99672:ed62cf0cf256 user: Serhiy Storchaka date: Fri Dec 25 21:04:29 2015 +0200 summary: Issue #22995: Instances of extension types with a state that aren't subclasses of list or dict and haven't implemented any pickle-related methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__, or __getstate__), can no longer be pickled. Including memoryview. files: Lib/test/test_csv.py | 13 ++++++ Lib/test/test_memoryview.py | 13 ++++++ Misc/NEWS | 5 ++ Objects/typeobject.c | 51 +++++++++++++++++------- 4 files changed, 67 insertions(+), 15 deletions(-) diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -1,6 +1,7 @@ # Copyright (C) 2001,2002 Python Software Foundation # csv package unit tests +import copy import io import sys import os @@ -9,6 +10,7 @@ from tempfile import TemporaryFile import csv import gc +import pickle from test import support class Test_Csv(unittest.TestCase): @@ -424,6 +426,17 @@ self.assertRaises(TypeError, csv.reader, [], quoting = -1) self.assertRaises(TypeError, csv.reader, [], quoting = 100) + def test_copy(self): + for name in csv.list_dialects(): + dialect = csv.get_dialect(name) + self.assertRaises(TypeError, copy.copy, dialect) + + def test_pickle(self): + for name in csv.list_dialects(): + dialect = csv.get_dialect(name) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + self.assertRaises(TypeError, pickle.dumps, dialect, proto) + class TestCsvBase(unittest.TestCase): def readerAssertEqual(self, input, expected_result): with TemporaryFile("w+", newline='') as fileobj: diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py --- a/Lib/test/test_memoryview.py +++ b/Lib/test/test_memoryview.py @@ -11,6 +11,8 @@ import weakref import array import io +import copy +import pickle class AbstractMemoryTests: @@ -519,6 +521,17 @@ m2 = m1[::-1] self.assertEqual(m2.hex(), '30' * 200000) + def test_copy(self): + m = memoryview(b'abc') + with self.assertRaises(TypeError): + copy.copy(m) + + def test_pickle(self): + m = memoryview(b'abc') + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + with self.assertRaises(TypeError): + pickle.dumps(m, proto) + if __name__ == "__main__": unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,11 @@ Core and Builtins ----------------- +- Issue #22995: Instances of extension types with a state that aren't + subclasses of list or dict and haven't implemented any pickle-related + methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__, + or __getstate__), can no longer be pickled. Including memoryview. + - Issue #20440: Massive replacing unsafe attribute setting code with special macro Py_SETREF. diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3831,7 +3831,7 @@ } Py_LOCAL(PyObject *) -_PyObject_GetState(PyObject *obj) +_PyObject_GetState(PyObject *obj, int required) { PyObject *state; PyObject *getstate; @@ -3846,6 +3846,13 @@ } PyErr_Clear(); + if (required && obj->ob_type->tp_itemsize) { + PyErr_Format(PyExc_TypeError, + "can't pickle %.200s objects", + Py_TYPE(obj)->tp_name); + return NULL; + } + { PyObject **dict; dict = _PyObject_GetDictPtr(obj); @@ -3870,6 +3877,24 @@ } assert(slotnames == Py_None || PyList_Check(slotnames)); + if (required) { + Py_ssize_t basicsize = PyBaseObject_Type.tp_basicsize; + if (obj->ob_type->tp_dictoffset) + basicsize += sizeof(PyObject *); + if (obj->ob_type->tp_weaklistoffset) + basicsize += sizeof(PyObject *); + if (slotnames != Py_None) + basicsize += sizeof(PyObject *) * Py_SIZE(slotnames); + if (obj->ob_type->tp_basicsize > basicsize) { + Py_DECREF(slotnames); + Py_DECREF(state); + PyErr_Format(PyExc_TypeError, + "can't pickle %.200s objects", + Py_TYPE(obj)->tp_name); + return NULL; + } + } + if (slotnames != Py_None && Py_SIZE(slotnames) > 0) { PyObject *slots; Py_ssize_t slotnames_size, i; @@ -4099,29 +4124,24 @@ PyObject *copyreg; PyObject *newobj, *newargs, *state, *listitems, *dictitems; PyObject *result; + int hasargs; if (Py_TYPE(obj)->tp_new == NULL) { PyErr_Format(PyExc_TypeError, - "can't pickle %s objects", + "can't pickle %.200s objects", Py_TYPE(obj)->tp_name); return NULL; } if (_PyObject_GetNewArguments(obj, &args, &kwargs) < 0) return NULL; - if (args == NULL) { - args = PyTuple_New(0); - if (args == NULL) { - Py_XDECREF(kwargs); - return NULL; - } - } copyreg = import_copyreg(); if (copyreg == NULL) { - Py_DECREF(args); + Py_XDECREF(args); Py_XDECREF(kwargs); return NULL; } + hasargs = (args != NULL); if (kwargs == NULL || PyDict_Size(kwargs) == 0) { _Py_IDENTIFIER(__newobj__); PyObject *cls; @@ -4131,13 +4151,13 @@ newobj = _PyObject_GetAttrId(copyreg, &PyId___newobj__); Py_DECREF(copyreg); if (newobj == NULL) { - Py_DECREF(args); + Py_XDECREF(args); return NULL; } - n = PyTuple_GET_SIZE(args); + n = args ? PyTuple_GET_SIZE(args) : 0; newargs = PyTuple_New(n+1); if (newargs == NULL) { - Py_DECREF(args); + Py_XDECREF(args); Py_DECREF(newobj); return NULL; } @@ -4149,7 +4169,7 @@ Py_INCREF(v); PyTuple_SET_ITEM(newargs, i+1, v); } - Py_DECREF(args); + Py_XDECREF(args); } else if (proto >= 4) { _Py_IDENTIFIER(__newobj_ex__); @@ -4180,7 +4200,8 @@ return NULL; } - state = _PyObject_GetState(obj); + state = _PyObject_GetState(obj, + !hasargs && !PyList_Check(obj) && !PyDict_Check(obj)); if (state == NULL) { Py_DECREF(newobj); Py_DECREF(newargs); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Dec 25 14:06:48 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Fri, 25 Dec 2015 19:06:48 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2322995=3A_Instances_of_extension_types_with_a_st?= =?utf-8?q?ate_that_aren=27t?= Message-ID: <20151225190648.8261.20589@psf.io> https://hg.python.org/cpython/rev/b8d108a2a38e changeset: 99677:b8d108a2a38e parent: 99675:80d1faa9735d parent: 99676:0cd2de69fb66 user: Serhiy Storchaka date: Fri Dec 25 21:05:35 2015 +0200 summary: Issue #22995: Instances of extension types with a state that aren't subclasses of list or dict and haven't implemented any pickle-related methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__, or __getstate__), can no longer be pickled. Including memoryview. files: Lib/test/test_csv.py | 13 ++++++ Lib/test/test_memoryview.py | 13 ++++++ Misc/NEWS | 5 ++ Objects/typeobject.c | 51 +++++++++++++++++------- 4 files changed, 67 insertions(+), 15 deletions(-) diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -1,6 +1,7 @@ # Copyright (C) 2001,2002 Python Software Foundation # csv package unit tests +import copy import io import sys import os @@ -9,6 +10,7 @@ from tempfile import TemporaryFile import csv import gc +import pickle from test import support class Test_Csv(unittest.TestCase): @@ -424,6 +426,17 @@ self.assertRaises(TypeError, csv.reader, [], quoting = -1) self.assertRaises(TypeError, csv.reader, [], quoting = 100) + def test_copy(self): + for name in csv.list_dialects(): + dialect = csv.get_dialect(name) + self.assertRaises(TypeError, copy.copy, dialect) + + def test_pickle(self): + for name in csv.list_dialects(): + dialect = csv.get_dialect(name) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + self.assertRaises(TypeError, pickle.dumps, dialect, proto) + class TestCsvBase(unittest.TestCase): def readerAssertEqual(self, input, expected_result): with TemporaryFile("w+", newline='') as fileobj: diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py --- a/Lib/test/test_memoryview.py +++ b/Lib/test/test_memoryview.py @@ -11,6 +11,8 @@ import weakref import array import io +import copy +import pickle class AbstractMemoryTests: @@ -519,6 +521,17 @@ m2 = m1[::-1] self.assertEqual(m2.hex(), '30' * 200000) + def test_copy(self): + m = memoryview(b'abc') + with self.assertRaises(TypeError): + copy.copy(m) + + def test_pickle(self): + m = memoryview(b'abc') + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + with self.assertRaises(TypeError): + pickle.dumps(m, proto) + if __name__ == "__main__": unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,11 @@ Core and Builtins ----------------- +- Issue #22995: Instances of extension types with a state that aren't + subclasses of list or dict and haven't implemented any pickle-related + methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__, + or __getstate__), can no longer be pickled. Including memoryview. + - Issue #20440: Massive replacing unsafe attribute setting code with special macro Py_SETREF. diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3839,7 +3839,7 @@ } Py_LOCAL(PyObject *) -_PyObject_GetState(PyObject *obj) +_PyObject_GetState(PyObject *obj, int required) { PyObject *state; PyObject *getstate; @@ -3854,6 +3854,13 @@ } PyErr_Clear(); + if (required && obj->ob_type->tp_itemsize) { + PyErr_Format(PyExc_TypeError, + "can't pickle %.200s objects", + Py_TYPE(obj)->tp_name); + return NULL; + } + { PyObject **dict; dict = _PyObject_GetDictPtr(obj); @@ -3878,6 +3885,24 @@ } assert(slotnames == Py_None || PyList_Check(slotnames)); + if (required) { + Py_ssize_t basicsize = PyBaseObject_Type.tp_basicsize; + if (obj->ob_type->tp_dictoffset) + basicsize += sizeof(PyObject *); + if (obj->ob_type->tp_weaklistoffset) + basicsize += sizeof(PyObject *); + if (slotnames != Py_None) + basicsize += sizeof(PyObject *) * Py_SIZE(slotnames); + if (obj->ob_type->tp_basicsize > basicsize) { + Py_DECREF(slotnames); + Py_DECREF(state); + PyErr_Format(PyExc_TypeError, + "can't pickle %.200s objects", + Py_TYPE(obj)->tp_name); + return NULL; + } + } + if (slotnames != Py_None && Py_SIZE(slotnames) > 0) { PyObject *slots; Py_ssize_t slotnames_size, i; @@ -4107,29 +4132,24 @@ PyObject *copyreg; PyObject *newobj, *newargs, *state, *listitems, *dictitems; PyObject *result; + int hasargs; if (Py_TYPE(obj)->tp_new == NULL) { PyErr_Format(PyExc_TypeError, - "can't pickle %s objects", + "can't pickle %.200s objects", Py_TYPE(obj)->tp_name); return NULL; } if (_PyObject_GetNewArguments(obj, &args, &kwargs) < 0) return NULL; - if (args == NULL) { - args = PyTuple_New(0); - if (args == NULL) { - Py_XDECREF(kwargs); - return NULL; - } - } copyreg = import_copyreg(); if (copyreg == NULL) { - Py_DECREF(args); + Py_XDECREF(args); Py_XDECREF(kwargs); return NULL; } + hasargs = (args != NULL); if (kwargs == NULL || PyDict_Size(kwargs) == 0) { _Py_IDENTIFIER(__newobj__); PyObject *cls; @@ -4139,13 +4159,13 @@ newobj = _PyObject_GetAttrId(copyreg, &PyId___newobj__); Py_DECREF(copyreg); if (newobj == NULL) { - Py_DECREF(args); + Py_XDECREF(args); return NULL; } - n = PyTuple_GET_SIZE(args); + n = args ? PyTuple_GET_SIZE(args) : 0; newargs = PyTuple_New(n+1); if (newargs == NULL) { - Py_DECREF(args); + Py_XDECREF(args); Py_DECREF(newobj); return NULL; } @@ -4157,7 +4177,7 @@ Py_INCREF(v); PyTuple_SET_ITEM(newargs, i+1, v); } - Py_DECREF(args); + Py_XDECREF(args); } else { _Py_IDENTIFIER(__newobj_ex__); @@ -4178,7 +4198,8 @@ } } - state = _PyObject_GetState(obj); + state = _PyObject_GetState(obj, + !hasargs && !PyList_Check(obj) && !PyDict_Check(obj)); if (state == NULL) { Py_DECREF(newobj); Py_DECREF(newargs); -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sat Dec 26 03:43:06 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 26 Dec 2015 08:43:06 +0000 Subject: [Python-checkins] Daily reference leaks (b8d108a2a38e): sum=-43 Message-ID: <20151226084306.21233.14283@psf.io> results for b8d108a2a38e on branch "default" -------------------------------------------- test_asyncio leaked [0, 0, -34] references, sum=-34 test_asyncio leaked [0, 0, -11] memory blocks, sum=-11 test_collections leaked [-2, 0, 0] references, sum=-2 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogkvReeJ', '--timeout', '7200'] From python-checkins at python.org Sat Dec 26 07:22:51 2015 From: python-checkins at python.org (vinay.sajip) Date: Sat, 26 Dec 2015 12:22:51 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogQ2xvc2VzICMyNTY2?= =?utf-8?q?4=3A_handled_logger_names_in_Unicode=2E?= Message-ID: <20151226122251.126297.2725@psf.io> https://hg.python.org/cpython/rev/512a628c683e changeset: 99678:512a628c683e branch: 2.7 parent: 99671:deda5b5160d2 user: Vinay Sajip date: Sat Dec 26 12:21:47 2015 +0000 summary: Closes #25664: handled logger names in Unicode. files: Lib/logging/__init__.py | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -465,7 +465,15 @@ record.message = record.getMessage() if self.usesTime(): record.asctime = self.formatTime(record, self.datefmt) - s = self._fmt % record.__dict__ + try: + s = self._fmt % record.__dict__ + except UnicodeDecodeError as e: + # Issue 25664. The logger name may be Unicode. Try again ... + try: + record.name = record.name.decode('utf-8') + s = self._fmt % record.__dict__ + except UnicodeDecodeError: + raise e if record.exc_info: # Cache the traceback text to avoid converting it multiple times # (it's constant anyway) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 26 07:36:09 2015 From: python-checkins at python.org (vinay.sajip) Date: Sat, 26 Dec 2015 12:36:09 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Closes_=2325789=3A_Improve?= =?utf-8?q?d_buffering_behaviour_in_launcher=2E?= Message-ID: <20151226123609.105564.76069@psf.io> https://hg.python.org/cpython/rev/d0a84d0c5ceb changeset: 99679:d0a84d0c5ceb parent: 99677:b8d108a2a38e user: Vinay Sajip date: Sat Dec 26 12:35:47 2015 +0000 summary: Closes #25789: Improved buffering behaviour in launcher. files: PC/launcher.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -98,7 +98,7 @@ MessageBox(NULL, message, TEXT("Python Launcher is sorry to say ..."), MB_OK); #endif - ExitProcess(rc); + exit(rc); } /* @@ -652,7 +652,7 @@ if (!ok) error(RC_CREATE_PROCESS, L"Failed to get exit code of process"); debug(L"child process exit code: %d\n", rc); - ExitProcess(rc); + exit(rc); } static void @@ -1357,6 +1357,7 @@ wchar_t * av[2]; #endif + setvbuf(stderr, (char *)NULL, _IONBF, 0); wp = get_env(L"PYLAUNCH_DEBUG"); if ((wp != NULL) && (*wp != L'\0')) log_fp = stderr; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 26 07:51:58 2015 From: python-checkins at python.org (vinay.sajip) Date: Sat, 26 Dec 2015 12:51:58 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogQ2xvc2VzICMyNTY4?= =?utf-8?q?5=3A_Made_SocketHandler_emission_more_efficient=2E?= Message-ID: <20151226125157.70417.38798@psf.io> https://hg.python.org/cpython/rev/6210b41a2394 changeset: 99680:6210b41a2394 branch: 3.5 parent: 99676:0cd2de69fb66 user: Vinay Sajip date: Sat Dec 26 12:48:44 2015 +0000 summary: Closes #25685: Made SocketHandler emission more efficient. files: Lib/logging/handlers.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -588,6 +588,8 @@ d['msg'] = record.getMessage() d['args'] = None d['exc_info'] = None + # Issue #25685: delete 'message' if present: redundant with 'msg' + d.pop('message', None) s = pickle.dumps(d, 1) slen = struct.pack(">L", len(s)) return slen + s -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 26 07:51:58 2015 From: python-checkins at python.org (vinay.sajip) Date: Sat, 26 Dec 2015 12:51:58 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Closes_=2325685=3A_Merged_fix_from_3=2E5=2E?= Message-ID: <20151226125158.124860.95739@psf.io> https://hg.python.org/cpython/rev/6a6a68a3d323 changeset: 99681:6a6a68a3d323 parent: 99679:d0a84d0c5ceb parent: 99680:6210b41a2394 user: Vinay Sajip date: Sat Dec 26 12:51:43 2015 +0000 summary: Closes #25685: Merged fix from 3.5. files: Lib/logging/handlers.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -597,6 +597,8 @@ d['msg'] = record.getMessage() d['args'] = None d['exc_info'] = None + # Issue #25685: delete 'message' if present: redundant with 'msg' + d.pop('message', None) s = pickle.dumps(d, 1) slen = struct.pack(">L", len(s)) return slen + s -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 26 08:11:49 2015 From: python-checkins at python.org (vinay.sajip) Date: Sat, 26 Dec 2015 13:11:49 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogRml4ZXMgIzI1MzYw?= =?utf-8?q?=3A_Search_for_pythonw=2Eexe_when_in_pyw=2Eexe=2E?= Message-ID: <20151226131149.126305.84921@psf.io> https://hg.python.org/cpython/rev/2af2367d7eda changeset: 99682:2af2367d7eda branch: 3.5 parent: 99680:6210b41a2394 user: Vinay Sajip date: Sat Dec 26 13:10:51 2015 +0000 summary: Fixes #25360: Search for pythonw.exe when in pyw.exe. files: PC/launcher.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1254,7 +1254,7 @@ * is no version specification. */ debug(L"searching PATH for python executable\n"); - cmd = find_on_path(L"python"); + cmd = find_on_path(PYTHON_EXECUTABLE); debug(L"Python on path: %ls\n", cmd ? cmd->value : L""); if (cmd) { debug(L"located python on PATH: %ls\n", cmd->value); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Dec 26 08:11:49 2015 From: python-checkins at python.org (vinay.sajip) Date: Sat, 26 Dec 2015 13:11:49 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Closes_=2325360=3A_Merged_fix_from_3=2E5=2E?= Message-ID: <20151226131149.3371.47081@psf.io> https://hg.python.org/cpython/rev/ba1e102c3320 changeset: 99683:ba1e102c3320 parent: 99681:6a6a68a3d323 parent: 99682:2af2367d7eda user: Vinay Sajip date: Sat Dec 26 13:11:38 2015 +0000 summary: Closes #25360: Merged fix from 3.5. files: PC/launcher.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1255,7 +1255,7 @@ * is no version specification. */ debug(L"searching PATH for python executable\n"); - cmd = find_on_path(L"python"); + cmd = find_on_path(PYTHON_EXECUTABLE); debug(L"Python on path: %ls\n", cmd ? cmd->value : L""); if (cmd) { debug(L"located python on PATH: %ls\n", cmd->value); -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sun Dec 27 03:44:34 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 27 Dec 2015 08:44:34 +0000 Subject: [Python-checkins] Daily reference leaks (ba1e102c3320): sum=7 Message-ID: <20151227084433.3365.53894@psf.io> results for ba1e102c3320 on branch "default" -------------------------------------------- test_asyncio leaked [0, 0, 3] memory blocks, sum=3 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogiUC8jp', '--timeout', '7200'] From python-checkins at python.org Sun Dec 27 05:44:03 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 27 Dec 2015 10:44:03 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIwNDQw?= =?utf-8?q?=3A_Applied_yet_one_patch_for_using_Py=5FSETREF=2E?= Message-ID: <20151227104403.124864.99842@psf.io> https://hg.python.org/cpython/rev/9fb57c0209ea changeset: 99684:9fb57c0209ea branch: 3.5 parent: 99682:2af2367d7eda user: Serhiy Storchaka date: Sun Dec 27 12:36:18 2015 +0200 summary: Issue #20440: Applied yet one patch for using Py_SETREF. The patch is automatically generated, it replaces the code that uses Py_CLEAR. files: Modules/_bz2module.c | 5 +- Modules/_io/bufferedio.c | 12 +-- Modules/_io/textio.c | 12 +-- Modules/_lzmamodule.c | 5 +- Modules/_pickle.c | 8 +- Modules/_struct.c | 3 +- Modules/cjkcodecs/multibytecodec.c | 3 +- Modules/itertoolsmodule.c | 57 ++++++---------- Objects/exceptions.c | 58 +++++++---------- Objects/rangeobject.c | 8 +- Python/ceval.c | 4 +- 11 files changed, 66 insertions(+), 109 deletions(-) diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c --- a/Modules/_bz2module.c +++ b/Modules/_bz2module.c @@ -540,9 +540,8 @@ if (d->eof) { d->needs_input = 0; if (d->bzs_avail_in_real > 0) { - Py_CLEAR(d->unused_data); - d->unused_data = PyBytes_FromStringAndSize( - bzs->next_in, d->bzs_avail_in_real); + Py_SETREF(d->unused_data, + PyBytes_FromStringAndSize(bzs->next_in, d->bzs_avail_in_real)); if (d->unused_data == NULL) goto error; } diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1196,8 +1196,7 @@ Py_CLEAR(res); goto end; } - Py_CLEAR(res); - res = _PyBytes_Join(_PyIO_empty_bytes, chunks); + Py_SETREF(res, _PyBytes_Join(_PyIO_empty_bytes, chunks)); end: LEAVE_BUFFERED(self) @@ -1452,9 +1451,8 @@ if (_PyIOBase_check_readable(raw, Py_True) == NULL) return -1; - Py_CLEAR(self->raw); Py_INCREF(raw); - self->raw = raw; + Py_SETREF(self->raw, raw); self->buffer_size = buffer_size; self->readable = 1; self->writable = 0; @@ -1805,9 +1803,8 @@ if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1; - Py_CLEAR(self->raw); Py_INCREF(raw); - self->raw = raw; + Py_SETREF(self->raw, raw); self->readable = 0; self->writable = 1; @@ -2309,9 +2306,8 @@ if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1; - Py_CLEAR(self->raw); Py_INCREF(raw); - self->raw = raw; + Py_SETREF(self->raw, raw); self->buffer_size = buffer_size; self->readable = 1; self->writable = 1; diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -995,8 +995,7 @@ "Oi", self->decoder, (int)self->readtranslate); if (incrementalDecoder == NULL) goto error; - Py_CLEAR(self->decoder); - self->decoder = incrementalDecoder; + Py_SETREF(self->decoder, incrementalDecoder); } } @@ -1374,8 +1373,7 @@ static void textiowrapper_set_decoded_chars(textio *self, PyObject *chars) { - Py_CLEAR(self->decoded_chars); - self->decoded_chars = chars; + Py_SETREF(self->decoded_chars, chars); self->decoded_chars_used = 0; } @@ -1523,8 +1521,7 @@ dec_buffer = NULL; /* Reference lost to PyBytes_Concat */ goto fail; } - Py_CLEAR(self->snapshot); - self->snapshot = Py_BuildValue("NN", dec_flags, next_input); + Py_SETREF(self->snapshot, Py_BuildValue("NN", dec_flags, next_input)); } Py_DECREF(input_chunk); @@ -1630,8 +1627,7 @@ if (chunks != NULL) { if (result != NULL && PyList_Append(chunks, result) < 0) goto fail; - Py_CLEAR(result); - result = PyUnicode_Join(_PyIO_empty_str, chunks); + Py_SETREF(result, PyUnicode_Join(_PyIO_empty_str, chunks)); if (result == NULL) goto fail; Py_CLEAR(chunks); diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c --- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -1011,9 +1011,8 @@ if (d->eof) { d->needs_input = 0; if (lzs->avail_in > 0) { - Py_CLEAR(d->unused_data); - d->unused_data = PyBytes_FromStringAndSize( - (char *)lzs->next_in, lzs->avail_in); + Py_SETREF(d->unused_data, + PyBytes_FromStringAndSize((char *)lzs->next_in, lzs->avail_in)); if (d->unused_data == NULL) goto error; } diff --git a/Modules/_pickle.c b/Modules/_pickle.c --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -846,9 +846,8 @@ static int _Pickler_ClearBuffer(PicklerObject *self) { - Py_CLEAR(self->output_buffer); - self->output_buffer = - PyBytes_FromStringAndSize(NULL, self->max_output_len); + Py_SETREF(self->output_buffer, + PyBytes_FromStringAndSize(NULL, self->max_output_len)); if (self->output_buffer == NULL) return -1; self->output_len = 0; @@ -3089,9 +3088,8 @@ Py_TYPE(item)->tp_name); return -1; } - Py_CLEAR(*module_name); Py_INCREF(item); - *module_name = item; + Py_SETREF(*module_name, item); } else if (PyErr_Occurred()) { return -1; diff --git a/Modules/_struct.c b/Modules/_struct.c --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1437,8 +1437,7 @@ return -1; } - Py_CLEAR(soself->s_format); - soself->s_format = o_format; + Py_SETREF(soself->s_format, o_format); ret = prepare_s(soself); return ret; diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -793,8 +793,7 @@ ctx->errors, final ? MBENC_FLUSH | MBENC_RESET : 0); if (r == NULL) { /* recover the original pending buffer */ - Py_CLEAR(ctx->pending); - ctx->pending = origpending; + Py_SETREF(ctx->pending, origpending); origpending = NULL; goto errorexit; } diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -159,15 +159,12 @@ PyObject *currkey, *currvalue, *tgtkey; if (!PyArg_ParseTuple(state, "OOO", &currkey, &currvalue, &tgtkey)) return NULL; - Py_CLEAR(lz->currkey); - lz->currkey = currkey; - Py_INCREF(lz->currkey); - Py_CLEAR(lz->currvalue); - lz->currvalue = currvalue; - Py_INCREF(lz->currvalue); - Py_CLEAR(lz->tgtkey); - lz->tgtkey = tgtkey; - Py_INCREF(lz->tgtkey); + Py_INCREF(currkey); + Py_SETREF(lz->currkey, currkey); + Py_INCREF(currvalue); + Py_SETREF(lz->currvalue, currvalue); + Py_INCREF(tgtkey); + Py_SETREF(lz->tgtkey, tgtkey); Py_RETURN_NONE; } @@ -747,9 +744,8 @@ PyErr_SetString(PyExc_ValueError, "Index out of range"); return NULL; } - Py_CLEAR(to->dataobj); - to->dataobj = tdo; - Py_INCREF(to->dataobj); + Py_INCREF(tdo); + Py_SETREF(to->dataobj, tdo); to->index = index; Py_RETURN_NONE; } @@ -974,9 +970,8 @@ int firstpass; if (!PyArg_ParseTuple(state, "Oi", &saved, &firstpass)) return NULL; - Py_CLEAR(lz->saved); - lz->saved = saved; - Py_XINCREF(lz->saved); + Py_XINCREF(saved); + Py_SETREF(lz->saved, saved); lz->firstpass = firstpass != 0; Py_RETURN_NONE; } @@ -1901,12 +1896,10 @@ if (! PyArg_ParseTuple(state, "O|O", &source, &active)) return NULL; - Py_CLEAR(lz->source); - lz->source = source; - Py_INCREF(lz->source); - Py_CLEAR(lz->active); - lz->active = active; - Py_XINCREF(lz->active); + Py_INCREF(source); + Py_SETREF(lz->source, source); + Py_XINCREF(active); + Py_SETREF(lz->active, active); Py_RETURN_NONE; } @@ -2262,8 +2255,7 @@ Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(lz->result); - lz->result = result; + Py_SETREF(lz->result, result); Py_RETURN_NONE; } @@ -2585,8 +2577,7 @@ PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(lz->result); - lz->result = result; + Py_SETREF(lz->result, result); Py_RETURN_NONE; } @@ -2916,8 +2907,7 @@ Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(lz->result); - lz->result = result; + Py_SETREF(lz->result, result); Py_RETURN_NONE; } @@ -3310,8 +3300,7 @@ Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(po->result); - po->result = result; + Py_SETREF(po->result, result); Py_RETURN_NONE; } @@ -3481,9 +3470,8 @@ static PyObject * accumulate_setstate(accumulateobject *lz, PyObject *state) { - Py_CLEAR(lz->total); - lz->total = state; - Py_INCREF(lz->total); + Py_INCREF(state); + Py_SETREF(lz->total, state); Py_RETURN_NONE; } @@ -4464,9 +4452,8 @@ static PyObject * zip_longest_setstate(ziplongestobject *lz, PyObject *state) { - Py_CLEAR(lz->fillvalue); - lz->fillvalue = state; - Py_INCREF(lz->fillvalue); + Py_INCREF(state); + Py_SETREF(lz->fillvalue, state); Py_RETURN_NONE; } diff --git a/Objects/exceptions.c b/Objects/exceptions.c --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -206,8 +206,7 @@ seq = PySequence_Tuple(val); if (!seq) return -1; - Py_CLEAR(self->args); - self->args = seq; + Py_SETREF(self->args, seq); return 0; } @@ -646,9 +645,8 @@ if (!PyArg_UnpackTuple(args, "ImportError", 1, 1, &msg)) return -1; - Py_CLEAR(self->msg); /* replacing */ - self->msg = msg; - Py_INCREF(self->msg); + Py_INCREF(msg); + Py_SETREF(self->msg, msg); return 0; } @@ -858,8 +856,7 @@ #endif /* Steals the reference to args */ - Py_CLEAR(self->args); - self->args = args; + Py_SETREF(self->args, args); *p_args = args = NULL; return 0; @@ -1278,9 +1275,8 @@ return -1; if (lenargs >= 1) { - Py_CLEAR(self->msg); - self->msg = PyTuple_GET_ITEM(args, 0); - Py_INCREF(self->msg); + Py_INCREF(PyTuple_GET_ITEM(args, 0)); + Py_SETREF(self->msg, PyTuple_GET_ITEM(args, 0)); } if (lenargs == 2) { info = PyTuple_GET_ITEM(args, 1); @@ -1295,21 +1291,17 @@ return -1; } - Py_CLEAR(self->filename); - self->filename = PyTuple_GET_ITEM(info, 0); - Py_INCREF(self->filename); - - Py_CLEAR(self->lineno); - self->lineno = PyTuple_GET_ITEM(info, 1); - Py_INCREF(self->lineno); - - Py_CLEAR(self->offset); - self->offset = PyTuple_GET_ITEM(info, 2); - Py_INCREF(self->offset); - - Py_CLEAR(self->text); - self->text = PyTuple_GET_ITEM(info, 3); - Py_INCREF(self->text); + Py_INCREF(PyTuple_GET_ITEM(info, 0)); + Py_SETREF(self->filename, PyTuple_GET_ITEM(info, 0)); + + Py_INCREF(PyTuple_GET_ITEM(info, 1)); + Py_SETREF(self->lineno, PyTuple_GET_ITEM(info, 1)); + + Py_INCREF(PyTuple_GET_ITEM(info, 2)); + Py_SETREF(self->offset, PyTuple_GET_ITEM(info, 2)); + + Py_INCREF(PyTuple_GET_ITEM(info, 3)); + Py_SETREF(self->text, PyTuple_GET_ITEM(info, 3)); Py_DECREF(info); @@ -1554,8 +1546,7 @@ PyObject *obj = PyUnicode_FromString(value); if (!obj) return -1; - Py_CLEAR(*attr); - *attr = obj; + Py_SETREF(*attr, obj); return 0; } @@ -1961,8 +1952,7 @@ Py_buffer view; if (PyObject_GetBuffer(ude->object, &view, PyBUF_SIMPLE) != 0) goto error; - Py_CLEAR(ude->object); - ude->object = PyBytes_FromStringAndSize(view.buf, view.len); + Py_SETREF(ude->object, PyBytes_FromStringAndSize(view.buf, view.len)); PyBuffer_Release(&view); if (!ude->object) goto error; @@ -2871,9 +2861,8 @@ } if (PyUnicode_Tailmatch(self->text, print_prefix, start, text_len, -1)) { - Py_CLEAR(self->msg); - self->msg = PyUnicode_FromString( - "Missing parentheses in call to 'print'"); + Py_SETREF(self->msg, + PyUnicode_FromString("Missing parentheses in call to 'print'")); return 1; } @@ -2886,9 +2875,8 @@ } if (PyUnicode_Tailmatch(self->text, exec_prefix, start, text_len, -1)) { - Py_CLEAR(self->msg); - self->msg = PyUnicode_FromString( - "Missing parentheses in call to 'exec'"); + Py_SETREF(self->msg, + PyUnicode_FromString("Missing parentheses in call to 'exec'")); return 1; } /* Fall back to the default error message */ diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -1001,8 +1001,7 @@ return NULL; cmp = PyObject_RichCompareBool(state, zero, Py_LT); if (cmp > 0) { - Py_CLEAR(r->index); - r->index = zero; + Py_SETREF(r->index, zero); Py_RETURN_NONE; } Py_DECREF(zero); @@ -1015,9 +1014,8 @@ if (cmp > 0) state = r->len; - Py_CLEAR(r->index); - r->index = state; - Py_INCREF(r->index); + Py_INCREF(state); + Py_SETREF(r->index, state); Py_RETURN_NONE; } diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4410,10 +4410,8 @@ { PyThreadState *tstate = PyThreadState_GET(); - Py_CLEAR(tstate->coroutine_wrapper); - Py_XINCREF(wrapper); - tstate->coroutine_wrapper = wrapper; + Py_SETREF(tstate->coroutine_wrapper, wrapper); } PyObject * -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 27 05:44:04 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 27 Dec 2015 10:44:04 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2320440=3A_Applied_yet_one_patch_for_using_Py=5FS?= =?utf-8?q?ETREF=2E?= Message-ID: <20151227104403.9616.89810@psf.io> https://hg.python.org/cpython/rev/bc7c56a225de changeset: 99685:bc7c56a225de parent: 99683:ba1e102c3320 parent: 99684:9fb57c0209ea user: Serhiy Storchaka date: Sun Dec 27 12:38:28 2015 +0200 summary: Issue #20440: Applied yet one patch for using Py_SETREF. The patch is automatically generated, it replaces the code that uses Py_CLEAR. files: Modules/_bz2module.c | 5 +- Modules/_io/bufferedio.c | 12 +-- Modules/_io/textio.c | 12 +-- Modules/_lzmamodule.c | 5 +- Modules/_pickle.c | 8 +- Modules/_struct.c | 3 +- Modules/cjkcodecs/multibytecodec.c | 3 +- Modules/itertoolsmodule.c | 55 ++++++---------- Objects/exceptions.c | 58 +++++++---------- Objects/rangeobject.c | 8 +- Python/ceval.c | 4 +- 11 files changed, 65 insertions(+), 108 deletions(-) diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c --- a/Modules/_bz2module.c +++ b/Modules/_bz2module.c @@ -540,9 +540,8 @@ if (d->eof) { d->needs_input = 0; if (d->bzs_avail_in_real > 0) { - Py_CLEAR(d->unused_data); - d->unused_data = PyBytes_FromStringAndSize( - bzs->next_in, d->bzs_avail_in_real); + Py_SETREF(d->unused_data, + PyBytes_FromStringAndSize(bzs->next_in, d->bzs_avail_in_real)); if (d->unused_data == NULL) goto error; } diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1196,8 +1196,7 @@ Py_CLEAR(res); goto end; } - Py_CLEAR(res); - res = _PyBytes_Join(_PyIO_empty_bytes, chunks); + Py_SETREF(res, _PyBytes_Join(_PyIO_empty_bytes, chunks)); end: LEAVE_BUFFERED(self) @@ -1452,9 +1451,8 @@ if (_PyIOBase_check_readable(raw, Py_True) == NULL) return -1; - Py_CLEAR(self->raw); Py_INCREF(raw); - self->raw = raw; + Py_SETREF(self->raw, raw); self->buffer_size = buffer_size; self->readable = 1; self->writable = 0; @@ -1805,9 +1803,8 @@ if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1; - Py_CLEAR(self->raw); Py_INCREF(raw); - self->raw = raw; + Py_SETREF(self->raw, raw); self->readable = 0; self->writable = 1; @@ -2309,9 +2306,8 @@ if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1; - Py_CLEAR(self->raw); Py_INCREF(raw); - self->raw = raw; + Py_SETREF(self->raw, raw); self->buffer_size = buffer_size; self->readable = 1; self->writable = 1; diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -995,8 +995,7 @@ "Oi", self->decoder, (int)self->readtranslate); if (incrementalDecoder == NULL) goto error; - Py_CLEAR(self->decoder); - self->decoder = incrementalDecoder; + Py_SETREF(self->decoder, incrementalDecoder); } } @@ -1374,8 +1373,7 @@ static void textiowrapper_set_decoded_chars(textio *self, PyObject *chars) { - Py_CLEAR(self->decoded_chars); - self->decoded_chars = chars; + Py_SETREF(self->decoded_chars, chars); self->decoded_chars_used = 0; } @@ -1523,8 +1521,7 @@ dec_buffer = NULL; /* Reference lost to PyBytes_Concat */ goto fail; } - Py_CLEAR(self->snapshot); - self->snapshot = Py_BuildValue("NN", dec_flags, next_input); + Py_SETREF(self->snapshot, Py_BuildValue("NN", dec_flags, next_input)); } Py_DECREF(input_chunk); @@ -1630,8 +1627,7 @@ if (chunks != NULL) { if (result != NULL && PyList_Append(chunks, result) < 0) goto fail; - Py_CLEAR(result); - result = PyUnicode_Join(_PyIO_empty_str, chunks); + Py_SETREF(result, PyUnicode_Join(_PyIO_empty_str, chunks)); if (result == NULL) goto fail; Py_CLEAR(chunks); diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c --- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -1011,9 +1011,8 @@ if (d->eof) { d->needs_input = 0; if (lzs->avail_in > 0) { - Py_CLEAR(d->unused_data); - d->unused_data = PyBytes_FromStringAndSize( - (char *)lzs->next_in, lzs->avail_in); + Py_SETREF(d->unused_data, + PyBytes_FromStringAndSize((char *)lzs->next_in, lzs->avail_in)); if (d->unused_data == NULL) goto error; } diff --git a/Modules/_pickle.c b/Modules/_pickle.c --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -869,9 +869,8 @@ static int _Pickler_ClearBuffer(PicklerObject *self) { - Py_CLEAR(self->output_buffer); - self->output_buffer = - PyBytes_FromStringAndSize(NULL, self->max_output_len); + Py_SETREF(self->output_buffer, + PyBytes_FromStringAndSize(NULL, self->max_output_len)); if (self->output_buffer == NULL) return -1; self->output_len = 0; @@ -3116,9 +3115,8 @@ Py_TYPE(item)->tp_name); return -1; } - Py_CLEAR(*module_name); Py_INCREF(item); - *module_name = item; + Py_SETREF(*module_name, item); } else if (PyErr_Occurred()) { return -1; diff --git a/Modules/_struct.c b/Modules/_struct.c --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1437,8 +1437,7 @@ return -1; } - Py_CLEAR(soself->s_format); - soself->s_format = o_format; + Py_SETREF(soself->s_format, o_format); ret = prepare_s(soself); return ret; diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -793,8 +793,7 @@ ctx->errors, final ? MBENC_FLUSH | MBENC_RESET : 0); if (r == NULL) { /* recover the original pending buffer */ - Py_CLEAR(ctx->pending); - ctx->pending = origpending; + Py_SETREF(ctx->pending, origpending); origpending = NULL; goto errorexit; } diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -158,15 +158,12 @@ PyObject *currkey, *currvalue, *tgtkey; if (!PyArg_ParseTuple(state, "OOO", &currkey, &currvalue, &tgtkey)) return NULL; - Py_CLEAR(lz->currkey); - lz->currkey = currkey; - Py_INCREF(lz->currkey); - Py_CLEAR(lz->currvalue); - lz->currvalue = currvalue; - Py_INCREF(lz->currvalue); - Py_CLEAR(lz->tgtkey); - lz->tgtkey = tgtkey; - Py_INCREF(lz->tgtkey); + Py_INCREF(currkey); + Py_SETREF(lz->currkey, currkey); + Py_INCREF(currvalue); + Py_SETREF(lz->currvalue, currvalue); + Py_INCREF(tgtkey); + Py_SETREF(lz->tgtkey, tgtkey); Py_RETURN_NONE; } @@ -745,9 +742,8 @@ PyErr_SetString(PyExc_ValueError, "Index out of range"); return NULL; } - Py_CLEAR(to->dataobj); - to->dataobj = tdo; - Py_INCREF(to->dataobj); + Py_INCREF(tdo); + Py_SETREF(to->dataobj, tdo); to->index = index; Py_RETURN_NONE; } @@ -988,8 +984,7 @@ if (!PyArg_ParseTuple(state, "O!i", &PyList_Type, &saved, &firstpass)) return NULL; Py_INCREF(saved); - Py_CLEAR(lz->saved); - lz->saved = saved; + Py_SETREF(lz->saved, saved); lz->firstpass = firstpass != 0; lz->index = 0; Py_RETURN_NONE; @@ -1920,12 +1915,10 @@ if (! PyArg_ParseTuple(state, "O|O", &source, &active)) return NULL; - Py_CLEAR(lz->source); - lz->source = source; - Py_INCREF(lz->source); - Py_CLEAR(lz->active); - lz->active = active; - Py_XINCREF(lz->active); + Py_INCREF(source); + Py_SETREF(lz->source, source); + Py_XINCREF(active); + Py_SETREF(lz->active, active); Py_RETURN_NONE; } @@ -2282,8 +2275,7 @@ Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(lz->result); - lz->result = result; + Py_SETREF(lz->result, result); Py_RETURN_NONE; } @@ -2604,8 +2596,7 @@ PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(lz->result); - lz->result = result; + Py_SETREF(lz->result, result); Py_RETURN_NONE; } @@ -2935,8 +2926,7 @@ Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(lz->result); - lz->result = result; + Py_SETREF(lz->result, result); Py_RETURN_NONE; } @@ -3324,8 +3314,7 @@ Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); } - Py_CLEAR(po->result); - po->result = result; + Py_SETREF(po->result, result); Py_RETURN_NONE; } @@ -3495,9 +3484,8 @@ static PyObject * accumulate_setstate(accumulateobject *lz, PyObject *state) { - Py_CLEAR(lz->total); - lz->total = state; - Py_INCREF(lz->total); + Py_INCREF(state); + Py_SETREF(lz->total, state); Py_RETURN_NONE; } @@ -4475,9 +4463,8 @@ static PyObject * zip_longest_setstate(ziplongestobject *lz, PyObject *state) { - Py_CLEAR(lz->fillvalue); - lz->fillvalue = state; - Py_INCREF(lz->fillvalue); + Py_INCREF(state); + Py_SETREF(lz->fillvalue, state); Py_RETURN_NONE; } diff --git a/Objects/exceptions.c b/Objects/exceptions.c --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -206,8 +206,7 @@ seq = PySequence_Tuple(val); if (!seq) return -1; - Py_CLEAR(self->args); - self->args = seq; + Py_SETREF(self->args, seq); return 0; } @@ -646,9 +645,8 @@ if (!PyArg_UnpackTuple(args, "ImportError", 1, 1, &msg)) return -1; - Py_CLEAR(self->msg); /* replacing */ - self->msg = msg; - Py_INCREF(self->msg); + Py_INCREF(msg); + Py_SETREF(self->msg, msg); return 0; } @@ -858,8 +856,7 @@ #endif /* Steals the reference to args */ - Py_CLEAR(self->args); - self->args = args; + Py_SETREF(self->args, args); *p_args = args = NULL; return 0; @@ -1278,9 +1275,8 @@ return -1; if (lenargs >= 1) { - Py_CLEAR(self->msg); - self->msg = PyTuple_GET_ITEM(args, 0); - Py_INCREF(self->msg); + Py_INCREF(PyTuple_GET_ITEM(args, 0)); + Py_SETREF(self->msg, PyTuple_GET_ITEM(args, 0)); } if (lenargs == 2) { info = PyTuple_GET_ITEM(args, 1); @@ -1295,21 +1291,17 @@ return -1; } - Py_CLEAR(self->filename); - self->filename = PyTuple_GET_ITEM(info, 0); - Py_INCREF(self->filename); - - Py_CLEAR(self->lineno); - self->lineno = PyTuple_GET_ITEM(info, 1); - Py_INCREF(self->lineno); - - Py_CLEAR(self->offset); - self->offset = PyTuple_GET_ITEM(info, 2); - Py_INCREF(self->offset); - - Py_CLEAR(self->text); - self->text = PyTuple_GET_ITEM(info, 3); - Py_INCREF(self->text); + Py_INCREF(PyTuple_GET_ITEM(info, 0)); + Py_SETREF(self->filename, PyTuple_GET_ITEM(info, 0)); + + Py_INCREF(PyTuple_GET_ITEM(info, 1)); + Py_SETREF(self->lineno, PyTuple_GET_ITEM(info, 1)); + + Py_INCREF(PyTuple_GET_ITEM(info, 2)); + Py_SETREF(self->offset, PyTuple_GET_ITEM(info, 2)); + + Py_INCREF(PyTuple_GET_ITEM(info, 3)); + Py_SETREF(self->text, PyTuple_GET_ITEM(info, 3)); Py_DECREF(info); @@ -1554,8 +1546,7 @@ PyObject *obj = PyUnicode_FromString(value); if (!obj) return -1; - Py_CLEAR(*attr); - *attr = obj; + Py_SETREF(*attr, obj); return 0; } @@ -1961,8 +1952,7 @@ Py_buffer view; if (PyObject_GetBuffer(ude->object, &view, PyBUF_SIMPLE) != 0) goto error; - Py_CLEAR(ude->object); - ude->object = PyBytes_FromStringAndSize(view.buf, view.len); + Py_SETREF(ude->object, PyBytes_FromStringAndSize(view.buf, view.len)); PyBuffer_Release(&view); if (!ude->object) goto error; @@ -2871,9 +2861,8 @@ } if (PyUnicode_Tailmatch(self->text, print_prefix, start, text_len, -1)) { - Py_CLEAR(self->msg); - self->msg = PyUnicode_FromString( - "Missing parentheses in call to 'print'"); + Py_SETREF(self->msg, + PyUnicode_FromString("Missing parentheses in call to 'print'")); return 1; } @@ -2886,9 +2875,8 @@ } if (PyUnicode_Tailmatch(self->text, exec_prefix, start, text_len, -1)) { - Py_CLEAR(self->msg); - self->msg = PyUnicode_FromString( - "Missing parentheses in call to 'exec'"); + Py_SETREF(self->msg, + PyUnicode_FromString("Missing parentheses in call to 'exec'")); return 1; } /* Fall back to the default error message */ diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -1001,8 +1001,7 @@ return NULL; cmp = PyObject_RichCompareBool(state, zero, Py_LT); if (cmp > 0) { - Py_CLEAR(r->index); - r->index = zero; + Py_SETREF(r->index, zero); Py_RETURN_NONE; } Py_DECREF(zero); @@ -1015,9 +1014,8 @@ if (cmp > 0) state = r->len; - Py_CLEAR(r->index); - r->index = state; - Py_INCREF(r->index); + Py_INCREF(state); + Py_SETREF(r->index, state); Py_RETURN_NONE; } diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4474,10 +4474,8 @@ { PyThreadState *tstate = PyThreadState_GET(); - Py_CLEAR(tstate->coroutine_wrapper); - Py_XINCREF(wrapper); - tstate->coroutine_wrapper = wrapper; + Py_SETREF(tstate->coroutine_wrapper, wrapper); } PyObject * -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 27 05:44:04 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 27 Dec 2015 10:44:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzIwNDQw?= =?utf-8?q?=3A_Applied_yet_one_patch_for_using_Py=5FSETREF=2E?= Message-ID: <20151227104404.126315.84165@psf.io> https://hg.python.org/cpython/rev/e6502bf289ab changeset: 99686:e6502bf289ab branch: 2.7 parent: 99678:512a628c683e user: Serhiy Storchaka date: Sun Dec 27 12:38:48 2015 +0200 summary: Issue #20440: Applied yet one patch for using Py_SETREF. The patch is automatically generated, it replaces the code that uses Py_CLEAR. files: Modules/_io/bufferedio.c | 12 +--- Modules/_io/textio.c | 15 ++---- Modules/_struct.c | 6 +- Objects/exceptions.c | 57 ++++++++++----------------- 4 files changed, 33 insertions(+), 57 deletions(-) diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1028,8 +1028,7 @@ Py_CLEAR(res); goto end; } - Py_CLEAR(res); - res = _PyBytes_Join(_PyIO_empty_bytes, chunks); + Py_SETREF(res, _PyBytes_Join(_PyIO_empty_bytes, chunks)); end: LEAVE_BUFFERED(self) @@ -1264,9 +1263,8 @@ if (_PyIOBase_check_readable(raw, Py_True) == NULL) return -1; - Py_CLEAR(self->raw); Py_INCREF(raw); - self->raw = raw; + Py_SETREF(self->raw, raw); self->buffer_size = buffer_size; self->readable = 1; self->writable = 0; @@ -1687,9 +1685,8 @@ if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1; - Py_CLEAR(self->raw); Py_INCREF(raw); - self->raw = raw; + Py_SETREF(self->raw, raw); self->readable = 0; self->writable = 1; @@ -2344,9 +2341,8 @@ if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1; - Py_CLEAR(self->raw); Py_INCREF(raw); - self->raw = raw; + Py_SETREF(self->raw, raw); self->buffer_size = buffer_size; self->readable = 1; self->writable = 1; diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -966,8 +966,7 @@ "Oi", self->decoder, (int)self->readtranslate); if (incrementalDecoder == NULL) goto error; - Py_CLEAR(self->decoder); - self->decoder = incrementalDecoder; + Py_SETREF(self->decoder, incrementalDecoder); } } @@ -1347,8 +1346,7 @@ static void textiowrapper_set_decoded_chars(textio *self, PyObject *chars) { - Py_CLEAR(self->decoded_chars); - self->decoded_chars = chars; + Py_SETREF(self->decoded_chars, chars); self->decoded_chars_used = 0; } @@ -1477,8 +1475,7 @@ goto fail; } Py_DECREF(dec_buffer); - Py_CLEAR(self->snapshot); - self->snapshot = Py_BuildValue("NN", dec_flags, next_input); + Py_SETREF(self->snapshot, Py_BuildValue("NN", dec_flags, next_input)); } Py_DECREF(input_chunk); @@ -1578,8 +1575,7 @@ if (chunks != NULL) { if (result != NULL && PyList_Append(chunks, result) < 0) goto fail; - Py_CLEAR(result); - result = PyUnicode_Join(_PyIO_empty_str, chunks); + Py_SETREF(result, PyUnicode_Join(_PyIO_empty_str, chunks)); if (result == NULL) goto fail; Py_CLEAR(chunks); @@ -1836,8 +1832,7 @@ if (chunks != NULL) { if (line != NULL && PyList_Append(chunks, line) < 0) goto error; - Py_CLEAR(line); - line = PyUnicode_Join(_PyIO_empty_str, chunks); + Py_SETREF(line, PyUnicode_Join(_PyIO_empty_str, chunks)); if (line == NULL) goto error; Py_DECREF(chunks); diff --git a/Modules/_struct.c b/Modules/_struct.c --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1377,15 +1377,13 @@ if (PyString_Check(o_format)) { Py_INCREF(o_format); - Py_CLEAR(soself->s_format); - soself->s_format = o_format; + Py_SETREF(soself->s_format, o_format); } else if (PyUnicode_Check(o_format)) { PyObject *str = PyUnicode_AsEncodedString(o_format, "ascii", NULL); if (str == NULL) return -1; - Py_CLEAR(soself->s_format); - soself->s_format = str; + Py_SETREF(soself->s_format, str); } else { PyErr_Format(PyExc_TypeError, diff --git a/Objects/exceptions.c b/Objects/exceptions.c --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -62,9 +62,8 @@ Py_SETREF(self->args, args); if (PyTuple_GET_SIZE(self->args) == 1) { - Py_CLEAR(self->message); - self->message = PyTuple_GET_ITEM(self->args, 0); - Py_INCREF(self->message); + Py_INCREF(PyTuple_GET_ITEM(self->args, 0)); + Py_SETREF(self->message, PyTuple_GET_ITEM(self->args, 0)); } return 0; } @@ -279,9 +278,8 @@ PyErr_SetString(PyExc_TypeError, "__dict__ must be a dictionary"); return -1; } - Py_CLEAR(self->dict); Py_INCREF(val); - self->dict = val; + Py_SETREF(self->dict, val); return 0; } @@ -307,8 +305,7 @@ seq = PySequence_Tuple(val); if (!seq) return -1; - Py_CLEAR(self->args); - self->args = seq; + Py_SETREF(self->args, seq); return 0; } @@ -608,19 +605,16 @@ &myerrno, &strerror, &filename)) { return -1; } - Py_CLEAR(self->myerrno); /* replacing */ - self->myerrno = myerrno; - Py_INCREF(self->myerrno); + Py_INCREF(myerrno); + Py_SETREF(self->myerrno, myerrno); - Py_CLEAR(self->strerror); /* replacing */ - self->strerror = strerror; - Py_INCREF(self->strerror); + Py_INCREF(strerror); + Py_SETREF(self->strerror, strerror); /* self->filename will remain Py_None otherwise */ if (filename != NULL) { - Py_CLEAR(self->filename); /* replacing */ - self->filename = filename; - Py_INCREF(self->filename); + Py_INCREF(filename); + Py_SETREF(self->filename, filename); subslice = PyTuple_GetSlice(args, 0, 2); if (!subslice) @@ -877,8 +871,7 @@ return -1; posix_errno = winerror_to_errno(errcode); - Py_CLEAR(self->winerror); - self->winerror = self->myerrno; + Py_SETREF(self->winerror, self->myerrno); o_errcode = PyInt_FromLong(posix_errno); if (!o_errcode) @@ -1063,9 +1056,8 @@ return -1; if (lenargs >= 1) { - Py_CLEAR(self->msg); - self->msg = PyTuple_GET_ITEM(args, 0); - Py_INCREF(self->msg); + Py_INCREF(PyTuple_GET_ITEM(args, 0)); + Py_SETREF(self->msg, PyTuple_GET_ITEM(args, 0)); } if (lenargs == 2) { info = PyTuple_GET_ITEM(args, 1); @@ -1080,21 +1072,17 @@ return -1; } - Py_CLEAR(self->filename); - self->filename = PyTuple_GET_ITEM(info, 0); - Py_INCREF(self->filename); + Py_INCREF(PyTuple_GET_ITEM(info, 0)); + Py_SETREF(self->filename, PyTuple_GET_ITEM(info, 0)); - Py_CLEAR(self->lineno); - self->lineno = PyTuple_GET_ITEM(info, 1); - Py_INCREF(self->lineno); + Py_INCREF(PyTuple_GET_ITEM(info, 1)); + Py_SETREF(self->lineno, PyTuple_GET_ITEM(info, 1)); - Py_CLEAR(self->offset); - self->offset = PyTuple_GET_ITEM(info, 2); - Py_INCREF(self->offset); + Py_INCREF(PyTuple_GET_ITEM(info, 2)); + Py_SETREF(self->offset, PyTuple_GET_ITEM(info, 2)); - Py_CLEAR(self->text); - self->text = PyTuple_GET_ITEM(info, 3); - Py_INCREF(self->text); + Py_INCREF(PyTuple_GET_ITEM(info, 3)); + Py_SETREF(self->text, PyTuple_GET_ITEM(info, 3)); Py_DECREF(info); } @@ -1327,8 +1315,7 @@ PyObject *obj = PyString_FromString(value); if (!obj) return -1; - Py_CLEAR(*attr); - *attr = obj; + Py_SETREF(*attr, obj); return 0; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 27 06:44:55 2015 From: python-checkins at python.org (nick.coghlan) Date: Sun, 27 Dec 2015 11:44:55 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Revise_implementation_strateg?= =?utf-8?q?y_for_PEP_432?= Message-ID: <20151227114455.21223.42534@psf.io> https://hg.python.org/peps/rev/7e423549e0df changeset: 6143:7e423549e0df user: Nick Coghlan date: Sun Dec 27 21:44:47 2015 +1000 summary: Revise implementation strategy for PEP 432 files: pep-0432.txt | 96 +++++++++++++++++++++++++++++++-------- 1 files changed, 76 insertions(+), 20 deletions(-) diff --git a/pep-0432.txt b/pep-0432.txt --- a/pep-0432.txt +++ b/pep-0432.txt @@ -7,7 +7,7 @@ Type: Standards Track Content-Type: text/x-rst Created: 28-Dec-2012 -Python-Version: 3.5 +Python-Version: 3.6 Post-History: 28-Dec-2012, 2-Jan-2013 @@ -100,7 +100,7 @@ Key Concerns ============ -There are a couple of key concerns that any change to the startup sequence +There are a few key concerns that any change to the startup sequence needs to take into account. @@ -123,6 +123,17 @@ future to add new configuration options. +Testability +----------- + +One of the problems with the complexity of the CPython startup sequence is the +combinatorial explosion of possible interactions between different configuration +settings. + +This concern impacts both the design of the new initialisation system, and +the proposed approach for getting there. + + Performance ----------- @@ -226,6 +237,54 @@ settings to the new structure). +Implementation Strategy +======================= + +An initial attempt was made at implementing an earlier version of this PEP for +Python 3.4 [2_], with one of the significant problems encountered being merge +conflicts after the initial structural changes were put in place to start the +refactoring process. Unlike some other previous major changes, such as the +switch to an AST-based compiler in Python 2.5, or the switch to the importlib +implementation of the import system in Python 3.3, there is no clear way to +structure a draft implementation that won't be prone to the kinds of merge +conflicts that afflicted the original attempt. + +Accordingly, the implementation strategy now being proposed is to implement this +refactoring as a private API for CPython 3.6, before exposing the new functions +and structures as public API elements in CPython 3.7. + +The affected APIs with a leading underscore, as they would be named in CPython +3.6: + +* ``_Py_IsCoreInitialized`` +* ``_Py_InitializeCore`` +* ``_PyCoreConfig`` +* ``_PyCoreConfig_INIT`` +* ``_Py_ReadHashSeed`` +* ``_Py_InitializeMainInterpreter`` +* ``_PyMainInterpreterConfig`` +* ``_PyMainInterpreterConfig_INIT`` +* ``_Py_ReadMainInterpreterConfig`` +* ``_PyRun_PrepareMain`` +* ``_PyRun_ExecMain`` +* ``_Py_InterpreterState_Main`` + +New APIs described in the rest of the PEP with a leading underscore are +intended to be retained permanently as private CPython implementation details. + +The principle benefit of this approach is allowing the refactoring to adopt the +new configuration structures to be handled on a setting by setting basis +over the course of the 3.6 and 3.7 development cycles, rather than having to +migrate them in a single monolithic change. It also means any new settings can +be handled using the new approach, even if some existing settings have yet to +be migrated. + +If all existing settings are successfully migrated to the new initialization +model in time for the 3.6.0a4 release in August 2016, then the proposal would +be to make the APIs public for the 3.6.0b1 release in September 2016, rather +than waiting for 3.7. + + Design Details ============== @@ -255,7 +314,7 @@ * ``Py_IsInitialized()`` returns ``0`` * The embedding application determines the settings required to create the main interpreter and moves to the next phase by calling - ``Py_InitializationCore``. + ``Py_InitializeCore``. * Core Initialized: @@ -329,8 +388,7 @@ void Py_InitializeCore(const PyCoreConfig *config); -Like ``Py_Initialize``, this part of the new API treats initialization -failures +Like ``Py_Initialize``, this part of the new API treats initialization failures as fatal errors. While that's still not particularly embedding friendly, the operations in this step *really* shouldn't be failing, and changing them to return error codes instead of aborting would be an even larger task than @@ -446,7 +504,7 @@ * Only builtin and frozen modules may be imported (due to above limitations) * ``sys.stderr`` is set to a temporary IO object using unbuffered binary mode -* The ``sys.flags`` attribute exists, but may contain flags may not yet +* The ``sys.flags`` attribute exists, but the individual flags may not yet have their final values. * The ``sys.flags.initialized`` attribute is set to ``0`` * The ``warnings`` module is not yet initialized @@ -466,7 +524,7 @@ Any call to ``Py_InitializeCore()`` must have a matching call to ``Py_Finalize()``. It is acceptable to skip calling ``Py_InitializeMainInterpreter()`` in between (e.g. if attempting to read the -main interpreter configuration settings fails) +main interpreter configuration settings fails). Determining the remaining configuration settings @@ -583,9 +641,9 @@ /* Main module * * If prepare_main is set, at most one of the main_* settings should - * be set before calling PyRun_PrepareMain (Py_ReadConfiguration will - * set one of them based on the command line arguments if prepare_main - * is non-zero when that API is called). + * be set before calling PyRun_PrepareMain (Py_ReadMainInterpreterConfig + * will set one of them based on the command line arguments if + * prepare_main is non-zero when that API is called). int prepare_main; PyUnicodeObject *main_source; /* -c switch */ PyUnicodeObject *main_path; /* filesystem path */ @@ -923,7 +981,7 @@ Issue 16499 [6_] added a ``-I`` option to change the behaviour of the normal CPython executable, but this is a hard to discover solution (and adds yet another option to an already complex CLI). This PEP proposes to -instead add a separate ``pysystem`` executable +instead add a separate ``system-python`` executable Currently, providing a separate executable with different default behaviour would be prohibitively hard to maintain. One of the goals of this PEP is to @@ -965,21 +1023,19 @@ both PyMainInterpreterConfig and PyMainInterpreterConfig_INIT when adding new fields? * The name of the new system Python executable is a bikeshed waiting to be - painted. The 3 options considered so far are ``spython``, ``pysystem`` - and ``python-minimal``. The PEP text reflects my current preferred choice - (``pysystem``). + painted. The 4 options considered so far are ``spython``, ``pysystem``, + ``python-minimal`` and `system-python``. The PEP text reflects my current + preferred choice (``system-python``). Implementation ============== -The reference implementation is being developed as a feature branch in my -BitBucket sandbox [2_]. Pull requests to fix the inevitably broken -Windows builds are welcome, but the basic design is still in too much flux -for other pull requests to be feasible just yet. Once the overall design -settles down and it's a matter of migrating individual settings over to -the new design, that level of collaboration should become more practical. +A reference implementation for an earlier design was developed as a feature +branch in my BitBucket sandbox [2_]. +There is not yet a reference implementation for the design currently +described in the PEP. The Status Quo ============== -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sun Dec 27 08:52:06 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 27 Dec 2015 13:52:06 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2320440=3A_More_use_of_Py=5FSETREF=2E?= Message-ID: <20151227135206.3373.65051@psf.io> https://hg.python.org/cpython/rev/539ba7267701 changeset: 99689:539ba7267701 parent: 99685:bc7c56a225de parent: 99687:4bfbb2714ae9 user: Serhiy Storchaka date: Sun Dec 27 15:44:33 2015 +0200 summary: Issue #20440: More use of Py_SETREF. This patch is manually crafted and contains changes that couldn't be handled automatically. files: Modules/_ctypes/_ctypes.c | 3 +- Modules/_elementtree.c | 34 +++++++++----------------- Modules/_sqlite/cursor.c | 4 +- Modules/zlibmodule.c | 18 ++++--------- Objects/exceptions.c | 19 +++++++------- Objects/unicodeobject.c | 2 +- Python/ast.c | 10 ++----- Python/errors.c | 13 +++------ 8 files changed, 40 insertions(+), 63 deletions(-) diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2983,10 +2983,9 @@ "restype must be a type, a callable, or None"); return -1; } - Py_XDECREF(self->checker); Py_INCREF(ob); Py_SETREF(self->restype, ob); - self->checker = PyObject_GetAttrString(ob, "_check_retval_"); + Py_SETREF(self->checker, PyObject_GetAttrString(ob, "_check_retval_")); if (self->checker == NULL) PyErr_Clear(); return 0; diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -965,9 +965,8 @@ return NULL; } - Py_CLEAR(self->tag); - self->tag = tag; - Py_INCREF(self->tag); + Py_INCREF(tag); + Py_SETREF(self->tag, tag); _clear_joined_ptr(&self->text); self->text = text ? JOIN_SET(text, PyList_CheckExact(text)) : Py_None; @@ -1010,9 +1009,8 @@ /* Stash attrib. */ if (attrib) { - Py_CLEAR(self->extra->attrib); - self->extra->attrib = attrib; Py_INCREF(attrib); + Py_SETREF(self->extra->attrib, attrib); } Py_RETURN_NONE; @@ -1961,8 +1959,7 @@ { _VALIDATE_ATTR_VALUE(value); Py_INCREF(value); - Py_DECREF(self->tag); - self->tag = value; + Py_SETREF(self->tag, value); return 0; } @@ -1995,8 +1992,7 @@ return -1; } Py_INCREF(value); - Py_DECREF(self->extra->attrib); - self->extra->attrib = value; + Py_SETREF(self->extra->attrib, value); return 0; } @@ -2533,13 +2529,10 @@ } self->index++; - Py_DECREF(this); Py_INCREF(node); - self->this = node; - - Py_DECREF(self->last); + Py_SETREF(self->this, node); Py_INCREF(node); - self->last = node; + Py_SETREF(self->last, node); if (treebuilder_append_event(self, self->start_event_obj, node) < 0) goto error; @@ -2612,15 +2605,12 @@ return NULL; } + item = self->last; + self->last = self->this; self->index--; - - item = PyList_GET_ITEM(self->stack, self->index); - Py_INCREF(item); - - Py_DECREF(self->last); - - self->last = self->this; - self->this = item; + self->this = PyList_GET_ITEM(self->stack, self->index); + Py_INCREF(self->this); + Py_DECREF(item); if (treebuilder_append_event(self, self->end_event_obj, self->last) < 0) return NULL; diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -524,10 +524,10 @@ if (self->statement) { (void)pysqlite_statement_reset(self->statement); - Py_DECREF(self->statement); } - self->statement = (pysqlite_Statement*)pysqlite_cache_get(self->connection->statement_cache, func_args); + Py_SETREF(self->statement, + (pysqlite_Statement *)pysqlite_cache_get(self->connection->statement_cache, func_args)); Py_DECREF(func_args); if (!self->statement) { diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -961,14 +961,11 @@ goto error; } Py_INCREF(self->unused_data); + Py_SETREF(retval->unused_data, self->unused_data); Py_INCREF(self->unconsumed_tail); + Py_SETREF(retval->unconsumed_tail, self->unconsumed_tail); Py_XINCREF(self->zdict); - Py_XDECREF(retval->unused_data); - Py_XDECREF(retval->unconsumed_tail); - Py_XDECREF(retval->zdict); - retval->unused_data = self->unused_data; - retval->unconsumed_tail = self->unconsumed_tail; - retval->zdict = self->zdict; + Py_SETREF(retval->zdict, self->zdict); retval->eof = self->eof; /* Mark it as being initialized */ @@ -1020,14 +1017,11 @@ } Py_INCREF(self->unused_data); + Py_SETREF(retval->unused_data, self->unused_data); Py_INCREF(self->unconsumed_tail); + Py_SETREF(retval->unconsumed_tail, self->unconsumed_tail); Py_XINCREF(self->zdict); - Py_XDECREF(retval->unused_data); - Py_XDECREF(retval->unconsumed_tail); - Py_XDECREF(retval->zdict); - retval->unused_data = self->unused_data; - retval->unconsumed_tail = self->unconsumed_tail; - retval->zdict = self->zdict; + Py_SETREF(retval->zdict, self->zdict); retval->eof = self->eof; /* Mark it as being initialized */ diff --git a/Objects/exceptions.c b/Objects/exceptions.c --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -561,12 +561,14 @@ if (size == 0) return 0; - Py_CLEAR(self->code); - if (size == 1) - self->code = PyTuple_GET_ITEM(args, 0); - else /* size > 1 */ - self->code = args; - Py_INCREF(self->code); + if (size == 1) { + Py_INCREF(PyTuple_GET_ITEM(args, 0)); + Py_SETREF(self->code, PyTuple_GET_ITEM(args, 0)); + } + else { /* size > 1 */ + Py_INCREF(args); + Py_SETREF(self->code, args); + } return 0; } @@ -625,9 +627,8 @@ #define GET_KWD(kwd) { \ kwd = PyDict_GetItemString(kwds, #kwd); \ if (kwd) { \ - Py_CLEAR(self->kwd); \ - self->kwd = kwd; \ - Py_INCREF(self->kwd);\ + Py_INCREF(kwd); \ + Py_SETREF(self->kwd, kwd); \ if (PyDict_DelItemString(kwds, #kwd)) \ return -1; \ } \ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -14443,8 +14443,8 @@ if (key == NULL) return -1; if (ctx->args_owned) { + ctx->args_owned = 0; Py_DECREF(ctx->args); - ctx->args_owned = 0; } ctx->args = PyObject_GetItem(ctx->dict, key); Py_DECREF(key); diff --git a/Python/ast.c b/Python/ast.c --- a/Python/ast.c +++ b/Python/ast.c @@ -4496,8 +4496,7 @@ return 0; error: - Py_XDECREF(*literal); - *literal = NULL; + Py_CLEAR(*literal); return -1; } @@ -4692,11 +4691,8 @@ state->last_str = str; } else { /* Concatenate this with the previous string. */ - PyObject *temp = PyUnicode_Concat(state->last_str, str); - Py_DECREF(state->last_str); - Py_DECREF(str); - state->last_str = temp; - if (!temp) + PyUnicode_AppendAndDel(&state->last_str, str); + if (!state->last_str) return -1; } FstringParser_check_invariants(state); diff --git a/Python/errors.c b/Python/errors.c --- a/Python/errors.c +++ b/Python/errors.c @@ -315,14 +315,11 @@ tstate = PyThreadState_GET(); if (++tstate->recursion_depth > Py_GetRecursionLimit()) { --tstate->recursion_depth; - /* throw away the old exception... */ - Py_DECREF(*exc); - Py_DECREF(*val); - /* ... and use the recursion error instead */ - *exc = PyExc_RecursionError; - *val = PyExc_RecursionErrorInst; - Py_INCREF(*exc); - Py_INCREF(*val); + /* throw away the old exception and use the recursion error instead */ + Py_INCREF(PyExc_RecursionError); + Py_SETREF(*exc, PyExc_RecursionError); + Py_INCREF(PyExc_RecursionErrorInst); + Py_SETREF(*val, PyExc_RecursionErrorInst); /* just keeping the old traceback */ return; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 27 08:52:06 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 27 Dec 2015 13:52:06 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzIwNDQw?= =?utf-8?q?=3A_More_use_of_Py=5FSETREF=2E?= Message-ID: <20151227135206.124868.17118@psf.io> https://hg.python.org/cpython/rev/11670e4be1a9 changeset: 99688:11670e4be1a9 branch: 2.7 parent: 99686:e6502bf289ab user: Serhiy Storchaka date: Sun Dec 27 15:41:58 2015 +0200 summary: Issue #20440: More use of Py_SETREF. This patch is manually crafted and contains changes that couldn't be handled automatically. files: Modules/_ctypes/_ctypes.c | 3 +- Modules/_elementtree.c | 33 ++++++++++---------------- Modules/_sqlite/cursor.c | 4 +- Modules/zlibmodule.c | 12 +++------ Objects/exceptions.c | 14 ++++++---- Python/errors.c | 13 ++++------ 6 files changed, 33 insertions(+), 46 deletions(-) diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -3081,10 +3081,9 @@ "restype must be a type, a callable, or None"); return -1; } - Py_XDECREF(self->checker); Py_INCREF(ob); Py_SETREF(self->restype, ob); - self->checker = PyObject_GetAttrString(ob, "_check_retval_"); + Py_SETREF(self->checker, PyObject_GetAttrString(ob, "_check_retval_")); if (self->checker == NULL) PyErr_Clear(); return 0; diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1573,9 +1573,8 @@ } if (strcmp(name, "tag") == 0) { - Py_DECREF(self->tag); - self->tag = value; - Py_INCREF(self->tag); + Py_INCREF(value); + Py_SETREF(self->tag, value); } else if (strcmp(name, "text") == 0) { Py_DECREF(JOIN_OBJ(self->text)); self->text = value; @@ -1587,9 +1586,8 @@ } else if (strcmp(name, "attrib") == 0) { if (!self->extra) element_new_extra(self, NULL); - Py_DECREF(self->extra->attrib); - self->extra->attrib = value; - Py_INCREF(self->extra->attrib); + Py_INCREF(value); + Py_SETREF(self->extra->attrib, value); } else { PyErr_SetString(PyExc_AttributeError, name); return -1; @@ -1800,13 +1798,11 @@ } self->index++; - Py_DECREF(this); Py_INCREF(node); - self->this = (ElementObject*) node; - - Py_DECREF(self->last); + Py_SETREF(self->this, (ElementObject*) node); + Py_INCREF(node); - self->last = (ElementObject*) node; + Py_SETREF(self->last, (ElementObject*) node); if (treebuilder_append_event(self, self->start_event_obj, node) < 0) goto error; @@ -1857,7 +1853,7 @@ LOCAL(PyObject*) treebuilder_handle_end(TreeBuilderObject* self, PyObject* tag) { - PyObject* item; + ElementObject *item; if (self->data) { if (self->this == self->last) { @@ -1882,15 +1878,12 @@ return NULL; } + item = self->last; + self->last = self->this; self->index--; - - item = PyList_GET_ITEM(self->stack, self->index); - Py_INCREF(item); - - Py_DECREF(self->last); - - self->last = (ElementObject*) self->this; - self->this = (ElementObject*) item; + self->this = (ElementObject *) PyList_GET_ITEM(self->stack, self->index); + Py_INCREF(self->this); + Py_DECREF(item); if (treebuilder_append_event(self, self->end_event_obj, (PyObject*)self->last) < 0) return NULL; diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -558,10 +558,10 @@ if (self->statement) { (void)pysqlite_statement_reset(self->statement); - Py_DECREF(self->statement); } - self->statement = (pysqlite_Statement*)pysqlite_cache_get(self->connection->statement_cache, func_args); + Py_SETREF(self->statement, + (pysqlite_Statement *)pysqlite_cache_get(self->connection->statement_cache, func_args)); Py_DECREF(func_args); if (!self->statement) { diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -731,11 +731,9 @@ } Py_INCREF(self->unused_data); + Py_SETREF(retval->unused_data, self->unused_data); Py_INCREF(self->unconsumed_tail); - Py_XDECREF(retval->unused_data); - Py_XDECREF(retval->unconsumed_tail); - retval->unused_data = self->unused_data; - retval->unconsumed_tail = self->unconsumed_tail; + Py_SETREF(retval->unconsumed_tail, self->unconsumed_tail); /* Mark it as being initialized */ retval->is_initialised = 1; @@ -782,11 +780,9 @@ } Py_INCREF(self->unused_data); + Py_SETREF(retval->unused_data, self->unused_data); Py_INCREF(self->unconsumed_tail); - Py_XDECREF(retval->unused_data); - Py_XDECREF(retval->unconsumed_tail); - retval->unused_data = self->unused_data; - retval->unconsumed_tail = self->unconsumed_tail; + Py_SETREF(retval->unconsumed_tail, self->unconsumed_tail); /* Mark it as being initialized */ retval->is_initialised = 1; diff --git a/Objects/exceptions.c b/Objects/exceptions.c --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -517,12 +517,14 @@ if (size == 0) return 0; - Py_CLEAR(self->code); - if (size == 1) - self->code = PyTuple_GET_ITEM(args, 0); - else if (size > 1) - self->code = args; - Py_INCREF(self->code); + if (size == 1) { + Py_INCREF(PyTuple_GET_ITEM(args, 0)); + Py_SETREF(self->code, PyTuple_GET_ITEM(args, 0)); + } + else { /* size > 1 */ + Py_INCREF(args); + Py_SETREF(self->code, args); + } return 0; } diff --git a/Python/errors.c b/Python/errors.c --- a/Python/errors.c +++ b/Python/errors.c @@ -227,14 +227,11 @@ tstate = PyThreadState_GET(); if (++tstate->recursion_depth > Py_GetRecursionLimit()) { --tstate->recursion_depth; - /* throw away the old exception... */ - Py_DECREF(*exc); - Py_DECREF(*val); - /* ... and use the recursion error instead */ - *exc = PyExc_RuntimeError; - *val = PyExc_RecursionErrorInst; - Py_INCREF(*exc); - Py_INCREF(*val); + /* throw away the old exception and use the recursion error instead */ + Py_INCREF(PyExc_RuntimeError); + Py_SETREF(*exc, PyExc_RuntimeError); + Py_INCREF(PyExc_RecursionErrorInst); + Py_SETREF(*val, PyExc_RecursionErrorInst); /* just keeping the old traceback */ return; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 27 08:52:06 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 27 Dec 2015 13:52:06 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIwNDQw?= =?utf-8?q?=3A_More_use_of_Py=5FSETREF=2E?= Message-ID: <20151227135206.124854.91576@psf.io> https://hg.python.org/cpython/rev/4bfbb2714ae9 changeset: 99687:4bfbb2714ae9 branch: 3.5 parent: 99684:9fb57c0209ea user: Serhiy Storchaka date: Sun Dec 27 15:41:34 2015 +0200 summary: Issue #20440: More use of Py_SETREF. This patch is manually crafted and contains changes that couldn't be handled automatically. files: Modules/_ctypes/_ctypes.c | 3 +- Modules/_elementtree.c | 38 +++++++++----------------- Modules/_sqlite/cursor.c | 4 +- Modules/zlibmodule.c | 18 ++++-------- Objects/exceptions.c | 19 +++++++------ Objects/unicodeobject.c | 2 +- Python/errors.c | 13 +++----- 7 files changed, 39 insertions(+), 58 deletions(-) diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2983,10 +2983,9 @@ "restype must be a type, a callable, or None"); return -1; } - Py_XDECREF(self->checker); Py_INCREF(ob); Py_SETREF(self->restype, ob); - self->checker = PyObject_GetAttrString(ob, "_check_retval_"); + Py_SETREF(self->checker, PyObject_GetAttrString(ob, "_check_retval_")); if (self->checker == NULL) PyErr_Clear(); return 0; diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -935,9 +935,8 @@ return NULL; } - Py_CLEAR(self->tag); - self->tag = tag; - Py_INCREF(self->tag); + Py_INCREF(tag); + Py_SETREF(self->tag, tag); _clear_joined_ptr(&self->text); self->text = text ? JOIN_SET(text, PyList_CheckExact(text)) : Py_None; @@ -980,9 +979,8 @@ /* Stash attrib. */ if (attrib) { - Py_CLEAR(self->extra->attrib); - self->extra->attrib = attrib; Py_INCREF(attrib); + Py_SETREF(self->extra->attrib, attrib); } Py_RETURN_NONE; @@ -1944,9 +1942,8 @@ return -1; if (strcmp(name, "tag") == 0) { - Py_DECREF(self->tag); - self->tag = value; - Py_INCREF(self->tag); + Py_INCREF(value); + Py_SETREF(self->tag, value); } else if (strcmp(name, "text") == 0) { Py_DECREF(JOIN_OBJ(self->text)); self->text = value; @@ -1960,9 +1957,8 @@ if (create_extra(self, NULL) < 0) return -1; } - Py_DECREF(self->extra->attrib); - self->extra->attrib = value; - Py_INCREF(self->extra->attrib); + Py_INCREF(value); + Py_SETREF(self->extra->attrib, value); } else { PyErr_SetString(PyExc_AttributeError, "Can't set arbitrary attributes on Element"); @@ -2554,13 +2550,10 @@ } self->index++; - Py_DECREF(this); Py_INCREF(node); - self->this = node; - - Py_DECREF(self->last); + Py_SETREF(self->this, node); Py_INCREF(node); - self->last = node; + Py_SETREF(self->last, node); if (treebuilder_append_event(self, self->start_event_obj, node) < 0) goto error; @@ -2633,15 +2626,12 @@ return NULL; } + item = self->last; + self->last = self->this; self->index--; - - item = PyList_GET_ITEM(self->stack, self->index); - Py_INCREF(item); - - Py_DECREF(self->last); - - self->last = self->this; - self->this = item; + self->this = PyList_GET_ITEM(self->stack, self->index); + Py_INCREF(self->this); + Py_DECREF(item); if (treebuilder_append_event(self, self->end_event_obj, self->last) < 0) return NULL; diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -524,10 +524,10 @@ if (self->statement) { (void)pysqlite_statement_reset(self->statement); - Py_DECREF(self->statement); } - self->statement = (pysqlite_Statement*)pysqlite_cache_get(self->connection->statement_cache, func_args); + Py_SETREF(self->statement, + (pysqlite_Statement *)pysqlite_cache_get(self->connection->statement_cache, func_args)); Py_DECREF(func_args); if (!self->statement) { diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -961,14 +961,11 @@ goto error; } Py_INCREF(self->unused_data); + Py_SETREF(retval->unused_data, self->unused_data); Py_INCREF(self->unconsumed_tail); + Py_SETREF(retval->unconsumed_tail, self->unconsumed_tail); Py_XINCREF(self->zdict); - Py_XDECREF(retval->unused_data); - Py_XDECREF(retval->unconsumed_tail); - Py_XDECREF(retval->zdict); - retval->unused_data = self->unused_data; - retval->unconsumed_tail = self->unconsumed_tail; - retval->zdict = self->zdict; + Py_SETREF(retval->zdict, self->zdict); retval->eof = self->eof; /* Mark it as being initialized */ @@ -1020,14 +1017,11 @@ } Py_INCREF(self->unused_data); + Py_SETREF(retval->unused_data, self->unused_data); Py_INCREF(self->unconsumed_tail); + Py_SETREF(retval->unconsumed_tail, self->unconsumed_tail); Py_XINCREF(self->zdict); - Py_XDECREF(retval->unused_data); - Py_XDECREF(retval->unconsumed_tail); - Py_XDECREF(retval->zdict); - retval->unused_data = self->unused_data; - retval->unconsumed_tail = self->unconsumed_tail; - retval->zdict = self->zdict; + Py_SETREF(retval->zdict, self->zdict); retval->eof = self->eof; /* Mark it as being initialized */ diff --git a/Objects/exceptions.c b/Objects/exceptions.c --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -561,12 +561,14 @@ if (size == 0) return 0; - Py_CLEAR(self->code); - if (size == 1) - self->code = PyTuple_GET_ITEM(args, 0); - else /* size > 1 */ - self->code = args; - Py_INCREF(self->code); + if (size == 1) { + Py_INCREF(PyTuple_GET_ITEM(args, 0)); + Py_SETREF(self->code, PyTuple_GET_ITEM(args, 0)); + } + else { /* size > 1 */ + Py_INCREF(args); + Py_SETREF(self->code, args); + } return 0; } @@ -625,9 +627,8 @@ #define GET_KWD(kwd) { \ kwd = PyDict_GetItemString(kwds, #kwd); \ if (kwd) { \ - Py_CLEAR(self->kwd); \ - self->kwd = kwd; \ - Py_INCREF(self->kwd);\ + Py_INCREF(kwd); \ + Py_SETREF(self->kwd, kwd); \ if (PyDict_DelItemString(kwds, #kwd)) \ return -1; \ } \ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -14191,8 +14191,8 @@ if (key == NULL) return -1; if (ctx->args_owned) { + ctx->args_owned = 0; Py_DECREF(ctx->args); - ctx->args_owned = 0; } ctx->args = PyObject_GetItem(ctx->dict, key); Py_DECREF(key); diff --git a/Python/errors.c b/Python/errors.c --- a/Python/errors.c +++ b/Python/errors.c @@ -315,14 +315,11 @@ tstate = PyThreadState_GET(); if (++tstate->recursion_depth > Py_GetRecursionLimit()) { --tstate->recursion_depth; - /* throw away the old exception... */ - Py_DECREF(*exc); - Py_DECREF(*val); - /* ... and use the recursion error instead */ - *exc = PyExc_RecursionError; - *val = PyExc_RecursionErrorInst; - Py_INCREF(*exc); - Py_INCREF(*val); + /* throw away the old exception and use the recursion error instead */ + Py_INCREF(PyExc_RecursionError); + Py_SETREF(*exc, PyExc_RecursionError); + Py_INCREF(PyExc_RecursionErrorInst); + Py_SETREF(*val, PyExc_RecursionErrorInst); /* just keeping the old traceback */ return; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 27 08:52:07 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 27 Dec 2015 13:52:07 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2320440=3A_Cleaning?= =?utf-8?q?_up_the_code_by_using_Py=5FSETREF_and_Py=5FCLEAR=2E?= Message-ID: <20151227135206.70431.54411@psf.io> https://hg.python.org/cpython/rev/b02d256b8827 changeset: 99690:b02d256b8827 user: Serhiy Storchaka date: Sun Dec 27 15:51:32 2015 +0200 summary: Issue #20440: Cleaning up the code by using Py_SETREF and Py_CLEAR. Old code is correct, but with Py_SETREF and Py_CLEAR it can be cleaner. This patch doesn't fix bugs and hence there is no need to backport it. files: Modules/_collectionsmodule.c | 5 +---- Modules/_ctypes/_ctypes.c | 10 ++++------ Modules/_elementtree.c | 6 +----- Modules/_io/bytesio.c | 6 ++---- Modules/itertoolsmodule.c | 22 ++++++---------------- Modules/pyexpat.c | 17 ++++------------- Objects/listobject.c | 10 ++-------- Objects/tupleobject.c | 5 +---- Objects/typeobject.c | 13 ++----------- 9 files changed, 23 insertions(+), 71 deletions(-) diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1222,7 +1222,6 @@ static int deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v) { - PyObject *old_value; block *b; Py_ssize_t n, len=Py_SIZE(deque), halflen=(len+1)>>1, index=i; @@ -1249,9 +1248,7 @@ b = b->leftlink; } Py_INCREF(v); - old_value = b->data[i]; - b->data[i] = v; - Py_DECREF(old_value); + Py_SETREF(b->data[i], v); return 0; } diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -5123,23 +5123,22 @@ comerror_init(PyObject *self, PyObject *args, PyObject *kwds) { PyObject *hresult, *text, *details; - PyBaseExceptionObject *bself; PyObject *a; int status; if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds)) - return -1; + return -1; if (!PyArg_ParseTuple(args, "OOO:COMError", &hresult, &text, &details)) return -1; a = PySequence_GetSlice(args, 1, PySequence_Size(args)); if (!a) - return -1; + return -1; status = PyObject_SetAttrString(self, "args", a); Py_DECREF(a); if (status < 0) - return -1; + return -1; if (PyObject_SetAttrString(self, "hresult", hresult) < 0) return -1; @@ -5150,9 +5149,8 @@ if (PyObject_SetAttrString(self, "details", details) < 0) return -1; - bself = (PyBaseExceptionObject *)self; Py_INCREF(args); - Py_SETREF(bself->args, args); + Py_SETREF((PyBaseExceptionObject *)self->args, args); return 0; } diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2338,13 +2338,9 @@ PyObject *element_factory) /*[clinic end generated code: output=91cfa7558970ee96 input=1b424eeefc35249c]*/ { - PyObject *tmp; - if (element_factory) { Py_INCREF(element_factory); - tmp = self->element_factory; - self->element_factory = element_factory; - Py_XDECREF(tmp); + Py_SETREF(self->element_factory, element_factory); } return 0; diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -87,7 +87,7 @@ static int unshare_buffer(bytesio *self, size_t size) { - PyObject *new_buf, *old_buf; + PyObject *new_buf; assert(SHARED_BUF(self)); assert(self->exports == 0); assert(size >= (size_t)self->string_size); @@ -96,9 +96,7 @@ return -1; memcpy(PyBytes_AS_STRING(new_buf), PyBytes_AS_STRING(self->buf), self->string_size); - old_buf = self->buf; - self->buf = new_buf; - Py_DECREF(old_buf); + Py_SETREF(self->buf, new_buf); return 0; } diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -77,7 +77,7 @@ static PyObject * groupby_next(groupbyobject *gbo) { - PyObject *newvalue, *newkey, *r, *grouper, *tmp; + PyObject *newvalue, *newkey, *r, *grouper; /* skip to next iteration group */ for (;;) { @@ -110,19 +110,12 @@ } } - tmp = gbo->currkey; - gbo->currkey = newkey; - Py_XDECREF(tmp); - - tmp = gbo->currvalue; - gbo->currvalue = newvalue; - Py_XDECREF(tmp); + Py_SETREF(gbo->currkey, newkey); + Py_SETREF(gbo->currvalue, newvalue); } Py_INCREF(gbo->currkey); - tmp = gbo->tgtkey; - gbo->tgtkey = gbo->currkey; - Py_XDECREF(tmp); + Py_SETREF(gbo->tgtkey, gbo->currkey); grouper = _grouper_create(gbo, gbo->tgtkey); if (grouper == NULL) @@ -3445,7 +3438,7 @@ static PyObject * accumulate_next(accumulateobject *lz) { - PyObject *val, *oldtotal, *newtotal; + PyObject *val, *newtotal; val = (*Py_TYPE(lz->it)->tp_iternext)(lz->it); if (val == NULL) @@ -3465,11 +3458,8 @@ if (newtotal == NULL) return NULL; - oldtotal = lz->total; - lz->total = newtotal; - Py_DECREF(oldtotal); - Py_INCREF(newtotal); + Py_SETREF(lz->total, newtotal); return newtotal; } diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1226,12 +1226,8 @@ self->itself = NULL; if (self->handlers != NULL) { - PyObject *temp; - for (i = 0; handler_info[i].name != NULL; i++) { - temp = self->handlers[i]; - self->handlers[i] = NULL; - Py_XDECREF(temp); - } + for (i = 0; handler_info[i].name != NULL; i++) + Py_CLEAR(self->handlers[i]); PyMem_Free(self->handlers); self->handlers = NULL; } @@ -1345,7 +1341,6 @@ int handlernum = handlername2int(name); if (handlernum >= 0) { xmlhandler c_handler = NULL; - PyObject *temp = self->handlers[handlernum]; if (v == Py_None) { /* If this is the character data handler, and a character @@ -1367,8 +1362,7 @@ Py_INCREF(v); c_handler = handler_info[handlernum].handler; } - self->handlers[handlernum] = v; - Py_XDECREF(temp); + Py_SETREF(self->handlers[handlernum], v); handler_info[handlernum].setter(self->itself, c_handler); return 1; } @@ -1898,15 +1892,12 @@ clear_handlers(xmlparseobject *self, int initial) { int i = 0; - PyObject *temp; for (; handler_info[i].name != NULL; i++) { if (initial) self->handlers[i] = NULL; else { - temp = self->handlers[i]; - self->handlers[i] = NULL; - Py_XDECREF(temp); + Py_CLEAR(self->handlers[i]); handler_info[i].setter(self->itself, NULL); } } diff --git a/Objects/listobject.c b/Objects/listobject.c --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -216,7 +216,6 @@ PyList_SetItem(PyObject *op, Py_ssize_t i, PyObject *newitem) { - PyObject *olditem; PyObject **p; if (!PyList_Check(op)) { Py_XDECREF(newitem); @@ -230,9 +229,7 @@ return -1; } p = ((PyListObject *)op) -> ob_item + i; - olditem = *p; - *p = newitem; - Py_XDECREF(olditem); + Py_SETREF(*p, newitem); return 0; } @@ -730,7 +727,6 @@ static int list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v) { - PyObject *old_value; if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "list assignment index out of range"); @@ -739,9 +735,7 @@ if (v == NULL) return list_ass_slice(a, i, i+1, v); Py_INCREF(v); - old_value = a->ob_item[i]; - a->ob_item[i] = v; - Py_DECREF(old_value); + Py_SETREF(a->ob_item[i], v); return 0; } diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -149,7 +149,6 @@ int PyTuple_SetItem(PyObject *op, Py_ssize_t i, PyObject *newitem) { - PyObject *olditem; PyObject **p; if (!PyTuple_Check(op) || op->ob_refcnt != 1) { Py_XDECREF(newitem); @@ -163,9 +162,7 @@ return -1; } p = ((PyTupleObject *)op) -> ob_item + i; - olditem = *p; - *p = newitem; - Py_XDECREF(olditem); + Py_SETREF(*p, newitem); return 0; } diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -401,7 +401,6 @@ static int type_set_name(PyTypeObject *type, PyObject *value, void *context) { - PyHeapTypeObject* et; char *tp_name; PyObject *tmp; @@ -430,17 +429,9 @@ if (tp_name == NULL) return -1; - et = (PyHeapTypeObject*)type; - + type->tp_name = tp_name; Py_INCREF(value); - - /* Wait until et is a sane state before Py_DECREF'ing the old et->ht_name - value. (Bug #16447.) */ - tmp = et->ht_name; - et->ht_name = value; - - type->tp_name = tp_name; - Py_DECREF(tmp); + Py_SETREF(((PyHeapTypeObject*)type)->ht_name, value); return 0; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 27 12:09:21 2015 From: python-checkins at python.org (guido.van.rossum) Date: Sun, 27 Dec 2015 17:09:21 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Change_Talin=27s_email_addres?= =?utf-8?q?s_to_viridia=40gmail=2Ecom=2E?= Message-ID: <20151227170920.77241.638@psf.io> https://hg.python.org/peps/rev/ca2f801ef18f changeset: 6144:ca2f801ef18f user: Guido van Rossum date: Sun Dec 27 10:09:06 2015 -0700 summary: Change Talin's email address to viridia at gmail.com. files: pep-3101.txt | 2 +- pep-3102.txt | 2 +- pep-3115.txt | 2 +- pep-3119.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pep-3101.txt b/pep-3101.txt --- a/pep-3101.txt +++ b/pep-3101.txt @@ -2,7 +2,7 @@ Title: Advanced String Formatting Version: $Revision$ Last-Modified: $Date$ -Author: Talin +Author: Talin Status: Final Type: Standards Track Content-Type: text/plain diff --git a/pep-3102.txt b/pep-3102.txt --- a/pep-3102.txt +++ b/pep-3102.txt @@ -2,7 +2,7 @@ Title: Keyword-Only Arguments Version: $Revision$ Last-Modified: $Date$ -Author: Talin +Author: Talin Status: Final Type: Standards Track Content-Type: text/plain diff --git a/pep-3115.txt b/pep-3115.txt --- a/pep-3115.txt +++ b/pep-3115.txt @@ -2,7 +2,7 @@ Title: Metaclasses in Python 3000 Version: $Revision$ Last-Modified: $Date$ -Author: Talin +Author: Talin Status: Final Type: Standards Track Content-Type: text/plain diff --git a/pep-3119.txt b/pep-3119.txt --- a/pep-3119.txt +++ b/pep-3119.txt @@ -2,7 +2,7 @@ Title: Introducing Abstract Base Classes Version: $Revision$ Last-Modified: $Date$ -Author: Guido van Rossum , Talin +Author: Guido van Rossum , Talin Status: Final Type: Standards Track Content-Type: text/x-rst -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sun Dec 27 15:09:16 2015 From: python-checkins at python.org (brett.cannon) Date: Sun, 27 Dec 2015 20:09:16 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_for_issue_=2325874?= Message-ID: <20151227200916.3375.17318@psf.io> https://hg.python.org/cpython/rev/c6bd004671a7 changeset: 99692:c6bd004671a7 parent: 99690:b02d256b8827 parent: 99691:5114871a3ac6 user: Brett Cannon date: Sun Dec 27 12:09:10 2015 -0800 summary: Merge for issue #25874 files: Doc/using/windows.rst | 8 ++++++++ Misc/ACKS | 1 + 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst --- a/Doc/using/windows.rst +++ b/Doc/using/windows.rst @@ -24,6 +24,14 @@ able to install for all users of a single machine, and a separate ZIP file is available for application-local distributions. +Supported Versions +------------------ + +As specified in :pep:`11`, a Python release only supports a Windows platform +while Microsoft considers the platform under extended support. This means that +Python 3.5 supports Windows Vista and newer. If you require Windows XP support +then please install Python 3.4. + Installation Steps ------------------ diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1558,6 +1558,7 @@ Gerry Wiener Frank Wierzbicki Santoso Wijaya +Chris Wilcox Bryce "Zooko" Wilcox-O'Hearn Timothy Wild Jakub Wilk -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 27 15:09:16 2015 From: python-checkins at python.org (brett.cannon) Date: Sun, 27 Dec 2015 20:09:16 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODc0?= =?utf-8?q?=3A_Clarify_platform_support_in_the_=22Using_Python_on_Windows?= =?utf-8?b?IiBkb2Mu?= Message-ID: <20151227200916.9634.92768@psf.io> https://hg.python.org/cpython/rev/5114871a3ac6 changeset: 99691:5114871a3ac6 branch: 3.5 parent: 99687:4bfbb2714ae9 user: Brett Cannon date: Sun Dec 27 12:08:37 2015 -0800 summary: Issue #25874: Clarify platform support in the "Using Python on Windows" doc. Thanks to Chris Wilcox for the initial patch. files: Doc/using/windows.rst | 8 ++++++++ Misc/ACKS | 1 + 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst --- a/Doc/using/windows.rst +++ b/Doc/using/windows.rst @@ -24,6 +24,14 @@ able to install for all users of a single machine, and a separate ZIP file is available for application-local distributions. +Supported Versions +------------------ + +As specified in :pep:`11`, a Python release only supports a Windows platform +while Microsoft considers the platform under extended support. This means that +Python 3.5 supports Windows Vista and newer. If you require Windows XP support +then please install Python 3.4. + Installation Steps ------------------ diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1554,6 +1554,7 @@ Gerry Wiener Frank Wierzbicki Santoso Wijaya +Chris Wilcox Bryce "Zooko" Wilcox-O'Hearn Timothy Wild Jakub Wilk -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 27 15:24:42 2015 From: python-checkins at python.org (brett.cannon) Date: Sun, 27 Dec 2015 20:24:42 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_for_issue_=2312484?= Message-ID: <20151227202442.21384.28017@psf.io> https://hg.python.org/cpython/rev/f4aee46c79ca changeset: 99694:f4aee46c79ca parent: 99692:c6bd004671a7 parent: 99693:003f1f60a09c user: Brett Cannon date: Sun Dec 27 12:24:36 2015 -0800 summary: Merge for issue #12484 files: Doc/c-api/import.rst | 5 ----- Doc/faq/extending.rst | 14 -------------- Misc/ACKS | 1 + 3 files changed, 1 insertions(+), 19 deletions(-) diff --git a/Doc/c-api/import.rst b/Doc/c-api/import.rst --- a/Doc/c-api/import.rst +++ b/Doc/c-api/import.rst @@ -236,11 +236,6 @@ For internal use only. -.. c:function:: PyObject* _PyImport_FixupExtension(char *, char *) - - For internal use only. - - .. c:function:: int PyImport_ImportFrozenModuleObject(PyObject *name) Load a frozen module named *name*. Return ``1`` for success, ``0`` if the diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -247,20 +247,6 @@ For Debian, run ``apt-get install python-dev``. -What does "SystemError: _PyImport_FixupExtension: module yourmodule not loaded" mean? -------------------------------------------------------------------------------------- - -This means that you have created an extension module named "yourmodule", but -your module init function does not initialize with that name. - -Every module init function will have a line similar to:: - - module = Py_InitModule("yourmodule", yourmodule_functions); - -If the string passed to this function is not the same name as your extension -module, the :exc:`SystemError` exception will be raised. - - How do I tell "incomplete input" from "invalid input"? ------------------------------------------------------ diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1313,6 +1313,7 @@ Denis Severson Ian Seyer Dmitry Shachnev +Anish Shah Daniel Shahaf Mark Shannon Ha Shao -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 27 15:24:42 2015 From: python-checkins at python.org (brett.cannon) Date: Sun, 27 Dec 2015 20:24:42 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzEyNDg0?= =?utf-8?q?=3A_Remove_a_mention_of_Py=5FInitModule=28=29_and?= Message-ID: <20151227202442.77243.68960@psf.io> https://hg.python.org/cpython/rev/003f1f60a09c changeset: 99693:003f1f60a09c branch: 3.5 parent: 99691:5114871a3ac6 user: Brett Cannon date: Sun Dec 27 12:24:06 2015 -0800 summary: Issue #12484: Remove a mention of Py_InitModule() and _PyImport_FixupExtension(). Thanks to Alejandro Santos for the bug report and Anish Shah for the patch. files: Doc/c-api/import.rst | 5 ----- Doc/faq/extending.rst | 14 -------------- Misc/ACKS | 1 + 3 files changed, 1 insertions(+), 19 deletions(-) diff --git a/Doc/c-api/import.rst b/Doc/c-api/import.rst --- a/Doc/c-api/import.rst +++ b/Doc/c-api/import.rst @@ -236,11 +236,6 @@ For internal use only. -.. c:function:: PyObject* _PyImport_FixupExtension(char *, char *) - - For internal use only. - - .. c:function:: int PyImport_ImportFrozenModuleObject(PyObject *name) Load a frozen module named *name*. Return ``1`` for success, ``0`` if the diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -247,20 +247,6 @@ For Debian, run ``apt-get install python-dev``. -What does "SystemError: _PyImport_FixupExtension: module yourmodule not loaded" mean? -------------------------------------------------------------------------------------- - -This means that you have created an extension module named "yourmodule", but -your module init function does not initialize with that name. - -Every module init function will have a line similar to:: - - module = Py_InitModule("yourmodule", yourmodule_functions); - -If the string passed to this function is not the same name as your extension -module, the :exc:`SystemError` exception will be raised. - - How do I tell "incomplete input" from "invalid input"? ------------------------------------------------------ diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1310,6 +1310,7 @@ Denis Severson Ian Seyer Dmitry Shachnev +Anish Shah Daniel Shahaf Mark Shannon Ha Shao -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Dec 27 16:17:09 2015 From: python-checkins at python.org (brett.cannon) Date: Sun, 27 Dec 2015 21:17:09 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325768=3A_Make_com?= =?utf-8?q?pileall_functions_return_booleans_and_document?= Message-ID: <20151227211709.70445.20220@psf.io> https://hg.python.org/cpython/rev/71f071f2e074 changeset: 99695:71f071f2e074 user: Brett Cannon date: Sun Dec 27 13:17:04 2015 -0800 summary: Issue #25768: Make compileall functions return booleans and document the return values as well as test them. Thanks to Nicholas Chammas for the bug report and initial patch. files: Doc/library/compileall.rst | 12 +++++++--- Doc/whatsnew/3.6.rst | 5 ++++ Lib/compileall.py | 16 +++++++------- Lib/test/test_compileall.py | 26 +++++++++++++++++++++++- Misc/ACKS | 1 + Misc/NEWS | 3 ++ 6 files changed, 49 insertions(+), 14 deletions(-) diff --git a/Doc/library/compileall.rst b/Doc/library/compileall.rst --- a/Doc/library/compileall.rst +++ b/Doc/library/compileall.rst @@ -103,7 +103,8 @@ .. function:: compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1) Recursively descend the directory tree named by *dir*, compiling all :file:`.py` - files along the way. + files along the way. Return a true value if all the files compiled successfully, + and a false value otherwise. The *maxlevels* parameter is used to limit the depth of the recursion; it defaults to ``10``. @@ -155,7 +156,8 @@ .. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1) - Compile the file with path *fullname*. + Compile the file with path *fullname*. Return a true value if the file + compiled successfully, and a false value otherwise. If *ddir* is given, it is prepended to the path to the file being compiled for use in compilation time tracebacks, and is also compiled in to the @@ -191,8 +193,10 @@ .. function:: compile_path(skip_curdir=True, maxlevels=0, force=False, quiet=0, legacy=False, optimize=-1) - Byte-compile all the :file:`.py` files found along ``sys.path``. If - *skip_curdir* is true (the default), the current directory is not included + Byte-compile all the :file:`.py` files found along ``sys.path``. Return a + true value if all the files compiled successfully, and a false value otherwise. + + If *skip_curdir* is true (the default), the current directory is not included in the search. All other parameters are passed to the :func:`compile_dir` function. Note that unlike the other compile functions, ``maxlevels`` defaults to ``0``. diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -230,6 +230,11 @@ Changes in the Python API ------------------------- +* The functions in the :mod:`compileall` module now return booleans instead + of ``1`` or ``0`` to represent success or failure, respectively. Thanks to + booleans being a subclass of integers, this should only be an issue if you + were doing identity checks for ``1`` or ``0``. See :issue:`25768`. + * Reading the :attr:`~urllib.parse.SplitResult.port` attribute of :func:`urllib.parse.urlsplit` and :func:`~urllib.parse.urlparse` results now raises :exc:`ValueError` for out-of-range values, rather than diff --git a/Lib/compileall.py b/Lib/compileall.py --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -68,7 +68,7 @@ """ files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels, ddir=ddir) - success = 1 + success = True if workers is not None and workers != 1 and ProcessPoolExecutor is not None: if workers < 0: raise ValueError('workers must be greater or equal to 0') @@ -81,12 +81,12 @@ legacy=legacy, optimize=optimize), files) - success = min(results, default=1) + success = min(results, default=True) else: for file in files: if not compile_file(file, ddir, force, rx, quiet, legacy, optimize): - success = 0 + success = False return success def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, @@ -104,7 +104,7 @@ legacy: if True, produce legacy pyc paths instead of PEP 3147 paths optimize: optimization level or -1 for level of the interpreter """ - success = 1 + success = True name = os.path.basename(fullname) if ddir is not None: dfile = os.path.join(ddir, name) @@ -144,7 +144,7 @@ ok = py_compile.compile(fullname, cfile, dfile, True, optimize=optimize) except py_compile.PyCompileError as err: - success = 0 + success = False if quiet >= 2: return success elif quiet: @@ -157,7 +157,7 @@ msg = msg.decode(sys.stdout.encoding) print(msg) except (SyntaxError, UnicodeError, OSError) as e: - success = 0 + success = False if quiet >= 2: return success elif quiet: @@ -167,7 +167,7 @@ print(e.__class__.__name__ + ':', e) else: if ok == 0: - success = 0 + success = False return success def compile_path(skip_curdir=1, maxlevels=0, force=False, quiet=0, @@ -183,7 +183,7 @@ legacy: as for compile_dir() (default False) optimize: as for compile_dir() (default -1) """ - success = 1 + success = True for dir in sys.path: if (not dir or dir == os.curdir) and skip_curdir: if quiet < 2: diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py --- a/Lib/test/test_compileall.py +++ b/Lib/test/test_compileall.py @@ -1,6 +1,7 @@ import sys import compileall import importlib.util +import test.test_importlib.util import os import pathlib import py_compile @@ -40,6 +41,11 @@ def tearDown(self): shutil.rmtree(self.directory) + def add_bad_source_file(self): + self.bad_source_path = os.path.join(self.directory, '_test_bad.py') + with open(self.bad_source_path, 'w') as file: + file.write('x (\n') + def data(self): with open(self.bc_path, 'rb') as file: data = file.read(8) @@ -78,15 +84,31 @@ os.unlink(fn) except: pass - compileall.compile_file(self.source_path, force=False, quiet=True) + self.assertTrue(compileall.compile_file(self.source_path, + force=False, quiet=True)) self.assertTrue(os.path.isfile(self.bc_path) and not os.path.isfile(self.bc_path2)) os.unlink(self.bc_path) - compileall.compile_dir(self.directory, force=False, quiet=True) + self.assertTrue(compileall.compile_dir(self.directory, force=False, + quiet=True)) self.assertTrue(os.path.isfile(self.bc_path) and os.path.isfile(self.bc_path2)) os.unlink(self.bc_path) os.unlink(self.bc_path2) + # Test against bad files + self.add_bad_source_file() + self.assertFalse(compileall.compile_file(self.bad_source_path, + force=False, quiet=2)) + self.assertFalse(compileall.compile_dir(self.directory, + force=False, quiet=2)) + + def test_compile_path(self): + self.assertTrue(compileall.compile_path(quiet=2)) + + with test.test_importlib.util.import_state(path=[self.directory]): + self.add_bad_source_file() + self.assertFalse(compileall.compile_path(skip_curdir=False, + force=True, quiet=2)) def test_no_pycache_in_non_package(self): # Bug 8563 reported that __pycache__ directories got created by diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -235,6 +235,7 @@ Michael Cetrulo Dave Chambers Pascal Chambon +Nicholas Chammas John Chandler Hye-Shik Chang Jeffrey Chang diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -123,6 +123,9 @@ Library ------- +- Issue #25768: Have the functions in compileall return booleans instead of + ints and add proper documentation and tests for the return values. + - Issue #24103: Fixed possible use after free in ElementTree.XMLPullParser. - Issue #25860: os.fwalk() no longer skips remaining directories when error -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Mon Dec 28 03:44:16 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 28 Dec 2015 08:44:16 +0000 Subject: [Python-checkins] Daily reference leaks (71f071f2e074): sum=4 Message-ID: <20151228084416.21388.89015@psf.io> results for 71f071f2e074 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogNb1uXr', '--timeout', '7200'] From python-checkins at python.org Mon Dec 28 16:50:27 2015 From: python-checkins at python.org (ezio.melotti) Date: Mon, 28 Dec 2015 21:50:27 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Remove_duplicate_method_in?= =?utf-8?q?_test=5Fpathlib=2E__Initial_patch_by_Navneet_Suman=2E?= Message-ID: <20151228215027.70443.1327@psf.io> https://hg.python.org/cpython/rev/1472c08d9c23 changeset: 99696:1472c08d9c23 user: Ezio Melotti date: Mon Dec 28 23:50:19 2015 +0200 summary: Remove duplicate method in test_pathlib. Initial patch by Navneet Suman. files: Lib/test/test_pathlib.py | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1437,13 +1437,13 @@ self.assertEqual(set(p.glob("dirA/../file*")), { P(BASE, "dirA/../fileA") }) self.assertEqual(set(p.glob("../xyzzy")), set()) - def _check_resolve_relative(self, p, expected): + + def _check_resolve(self, p, expected): q = p.resolve() self.assertEqual(q, expected) - def _check_resolve_absolute(self, p, expected): - q = p.resolve() - self.assertEqual(q, expected) + # this can be used to check both relative and absolute resolutions + _check_resolve_relative = _check_resolve_absolute = _check_resolve @with_symlinks def test_resolve_common(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 17:01:52 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 28 Dec 2015 22:01:52 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_Merge_heads?= Message-ID: <20151228220152.3385.4382@psf.io> https://hg.python.org/cpython/rev/f4c5f3857d4b changeset: 99699:f4c5f3857d4b parent: 99698:a0f9a8bee85f parent: 99696:1472c08d9c23 user: Serhiy Storchaka date: Tue Dec 29 00:01:31 2015 +0200 summary: Merge heads files: Lib/test/test_pathlib.py | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1437,13 +1437,13 @@ self.assertEqual(set(p.glob("dirA/../file*")), { P(BASE, "dirA/../fileA") }) self.assertEqual(set(p.glob("../xyzzy")), set()) - def _check_resolve_relative(self, p, expected): + + def _check_resolve(self, p, expected): q = p.resolve() self.assertEqual(q, expected) - def _check_resolve_absolute(self, p, expected): - q = p.resolve() - self.assertEqual(q, expected) + # this can be used to check both relative and absolute resolutions + _check_resolve_relative = _check_resolve_absolute = _check_resolve @with_symlinks def test_resolve_common(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 17:01:52 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 28 Dec 2015 22:01:52 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NDQ3?= =?utf-8?q?=3A_Copying_the_lru=5Fcache=28=29_wrapper_object_now_always_wor?= =?utf-8?b?a3Ms?= Message-ID: <20151228220152.8269.28972@psf.io> https://hg.python.org/cpython/rev/33b428ef34b9 changeset: 99697:33b428ef34b9 branch: 3.5 parent: 99693:003f1f60a09c user: Serhiy Storchaka date: Mon Dec 28 23:58:07 2015 +0200 summary: Issue #25447: Copying the lru_cache() wrapper object now always works, independedly from the type of the wrapped object (by returning the original object unchanged). files: Lib/test/test_functools.py | 14 ++++++++++++-- Misc/NEWS | 4 ++++ Modules/_functoolsmodule.c | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -1262,14 +1262,24 @@ def test_copy(self): cls = self.__class__ - for f in cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth: + def orig(x, y): + return 3 * x + y + part = self.module.partial(orig, 2) + funcs = (cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth, + self.module.lru_cache(2)(part)) + for f in funcs: with self.subTest(func=f): f_copy = copy.copy(f) self.assertIs(f_copy, f) def test_deepcopy(self): cls = self.__class__ - for f in cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth: + def orig(x, y): + return 3 * x + y + part = self.module.partial(orig, 2) + funcs = (cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth, + self.module.lru_cache(2)(part)) + for f in funcs: with self.subTest(func=f): f_copy = copy.deepcopy(f) self.assertIs(f_copy, f) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -36,6 +36,10 @@ Library ------- +- Issue #25447: Copying the lru_cache() wrapper object now always works, + independedly from the type of the wrapped object (by returning the original + object unchanged). + - Issue #24103: Fixed possible use after free in ElementTree.XMLPullParser. - Issue #25860: os.fwalk() no longer skips remaining directories when error diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -1053,6 +1053,20 @@ return PyObject_GetAttrString(self, "__qualname__"); } +static PyObject * +lru_cache_copy(PyObject *self, PyObject *unused) +{ + Py_INCREF(self); + return self; +} + +static PyObject * +lru_cache_deepcopy(PyObject *self, PyObject *unused) +{ + Py_INCREF(self); + return self; +} + static int lru_cache_tp_traverse(lru_cache_object *self, visitproc visit, void *arg) { @@ -1104,6 +1118,8 @@ {"cache_info", (PyCFunction)lru_cache_cache_info, METH_NOARGS}, {"cache_clear", (PyCFunction)lru_cache_cache_clear, METH_NOARGS}, {"__reduce__", (PyCFunction)lru_cache_reduce, METH_NOARGS}, + {"__copy__", (PyCFunction)lru_cache_copy, METH_VARARGS}, + {"__deepcopy__", (PyCFunction)lru_cache_deepcopy, METH_VARARGS}, {NULL} }; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 17:01:52 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 28 Dec 2015 22:01:52 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325447=3A_Copying_the_lru=5Fcache=28=29_wrapper_?= =?utf-8?q?object_now_always_works=2C?= Message-ID: <20151228220152.3379.36662@psf.io> https://hg.python.org/cpython/rev/a0f9a8bee85f changeset: 99698:a0f9a8bee85f parent: 99695:71f071f2e074 parent: 99697:33b428ef34b9 user: Serhiy Storchaka date: Mon Dec 28 23:59:09 2015 +0200 summary: Issue #25447: Copying the lru_cache() wrapper object now always works, independedly from the type of the wrapped object (by returning the original object unchanged). files: Lib/test/test_functools.py | 14 ++++++++++++-- Misc/NEWS | 4 ++++ Modules/_functoolsmodule.c | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -1262,14 +1262,24 @@ def test_copy(self): cls = self.__class__ - for f in cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth: + def orig(x, y): + return 3 * x + y + part = self.module.partial(orig, 2) + funcs = (cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth, + self.module.lru_cache(2)(part)) + for f in funcs: with self.subTest(func=f): f_copy = copy.copy(f) self.assertIs(f_copy, f) def test_deepcopy(self): cls = self.__class__ - for f in cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth: + def orig(x, y): + return 3 * x + y + part = self.module.partial(orig, 2) + funcs = (cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth, + self.module.lru_cache(2)(part)) + for f in funcs: with self.subTest(func=f): f_copy = copy.deepcopy(f) self.assertIs(f_copy, f) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -123,6 +123,10 @@ Library ------- +- Issue #25447: Copying the lru_cache() wrapper object now always works, + independedly from the type of the wrapped object (by returning the original + object unchanged). + - Issue #25768: Have the functions in compileall return booleans instead of ints and add proper documentation and tests for the return values. diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -1053,6 +1053,20 @@ return PyObject_GetAttrString(self, "__qualname__"); } +static PyObject * +lru_cache_copy(PyObject *self, PyObject *unused) +{ + Py_INCREF(self); + return self; +} + +static PyObject * +lru_cache_deepcopy(PyObject *self, PyObject *unused) +{ + Py_INCREF(self); + return self; +} + static int lru_cache_tp_traverse(lru_cache_object *self, visitproc visit, void *arg) { @@ -1104,6 +1118,8 @@ {"cache_info", (PyCFunction)lru_cache_cache_info, METH_NOARGS}, {"cache_clear", (PyCFunction)lru_cache_cache_clear, METH_NOARGS}, {"__reduce__", (PyCFunction)lru_cache_reduce, METH_NOARGS}, + {"__copy__", (PyCFunction)lru_cache_copy, METH_VARARGS}, + {"__deepcopy__", (PyCFunction)lru_cache_deepcopy, METH_VARARGS}, {NULL} }; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 17:14:11 2015 From: python-checkins at python.org (stefan.krah) Date: Mon, 28 Dec 2015 22:14:11 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325928=3A_Add_Deci?= =?utf-8?q?mal=2Eas=5Finteger=5Fratio=28=29=2E_Python_parts_and_docs_by?= Message-ID: <20151228221411.3365.55364@psf.io> https://hg.python.org/cpython/rev/f3b09c269af0 changeset: 99700:f3b09c269af0 parent: 99696:1472c08d9c23 user: Stefan Krah date: Mon Dec 28 23:02:02 2015 +0100 summary: Issue #25928: Add Decimal.as_integer_ratio(). Python parts and docs by Mark Dickinson. files: Doc/library/decimal.rst | 13 ++ Lib/_pydecimal.py | 52 ++++++++ Lib/test/test_decimal.py | 33 +++++ Misc/NEWS | 2 + Modules/_decimal/_decimal.c | 101 +++++++++++++++++ Modules/_decimal/docstrings.h | 9 + Modules/_decimal/tests/deccheck.py | 6 +- 7 files changed, 213 insertions(+), 3 deletions(-) diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst --- a/Doc/library/decimal.rst +++ b/Doc/library/decimal.rst @@ -448,6 +448,19 @@ ``Decimal('321e+5').adjusted()`` returns seven. Used for determining the position of the most significant digit with respect to the decimal point. + .. method:: as_integer_ratio() + + Return a pair ``(n, d)`` of integers that represent the given + :class:`Decimal` instance as a fraction, in lowest terms and + with a positive denominator:: + + >>> Decimal('-3.14').as_integer_ratio() + (-157, 50) + + The conversion is exact. Raise OverflowError on infinities and ValueError + on NaNs. + + .. versionadded:: 3.6 .. method:: as_tuple() diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -1010,6 +1010,58 @@ """ return DecimalTuple(self._sign, tuple(map(int, self._int)), self._exp) + def as_integer_ratio(self): + """Express a finite Decimal instance in the form n / d. + + Returns a pair (n, d) of integers. When called on an infinity + or NaN, raises OverflowError or ValueError respectively. + + >>> Decimal('3.14').as_integer_ratio() + (157, 50) + >>> Decimal('-123e5').as_integer_ratio() + (-12300000, 1) + >>> Decimal('0.00').as_integer_ratio() + (0, 1) + + """ + if self._is_special: + if self.is_nan(): + raise ValueError("Cannot pass NaN " + "to decimal.as_integer_ratio.") + else: + raise OverflowError("Cannot pass infinity " + "to decimal.as_integer_ratio.") + + if not self: + return 0, 1 + + # Find n, d in lowest terms such that abs(self) == n / d; + # we'll deal with the sign later. + n = int(self._int) + if self._exp >= 0: + # self is an integer. + n, d = n * 10**self._exp, 1 + else: + # Find d2, d5 such that abs(self) = n / (2**d2 * 5**d5). + d5 = -self._exp + while d5 > 0 and n % 5 == 0: + n //= 5 + d5 -= 1 + + # (n & -n).bit_length() - 1 counts trailing zeros in binary + # representation of n (provided n is nonzero). + d2 = -self._exp + shift2 = min((n & -n).bit_length() - 1, d2) + if shift2: + n >>= shift2 + d2 -= shift2 + + d = 5**d5 << d2 + + if self._sign: + n = -n + return n, d + def __repr__(self): """Represents the number as an instance of Decimal.""" # Invariant: eval(repr(d)) == d diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -2047,6 +2047,39 @@ d = Decimal( (1, (0, 2, 7, 1), 'F') ) self.assertEqual(d.as_tuple(), (1, (0,), 'F')) + def test_as_integer_ratio(self): + Decimal = self.decimal.Decimal + + # exceptional cases + self.assertRaises(OverflowError, + Decimal.as_integer_ratio, Decimal('inf')) + self.assertRaises(OverflowError, + Decimal.as_integer_ratio, Decimal('-inf')) + self.assertRaises(ValueError, + Decimal.as_integer_ratio, Decimal('-nan')) + self.assertRaises(ValueError, + Decimal.as_integer_ratio, Decimal('snan123')) + + for exp in range(-4, 2): + for coeff in range(1000): + for sign in '+', '-': + d = Decimal('%s%dE%d' % (sign, coeff, exp)) + pq = d.as_integer_ratio() + p, q = pq + + # check return type + self.assertIsInstance(pq, tuple) + self.assertIsInstance(p, int) + self.assertIsInstance(q, int) + + # check normalization: q should be positive; + # p should be relatively prime to q. + self.assertGreater(q, 0) + self.assertEqual(math.gcd(p, q), 1) + + # check that p/q actually gives the correct value + self.assertEqual(Decimal(p) / Decimal(q), d) + def test_subclassing(self): # Different behaviours when subclassing Decimal Decimal = self.decimal.Decimal diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -123,6 +123,8 @@ Library ------- +- Issue #25928: Add Decimal.as_integer_ratio(). + - Issue #25768: Have the functions in compileall return booleans instead of ints and add proper documentation and tests for the return values. diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -3380,6 +3380,106 @@ return (PyObject *) pylong; } +/* Convert a Decimal to its exact integer ratio representation. */ +static PyObject * +dec_as_integer_ratio(PyObject *self, PyObject *args UNUSED) +{ + PyObject *numerator = NULL; + PyObject *denominator = NULL; + PyObject *exponent = NULL; + PyObject *result = NULL; + PyObject *tmp; + mpd_ssize_t exp; + PyObject *context; + uint32_t status = 0; + PyNumberMethods *long_methods = PyLong_Type.tp_as_number; + + if (mpd_isspecial(MPD(self))) { + if (mpd_isnan(MPD(self))) { + PyErr_SetString(PyExc_ValueError, + "cannot convert NaN to integer ratio"); + } + else { + PyErr_SetString(PyExc_OverflowError, + "cannot convert Infinity to integer ratio"); + } + return NULL; + } + + CURRENT_CONTEXT(context); + + tmp = dec_alloc(); + if (tmp == NULL) { + return NULL; + } + + if (!mpd_qcopy(MPD(tmp), MPD(self), &status)) { + Py_DECREF(tmp); + PyErr_NoMemory(); + return NULL; + } + + exp = mpd_iszero(MPD(tmp)) ? 0 : MPD(tmp)->exp; + MPD(tmp)->exp = 0; + + /* context and rounding are unused here: the conversion is exact */ + numerator = dec_as_long(tmp, context, MPD_ROUND_FLOOR); + Py_DECREF(tmp); + if (numerator == NULL) { + goto error; + } + + exponent = PyLong_FromSsize_t(exp < 0 ? -exp : exp); + if (exponent == NULL) { + goto error; + } + + tmp = PyLong_FromLong(10); + if (tmp == NULL) { + goto error; + } + + Py_SETREF(exponent, long_methods->nb_power(tmp, exponent, Py_None)); + Py_DECREF(tmp); + if (exponent == NULL) { + goto error; + } + + if (exp >= 0) { + Py_SETREF(numerator, long_methods->nb_multiply(numerator, exponent)); + if (numerator == NULL) { + goto error; + } + denominator = PyLong_FromLong(1); + if (denominator == NULL) { + goto error; + } + } + else { + denominator = exponent; + exponent = NULL; + tmp = _PyLong_GCD(numerator, denominator); + if (tmp == NULL) { + goto error; + } + Py_SETREF(numerator, long_methods->nb_floor_divide(numerator, tmp)); + Py_SETREF(denominator, long_methods->nb_floor_divide(denominator, tmp)); + Py_DECREF(tmp); + if (numerator == NULL || denominator == NULL) { + goto error; + } + } + + result = PyTuple_Pack(2, numerator, denominator); + + +error: + Py_XDECREF(exponent); + Py_XDECREF(denominator); + Py_XDECREF(numerator); + return result; +} + static PyObject * PyDec_ToIntegralValue(PyObject *dec, PyObject *args, PyObject *kwds) { @@ -4688,6 +4788,7 @@ /* Miscellaneous */ { "from_float", dec_from_float, METH_O|METH_CLASS, doc_from_float }, { "as_tuple", PyDec_AsTuple, METH_NOARGS, doc_as_tuple }, + { "as_integer_ratio", dec_as_integer_ratio, METH_NOARGS, doc_as_integer_ratio }, /* Special methods */ { "__copy__", dec_copy, METH_NOARGS, NULL }, diff --git a/Modules/_decimal/docstrings.h b/Modules/_decimal/docstrings.h --- a/Modules/_decimal/docstrings.h +++ b/Modules/_decimal/docstrings.h @@ -70,6 +70,15 @@ Return a tuple representation of the number.\n\ \n"); +PyDoc_STRVAR(doc_as_integer_ratio, +"as_integer_ratio($self, /)\n--\n\n\ +Decimal.as_integer_ratio() -> (int, int)\n\ +\n\ +Return a pair of integers, whose ratio is exactly equal to the original\n\ +Decimal and with a positive denominator. The ratio is in lowest terms.\n\ +Raise OverflowError on infinities and a ValueError on NaNs.\n\ +\n"); + PyDoc_STRVAR(doc_canonical, "canonical($self, /)\n--\n\n\ Return the canonical encoding of the argument. Currently, the encoding\n\ diff --git a/Modules/_decimal/tests/deccheck.py b/Modules/_decimal/tests/deccheck.py --- a/Modules/_decimal/tests/deccheck.py +++ b/Modules/_decimal/tests/deccheck.py @@ -50,8 +50,8 @@ '__abs__', '__bool__', '__ceil__', '__complex__', '__copy__', '__floor__', '__float__', '__hash__', '__int__', '__neg__', '__pos__', '__reduce__', '__repr__', '__str__', '__trunc__', - 'adjusted', 'as_tuple', 'canonical', 'conjugate', 'copy_abs', - 'copy_negate', 'is_canonical', 'is_finite', 'is_infinite', + 'adjusted', 'as_integer_ratio', 'as_tuple', 'canonical', 'conjugate', + 'copy_abs', 'copy_negate', 'is_canonical', 'is_finite', 'is_infinite', 'is_nan', 'is_qnan', 'is_signed', 'is_snan', 'is_zero', 'radix' ), # Unary with optional context: @@ -128,7 +128,7 @@ # Functions that require a restricted exponent range for reasonable runtimes. UnaryRestricted = [ '__ceil__', '__floor__', '__int__', '__trunc__', - 'to_integral', 'to_integral_value' + 'as_integer_ratio', 'to_integral', 'to_integral_value' ] BinaryRestricted = ['__round__'] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 17:14:13 2015 From: python-checkins at python.org (stefan.krah) Date: Mon, 28 Dec 2015 22:14:13 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?b?KTogTWVyZ2Uu?= Message-ID: <20151228221411.126309.19597@psf.io> https://hg.python.org/cpython/rev/7f44e0ff6d72 changeset: 99701:7f44e0ff6d72 parent: 99700:f3b09c269af0 parent: 99699:f4c5f3857d4b user: Stefan Krah date: Mon Dec 28 23:12:52 2015 +0100 summary: Merge. files: Lib/test/test_functools.py | 14 ++++++++++++-- Misc/NEWS | 4 ++++ Modules/_functoolsmodule.c | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -1262,14 +1262,24 @@ def test_copy(self): cls = self.__class__ - for f in cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth: + def orig(x, y): + return 3 * x + y + part = self.module.partial(orig, 2) + funcs = (cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth, + self.module.lru_cache(2)(part)) + for f in funcs: with self.subTest(func=f): f_copy = copy.copy(f) self.assertIs(f_copy, f) def test_deepcopy(self): cls = self.__class__ - for f in cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth: + def orig(x, y): + return 3 * x + y + part = self.module.partial(orig, 2) + funcs = (cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth, + self.module.lru_cache(2)(part)) + for f in funcs: with self.subTest(func=f): f_copy = copy.deepcopy(f) self.assertIs(f_copy, f) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -125,6 +125,10 @@ - Issue #25928: Add Decimal.as_integer_ratio(). +- Issue #25447: Copying the lru_cache() wrapper object now always works, + independedly from the type of the wrapped object (by returning the original + object unchanged). + - Issue #25768: Have the functions in compileall return booleans instead of ints and add proper documentation and tests for the return values. diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -1053,6 +1053,20 @@ return PyObject_GetAttrString(self, "__qualname__"); } +static PyObject * +lru_cache_copy(PyObject *self, PyObject *unused) +{ + Py_INCREF(self); + return self; +} + +static PyObject * +lru_cache_deepcopy(PyObject *self, PyObject *unused) +{ + Py_INCREF(self); + return self; +} + static int lru_cache_tp_traverse(lru_cache_object *self, visitproc visit, void *arg) { @@ -1104,6 +1118,8 @@ {"cache_info", (PyCFunction)lru_cache_cache_info, METH_NOARGS}, {"cache_clear", (PyCFunction)lru_cache_cache_clear, METH_NOARGS}, {"__reduce__", (PyCFunction)lru_cache_reduce, METH_NOARGS}, + {"__copy__", (PyCFunction)lru_cache_copy, METH_VARARGS}, + {"__deepcopy__", (PyCFunction)lru_cache_deepcopy, METH_VARARGS}, {NULL} }; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 17:17:33 2015 From: python-checkins at python.org (stefan.krah) Date: Mon, 28 Dec 2015 22:17:33 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Fix_typo=2E?= Message-ID: <20151228221733.8279.11254@psf.io> https://hg.python.org/cpython/rev/c8b582b6c3b3 changeset: 99702:c8b582b6c3b3 user: Stefan Krah date: Mon Dec 28 23:17:05 2015 +0100 summary: Fix typo. files: Misc/NEWS | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -126,7 +126,7 @@ - Issue #25928: Add Decimal.as_integer_ratio(). - Issue #25447: Copying the lru_cache() wrapper object now always works, - independedly from the type of the wrapped object (by returning the original + independently from the type of the wrapped object (by returning the original object unchanged). - Issue #25768: Have the functions in compileall return booleans instead of -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 18:12:00 2015 From: python-checkins at python.org (stefan.krah) Date: Mon, 28 Dec 2015 23:12:00 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325928=3A_Temporar?= =?utf-8?q?ily_disable_some_tests_in_test=5Fstatistics_in_order?= Message-ID: <20151228231200.77245.70239@psf.io> https://hg.python.org/cpython/rev/510ff609cb4f changeset: 99703:510ff609cb4f user: Stefan Krah date: Tue Dec 29 00:11:36 2015 +0100 summary: Issue #25928: Temporarily disable some tests in test_statistics in order to sort out its assumptions about the as_integer_ratio() interface. files: Lib/test/test_statistics.py | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -699,6 +699,7 @@ num, den = statistics._exact_ratio(x) self.assertEqual(x, num/den) + @unittest.skipIf(True, "temporarily disabled: see #25928") def test_decimal(self): D = Decimal _exact_ratio = statistics._exact_ratio @@ -730,6 +731,7 @@ self.assertIs(ratio[1], None) self.assertEqual(type(ratio[0]), type(nan)) + @unittest.skipIf(True, "temporarily disabled: see #25928") def test_decimal_nan(self): NAN = Decimal("NAN") sNAN = Decimal("sNAN") @@ -1258,6 +1260,7 @@ with decimal.localcontext(decimal.BasicContext): self.assertRaises(decimal.InvalidOperation, statistics._sum, data) + @unittest.skipIf(True, "temporarily disabled: see #25928") def test_decimal_snan_raises(self): # Adding sNAN should raise InvalidOperation. sNAN = Decimal('sNAN') -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 20:15:52 2015 From: python-checkins at python.org (stefan.krah) Date: Tue, 29 Dec 2015 01:15:52 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325940=3A_Make_bui?= =?utf-8?q?ldbots_usable_again_until_a_solution_is_found=2E?= Message-ID: <20151229011552.9642.41998@psf.io> https://hg.python.org/cpython/rev/9d0c15425b59 changeset: 99704:9d0c15425b59 user: Stefan Krah date: Tue Dec 29 02:15:35 2015 +0100 summary: Issue #25940: Make buildbots usable again until a solution is found. files: Lib/test/test_ssl.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -1342,6 +1342,7 @@ self.assertRaises(TypeError, bio.write, 1) + at unittest.skipIf(True, "temporarily disabled: see #25940") class NetworkedTests(unittest.TestCase): def test_connect(self): @@ -1711,6 +1712,7 @@ % (count, func.__name__)) return ret + @unittest.skipIf(True, "temporarily disabled: see #25940") def test_handshake(self): with support.transient_internet("svn.python.org"): sock = socket.socket(socket.AF_INET) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 20:18:27 2015 From: python-checkins at python.org (brett.cannon) Date: Tue, 29 Dec 2015 01:18:27 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2324725=3A_Skip_the?= =?utf-8?q?_test=5Fsocket=2EtestFDPassEmpty_on_OS_X=2E?= Message-ID: <20151229011826.105572.99904@psf.io> https://hg.python.org/cpython/rev/b4c6631737b3 changeset: 99705:b4c6631737b3 parent: 99703:510ff609cb4f user: Brett Cannon date: Mon Dec 28 17:17:58 2015 -0800 summary: Issue #24725: Skip the test_socket.testFDPassEmpty on OS X. In OS X 10.11, the test fails consistently due to a platform change since 10.10. Thanks to Jeff Ramnani for the patch. files: Lib/test/test_socket.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -2809,6 +2809,7 @@ nbytes = self.sendmsgToServer([msg]) self.assertEqual(nbytes, len(msg)) + @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #24725") def testFDPassEmpty(self): # Try to pass an empty FD array. Can receive either no array # or an empty array. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 20:18:27 2015 From: python-checkins at python.org (brett.cannon) Date: Tue, 29 Dec 2015 01:18:27 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_Merge?= Message-ID: <20151229011826.70437.67889@psf.io> https://hg.python.org/cpython/rev/2e8f147c03b2 changeset: 99706:2e8f147c03b2 parent: 99705:b4c6631737b3 parent: 99704:9d0c15425b59 user: Brett Cannon date: Mon Dec 28 17:18:21 2015 -0800 summary: Merge files: Lib/test/test_ssl.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -1342,6 +1342,7 @@ self.assertRaises(TypeError, bio.write, 1) + at unittest.skipIf(True, "temporarily disabled: see #25940") class NetworkedTests(unittest.TestCase): def test_connect(self): @@ -1711,6 +1712,7 @@ % (count, func.__name__)) return ret + @unittest.skipIf(True, "temporarily disabled: see #25940") def test_handshake(self): with support.transient_internet("svn.python.org"): sock = socket.socket(socket.AF_INET) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 20:21:48 2015 From: python-checkins at python.org (brett.cannon) Date: Tue, 29 Dec 2015 01:21:48 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Tweak_skipping_message?= Message-ID: <20151229012148.3379.15838@psf.io> https://hg.python.org/cpython/rev/ea06ef0bfd36 changeset: 99707:ea06ef0bfd36 user: Brett Cannon date: Mon Dec 28 17:21:44 2015 -0800 summary: Tweak skipping message files: Lib/test/test_socket.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -2809,7 +2809,7 @@ nbytes = self.sendmsgToServer([msg]) self.assertEqual(nbytes, len(msg)) - @unittest.skipIf(sys.platform == "darwin", "skipping, see issue #24725") + @unittest.skipIf(sys.platform == "darwin", "see issue #24725") def testFDPassEmpty(self): # Try to pass an empty FD array. Can receive either no array # or an empty array. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 20:23:40 2015 From: python-checkins at python.org (brett.cannon) Date: Tue, 29 Dec 2015 01:23:40 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325234=3A_Skip_tes?= =?utf-8?q?t=5Feintr=2Etest=5Fos=5Fopen_under_OS_X=2E?= Message-ID: <20151229012339.77243.86103@psf.io> https://hg.python.org/cpython/rev/7fc1296d1acf changeset: 99708:7fc1296d1acf user: Brett Cannon date: Mon Dec 28 17:23:35 2015 -0800 summary: Issue #25234: Skip test_eintr.test_os_open under OS X. Test inconsistently hangs. files: Lib/test/eintrdata/eintr_tester.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Lib/test/eintrdata/eintr_tester.py b/Lib/test/eintrdata/eintr_tester.py --- a/Lib/test/eintrdata/eintr_tester.py +++ b/Lib/test/eintrdata/eintr_tester.py @@ -345,6 +345,7 @@ fd = os.open(path, os.O_WRONLY) os.close(fd) + @unittest.skipIf(sys.platform == "darwin", "hangs under OS X; see issue #25234") def test_os_open(self): self._test_open("fd = os.open(path, os.O_RDONLY)\nos.close(fd)", self.os_open) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 20:28:24 2015 From: python-checkins at python.org (brett.cannon) Date: Tue, 29 Dec 2015 01:28:24 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325930=3A_Document?= =?utf-8?q?_that_os=2Eunlink_and_os=2Eremove_are_*semantically*?= Message-ID: <20151229012823.8281.66852@psf.io> https://hg.python.org/cpython/rev/81c7b26f5b4e changeset: 99709:81c7b26f5b4e user: Brett Cannon date: Mon Dec 28 17:28:19 2015 -0800 summary: Issue #25930: Document that os.unlink and os.remove are *semantically* identical. Saying that the functions were identical confused some users who were upset when the functions were no longer simply the same function under different names. Thanks to Anthony Sottile for the bug report and Swati Jaiswal for the initial patch. files: Doc/library/os.rst | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1789,7 +1789,7 @@ be raised; on Unix, the directory entry is removed but the storage allocated to the file is not made available until the original file is no longer in use. - This function is identical to :func:`unlink`. + This function is semantically identical to :func:`unlink`. .. versionadded:: 3.3 The *dir_fd* argument. @@ -2452,10 +2452,10 @@ .. function:: unlink(path, *, dir_fd=None) - Remove (delete) the file *path*. This function is identical to - :func:`remove`; the ``unlink`` name is its traditional Unix - name. Please see the documentation for :func:`remove` for - further information. + Remove (delete) the file *path*. This function is semantically + identical to :func:`remove`; the ``unlink`` name is its + traditional Unix name. Please see the documentation for + :func:`remove` for further information. .. versionadded:: 3.3 The *dir_fd* parameter. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 20:31:01 2015 From: python-checkins at python.org (brett.cannon) Date: Tue, 29 Dec 2015 01:31:01 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_for_backport__of_fix_for_issue_=2325930?= Message-ID: <20151229013101.21392.40758@psf.io> https://hg.python.org/cpython/rev/e082519bc2c8 changeset: 99711:e082519bc2c8 parent: 99709:81c7b26f5b4e parent: 99710:9f13322eba8e user: Brett Cannon date: Mon Dec 28 17:30:57 2015 -0800 summary: Merge for backport of fix for issue #25930 files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 20:31:01 2015 From: python-checkins at python.org (brett.cannon) Date: Tue, 29 Dec 2015 01:31:01 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Backport_of_fi?= =?utf-8?q?x_for_issue_=2325930?= Message-ID: <20151229013101.3365.92237@psf.io> https://hg.python.org/cpython/rev/9f13322eba8e changeset: 99710:9f13322eba8e branch: 3.5 parent: 99697:33b428ef34b9 user: Brett Cannon date: Mon Dec 28 17:30:32 2015 -0800 summary: Backport of fix for issue #25930 files: Doc/library/os.rst | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1789,7 +1789,7 @@ be raised; on Unix, the directory entry is removed but the storage allocated to the file is not made available until the original file is no longer in use. - This function is identical to :func:`unlink`. + This function is semantically identical to :func:`unlink`. .. versionadded:: 3.3 The *dir_fd* argument. @@ -2452,10 +2452,10 @@ .. function:: unlink(path, *, dir_fd=None) - Remove (delete) the file *path*. This function is identical to - :func:`remove`; the ``unlink`` name is its traditional Unix - name. Please see the documentation for :func:`remove` for - further information. + Remove (delete) the file *path*. This function is semantically + identical to :func:`remove`; the ``unlink`` name is its + traditional Unix name. Please see the documentation for + :func:`remove` for further information. .. versionadded:: 3.3 The *dir_fd* parameter. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Dec 28 20:55:34 2015 From: python-checkins at python.org (brett.cannon) Date: Tue, 29 Dec 2015 01:55:34 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325802=3A_Deprecat?= =?utf-8?q?e_load=5Fmodule=28=29_on_importlib=2Emachinery=2ESourceFileLoad?= =?utf-8?q?er?= Message-ID: <20151229015533.105568.45077@psf.io> https://hg.python.org/cpython/rev/ab0e60a36368 changeset: 99712:ab0e60a36368 user: Brett Cannon date: Mon Dec 28 17:55:27 2015 -0800 summary: Issue #25802: Deprecate load_module() on importlib.machinery.SourceFileLoader and SourcelessFileLoader. They were the only remaining implementations of load_module() not documented as deprecated. files: Doc/library/importlib.rst | 8 + Doc/whatsnew/3.6.rst | 7 +- Lib/importlib/_bootstrap_external.py | 1 + Misc/NEWS | 3 + Python/importlib_external.h | 3041 +++++++------ 5 files changed, 1539 insertions(+), 1521 deletions(-) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -921,6 +921,10 @@ Concrete implementation of :meth:`importlib.abc.Loader.load_module` where specifying the name of the module to load is optional. + .. deprecated:: 3.6 + + Use :meth:`importlib.abc.Loader.exec_module` instead. + .. class:: SourcelessFileLoader(fullname, path) @@ -960,6 +964,10 @@ Concrete implementation of :meth:`importlib.abc.Loader.load_module` where specifying the name of the module to load is optional. + .. deprecated:: 3.6 + + Use :meth:`importlib.abc.Loader.exec_module` instead. + .. class:: ExtensionFileLoader(fullname, path) diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -189,7 +189,12 @@ Deprecated Python modules, functions and methods ------------------------------------------------ -* None yet. +* :meth:`importlib.machinery.SourceFileLoader` and + :meth:`importlib.machinery.SourcelessFileLoader` are now deprecated. They + were the only remaining implementations of + :meth:`importlib.abc.Loader.load_module` in :mod:`importlib` that had not + been deprecated in previous versions of Python in favour of + :meth:`importlib.abc.Loader.exec_module`. Deprecated functions and types of the C API diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -655,6 +655,7 @@ _bootstrap._call_with_frames_removed(exec, code, module.__dict__) def load_module(self, fullname): + """This module is deprecated.""" return _bootstrap._load_module_shim(self, fullname) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -123,6 +123,9 @@ Library ------- +- Issue #25802: Document as deprecated the remaining implementations of + importlib.abc.Loader.load_module(). + - Issue #25928: Add Decimal.as_integer_ratio(). - Issue #25447: Copying the lru_cache() wrapper object now always works, diff --git a/Python/importlib_external.h b/Python/importlib_external.h --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -1039,581 +1039,304 @@ 111,100,117,108,101,99,2,0,0,0,0,0,0,0,2,0, 0,0,3,0,0,0,67,0,0,0,115,16,0,0,0,116, 0,0,106,1,0,124,0,0,124,1,0,131,2,0,83,41, - 1,78,41,2,114,114,0,0,0,218,17,95,108,111,97,100, - 95,109,111,100,117,108,101,95,115,104,105,109,41,2,114,100, - 0,0,0,114,119,0,0,0,114,4,0,0,0,114,4,0, - 0,0,114,5,0,0,0,218,11,108,111,97,100,95,109,111, - 100,117,108,101,145,2,0,0,115,2,0,0,0,0,1,122, - 25,95,76,111,97,100,101,114,66,97,115,105,99,115,46,108, - 111,97,100,95,109,111,100,117,108,101,78,41,8,114,105,0, - 0,0,114,104,0,0,0,114,106,0,0,0,114,107,0,0, - 0,114,153,0,0,0,114,180,0,0,0,114,185,0,0,0, - 114,187,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 4,0,0,0,114,5,0,0,0,114,178,0,0,0,121,2, - 0,0,115,10,0,0,0,12,3,6,2,12,8,12,3,12, - 8,114,178,0,0,0,99,0,0,0,0,0,0,0,0,0, - 0,0,0,4,0,0,0,64,0,0,0,115,106,0,0,0, - 101,0,0,90,1,0,100,0,0,90,2,0,100,1,0,100, - 2,0,132,0,0,90,3,0,100,3,0,100,4,0,132,0, - 0,90,4,0,100,5,0,100,6,0,132,0,0,90,5,0, - 100,7,0,100,8,0,132,0,0,90,6,0,100,9,0,100, - 10,0,132,0,0,90,7,0,100,11,0,100,18,0,100,13, - 0,100,14,0,132,0,1,90,8,0,100,15,0,100,16,0, - 132,0,0,90,9,0,100,17,0,83,41,19,218,12,83,111, - 117,114,99,101,76,111,97,100,101,114,99,2,0,0,0,0, - 0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,115, - 10,0,0,0,116,0,0,130,1,0,100,1,0,83,41,2, - 122,178,79,112,116,105,111,110,97,108,32,109,101,116,104,111, - 100,32,116,104,97,116,32,114,101,116,117,114,110,115,32,116, - 104,101,32,109,111,100,105,102,105,99,97,116,105,111,110,32, - 116,105,109,101,32,40,97,110,32,105,110,116,41,32,102,111, - 114,32,116,104,101,10,32,32,32,32,32,32,32,32,115,112, - 101,99,105,102,105,101,100,32,112,97,116,104,44,32,119,104, - 101,114,101,32,112,97,116,104,32,105,115,32,97,32,115,116, - 114,46,10,10,32,32,32,32,32,32,32,32,82,97,105,115, + 1,122,26,84,104,105,115,32,109,111,100,117,108,101,32,105, + 115,32,100,101,112,114,101,99,97,116,101,100,46,41,2,114, + 114,0,0,0,218,17,95,108,111,97,100,95,109,111,100,117, + 108,101,95,115,104,105,109,41,2,114,100,0,0,0,114,119, + 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0, + 0,0,218,11,108,111,97,100,95,109,111,100,117,108,101,145, + 2,0,0,115,2,0,0,0,0,2,122,25,95,76,111,97, + 100,101,114,66,97,115,105,99,115,46,108,111,97,100,95,109, + 111,100,117,108,101,78,41,8,114,105,0,0,0,114,104,0, + 0,0,114,106,0,0,0,114,107,0,0,0,114,153,0,0, + 0,114,180,0,0,0,114,185,0,0,0,114,187,0,0,0, + 114,4,0,0,0,114,4,0,0,0,114,4,0,0,0,114, + 5,0,0,0,114,178,0,0,0,121,2,0,0,115,10,0, + 0,0,12,3,6,2,12,8,12,3,12,8,114,178,0,0, + 0,99,0,0,0,0,0,0,0,0,0,0,0,0,4,0, + 0,0,64,0,0,0,115,106,0,0,0,101,0,0,90,1, + 0,100,0,0,90,2,0,100,1,0,100,2,0,132,0,0, + 90,3,0,100,3,0,100,4,0,132,0,0,90,4,0,100, + 5,0,100,6,0,132,0,0,90,5,0,100,7,0,100,8, + 0,132,0,0,90,6,0,100,9,0,100,10,0,132,0,0, + 90,7,0,100,11,0,100,18,0,100,13,0,100,14,0,132, + 0,1,90,8,0,100,15,0,100,16,0,132,0,0,90,9, + 0,100,17,0,83,41,19,218,12,83,111,117,114,99,101,76, + 111,97,100,101,114,99,2,0,0,0,0,0,0,0,2,0, + 0,0,1,0,0,0,67,0,0,0,115,10,0,0,0,116, + 0,0,130,1,0,100,1,0,83,41,2,122,178,79,112,116, + 105,111,110,97,108,32,109,101,116,104,111,100,32,116,104,97, + 116,32,114,101,116,117,114,110,115,32,116,104,101,32,109,111, + 100,105,102,105,99,97,116,105,111,110,32,116,105,109,101,32, + 40,97,110,32,105,110,116,41,32,102,111,114,32,116,104,101, + 10,32,32,32,32,32,32,32,32,115,112,101,99,105,102,105, + 101,100,32,112,97,116,104,44,32,119,104,101,114,101,32,112, + 97,116,104,32,105,115,32,97,32,115,116,114,46,10,10,32, + 32,32,32,32,32,32,32,82,97,105,115,101,115,32,73,79, + 69,114,114,111,114,32,119,104,101,110,32,116,104,101,32,112, + 97,116,104,32,99,97,110,110,111,116,32,98,101,32,104,97, + 110,100,108,101,100,46,10,32,32,32,32,32,32,32,32,78, + 41,1,218,7,73,79,69,114,114,111,114,41,2,114,100,0, + 0,0,114,35,0,0,0,114,4,0,0,0,114,4,0,0, + 0,114,5,0,0,0,218,10,112,97,116,104,95,109,116,105, + 109,101,152,2,0,0,115,2,0,0,0,0,6,122,23,83, + 111,117,114,99,101,76,111,97,100,101,114,46,112,97,116,104, + 95,109,116,105,109,101,99,2,0,0,0,0,0,0,0,2, + 0,0,0,3,0,0,0,67,0,0,0,115,19,0,0,0, + 100,1,0,124,0,0,106,0,0,124,1,0,131,1,0,105, + 1,0,83,41,2,97,170,1,0,0,79,112,116,105,111,110, + 97,108,32,109,101,116,104,111,100,32,114,101,116,117,114,110, + 105,110,103,32,97,32,109,101,116,97,100,97,116,97,32,100, + 105,99,116,32,102,111,114,32,116,104,101,32,115,112,101,99, + 105,102,105,101,100,32,112,97,116,104,10,32,32,32,32,32, + 32,32,32,116,111,32,98,121,32,116,104,101,32,112,97,116, + 104,32,40,115,116,114,41,46,10,32,32,32,32,32,32,32, + 32,80,111,115,115,105,98,108,101,32,107,101,121,115,58,10, + 32,32,32,32,32,32,32,32,45,32,39,109,116,105,109,101, + 39,32,40,109,97,110,100,97,116,111,114,121,41,32,105,115, + 32,116,104,101,32,110,117,109,101,114,105,99,32,116,105,109, + 101,115,116,97,109,112,32,111,102,32,108,97,115,116,32,115, + 111,117,114,99,101,10,32,32,32,32,32,32,32,32,32,32, + 99,111,100,101,32,109,111,100,105,102,105,99,97,116,105,111, + 110,59,10,32,32,32,32,32,32,32,32,45,32,39,115,105, + 122,101,39,32,40,111,112,116,105,111,110,97,108,41,32,105, + 115,32,116,104,101,32,115,105,122,101,32,105,110,32,98,121, + 116,101,115,32,111,102,32,116,104,101,32,115,111,117,114,99, + 101,32,99,111,100,101,46,10,10,32,32,32,32,32,32,32, + 32,73,109,112,108,101,109,101,110,116,105,110,103,32,116,104, + 105,115,32,109,101,116,104,111,100,32,97,108,108,111,119,115, + 32,116,104,101,32,108,111,97,100,101,114,32,116,111,32,114, + 101,97,100,32,98,121,116,101,99,111,100,101,32,102,105,108, + 101,115,46,10,32,32,32,32,32,32,32,32,82,97,105,115, 101,115,32,73,79,69,114,114,111,114,32,119,104,101,110,32, 116,104,101,32,112,97,116,104,32,99,97,110,110,111,116,32, 98,101,32,104,97,110,100,108,101,100,46,10,32,32,32,32, - 32,32,32,32,78,41,1,218,7,73,79,69,114,114,111,114, + 32,32,32,32,114,126,0,0,0,41,1,114,190,0,0,0, 41,2,114,100,0,0,0,114,35,0,0,0,114,4,0,0, 0,114,4,0,0,0,114,5,0,0,0,218,10,112,97,116, - 104,95,109,116,105,109,101,151,2,0,0,115,2,0,0,0, - 0,6,122,23,83,111,117,114,99,101,76,111,97,100,101,114, - 46,112,97,116,104,95,109,116,105,109,101,99,2,0,0,0, - 0,0,0,0,2,0,0,0,3,0,0,0,67,0,0,0, - 115,19,0,0,0,100,1,0,124,0,0,106,0,0,124,1, - 0,131,1,0,105,1,0,83,41,2,97,170,1,0,0,79, - 112,116,105,111,110,97,108,32,109,101,116,104,111,100,32,114, - 101,116,117,114,110,105,110,103,32,97,32,109,101,116,97,100, - 97,116,97,32,100,105,99,116,32,102,111,114,32,116,104,101, - 32,115,112,101,99,105,102,105,101,100,32,112,97,116,104,10, - 32,32,32,32,32,32,32,32,116,111,32,98,121,32,116,104, - 101,32,112,97,116,104,32,40,115,116,114,41,46,10,32,32, - 32,32,32,32,32,32,80,111,115,115,105,98,108,101,32,107, - 101,121,115,58,10,32,32,32,32,32,32,32,32,45,32,39, - 109,116,105,109,101,39,32,40,109,97,110,100,97,116,111,114, - 121,41,32,105,115,32,116,104,101,32,110,117,109,101,114,105, - 99,32,116,105,109,101,115,116,97,109,112,32,111,102,32,108, - 97,115,116,32,115,111,117,114,99,101,10,32,32,32,32,32, - 32,32,32,32,32,99,111,100,101,32,109,111,100,105,102,105, - 99,97,116,105,111,110,59,10,32,32,32,32,32,32,32,32, - 45,32,39,115,105,122,101,39,32,40,111,112,116,105,111,110, - 97,108,41,32,105,115,32,116,104,101,32,115,105,122,101,32, - 105,110,32,98,121,116,101,115,32,111,102,32,116,104,101,32, - 115,111,117,114,99,101,32,99,111,100,101,46,10,10,32,32, - 32,32,32,32,32,32,73,109,112,108,101,109,101,110,116,105, - 110,103,32,116,104,105,115,32,109,101,116,104,111,100,32,97, - 108,108,111,119,115,32,116,104,101,32,108,111,97,100,101,114, - 32,116,111,32,114,101,97,100,32,98,121,116,101,99,111,100, - 101,32,102,105,108,101,115,46,10,32,32,32,32,32,32,32, - 32,82,97,105,115,101,115,32,73,79,69,114,114,111,114,32, - 119,104,101,110,32,116,104,101,32,112,97,116,104,32,99,97, - 110,110,111,116,32,98,101,32,104,97,110,100,108,101,100,46, - 10,32,32,32,32,32,32,32,32,114,126,0,0,0,41,1, - 114,190,0,0,0,41,2,114,100,0,0,0,114,35,0,0, - 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 218,10,112,97,116,104,95,115,116,97,116,115,159,2,0,0, - 115,2,0,0,0,0,11,122,23,83,111,117,114,99,101,76, - 111,97,100,101,114,46,112,97,116,104,95,115,116,97,116,115, - 99,4,0,0,0,0,0,0,0,4,0,0,0,3,0,0, - 0,67,0,0,0,115,16,0,0,0,124,0,0,106,0,0, - 124,2,0,124,3,0,131,2,0,83,41,1,122,228,79,112, - 116,105,111,110,97,108,32,109,101,116,104,111,100,32,119,104, - 105,99,104,32,119,114,105,116,101,115,32,100,97,116,97,32, - 40,98,121,116,101,115,41,32,116,111,32,97,32,102,105,108, - 101,32,112,97,116,104,32,40,97,32,115,116,114,41,46,10, - 10,32,32,32,32,32,32,32,32,73,109,112,108,101,109,101, - 110,116,105,110,103,32,116,104,105,115,32,109,101,116,104,111, - 100,32,97,108,108,111,119,115,32,102,111,114,32,116,104,101, - 32,119,114,105,116,105,110,103,32,111,102,32,98,121,116,101, - 99,111,100,101,32,102,105,108,101,115,46,10,10,32,32,32, - 32,32,32,32,32,84,104,101,32,115,111,117,114,99,101,32, - 112,97,116,104,32,105,115,32,110,101,101,100,101,100,32,105, - 110,32,111,114,100,101,114,32,116,111,32,99,111,114,114,101, - 99,116,108,121,32,116,114,97,110,115,102,101,114,32,112,101, - 114,109,105,115,115,105,111,110,115,10,32,32,32,32,32,32, - 32,32,41,1,218,8,115,101,116,95,100,97,116,97,41,4, - 114,100,0,0,0,114,90,0,0,0,90,10,99,97,99,104, - 101,95,112,97,116,104,114,53,0,0,0,114,4,0,0,0, - 114,4,0,0,0,114,5,0,0,0,218,15,95,99,97,99, - 104,101,95,98,121,116,101,99,111,100,101,172,2,0,0,115, - 2,0,0,0,0,8,122,28,83,111,117,114,99,101,76,111, - 97,100,101,114,46,95,99,97,99,104,101,95,98,121,116,101, - 99,111,100,101,99,3,0,0,0,0,0,0,0,3,0,0, - 0,1,0,0,0,67,0,0,0,115,4,0,0,0,100,1, - 0,83,41,2,122,150,79,112,116,105,111,110,97,108,32,109, - 101,116,104,111,100,32,119,104,105,99,104,32,119,114,105,116, - 101,115,32,100,97,116,97,32,40,98,121,116,101,115,41,32, - 116,111,32,97,32,102,105,108,101,32,112,97,116,104,32,40, - 97,32,115,116,114,41,46,10,10,32,32,32,32,32,32,32, - 32,73,109,112,108,101,109,101,110,116,105,110,103,32,116,104, - 105,115,32,109,101,116,104,111,100,32,97,108,108,111,119,115, - 32,102,111,114,32,116,104,101,32,119,114,105,116,105,110,103, - 32,111,102,32,98,121,116,101,99,111,100,101,32,102,105,108, - 101,115,46,10,32,32,32,32,32,32,32,32,78,114,4,0, - 0,0,41,3,114,100,0,0,0,114,35,0,0,0,114,53, - 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0, - 0,0,114,192,0,0,0,182,2,0,0,115,0,0,0,0, - 122,21,83,111,117,114,99,101,76,111,97,100,101,114,46,115, - 101,116,95,100,97,116,97,99,2,0,0,0,0,0,0,0, - 5,0,0,0,16,0,0,0,67,0,0,0,115,105,0,0, - 0,124,0,0,106,0,0,124,1,0,131,1,0,125,2,0, - 121,19,0,124,0,0,106,1,0,124,2,0,131,1,0,125, - 3,0,87,110,58,0,4,116,2,0,107,10,0,114,94,0, - 1,125,4,0,1,122,26,0,116,3,0,100,1,0,100,2, - 0,124,1,0,131,1,1,124,4,0,130,2,0,87,89,100, - 3,0,100,3,0,125,4,0,126,4,0,88,110,1,0,88, - 116,4,0,124,3,0,131,1,0,83,41,4,122,52,67,111, - 110,99,114,101,116,101,32,105,109,112,108,101,109,101,110,116, - 97,116,105,111,110,32,111,102,32,73,110,115,112,101,99,116, - 76,111,97,100,101,114,46,103,101,116,95,115,111,117,114,99, - 101,46,122,39,115,111,117,114,99,101,32,110,111,116,32,97, - 118,97,105,108,97,98,108,101,32,116,104,114,111,117,103,104, - 32,103,101,116,95,100,97,116,97,40,41,114,98,0,0,0, - 78,41,5,114,151,0,0,0,218,8,103,101,116,95,100,97, - 116,97,114,40,0,0,0,114,99,0,0,0,114,149,0,0, - 0,41,5,114,100,0,0,0,114,119,0,0,0,114,35,0, - 0,0,114,147,0,0,0,218,3,101,120,99,114,4,0,0, - 0,114,4,0,0,0,114,5,0,0,0,218,10,103,101,116, - 95,115,111,117,114,99,101,189,2,0,0,115,14,0,0,0, - 0,2,15,1,3,1,19,1,18,1,9,1,31,1,122,23, - 83,111,117,114,99,101,76,111,97,100,101,114,46,103,101,116, - 95,115,111,117,114,99,101,218,9,95,111,112,116,105,109,105, - 122,101,114,29,0,0,0,99,3,0,0,0,1,0,0,0, - 4,0,0,0,9,0,0,0,67,0,0,0,115,34,0,0, - 0,116,0,0,106,1,0,116,2,0,124,1,0,124,2,0, - 100,1,0,100,2,0,100,3,0,100,4,0,124,3,0,131, - 4,2,83,41,5,122,130,82,101,116,117,114,110,32,116,104, - 101,32,99,111,100,101,32,111,98,106,101,99,116,32,99,111, - 109,112,105,108,101,100,32,102,114,111,109,32,115,111,117,114, - 99,101,46,10,10,32,32,32,32,32,32,32,32,84,104,101, - 32,39,100,97,116,97,39,32,97,114,103,117,109,101,110,116, - 32,99,97,110,32,98,101,32,97,110,121,32,111,98,106,101, - 99,116,32,116,121,112,101,32,116,104,97,116,32,99,111,109, - 112,105,108,101,40,41,32,115,117,112,112,111,114,116,115,46, - 10,32,32,32,32,32,32,32,32,114,183,0,0,0,218,12, - 100,111,110,116,95,105,110,104,101,114,105,116,84,114,68,0, - 0,0,41,3,114,114,0,0,0,114,182,0,0,0,218,7, - 99,111,109,112,105,108,101,41,4,114,100,0,0,0,114,53, - 0,0,0,114,35,0,0,0,114,197,0,0,0,114,4,0, - 0,0,114,4,0,0,0,114,5,0,0,0,218,14,115,111, - 117,114,99,101,95,116,111,95,99,111,100,101,199,2,0,0, - 115,4,0,0,0,0,5,21,1,122,27,83,111,117,114,99, - 101,76,111,97,100,101,114,46,115,111,117,114,99,101,95,116, - 111,95,99,111,100,101,99,2,0,0,0,0,0,0,0,10, - 0,0,0,43,0,0,0,67,0,0,0,115,183,1,0,0, - 124,0,0,106,0,0,124,1,0,131,1,0,125,2,0,100, - 1,0,125,3,0,121,16,0,116,1,0,124,2,0,131,1, - 0,125,4,0,87,110,24,0,4,116,2,0,107,10,0,114, - 63,0,1,1,1,100,1,0,125,4,0,89,110,205,0,88, - 121,19,0,124,0,0,106,3,0,124,2,0,131,1,0,125, - 5,0,87,110,18,0,4,116,4,0,107,10,0,114,103,0, - 1,1,1,89,110,165,0,88,116,5,0,124,5,0,100,2, - 0,25,131,1,0,125,3,0,121,19,0,124,0,0,106,6, - 0,124,4,0,131,1,0,125,6,0,87,110,18,0,4,116, - 7,0,107,10,0,114,159,0,1,1,1,89,110,109,0,88, - 121,34,0,116,8,0,124,6,0,100,3,0,124,5,0,100, - 4,0,124,1,0,100,5,0,124,4,0,131,1,3,125,7, - 0,87,110,24,0,4,116,9,0,116,10,0,102,2,0,107, - 10,0,114,220,0,1,1,1,89,110,48,0,88,116,11,0, - 106,12,0,100,6,0,124,4,0,124,2,0,131,3,0,1, - 116,13,0,124,7,0,100,4,0,124,1,0,100,7,0,124, - 4,0,100,8,0,124,2,0,131,1,3,83,124,0,0,106, - 6,0,124,2,0,131,1,0,125,8,0,124,0,0,106,14, - 0,124,8,0,124,2,0,131,2,0,125,9,0,116,11,0, - 106,12,0,100,9,0,124,2,0,131,2,0,1,116,15,0, - 106,16,0,12,114,179,1,124,4,0,100,1,0,107,9,0, - 114,179,1,124,3,0,100,1,0,107,9,0,114,179,1,116, - 17,0,124,9,0,124,3,0,116,18,0,124,8,0,131,1, - 0,131,3,0,125,6,0,121,39,0,124,0,0,106,19,0, - 124,2,0,124,4,0,124,6,0,131,3,0,1,116,11,0, - 106,12,0,100,10,0,124,4,0,131,2,0,1,87,110,18, - 0,4,116,2,0,107,10,0,114,178,1,1,1,1,89,110, - 1,0,88,124,9,0,83,41,11,122,190,67,111,110,99,114, - 101,116,101,32,105,109,112,108,101,109,101,110,116,97,116,105, - 111,110,32,111,102,32,73,110,115,112,101,99,116,76,111,97, - 100,101,114,46,103,101,116,95,99,111,100,101,46,10,10,32, - 32,32,32,32,32,32,32,82,101,97,100,105,110,103,32,111, - 102,32,98,121,116,101,99,111,100,101,32,114,101,113,117,105, - 114,101,115,32,112,97,116,104,95,115,116,97,116,115,32,116, - 111,32,98,101,32,105,109,112,108,101,109,101,110,116,101,100, - 46,32,84,111,32,119,114,105,116,101,10,32,32,32,32,32, - 32,32,32,98,121,116,101,99,111,100,101,44,32,115,101,116, - 95,100,97,116,97,32,109,117,115,116,32,97,108,115,111,32, - 98,101,32,105,109,112,108,101,109,101,110,116,101,100,46,10, - 10,32,32,32,32,32,32,32,32,78,114,126,0,0,0,114, - 132,0,0,0,114,98,0,0,0,114,35,0,0,0,122,13, - 123,125,32,109,97,116,99,104,101,115,32,123,125,114,89,0, - 0,0,114,90,0,0,0,122,19,99,111,100,101,32,111,98, - 106,101,99,116,32,102,114,111,109,32,123,125,122,10,119,114, - 111,116,101,32,123,33,114,125,41,20,114,151,0,0,0,114, - 79,0,0,0,114,66,0,0,0,114,191,0,0,0,114,189, - 0,0,0,114,14,0,0,0,114,194,0,0,0,114,40,0, - 0,0,114,135,0,0,0,114,99,0,0,0,114,130,0,0, - 0,114,114,0,0,0,114,129,0,0,0,114,141,0,0,0, - 114,200,0,0,0,114,7,0,0,0,218,19,100,111,110,116, - 95,119,114,105,116,101,95,98,121,116,101,99,111,100,101,114, - 144,0,0,0,114,31,0,0,0,114,193,0,0,0,41,10, - 114,100,0,0,0,114,119,0,0,0,114,90,0,0,0,114, - 133,0,0,0,114,89,0,0,0,218,2,115,116,114,53,0, - 0,0,218,10,98,121,116,101,115,95,100,97,116,97,114,147, - 0,0,0,90,11,99,111,100,101,95,111,98,106,101,99,116, - 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 181,0,0,0,207,2,0,0,115,78,0,0,0,0,7,15, - 1,6,1,3,1,16,1,13,1,11,2,3,1,19,1,13, - 1,5,2,16,1,3,1,19,1,13,1,5,2,3,1,9, - 1,12,1,13,1,19,1,5,2,12,1,7,1,15,1,6, - 1,7,1,15,1,18,1,16,1,22,1,12,1,9,1,15, - 1,3,1,19,1,20,1,13,1,5,1,122,21,83,111,117, - 114,99,101,76,111,97,100,101,114,46,103,101,116,95,99,111, - 100,101,78,114,87,0,0,0,41,10,114,105,0,0,0,114, - 104,0,0,0,114,106,0,0,0,114,190,0,0,0,114,191, - 0,0,0,114,193,0,0,0,114,192,0,0,0,114,196,0, - 0,0,114,200,0,0,0,114,181,0,0,0,114,4,0,0, - 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,188,0,0,0,149,2,0,0,115,14,0,0,0,12,2, - 12,8,12,13,12,10,12,7,12,10,18,8,114,188,0,0, - 0,99,0,0,0,0,0,0,0,0,0,0,0,0,4,0, - 0,0,0,0,0,0,115,112,0,0,0,101,0,0,90,1, - 0,100,0,0,90,2,0,100,1,0,90,3,0,100,2,0, - 100,3,0,132,0,0,90,4,0,100,4,0,100,5,0,132, - 0,0,90,5,0,100,6,0,100,7,0,132,0,0,90,6, - 0,101,7,0,135,0,0,102,1,0,100,8,0,100,9,0, - 134,0,0,131,1,0,90,8,0,101,7,0,100,10,0,100, - 11,0,132,0,0,131,1,0,90,9,0,100,12,0,100,13, - 0,132,0,0,90,10,0,135,0,0,83,41,14,218,10,70, - 105,108,101,76,111,97,100,101,114,122,103,66,97,115,101,32, - 102,105,108,101,32,108,111,97,100,101,114,32,99,108,97,115, - 115,32,119,104,105,99,104,32,105,109,112,108,101,109,101,110, - 116,115,32,116,104,101,32,108,111,97,100,101,114,32,112,114, - 111,116,111,99,111,108,32,109,101,116,104,111,100,115,32,116, - 104,97,116,10,32,32,32,32,114,101,113,117,105,114,101,32, - 102,105,108,101,32,115,121,115,116,101,109,32,117,115,97,103, - 101,46,99,3,0,0,0,0,0,0,0,3,0,0,0,2, - 0,0,0,67,0,0,0,115,22,0,0,0,124,1,0,124, - 0,0,95,0,0,124,2,0,124,0,0,95,1,0,100,1, - 0,83,41,2,122,75,67,97,99,104,101,32,116,104,101,32, - 109,111,100,117,108,101,32,110,97,109,101,32,97,110,100,32, - 116,104,101,32,112,97,116,104,32,116,111,32,116,104,101,32, - 102,105,108,101,32,102,111,117,110,100,32,98,121,32,116,104, - 101,10,32,32,32,32,32,32,32,32,102,105,110,100,101,114, - 46,78,41,2,114,98,0,0,0,114,35,0,0,0,41,3, - 114,100,0,0,0,114,119,0,0,0,114,35,0,0,0,114, - 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,179, - 0,0,0,8,3,0,0,115,4,0,0,0,0,3,9,1, - 122,19,70,105,108,101,76,111,97,100,101,114,46,95,95,105, - 110,105,116,95,95,99,2,0,0,0,0,0,0,0,2,0, - 0,0,2,0,0,0,67,0,0,0,115,34,0,0,0,124, - 0,0,106,0,0,124,1,0,106,0,0,107,2,0,111,33, - 0,124,0,0,106,1,0,124,1,0,106,1,0,107,2,0, - 83,41,1,78,41,2,218,9,95,95,99,108,97,115,115,95, - 95,114,111,0,0,0,41,2,114,100,0,0,0,218,5,111, - 116,104,101,114,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,218,6,95,95,101,113,95,95,14,3,0,0,115, - 4,0,0,0,0,1,18,1,122,17,70,105,108,101,76,111, - 97,100,101,114,46,95,95,101,113,95,95,99,1,0,0,0, - 0,0,0,0,1,0,0,0,3,0,0,0,67,0,0,0, - 115,26,0,0,0,116,0,0,124,0,0,106,1,0,131,1, - 0,116,0,0,124,0,0,106,2,0,131,1,0,65,83,41, - 1,78,41,3,218,4,104,97,115,104,114,98,0,0,0,114, - 35,0,0,0,41,1,114,100,0,0,0,114,4,0,0,0, - 114,4,0,0,0,114,5,0,0,0,218,8,95,95,104,97, - 115,104,95,95,18,3,0,0,115,2,0,0,0,0,1,122, - 19,70,105,108,101,76,111,97,100,101,114,46,95,95,104,97, - 115,104,95,95,99,2,0,0,0,0,0,0,0,2,0,0, - 0,3,0,0,0,3,0,0,0,115,22,0,0,0,116,0, - 0,116,1,0,124,0,0,131,2,0,106,2,0,124,1,0, - 131,1,0,83,41,1,122,100,76,111,97,100,32,97,32,109, - 111,100,117,108,101,32,102,114,111,109,32,97,32,102,105,108, - 101,46,10,10,32,32,32,32,32,32,32,32,84,104,105,115, - 32,109,101,116,104,111,100,32,105,115,32,100,101,112,114,101, - 99,97,116,101,100,46,32,32,85,115,101,32,101,120,101,99, - 95,109,111,100,117,108,101,40,41,32,105,110,115,116,101,97, - 100,46,10,10,32,32,32,32,32,32,32,32,41,3,218,5, - 115,117,112,101,114,114,204,0,0,0,114,187,0,0,0,41, - 2,114,100,0,0,0,114,119,0,0,0,41,1,114,205,0, - 0,0,114,4,0,0,0,114,5,0,0,0,114,187,0,0, - 0,21,3,0,0,115,2,0,0,0,0,10,122,22,70,105, - 108,101,76,111,97,100,101,114,46,108,111,97,100,95,109,111, - 100,117,108,101,99,2,0,0,0,0,0,0,0,2,0,0, - 0,1,0,0,0,67,0,0,0,115,7,0,0,0,124,0, - 0,106,0,0,83,41,1,122,58,82,101,116,117,114,110,32, - 116,104,101,32,112,97,116,104,32,116,111,32,116,104,101,32, - 115,111,117,114,99,101,32,102,105,108,101,32,97,115,32,102, - 111,117,110,100,32,98,121,32,116,104,101,32,102,105,110,100, - 101,114,46,41,1,114,35,0,0,0,41,2,114,100,0,0, - 0,114,119,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,151,0,0,0,33,3,0,0,115,2, - 0,0,0,0,3,122,23,70,105,108,101,76,111,97,100,101, - 114,46,103,101,116,95,102,105,108,101,110,97,109,101,99,2, - 0,0,0,0,0,0,0,3,0,0,0,9,0,0,0,67, - 0,0,0,115,42,0,0,0,116,0,0,106,1,0,124,1, - 0,100,1,0,131,2,0,143,17,0,125,2,0,124,2,0, - 106,2,0,131,0,0,83,87,100,2,0,81,82,88,100,2, - 0,83,41,3,122,39,82,101,116,117,114,110,32,116,104,101, - 32,100,97,116,97,32,102,114,111,109,32,112,97,116,104,32, - 97,115,32,114,97,119,32,98,121,116,101,115,46,218,1,114, - 78,41,3,114,49,0,0,0,114,50,0,0,0,90,4,114, - 101,97,100,41,3,114,100,0,0,0,114,35,0,0,0,114, - 54,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,194,0,0,0,38,3,0,0,115,4,0,0, - 0,0,2,21,1,122,19,70,105,108,101,76,111,97,100,101, - 114,46,103,101,116,95,100,97,116,97,41,11,114,105,0,0, - 0,114,104,0,0,0,114,106,0,0,0,114,107,0,0,0, - 114,179,0,0,0,114,207,0,0,0,114,209,0,0,0,114, - 116,0,0,0,114,187,0,0,0,114,151,0,0,0,114,194, - 0,0,0,114,4,0,0,0,114,4,0,0,0,41,1,114, - 205,0,0,0,114,5,0,0,0,114,204,0,0,0,3,3, - 0,0,115,14,0,0,0,12,3,6,2,12,6,12,4,12, - 3,24,12,18,5,114,204,0,0,0,99,0,0,0,0,0, - 0,0,0,0,0,0,0,4,0,0,0,64,0,0,0,115, - 64,0,0,0,101,0,0,90,1,0,100,0,0,90,2,0, - 100,1,0,90,3,0,100,2,0,100,3,0,132,0,0,90, - 4,0,100,4,0,100,5,0,132,0,0,90,5,0,100,6, - 0,100,7,0,100,8,0,100,9,0,132,0,1,90,6,0, - 100,10,0,83,41,11,218,16,83,111,117,114,99,101,70,105, - 108,101,76,111,97,100,101,114,122,62,67,111,110,99,114,101, - 116,101,32,105,109,112,108,101,109,101,110,116,97,116,105,111, - 110,32,111,102,32,83,111,117,114,99,101,76,111,97,100,101, - 114,32,117,115,105,110,103,32,116,104,101,32,102,105,108,101, - 32,115,121,115,116,101,109,46,99,2,0,0,0,0,0,0, - 0,3,0,0,0,4,0,0,0,67,0,0,0,115,34,0, - 0,0,116,0,0,124,1,0,131,1,0,125,2,0,100,1, - 0,124,2,0,106,1,0,100,2,0,124,2,0,106,2,0, - 105,2,0,83,41,3,122,33,82,101,116,117,114,110,32,116, - 104,101,32,109,101,116,97,100,97,116,97,32,102,111,114,32, - 116,104,101,32,112,97,116,104,46,114,126,0,0,0,114,127, - 0,0,0,41,3,114,39,0,0,0,218,8,115,116,95,109, - 116,105,109,101,90,7,115,116,95,115,105,122,101,41,3,114, - 100,0,0,0,114,35,0,0,0,114,202,0,0,0,114,4, - 0,0,0,114,4,0,0,0,114,5,0,0,0,114,191,0, - 0,0,48,3,0,0,115,4,0,0,0,0,2,12,1,122, - 27,83,111,117,114,99,101,70,105,108,101,76,111,97,100,101, - 114,46,112,97,116,104,95,115,116,97,116,115,99,4,0,0, - 0,0,0,0,0,5,0,0,0,5,0,0,0,67,0,0, - 0,115,34,0,0,0,116,0,0,124,1,0,131,1,0,125, - 4,0,124,0,0,106,1,0,124,2,0,124,3,0,100,1, - 0,124,4,0,131,2,1,83,41,2,78,218,5,95,109,111, - 100,101,41,2,114,97,0,0,0,114,192,0,0,0,41,5, - 114,100,0,0,0,114,90,0,0,0,114,89,0,0,0,114, - 53,0,0,0,114,42,0,0,0,114,4,0,0,0,114,4, - 0,0,0,114,5,0,0,0,114,193,0,0,0,53,3,0, - 0,115,4,0,0,0,0,2,12,1,122,32,83,111,117,114, - 99,101,70,105,108,101,76,111,97,100,101,114,46,95,99,97, - 99,104,101,95,98,121,116,101,99,111,100,101,114,214,0,0, - 0,105,182,1,0,0,99,3,0,0,0,1,0,0,0,9, - 0,0,0,17,0,0,0,67,0,0,0,115,62,1,0,0, - 116,0,0,124,1,0,131,1,0,92,2,0,125,4,0,125, - 5,0,103,0,0,125,6,0,120,54,0,124,4,0,114,80, - 0,116,1,0,124,4,0,131,1,0,12,114,80,0,116,0, - 0,124,4,0,131,1,0,92,2,0,125,4,0,125,7,0, - 124,6,0,106,2,0,124,7,0,131,1,0,1,113,27,0, - 87,120,135,0,116,3,0,124,6,0,131,1,0,68,93,121, - 0,125,7,0,116,4,0,124,4,0,124,7,0,131,2,0, - 125,4,0,121,17,0,116,5,0,106,6,0,124,4,0,131, - 1,0,1,87,113,94,0,4,116,7,0,107,10,0,114,155, - 0,1,1,1,119,94,0,89,113,94,0,4,116,8,0,107, - 10,0,114,214,0,1,125,8,0,1,122,28,0,116,9,0, - 106,10,0,100,1,0,124,4,0,124,8,0,131,3,0,1, - 100,2,0,83,87,89,100,2,0,100,2,0,125,8,0,126, - 8,0,88,113,94,0,88,113,94,0,87,121,36,0,116,11, - 0,124,1,0,124,2,0,124,3,0,131,3,0,1,116,9, - 0,106,10,0,100,3,0,124,1,0,131,2,0,1,87,110, - 56,0,4,116,8,0,107,10,0,114,57,1,1,125,8,0, - 1,122,24,0,116,9,0,106,10,0,100,1,0,124,1,0, - 124,8,0,131,3,0,1,87,89,100,2,0,100,2,0,125, - 8,0,126,8,0,88,110,1,0,88,100,2,0,83,41,4, - 122,27,87,114,105,116,101,32,98,121,116,101,115,32,100,97, - 116,97,32,116,111,32,97,32,102,105,108,101,46,122,27,99, - 111,117,108,100,32,110,111,116,32,99,114,101,97,116,101,32, - 123,33,114,125,58,32,123,33,114,125,78,122,12,99,114,101, - 97,116,101,100,32,123,33,114,125,41,12,114,38,0,0,0, - 114,46,0,0,0,114,157,0,0,0,114,33,0,0,0,114, - 28,0,0,0,114,3,0,0,0,90,5,109,107,100,105,114, - 218,15,70,105,108,101,69,120,105,115,116,115,69,114,114,111, - 114,114,40,0,0,0,114,114,0,0,0,114,129,0,0,0, - 114,55,0,0,0,41,9,114,100,0,0,0,114,35,0,0, - 0,114,53,0,0,0,114,214,0,0,0,218,6,112,97,114, - 101,110,116,114,94,0,0,0,114,27,0,0,0,114,23,0, - 0,0,114,195,0,0,0,114,4,0,0,0,114,4,0,0, - 0,114,5,0,0,0,114,192,0,0,0,58,3,0,0,115, - 42,0,0,0,0,2,18,1,6,2,22,1,18,1,17,2, - 19,1,15,1,3,1,17,1,13,2,7,1,18,3,9,1, - 10,1,27,1,3,1,16,1,20,1,18,2,12,1,122,25, - 83,111,117,114,99,101,70,105,108,101,76,111,97,100,101,114, - 46,115,101,116,95,100,97,116,97,78,41,7,114,105,0,0, - 0,114,104,0,0,0,114,106,0,0,0,114,107,0,0,0, - 114,191,0,0,0,114,193,0,0,0,114,192,0,0,0,114, - 4,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,212,0,0,0,44,3,0,0,115,8,0,0, - 0,12,2,6,2,12,5,12,5,114,212,0,0,0,99,0, - 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,64, - 0,0,0,115,46,0,0,0,101,0,0,90,1,0,100,0, - 0,90,2,0,100,1,0,90,3,0,100,2,0,100,3,0, - 132,0,0,90,4,0,100,4,0,100,5,0,132,0,0,90, - 5,0,100,6,0,83,41,7,218,20,83,111,117,114,99,101, - 108,101,115,115,70,105,108,101,76,111,97,100,101,114,122,45, - 76,111,97,100,101,114,32,119,104,105,99,104,32,104,97,110, - 100,108,101,115,32,115,111,117,114,99,101,108,101,115,115,32, - 102,105,108,101,32,105,109,112,111,114,116,115,46,99,2,0, - 0,0,0,0,0,0,5,0,0,0,6,0,0,0,67,0, - 0,0,115,76,0,0,0,124,0,0,106,0,0,124,1,0, - 131,1,0,125,2,0,124,0,0,106,1,0,124,2,0,131, - 1,0,125,3,0,116,2,0,124,3,0,100,1,0,124,1, - 0,100,2,0,124,2,0,131,1,2,125,4,0,116,3,0, - 124,4,0,100,1,0,124,1,0,100,3,0,124,2,0,131, - 1,2,83,41,4,78,114,98,0,0,0,114,35,0,0,0, - 114,89,0,0,0,41,4,114,151,0,0,0,114,194,0,0, - 0,114,135,0,0,0,114,141,0,0,0,41,5,114,100,0, - 0,0,114,119,0,0,0,114,35,0,0,0,114,53,0,0, - 0,114,203,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,181,0,0,0,93,3,0,0,115,8, - 0,0,0,0,1,15,1,15,1,24,1,122,29,83,111,117, - 114,99,101,108,101,115,115,70,105,108,101,76,111,97,100,101, - 114,46,103,101,116,95,99,111,100,101,99,2,0,0,0,0, - 0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,115, - 4,0,0,0,100,1,0,83,41,2,122,39,82,101,116,117, - 114,110,32,78,111,110,101,32,97,115,32,116,104,101,114,101, - 32,105,115,32,110,111,32,115,111,117,114,99,101,32,99,111, - 100,101,46,78,114,4,0,0,0,41,2,114,100,0,0,0, - 114,119,0,0,0,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,114,196,0,0,0,99,3,0,0,115,2,0, - 0,0,0,2,122,31,83,111,117,114,99,101,108,101,115,115, - 70,105,108,101,76,111,97,100,101,114,46,103,101,116,95,115, - 111,117,114,99,101,78,41,6,114,105,0,0,0,114,104,0, - 0,0,114,106,0,0,0,114,107,0,0,0,114,181,0,0, - 0,114,196,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,4,0,0,0,114,5,0,0,0,114,217,0,0,0,89, - 3,0,0,115,6,0,0,0,12,2,6,2,12,6,114,217, - 0,0,0,99,0,0,0,0,0,0,0,0,0,0,0,0, - 3,0,0,0,64,0,0,0,115,136,0,0,0,101,0,0, - 90,1,0,100,0,0,90,2,0,100,1,0,90,3,0,100, - 2,0,100,3,0,132,0,0,90,4,0,100,4,0,100,5, - 0,132,0,0,90,5,0,100,6,0,100,7,0,132,0,0, - 90,6,0,100,8,0,100,9,0,132,0,0,90,7,0,100, - 10,0,100,11,0,132,0,0,90,8,0,100,12,0,100,13, - 0,132,0,0,90,9,0,100,14,0,100,15,0,132,0,0, - 90,10,0,100,16,0,100,17,0,132,0,0,90,11,0,101, - 12,0,100,18,0,100,19,0,132,0,0,131,1,0,90,13, - 0,100,20,0,83,41,21,218,19,69,120,116,101,110,115,105, - 111,110,70,105,108,101,76,111,97,100,101,114,122,93,76,111, - 97,100,101,114,32,102,111,114,32,101,120,116,101,110,115,105, - 111,110,32,109,111,100,117,108,101,115,46,10,10,32,32,32, - 32,84,104,101,32,99,111,110,115,116,114,117,99,116,111,114, - 32,105,115,32,100,101,115,105,103,110,101,100,32,116,111,32, - 119,111,114,107,32,119,105,116,104,32,70,105,108,101,70,105, - 110,100,101,114,46,10,10,32,32,32,32,99,3,0,0,0, - 0,0,0,0,3,0,0,0,2,0,0,0,67,0,0,0, - 115,22,0,0,0,124,1,0,124,0,0,95,0,0,124,2, - 0,124,0,0,95,1,0,100,0,0,83,41,1,78,41,2, - 114,98,0,0,0,114,35,0,0,0,41,3,114,100,0,0, - 0,114,98,0,0,0,114,35,0,0,0,114,4,0,0,0, - 114,4,0,0,0,114,5,0,0,0,114,179,0,0,0,116, - 3,0,0,115,4,0,0,0,0,1,9,1,122,28,69,120, - 116,101,110,115,105,111,110,70,105,108,101,76,111,97,100,101, - 114,46,95,95,105,110,105,116,95,95,99,2,0,0,0,0, - 0,0,0,2,0,0,0,2,0,0,0,67,0,0,0,115, - 34,0,0,0,124,0,0,106,0,0,124,1,0,106,0,0, - 107,2,0,111,33,0,124,0,0,106,1,0,124,1,0,106, - 1,0,107,2,0,83,41,1,78,41,2,114,205,0,0,0, - 114,111,0,0,0,41,2,114,100,0,0,0,114,206,0,0, - 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,207,0,0,0,120,3,0,0,115,4,0,0,0,0,1, - 18,1,122,26,69,120,116,101,110,115,105,111,110,70,105,108, - 101,76,111,97,100,101,114,46,95,95,101,113,95,95,99,1, - 0,0,0,0,0,0,0,1,0,0,0,3,0,0,0,67, - 0,0,0,115,26,0,0,0,116,0,0,124,0,0,106,1, - 0,131,1,0,116,0,0,124,0,0,106,2,0,131,1,0, - 65,83,41,1,78,41,3,114,208,0,0,0,114,98,0,0, - 0,114,35,0,0,0,41,1,114,100,0,0,0,114,4,0, - 0,0,114,4,0,0,0,114,5,0,0,0,114,209,0,0, - 0,124,3,0,0,115,2,0,0,0,0,1,122,28,69,120, - 116,101,110,115,105,111,110,70,105,108,101,76,111,97,100,101, - 114,46,95,95,104,97,115,104,95,95,99,2,0,0,0,0, - 0,0,0,3,0,0,0,4,0,0,0,67,0,0,0,115, - 50,0,0,0,116,0,0,106,1,0,116,2,0,106,3,0, - 124,1,0,131,2,0,125,2,0,116,0,0,106,4,0,100, - 1,0,124,1,0,106,5,0,124,0,0,106,6,0,131,3, - 0,1,124,2,0,83,41,2,122,38,67,114,101,97,116,101, - 32,97,110,32,117,110,105,116,105,97,108,105,122,101,100,32, - 101,120,116,101,110,115,105,111,110,32,109,111,100,117,108,101, - 122,38,101,120,116,101,110,115,105,111,110,32,109,111,100,117, - 108,101,32,123,33,114,125,32,108,111,97,100,101,100,32,102, - 114,111,109,32,123,33,114,125,41,7,114,114,0,0,0,114, - 182,0,0,0,114,139,0,0,0,90,14,99,114,101,97,116, - 101,95,100,121,110,97,109,105,99,114,129,0,0,0,114,98, - 0,0,0,114,35,0,0,0,41,3,114,100,0,0,0,114, - 158,0,0,0,114,184,0,0,0,114,4,0,0,0,114,4, - 0,0,0,114,5,0,0,0,114,180,0,0,0,127,3,0, - 0,115,10,0,0,0,0,2,6,1,15,1,9,1,16,1, - 122,33,69,120,116,101,110,115,105,111,110,70,105,108,101,76, - 111,97,100,101,114,46,99,114,101,97,116,101,95,109,111,100, - 117,108,101,99,2,0,0,0,0,0,0,0,2,0,0,0, - 4,0,0,0,67,0,0,0,115,48,0,0,0,116,0,0, - 106,1,0,116,2,0,106,3,0,124,1,0,131,2,0,1, - 116,0,0,106,4,0,100,1,0,124,0,0,106,5,0,124, - 0,0,106,6,0,131,3,0,1,100,2,0,83,41,3,122, - 30,73,110,105,116,105,97,108,105,122,101,32,97,110,32,101, - 120,116,101,110,115,105,111,110,32,109,111,100,117,108,101,122, - 40,101,120,116,101,110,115,105,111,110,32,109,111,100,117,108, - 101,32,123,33,114,125,32,101,120,101,99,117,116,101,100,32, - 102,114,111,109,32,123,33,114,125,78,41,7,114,114,0,0, - 0,114,182,0,0,0,114,139,0,0,0,90,12,101,120,101, - 99,95,100,121,110,97,109,105,99,114,129,0,0,0,114,98, - 0,0,0,114,35,0,0,0,41,2,114,100,0,0,0,114, - 184,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,114,185,0,0,0,135,3,0,0,115,6,0,0, - 0,0,2,19,1,9,1,122,31,69,120,116,101,110,115,105, - 111,110,70,105,108,101,76,111,97,100,101,114,46,101,120,101, - 99,95,109,111,100,117,108,101,99,2,0,0,0,0,0,0, - 0,2,0,0,0,4,0,0,0,3,0,0,0,115,48,0, - 0,0,116,0,0,124,0,0,106,1,0,131,1,0,100,1, - 0,25,137,0,0,116,2,0,135,0,0,102,1,0,100,2, - 0,100,3,0,134,0,0,116,3,0,68,131,1,0,131,1, - 0,83,41,4,122,49,82,101,116,117,114,110,32,84,114,117, - 101,32,105,102,32,116,104,101,32,101,120,116,101,110,115,105, - 111,110,32,109,111,100,117,108,101,32,105,115,32,97,32,112, - 97,99,107,97,103,101,46,114,29,0,0,0,99,1,0,0, - 0,0,0,0,0,2,0,0,0,4,0,0,0,51,0,0, - 0,115,31,0,0,0,124,0,0,93,21,0,125,1,0,136, - 0,0,100,0,0,124,1,0,23,107,2,0,86,1,113,3, - 0,100,1,0,83,41,2,114,179,0,0,0,78,114,4,0, - 0,0,41,2,114,22,0,0,0,218,6,115,117,102,102,105, - 120,41,1,218,9,102,105,108,101,95,110,97,109,101,114,4, - 0,0,0,114,5,0,0,0,250,9,60,103,101,110,101,120, - 112,114,62,144,3,0,0,115,2,0,0,0,6,1,122,49, - 69,120,116,101,110,115,105,111,110,70,105,108,101,76,111,97, - 100,101,114,46,105,115,95,112,97,99,107,97,103,101,46,60, - 108,111,99,97,108,115,62,46,60,103,101,110,101,120,112,114, - 62,41,4,114,38,0,0,0,114,35,0,0,0,218,3,97, - 110,121,218,18,69,88,84,69,78,83,73,79,78,95,83,85, - 70,70,73,88,69,83,41,2,114,100,0,0,0,114,119,0, - 0,0,114,4,0,0,0,41,1,114,220,0,0,0,114,5, - 0,0,0,114,153,0,0,0,141,3,0,0,115,6,0,0, - 0,0,2,19,1,18,1,122,30,69,120,116,101,110,115,105, - 111,110,70,105,108,101,76,111,97,100,101,114,46,105,115,95, - 112,97,99,107,97,103,101,99,2,0,0,0,0,0,0,0, - 2,0,0,0,1,0,0,0,67,0,0,0,115,4,0,0, - 0,100,1,0,83,41,2,122,63,82,101,116,117,114,110,32, - 78,111,110,101,32,97,115,32,97,110,32,101,120,116,101,110, - 115,105,111,110,32,109,111,100,117,108,101,32,99,97,110,110, - 111,116,32,99,114,101,97,116,101,32,97,32,99,111,100,101, - 32,111,98,106,101,99,116,46,78,114,4,0,0,0,41,2, - 114,100,0,0,0,114,119,0,0,0,114,4,0,0,0,114, - 4,0,0,0,114,5,0,0,0,114,181,0,0,0,147,3, - 0,0,115,2,0,0,0,0,2,122,28,69,120,116,101,110, - 115,105,111,110,70,105,108,101,76,111,97,100,101,114,46,103, - 101,116,95,99,111,100,101,99,2,0,0,0,0,0,0,0, - 2,0,0,0,1,0,0,0,67,0,0,0,115,4,0,0, - 0,100,1,0,83,41,2,122,53,82,101,116,117,114,110,32, - 78,111,110,101,32,97,115,32,101,120,116,101,110,115,105,111, - 110,32,109,111,100,117,108,101,115,32,104,97,118,101,32,110, - 111,32,115,111,117,114,99,101,32,99,111,100,101,46,78,114, - 4,0,0,0,41,2,114,100,0,0,0,114,119,0,0,0, - 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 196,0,0,0,151,3,0,0,115,2,0,0,0,0,2,122, - 30,69,120,116,101,110,115,105,111,110,70,105,108,101,76,111, - 97,100,101,114,46,103,101,116,95,115,111,117,114,99,101,99, + 104,95,115,116,97,116,115,160,2,0,0,115,2,0,0,0, + 0,11,122,23,83,111,117,114,99,101,76,111,97,100,101,114, + 46,112,97,116,104,95,115,116,97,116,115,99,4,0,0,0, + 0,0,0,0,4,0,0,0,3,0,0,0,67,0,0,0, + 115,16,0,0,0,124,0,0,106,0,0,124,2,0,124,3, + 0,131,2,0,83,41,1,122,228,79,112,116,105,111,110,97, + 108,32,109,101,116,104,111,100,32,119,104,105,99,104,32,119, + 114,105,116,101,115,32,100,97,116,97,32,40,98,121,116,101, + 115,41,32,116,111,32,97,32,102,105,108,101,32,112,97,116, + 104,32,40,97,32,115,116,114,41,46,10,10,32,32,32,32, + 32,32,32,32,73,109,112,108,101,109,101,110,116,105,110,103, + 32,116,104,105,115,32,109,101,116,104,111,100,32,97,108,108, + 111,119,115,32,102,111,114,32,116,104,101,32,119,114,105,116, + 105,110,103,32,111,102,32,98,121,116,101,99,111,100,101,32, + 102,105,108,101,115,46,10,10,32,32,32,32,32,32,32,32, + 84,104,101,32,115,111,117,114,99,101,32,112,97,116,104,32, + 105,115,32,110,101,101,100,101,100,32,105,110,32,111,114,100, + 101,114,32,116,111,32,99,111,114,114,101,99,116,108,121,32, + 116,114,97,110,115,102,101,114,32,112,101,114,109,105,115,115, + 105,111,110,115,10,32,32,32,32,32,32,32,32,41,1,218, + 8,115,101,116,95,100,97,116,97,41,4,114,100,0,0,0, + 114,90,0,0,0,90,10,99,97,99,104,101,95,112,97,116, + 104,114,53,0,0,0,114,4,0,0,0,114,4,0,0,0, + 114,5,0,0,0,218,15,95,99,97,99,104,101,95,98,121, + 116,101,99,111,100,101,173,2,0,0,115,2,0,0,0,0, + 8,122,28,83,111,117,114,99,101,76,111,97,100,101,114,46, + 95,99,97,99,104,101,95,98,121,116,101,99,111,100,101,99, + 3,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0, + 67,0,0,0,115,4,0,0,0,100,1,0,83,41,2,122, + 150,79,112,116,105,111,110,97,108,32,109,101,116,104,111,100, + 32,119,104,105,99,104,32,119,114,105,116,101,115,32,100,97, + 116,97,32,40,98,121,116,101,115,41,32,116,111,32,97,32, + 102,105,108,101,32,112,97,116,104,32,40,97,32,115,116,114, + 41,46,10,10,32,32,32,32,32,32,32,32,73,109,112,108, + 101,109,101,110,116,105,110,103,32,116,104,105,115,32,109,101, + 116,104,111,100,32,97,108,108,111,119,115,32,102,111,114,32, + 116,104,101,32,119,114,105,116,105,110,103,32,111,102,32,98, + 121,116,101,99,111,100,101,32,102,105,108,101,115,46,10,32, + 32,32,32,32,32,32,32,78,114,4,0,0,0,41,3,114, + 100,0,0,0,114,35,0,0,0,114,53,0,0,0,114,4, + 0,0,0,114,4,0,0,0,114,5,0,0,0,114,192,0, + 0,0,183,2,0,0,115,0,0,0,0,122,21,83,111,117, + 114,99,101,76,111,97,100,101,114,46,115,101,116,95,100,97, + 116,97,99,2,0,0,0,0,0,0,0,5,0,0,0,16, + 0,0,0,67,0,0,0,115,105,0,0,0,124,0,0,106, + 0,0,124,1,0,131,1,0,125,2,0,121,19,0,124,0, + 0,106,1,0,124,2,0,131,1,0,125,3,0,87,110,58, + 0,4,116,2,0,107,10,0,114,94,0,1,125,4,0,1, + 122,26,0,116,3,0,100,1,0,100,2,0,124,1,0,131, + 1,1,124,4,0,130,2,0,87,89,100,3,0,100,3,0, + 125,4,0,126,4,0,88,110,1,0,88,116,4,0,124,3, + 0,131,1,0,83,41,4,122,52,67,111,110,99,114,101,116, + 101,32,105,109,112,108,101,109,101,110,116,97,116,105,111,110, + 32,111,102,32,73,110,115,112,101,99,116,76,111,97,100,101, + 114,46,103,101,116,95,115,111,117,114,99,101,46,122,39,115, + 111,117,114,99,101,32,110,111,116,32,97,118,97,105,108,97, + 98,108,101,32,116,104,114,111,117,103,104,32,103,101,116,95, + 100,97,116,97,40,41,114,98,0,0,0,78,41,5,114,151, + 0,0,0,218,8,103,101,116,95,100,97,116,97,114,40,0, + 0,0,114,99,0,0,0,114,149,0,0,0,41,5,114,100, + 0,0,0,114,119,0,0,0,114,35,0,0,0,114,147,0, + 0,0,218,3,101,120,99,114,4,0,0,0,114,4,0,0, + 0,114,5,0,0,0,218,10,103,101,116,95,115,111,117,114, + 99,101,190,2,0,0,115,14,0,0,0,0,2,15,1,3, + 1,19,1,18,1,9,1,31,1,122,23,83,111,117,114,99, + 101,76,111,97,100,101,114,46,103,101,116,95,115,111,117,114, + 99,101,218,9,95,111,112,116,105,109,105,122,101,114,29,0, + 0,0,99,3,0,0,0,1,0,0,0,4,0,0,0,9, + 0,0,0,67,0,0,0,115,34,0,0,0,116,0,0,106, + 1,0,116,2,0,124,1,0,124,2,0,100,1,0,100,2, + 0,100,3,0,100,4,0,124,3,0,131,4,2,83,41,5, + 122,130,82,101,116,117,114,110,32,116,104,101,32,99,111,100, + 101,32,111,98,106,101,99,116,32,99,111,109,112,105,108,101, + 100,32,102,114,111,109,32,115,111,117,114,99,101,46,10,10, + 32,32,32,32,32,32,32,32,84,104,101,32,39,100,97,116, + 97,39,32,97,114,103,117,109,101,110,116,32,99,97,110,32, + 98,101,32,97,110,121,32,111,98,106,101,99,116,32,116,121, + 112,101,32,116,104,97,116,32,99,111,109,112,105,108,101,40, + 41,32,115,117,112,112,111,114,116,115,46,10,32,32,32,32, + 32,32,32,32,114,183,0,0,0,218,12,100,111,110,116,95, + 105,110,104,101,114,105,116,84,114,68,0,0,0,41,3,114, + 114,0,0,0,114,182,0,0,0,218,7,99,111,109,112,105, + 108,101,41,4,114,100,0,0,0,114,53,0,0,0,114,35, + 0,0,0,114,197,0,0,0,114,4,0,0,0,114,4,0, + 0,0,114,5,0,0,0,218,14,115,111,117,114,99,101,95, + 116,111,95,99,111,100,101,200,2,0,0,115,4,0,0,0, + 0,5,21,1,122,27,83,111,117,114,99,101,76,111,97,100, + 101,114,46,115,111,117,114,99,101,95,116,111,95,99,111,100, + 101,99,2,0,0,0,0,0,0,0,10,0,0,0,43,0, + 0,0,67,0,0,0,115,183,1,0,0,124,0,0,106,0, + 0,124,1,0,131,1,0,125,2,0,100,1,0,125,3,0, + 121,16,0,116,1,0,124,2,0,131,1,0,125,4,0,87, + 110,24,0,4,116,2,0,107,10,0,114,63,0,1,1,1, + 100,1,0,125,4,0,89,110,205,0,88,121,19,0,124,0, + 0,106,3,0,124,2,0,131,1,0,125,5,0,87,110,18, + 0,4,116,4,0,107,10,0,114,103,0,1,1,1,89,110, + 165,0,88,116,5,0,124,5,0,100,2,0,25,131,1,0, + 125,3,0,121,19,0,124,0,0,106,6,0,124,4,0,131, + 1,0,125,6,0,87,110,18,0,4,116,7,0,107,10,0, + 114,159,0,1,1,1,89,110,109,0,88,121,34,0,116,8, + 0,124,6,0,100,3,0,124,5,0,100,4,0,124,1,0, + 100,5,0,124,4,0,131,1,3,125,7,0,87,110,24,0, + 4,116,9,0,116,10,0,102,2,0,107,10,0,114,220,0, + 1,1,1,89,110,48,0,88,116,11,0,106,12,0,100,6, + 0,124,4,0,124,2,0,131,3,0,1,116,13,0,124,7, + 0,100,4,0,124,1,0,100,7,0,124,4,0,100,8,0, + 124,2,0,131,1,3,83,124,0,0,106,6,0,124,2,0, + 131,1,0,125,8,0,124,0,0,106,14,0,124,8,0,124, + 2,0,131,2,0,125,9,0,116,11,0,106,12,0,100,9, + 0,124,2,0,131,2,0,1,116,15,0,106,16,0,12,114, + 179,1,124,4,0,100,1,0,107,9,0,114,179,1,124,3, + 0,100,1,0,107,9,0,114,179,1,116,17,0,124,9,0, + 124,3,0,116,18,0,124,8,0,131,1,0,131,3,0,125, + 6,0,121,39,0,124,0,0,106,19,0,124,2,0,124,4, + 0,124,6,0,131,3,0,1,116,11,0,106,12,0,100,10, + 0,124,4,0,131,2,0,1,87,110,18,0,4,116,2,0, + 107,10,0,114,178,1,1,1,1,89,110,1,0,88,124,9, + 0,83,41,11,122,190,67,111,110,99,114,101,116,101,32,105, + 109,112,108,101,109,101,110,116,97,116,105,111,110,32,111,102, + 32,73,110,115,112,101,99,116,76,111,97,100,101,114,46,103, + 101,116,95,99,111,100,101,46,10,10,32,32,32,32,32,32, + 32,32,82,101,97,100,105,110,103,32,111,102,32,98,121,116, + 101,99,111,100,101,32,114,101,113,117,105,114,101,115,32,112, + 97,116,104,95,115,116,97,116,115,32,116,111,32,98,101,32, + 105,109,112,108,101,109,101,110,116,101,100,46,32,84,111,32, + 119,114,105,116,101,10,32,32,32,32,32,32,32,32,98,121, + 116,101,99,111,100,101,44,32,115,101,116,95,100,97,116,97, + 32,109,117,115,116,32,97,108,115,111,32,98,101,32,105,109, + 112,108,101,109,101,110,116,101,100,46,10,10,32,32,32,32, + 32,32,32,32,78,114,126,0,0,0,114,132,0,0,0,114, + 98,0,0,0,114,35,0,0,0,122,13,123,125,32,109,97, + 116,99,104,101,115,32,123,125,114,89,0,0,0,114,90,0, + 0,0,122,19,99,111,100,101,32,111,98,106,101,99,116,32, + 102,114,111,109,32,123,125,122,10,119,114,111,116,101,32,123, + 33,114,125,41,20,114,151,0,0,0,114,79,0,0,0,114, + 66,0,0,0,114,191,0,0,0,114,189,0,0,0,114,14, + 0,0,0,114,194,0,0,0,114,40,0,0,0,114,135,0, + 0,0,114,99,0,0,0,114,130,0,0,0,114,114,0,0, + 0,114,129,0,0,0,114,141,0,0,0,114,200,0,0,0, + 114,7,0,0,0,218,19,100,111,110,116,95,119,114,105,116, + 101,95,98,121,116,101,99,111,100,101,114,144,0,0,0,114, + 31,0,0,0,114,193,0,0,0,41,10,114,100,0,0,0, + 114,119,0,0,0,114,90,0,0,0,114,133,0,0,0,114, + 89,0,0,0,218,2,115,116,114,53,0,0,0,218,10,98, + 121,116,101,115,95,100,97,116,97,114,147,0,0,0,90,11, + 99,111,100,101,95,111,98,106,101,99,116,114,4,0,0,0, + 114,4,0,0,0,114,5,0,0,0,114,181,0,0,0,208, + 2,0,0,115,78,0,0,0,0,7,15,1,6,1,3,1, + 16,1,13,1,11,2,3,1,19,1,13,1,5,2,16,1, + 3,1,19,1,13,1,5,2,3,1,9,1,12,1,13,1, + 19,1,5,2,12,1,7,1,15,1,6,1,7,1,15,1, + 18,1,16,1,22,1,12,1,9,1,15,1,3,1,19,1, + 20,1,13,1,5,1,122,21,83,111,117,114,99,101,76,111, + 97,100,101,114,46,103,101,116,95,99,111,100,101,78,114,87, + 0,0,0,41,10,114,105,0,0,0,114,104,0,0,0,114, + 106,0,0,0,114,190,0,0,0,114,191,0,0,0,114,193, + 0,0,0,114,192,0,0,0,114,196,0,0,0,114,200,0, + 0,0,114,181,0,0,0,114,4,0,0,0,114,4,0,0, + 0,114,4,0,0,0,114,5,0,0,0,114,188,0,0,0, + 150,2,0,0,115,14,0,0,0,12,2,12,8,12,13,12, + 10,12,7,12,10,18,8,114,188,0,0,0,99,0,0,0, + 0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0, + 0,115,112,0,0,0,101,0,0,90,1,0,100,0,0,90, + 2,0,100,1,0,90,3,0,100,2,0,100,3,0,132,0, + 0,90,4,0,100,4,0,100,5,0,132,0,0,90,5,0, + 100,6,0,100,7,0,132,0,0,90,6,0,101,7,0,135, + 0,0,102,1,0,100,8,0,100,9,0,134,0,0,131,1, + 0,90,8,0,101,7,0,100,10,0,100,11,0,132,0,0, + 131,1,0,90,9,0,100,12,0,100,13,0,132,0,0,90, + 10,0,135,0,0,83,41,14,218,10,70,105,108,101,76,111, + 97,100,101,114,122,103,66,97,115,101,32,102,105,108,101,32, + 108,111,97,100,101,114,32,99,108,97,115,115,32,119,104,105, + 99,104,32,105,109,112,108,101,109,101,110,116,115,32,116,104, + 101,32,108,111,97,100,101,114,32,112,114,111,116,111,99,111, + 108,32,109,101,116,104,111,100,115,32,116,104,97,116,10,32, + 32,32,32,114,101,113,117,105,114,101,32,102,105,108,101,32, + 115,121,115,116,101,109,32,117,115,97,103,101,46,99,3,0, + 0,0,0,0,0,0,3,0,0,0,2,0,0,0,67,0, + 0,0,115,22,0,0,0,124,1,0,124,0,0,95,0,0, + 124,2,0,124,0,0,95,1,0,100,1,0,83,41,2,122, + 75,67,97,99,104,101,32,116,104,101,32,109,111,100,117,108, + 101,32,110,97,109,101,32,97,110,100,32,116,104,101,32,112, + 97,116,104,32,116,111,32,116,104,101,32,102,105,108,101,32, + 102,111,117,110,100,32,98,121,32,116,104,101,10,32,32,32, + 32,32,32,32,32,102,105,110,100,101,114,46,78,41,2,114, + 98,0,0,0,114,35,0,0,0,41,3,114,100,0,0,0, + 114,119,0,0,0,114,35,0,0,0,114,4,0,0,0,114, + 4,0,0,0,114,5,0,0,0,114,179,0,0,0,9,3, + 0,0,115,4,0,0,0,0,3,9,1,122,19,70,105,108, + 101,76,111,97,100,101,114,46,95,95,105,110,105,116,95,95, + 99,2,0,0,0,0,0,0,0,2,0,0,0,2,0,0, + 0,67,0,0,0,115,34,0,0,0,124,0,0,106,0,0, + 124,1,0,106,0,0,107,2,0,111,33,0,124,0,0,106, + 1,0,124,1,0,106,1,0,107,2,0,83,41,1,78,41, + 2,218,9,95,95,99,108,97,115,115,95,95,114,111,0,0, + 0,41,2,114,100,0,0,0,218,5,111,116,104,101,114,114, + 4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,6, + 95,95,101,113,95,95,15,3,0,0,115,4,0,0,0,0, + 1,18,1,122,17,70,105,108,101,76,111,97,100,101,114,46, + 95,95,101,113,95,95,99,1,0,0,0,0,0,0,0,1, + 0,0,0,3,0,0,0,67,0,0,0,115,26,0,0,0, + 116,0,0,124,0,0,106,1,0,131,1,0,116,0,0,124, + 0,0,106,2,0,131,1,0,65,83,41,1,78,41,3,218, + 4,104,97,115,104,114,98,0,0,0,114,35,0,0,0,41, + 1,114,100,0,0,0,114,4,0,0,0,114,4,0,0,0, + 114,5,0,0,0,218,8,95,95,104,97,115,104,95,95,19, + 3,0,0,115,2,0,0,0,0,1,122,19,70,105,108,101, + 76,111,97,100,101,114,46,95,95,104,97,115,104,95,95,99, + 2,0,0,0,0,0,0,0,2,0,0,0,3,0,0,0, + 3,0,0,0,115,22,0,0,0,116,0,0,116,1,0,124, + 0,0,131,2,0,106,2,0,124,1,0,131,1,0,83,41, + 1,122,100,76,111,97,100,32,97,32,109,111,100,117,108,101, + 32,102,114,111,109,32,97,32,102,105,108,101,46,10,10,32, + 32,32,32,32,32,32,32,84,104,105,115,32,109,101,116,104, + 111,100,32,105,115,32,100,101,112,114,101,99,97,116,101,100, + 46,32,32,85,115,101,32,101,120,101,99,95,109,111,100,117, + 108,101,40,41,32,105,110,115,116,101,97,100,46,10,10,32, + 32,32,32,32,32,32,32,41,3,218,5,115,117,112,101,114, + 114,204,0,0,0,114,187,0,0,0,41,2,114,100,0,0, + 0,114,119,0,0,0,41,1,114,205,0,0,0,114,4,0, + 0,0,114,5,0,0,0,114,187,0,0,0,22,3,0,0, + 115,2,0,0,0,0,10,122,22,70,105,108,101,76,111,97, + 100,101,114,46,108,111,97,100,95,109,111,100,117,108,101,99, 2,0,0,0,0,0,0,0,2,0,0,0,1,0,0,0, 67,0,0,0,115,7,0,0,0,124,0,0,106,0,0,83, 41,1,122,58,82,101,116,117,114,110,32,116,104,101,32,112, @@ -1622,959 +1345,1237 @@ 98,121,32,116,104,101,32,102,105,110,100,101,114,46,41,1, 114,35,0,0,0,41,2,114,100,0,0,0,114,119,0,0, 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,151,0,0,0,155,3,0,0,115,2,0,0,0,0,3, - 122,32,69,120,116,101,110,115,105,111,110,70,105,108,101,76, - 111,97,100,101,114,46,103,101,116,95,102,105,108,101,110,97, - 109,101,78,41,14,114,105,0,0,0,114,104,0,0,0,114, - 106,0,0,0,114,107,0,0,0,114,179,0,0,0,114,207, - 0,0,0,114,209,0,0,0,114,180,0,0,0,114,185,0, - 0,0,114,153,0,0,0,114,181,0,0,0,114,196,0,0, - 0,114,116,0,0,0,114,151,0,0,0,114,4,0,0,0, - 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 218,0,0,0,108,3,0,0,115,20,0,0,0,12,6,6, - 2,12,4,12,4,12,3,12,8,12,6,12,6,12,4,12, - 4,114,218,0,0,0,99,0,0,0,0,0,0,0,0,0, - 0,0,0,2,0,0,0,64,0,0,0,115,130,0,0,0, - 101,0,0,90,1,0,100,0,0,90,2,0,100,1,0,90, - 3,0,100,2,0,100,3,0,132,0,0,90,4,0,100,4, - 0,100,5,0,132,0,0,90,5,0,100,6,0,100,7,0, - 132,0,0,90,6,0,100,8,0,100,9,0,132,0,0,90, - 7,0,100,10,0,100,11,0,132,0,0,90,8,0,100,12, - 0,100,13,0,132,0,0,90,9,0,100,14,0,100,15,0, - 132,0,0,90,10,0,100,16,0,100,17,0,132,0,0,90, - 11,0,100,18,0,100,19,0,132,0,0,90,12,0,100,20, - 0,83,41,21,218,14,95,78,97,109,101,115,112,97,99,101, - 80,97,116,104,97,38,1,0,0,82,101,112,114,101,115,101, - 110,116,115,32,97,32,110,97,109,101,115,112,97,99,101,32, - 112,97,99,107,97,103,101,39,115,32,112,97,116,104,46,32, - 32,73,116,32,117,115,101,115,32,116,104,101,32,109,111,100, - 117,108,101,32,110,97,109,101,10,32,32,32,32,116,111,32, - 102,105,110,100,32,105,116,115,32,112,97,114,101,110,116,32, - 109,111,100,117,108,101,44,32,97,110,100,32,102,114,111,109, - 32,116,104,101,114,101,32,105,116,32,108,111,111,107,115,32, - 117,112,32,116,104,101,32,112,97,114,101,110,116,39,115,10, - 32,32,32,32,95,95,112,97,116,104,95,95,46,32,32,87, - 104,101,110,32,116,104,105,115,32,99,104,97,110,103,101,115, - 44,32,116,104,101,32,109,111,100,117,108,101,39,115,32,111, - 119,110,32,112,97,116,104,32,105,115,32,114,101,99,111,109, - 112,117,116,101,100,44,10,32,32,32,32,117,115,105,110,103, - 32,112,97,116,104,95,102,105,110,100,101,114,46,32,32,70, - 111,114,32,116,111,112,45,108,101,118,101,108,32,109,111,100, - 117,108,101,115,44,32,116,104,101,32,112,97,114,101,110,116, - 32,109,111,100,117,108,101,39,115,32,112,97,116,104,10,32, - 32,32,32,105,115,32,115,121,115,46,112,97,116,104,46,99, - 4,0,0,0,0,0,0,0,4,0,0,0,2,0,0,0, - 67,0,0,0,115,52,0,0,0,124,1,0,124,0,0,95, - 0,0,124,2,0,124,0,0,95,1,0,116,2,0,124,0, - 0,106,3,0,131,0,0,131,1,0,124,0,0,95,4,0, - 124,3,0,124,0,0,95,5,0,100,0,0,83,41,1,78, - 41,6,218,5,95,110,97,109,101,218,5,95,112,97,116,104, - 114,93,0,0,0,218,16,95,103,101,116,95,112,97,114,101, - 110,116,95,112,97,116,104,218,17,95,108,97,115,116,95,112, - 97,114,101,110,116,95,112,97,116,104,218,12,95,112,97,116, - 104,95,102,105,110,100,101,114,41,4,114,100,0,0,0,114, - 98,0,0,0,114,35,0,0,0,218,11,112,97,116,104,95, - 102,105,110,100,101,114,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,179,0,0,0,168,3,0,0,115,8, - 0,0,0,0,1,9,1,9,1,21,1,122,23,95,78,97, - 109,101,115,112,97,99,101,80,97,116,104,46,95,95,105,110, - 105,116,95,95,99,1,0,0,0,0,0,0,0,4,0,0, - 0,3,0,0,0,67,0,0,0,115,53,0,0,0,124,0, - 0,106,0,0,106,1,0,100,1,0,131,1,0,92,3,0, - 125,1,0,125,2,0,125,3,0,124,2,0,100,2,0,107, - 2,0,114,43,0,100,6,0,83,124,1,0,100,5,0,102, - 2,0,83,41,7,122,62,82,101,116,117,114,110,115,32,97, - 32,116,117,112,108,101,32,111,102,32,40,112,97,114,101,110, - 116,45,109,111,100,117,108,101,45,110,97,109,101,44,32,112, - 97,114,101,110,116,45,112,97,116,104,45,97,116,116,114,45, - 110,97,109,101,41,114,58,0,0,0,114,30,0,0,0,114, - 7,0,0,0,114,35,0,0,0,90,8,95,95,112,97,116, - 104,95,95,41,2,122,3,115,121,115,122,4,112,97,116,104, - 41,2,114,225,0,0,0,114,32,0,0,0,41,4,114,100, - 0,0,0,114,216,0,0,0,218,3,100,111,116,90,2,109, - 101,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 218,23,95,102,105,110,100,95,112,97,114,101,110,116,95,112, - 97,116,104,95,110,97,109,101,115,174,3,0,0,115,8,0, - 0,0,0,2,27,1,12,2,4,3,122,38,95,78,97,109, - 101,115,112,97,99,101,80,97,116,104,46,95,102,105,110,100, - 95,112,97,114,101,110,116,95,112,97,116,104,95,110,97,109, - 101,115,99,1,0,0,0,0,0,0,0,3,0,0,0,3, - 0,0,0,67,0,0,0,115,38,0,0,0,124,0,0,106, - 0,0,131,0,0,92,2,0,125,1,0,125,2,0,116,1, - 0,116,2,0,106,3,0,124,1,0,25,124,2,0,131,2, - 0,83,41,1,78,41,4,114,232,0,0,0,114,110,0,0, - 0,114,7,0,0,0,218,7,109,111,100,117,108,101,115,41, - 3,114,100,0,0,0,90,18,112,97,114,101,110,116,95,109, - 111,100,117,108,101,95,110,97,109,101,90,14,112,97,116,104, - 95,97,116,116,114,95,110,97,109,101,114,4,0,0,0,114, - 4,0,0,0,114,5,0,0,0,114,227,0,0,0,184,3, - 0,0,115,4,0,0,0,0,1,18,1,122,31,95,78,97, - 109,101,115,112,97,99,101,80,97,116,104,46,95,103,101,116, - 95,112,97,114,101,110,116,95,112,97,116,104,99,1,0,0, - 0,0,0,0,0,3,0,0,0,3,0,0,0,67,0,0, - 0,115,118,0,0,0,116,0,0,124,0,0,106,1,0,131, - 0,0,131,1,0,125,1,0,124,1,0,124,0,0,106,2, - 0,107,3,0,114,111,0,124,0,0,106,3,0,124,0,0, - 106,4,0,124,1,0,131,2,0,125,2,0,124,2,0,100, - 0,0,107,9,0,114,102,0,124,2,0,106,5,0,100,0, - 0,107,8,0,114,102,0,124,2,0,106,6,0,114,102,0, - 124,2,0,106,6,0,124,0,0,95,7,0,124,1,0,124, - 0,0,95,2,0,124,0,0,106,7,0,83,41,1,78,41, - 8,114,93,0,0,0,114,227,0,0,0,114,228,0,0,0, - 114,229,0,0,0,114,225,0,0,0,114,120,0,0,0,114, - 150,0,0,0,114,226,0,0,0,41,3,114,100,0,0,0, - 90,11,112,97,114,101,110,116,95,112,97,116,104,114,158,0, + 114,151,0,0,0,34,3,0,0,115,2,0,0,0,0,3, + 122,23,70,105,108,101,76,111,97,100,101,114,46,103,101,116, + 95,102,105,108,101,110,97,109,101,99,2,0,0,0,0,0, + 0,0,3,0,0,0,9,0,0,0,67,0,0,0,115,42, + 0,0,0,116,0,0,106,1,0,124,1,0,100,1,0,131, + 2,0,143,17,0,125,2,0,124,2,0,106,2,0,131,0, + 0,83,87,100,2,0,81,82,88,100,2,0,83,41,3,122, + 39,82,101,116,117,114,110,32,116,104,101,32,100,97,116,97, + 32,102,114,111,109,32,112,97,116,104,32,97,115,32,114,97, + 119,32,98,121,116,101,115,46,218,1,114,78,41,3,114,49, + 0,0,0,114,50,0,0,0,90,4,114,101,97,100,41,3, + 114,100,0,0,0,114,35,0,0,0,114,54,0,0,0,114, + 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,194, + 0,0,0,39,3,0,0,115,4,0,0,0,0,2,21,1, + 122,19,70,105,108,101,76,111,97,100,101,114,46,103,101,116, + 95,100,97,116,97,41,11,114,105,0,0,0,114,104,0,0, + 0,114,106,0,0,0,114,107,0,0,0,114,179,0,0,0, + 114,207,0,0,0,114,209,0,0,0,114,116,0,0,0,114, + 187,0,0,0,114,151,0,0,0,114,194,0,0,0,114,4, + 0,0,0,114,4,0,0,0,41,1,114,205,0,0,0,114, + 5,0,0,0,114,204,0,0,0,4,3,0,0,115,14,0, + 0,0,12,3,6,2,12,6,12,4,12,3,24,12,18,5, + 114,204,0,0,0,99,0,0,0,0,0,0,0,0,0,0, + 0,0,4,0,0,0,64,0,0,0,115,64,0,0,0,101, + 0,0,90,1,0,100,0,0,90,2,0,100,1,0,90,3, + 0,100,2,0,100,3,0,132,0,0,90,4,0,100,4,0, + 100,5,0,132,0,0,90,5,0,100,6,0,100,7,0,100, + 8,0,100,9,0,132,0,1,90,6,0,100,10,0,83,41, + 11,218,16,83,111,117,114,99,101,70,105,108,101,76,111,97, + 100,101,114,122,62,67,111,110,99,114,101,116,101,32,105,109, + 112,108,101,109,101,110,116,97,116,105,111,110,32,111,102,32, + 83,111,117,114,99,101,76,111,97,100,101,114,32,117,115,105, + 110,103,32,116,104,101,32,102,105,108,101,32,115,121,115,116, + 101,109,46,99,2,0,0,0,0,0,0,0,3,0,0,0, + 4,0,0,0,67,0,0,0,115,34,0,0,0,116,0,0, + 124,1,0,131,1,0,125,2,0,100,1,0,124,2,0,106, + 1,0,100,2,0,124,2,0,106,2,0,105,2,0,83,41, + 3,122,33,82,101,116,117,114,110,32,116,104,101,32,109,101, + 116,97,100,97,116,97,32,102,111,114,32,116,104,101,32,112, + 97,116,104,46,114,126,0,0,0,114,127,0,0,0,41,3, + 114,39,0,0,0,218,8,115,116,95,109,116,105,109,101,90, + 7,115,116,95,115,105,122,101,41,3,114,100,0,0,0,114, + 35,0,0,0,114,202,0,0,0,114,4,0,0,0,114,4, + 0,0,0,114,5,0,0,0,114,191,0,0,0,49,3,0, + 0,115,4,0,0,0,0,2,12,1,122,27,83,111,117,114, + 99,101,70,105,108,101,76,111,97,100,101,114,46,112,97,116, + 104,95,115,116,97,116,115,99,4,0,0,0,0,0,0,0, + 5,0,0,0,5,0,0,0,67,0,0,0,115,34,0,0, + 0,116,0,0,124,1,0,131,1,0,125,4,0,124,0,0, + 106,1,0,124,2,0,124,3,0,100,1,0,124,4,0,131, + 2,1,83,41,2,78,218,5,95,109,111,100,101,41,2,114, + 97,0,0,0,114,192,0,0,0,41,5,114,100,0,0,0, + 114,90,0,0,0,114,89,0,0,0,114,53,0,0,0,114, + 42,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, + 0,0,0,114,193,0,0,0,54,3,0,0,115,4,0,0, + 0,0,2,12,1,122,32,83,111,117,114,99,101,70,105,108, + 101,76,111,97,100,101,114,46,95,99,97,99,104,101,95,98, + 121,116,101,99,111,100,101,114,214,0,0,0,105,182,1,0, + 0,99,3,0,0,0,1,0,0,0,9,0,0,0,17,0, + 0,0,67,0,0,0,115,62,1,0,0,116,0,0,124,1, + 0,131,1,0,92,2,0,125,4,0,125,5,0,103,0,0, + 125,6,0,120,54,0,124,4,0,114,80,0,116,1,0,124, + 4,0,131,1,0,12,114,80,0,116,0,0,124,4,0,131, + 1,0,92,2,0,125,4,0,125,7,0,124,6,0,106,2, + 0,124,7,0,131,1,0,1,113,27,0,87,120,135,0,116, + 3,0,124,6,0,131,1,0,68,93,121,0,125,7,0,116, + 4,0,124,4,0,124,7,0,131,2,0,125,4,0,121,17, + 0,116,5,0,106,6,0,124,4,0,131,1,0,1,87,113, + 94,0,4,116,7,0,107,10,0,114,155,0,1,1,1,119, + 94,0,89,113,94,0,4,116,8,0,107,10,0,114,214,0, + 1,125,8,0,1,122,28,0,116,9,0,106,10,0,100,1, + 0,124,4,0,124,8,0,131,3,0,1,100,2,0,83,87, + 89,100,2,0,100,2,0,125,8,0,126,8,0,88,113,94, + 0,88,113,94,0,87,121,36,0,116,11,0,124,1,0,124, + 2,0,124,3,0,131,3,0,1,116,9,0,106,10,0,100, + 3,0,124,1,0,131,2,0,1,87,110,56,0,4,116,8, + 0,107,10,0,114,57,1,1,125,8,0,1,122,24,0,116, + 9,0,106,10,0,100,1,0,124,1,0,124,8,0,131,3, + 0,1,87,89,100,2,0,100,2,0,125,8,0,126,8,0, + 88,110,1,0,88,100,2,0,83,41,4,122,27,87,114,105, + 116,101,32,98,121,116,101,115,32,100,97,116,97,32,116,111, + 32,97,32,102,105,108,101,46,122,27,99,111,117,108,100,32, + 110,111,116,32,99,114,101,97,116,101,32,123,33,114,125,58, + 32,123,33,114,125,78,122,12,99,114,101,97,116,101,100,32, + 123,33,114,125,41,12,114,38,0,0,0,114,46,0,0,0, + 114,157,0,0,0,114,33,0,0,0,114,28,0,0,0,114, + 3,0,0,0,90,5,109,107,100,105,114,218,15,70,105,108, + 101,69,120,105,115,116,115,69,114,114,111,114,114,40,0,0, + 0,114,114,0,0,0,114,129,0,0,0,114,55,0,0,0, + 41,9,114,100,0,0,0,114,35,0,0,0,114,53,0,0, + 0,114,214,0,0,0,218,6,112,97,114,101,110,116,114,94, + 0,0,0,114,27,0,0,0,114,23,0,0,0,114,195,0, 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0, - 0,218,12,95,114,101,99,97,108,99,117,108,97,116,101,188, - 3,0,0,115,16,0,0,0,0,2,18,1,15,1,21,3, - 27,1,9,1,12,1,9,1,122,27,95,78,97,109,101,115, - 112,97,99,101,80,97,116,104,46,95,114,101,99,97,108,99, - 117,108,97,116,101,99,1,0,0,0,0,0,0,0,1,0, - 0,0,2,0,0,0,67,0,0,0,115,16,0,0,0,116, - 0,0,124,0,0,106,1,0,131,0,0,131,1,0,83,41, - 1,78,41,2,218,4,105,116,101,114,114,234,0,0,0,41, - 1,114,100,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,218,8,95,95,105,116,101,114,95,95,201, - 3,0,0,115,2,0,0,0,0,1,122,23,95,78,97,109, - 101,115,112,97,99,101,80,97,116,104,46,95,95,105,116,101, - 114,95,95,99,1,0,0,0,0,0,0,0,1,0,0,0, - 2,0,0,0,67,0,0,0,115,16,0,0,0,116,0,0, - 124,0,0,106,1,0,131,0,0,131,1,0,83,41,1,78, - 41,2,114,31,0,0,0,114,234,0,0,0,41,1,114,100, - 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0, - 0,0,218,7,95,95,108,101,110,95,95,204,3,0,0,115, - 2,0,0,0,0,1,122,22,95,78,97,109,101,115,112,97, - 99,101,80,97,116,104,46,95,95,108,101,110,95,95,99,1, - 0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,67, - 0,0,0,115,16,0,0,0,100,1,0,106,0,0,124,0, - 0,106,1,0,131,1,0,83,41,2,78,122,20,95,78,97, - 109,101,115,112,97,99,101,80,97,116,104,40,123,33,114,125, - 41,41,2,114,47,0,0,0,114,226,0,0,0,41,1,114, - 100,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,218,8,95,95,114,101,112,114,95,95,207,3,0, - 0,115,2,0,0,0,0,1,122,23,95,78,97,109,101,115, - 112,97,99,101,80,97,116,104,46,95,95,114,101,112,114,95, - 95,99,2,0,0,0,0,0,0,0,2,0,0,0,2,0, - 0,0,67,0,0,0,115,16,0,0,0,124,1,0,124,0, - 0,106,0,0,131,0,0,107,6,0,83,41,1,78,41,1, - 114,234,0,0,0,41,2,114,100,0,0,0,218,4,105,116, - 101,109,114,4,0,0,0,114,4,0,0,0,114,5,0,0, - 0,218,12,95,95,99,111,110,116,97,105,110,115,95,95,210, - 3,0,0,115,2,0,0,0,0,1,122,27,95,78,97,109, - 101,115,112,97,99,101,80,97,116,104,46,95,95,99,111,110, - 116,97,105,110,115,95,95,99,2,0,0,0,0,0,0,0, - 2,0,0,0,2,0,0,0,67,0,0,0,115,20,0,0, - 0,124,0,0,106,0,0,106,1,0,124,1,0,131,1,0, - 1,100,0,0,83,41,1,78,41,2,114,226,0,0,0,114, - 157,0,0,0,41,2,114,100,0,0,0,114,239,0,0,0, - 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 157,0,0,0,213,3,0,0,115,2,0,0,0,0,1,122, - 21,95,78,97,109,101,115,112,97,99,101,80,97,116,104,46, - 97,112,112,101,110,100,78,41,13,114,105,0,0,0,114,104, - 0,0,0,114,106,0,0,0,114,107,0,0,0,114,179,0, - 0,0,114,232,0,0,0,114,227,0,0,0,114,234,0,0, - 0,114,236,0,0,0,114,237,0,0,0,114,238,0,0,0, - 114,240,0,0,0,114,157,0,0,0,114,4,0,0,0,114, - 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,224, - 0,0,0,161,3,0,0,115,20,0,0,0,12,5,6,2, - 12,6,12,10,12,4,12,13,12,3,12,3,12,3,12,3, - 114,224,0,0,0,99,0,0,0,0,0,0,0,0,0,0, - 0,0,3,0,0,0,64,0,0,0,115,118,0,0,0,101, - 0,0,90,1,0,100,0,0,90,2,0,100,1,0,100,2, - 0,132,0,0,90,3,0,101,4,0,100,3,0,100,4,0, - 132,0,0,131,1,0,90,5,0,100,5,0,100,6,0,132, - 0,0,90,6,0,100,7,0,100,8,0,132,0,0,90,7, - 0,100,9,0,100,10,0,132,0,0,90,8,0,100,11,0, - 100,12,0,132,0,0,90,9,0,100,13,0,100,14,0,132, - 0,0,90,10,0,100,15,0,100,16,0,132,0,0,90,11, - 0,100,17,0,83,41,18,218,16,95,78,97,109,101,115,112, - 97,99,101,76,111,97,100,101,114,99,4,0,0,0,0,0, - 0,0,4,0,0,0,4,0,0,0,67,0,0,0,115,25, - 0,0,0,116,0,0,124,1,0,124,2,0,124,3,0,131, - 3,0,124,0,0,95,1,0,100,0,0,83,41,1,78,41, - 2,114,224,0,0,0,114,226,0,0,0,41,4,114,100,0, - 0,0,114,98,0,0,0,114,35,0,0,0,114,230,0,0, - 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,179,0,0,0,219,3,0,0,115,2,0,0,0,0,1, - 122,25,95,78,97,109,101,115,112,97,99,101,76,111,97,100, - 101,114,46,95,95,105,110,105,116,95,95,99,2,0,0,0, - 0,0,0,0,2,0,0,0,2,0,0,0,67,0,0,0, - 115,16,0,0,0,100,1,0,106,0,0,124,1,0,106,1, - 0,131,1,0,83,41,2,122,115,82,101,116,117,114,110,32, - 114,101,112,114,32,102,111,114,32,116,104,101,32,109,111,100, - 117,108,101,46,10,10,32,32,32,32,32,32,32,32,84,104, - 101,32,109,101,116,104,111,100,32,105,115,32,100,101,112,114, - 101,99,97,116,101,100,46,32,32,84,104,101,32,105,109,112, - 111,114,116,32,109,97,99,104,105,110,101,114,121,32,100,111, - 101,115,32,116,104,101,32,106,111,98,32,105,116,115,101,108, - 102,46,10,10,32,32,32,32,32,32,32,32,122,25,60,109, - 111,100,117,108,101,32,123,33,114,125,32,40,110,97,109,101, - 115,112,97,99,101,41,62,41,2,114,47,0,0,0,114,105, - 0,0,0,41,2,114,164,0,0,0,114,184,0,0,0,114, - 4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,11, - 109,111,100,117,108,101,95,114,101,112,114,222,3,0,0,115, - 2,0,0,0,0,7,122,28,95,78,97,109,101,115,112,97, - 99,101,76,111,97,100,101,114,46,109,111,100,117,108,101,95, - 114,101,112,114,99,2,0,0,0,0,0,0,0,2,0,0, - 0,1,0,0,0,67,0,0,0,115,4,0,0,0,100,1, - 0,83,41,2,78,84,114,4,0,0,0,41,2,114,100,0, - 0,0,114,119,0,0,0,114,4,0,0,0,114,4,0,0, - 0,114,5,0,0,0,114,153,0,0,0,231,3,0,0,115, - 2,0,0,0,0,1,122,27,95,78,97,109,101,115,112,97, - 99,101,76,111,97,100,101,114,46,105,115,95,112,97,99,107, - 97,103,101,99,2,0,0,0,0,0,0,0,2,0,0,0, - 1,0,0,0,67,0,0,0,115,4,0,0,0,100,1,0, - 83,41,2,78,114,30,0,0,0,114,4,0,0,0,41,2, - 114,100,0,0,0,114,119,0,0,0,114,4,0,0,0,114, - 4,0,0,0,114,5,0,0,0,114,196,0,0,0,234,3, - 0,0,115,2,0,0,0,0,1,122,27,95,78,97,109,101, - 115,112,97,99,101,76,111,97,100,101,114,46,103,101,116,95, - 115,111,117,114,99,101,99,2,0,0,0,0,0,0,0,2, - 0,0,0,6,0,0,0,67,0,0,0,115,22,0,0,0, - 116,0,0,100,1,0,100,2,0,100,3,0,100,4,0,100, - 5,0,131,3,1,83,41,6,78,114,30,0,0,0,122,8, - 60,115,116,114,105,110,103,62,114,183,0,0,0,114,198,0, - 0,0,84,41,1,114,199,0,0,0,41,2,114,100,0,0, - 0,114,119,0,0,0,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,181,0,0,0,237,3,0,0,115,2, - 0,0,0,0,1,122,25,95,78,97,109,101,115,112,97,99, - 101,76,111,97,100,101,114,46,103,101,116,95,99,111,100,101, - 99,2,0,0,0,0,0,0,0,2,0,0,0,1,0,0, - 0,67,0,0,0,115,4,0,0,0,100,1,0,83,41,2, - 122,42,85,115,101,32,100,101,102,97,117,108,116,32,115,101, - 109,97,110,116,105,99,115,32,102,111,114,32,109,111,100,117, - 108,101,32,99,114,101,97,116,105,111,110,46,78,114,4,0, - 0,0,41,2,114,100,0,0,0,114,158,0,0,0,114,4, - 0,0,0,114,4,0,0,0,114,5,0,0,0,114,180,0, - 0,0,240,3,0,0,115,0,0,0,0,122,30,95,78,97, - 109,101,115,112,97,99,101,76,111,97,100,101,114,46,99,114, - 101,97,116,101,95,109,111,100,117,108,101,99,2,0,0,0, - 0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,0, - 115,4,0,0,0,100,0,0,83,41,1,78,114,4,0,0, - 0,41,2,114,100,0,0,0,114,184,0,0,0,114,4,0, - 0,0,114,4,0,0,0,114,5,0,0,0,114,185,0,0, - 0,243,3,0,0,115,2,0,0,0,0,1,122,28,95,78, - 97,109,101,115,112,97,99,101,76,111,97,100,101,114,46,101, - 120,101,99,95,109,111,100,117,108,101,99,2,0,0,0,0, - 0,0,0,2,0,0,0,3,0,0,0,67,0,0,0,115, - 35,0,0,0,116,0,0,106,1,0,100,1,0,124,0,0, - 106,2,0,131,2,0,1,116,0,0,106,3,0,124,0,0, - 124,1,0,131,2,0,83,41,2,122,98,76,111,97,100,32, - 97,32,110,97,109,101,115,112,97,99,101,32,109,111,100,117, - 108,101,46,10,10,32,32,32,32,32,32,32,32,84,104,105, - 115,32,109,101,116,104,111,100,32,105,115,32,100,101,112,114, - 101,99,97,116,101,100,46,32,32,85,115,101,32,101,120,101, - 99,95,109,111,100,117,108,101,40,41,32,105,110,115,116,101, - 97,100,46,10,10,32,32,32,32,32,32,32,32,122,38,110, - 97,109,101,115,112,97,99,101,32,109,111,100,117,108,101,32, - 108,111,97,100,101,100,32,119,105,116,104,32,112,97,116,104, - 32,123,33,114,125,41,4,114,114,0,0,0,114,129,0,0, - 0,114,226,0,0,0,114,186,0,0,0,41,2,114,100,0, - 0,0,114,119,0,0,0,114,4,0,0,0,114,4,0,0, - 0,114,5,0,0,0,114,187,0,0,0,246,3,0,0,115, - 6,0,0,0,0,7,9,1,10,1,122,28,95,78,97,109, - 101,115,112,97,99,101,76,111,97,100,101,114,46,108,111,97, - 100,95,109,111,100,117,108,101,78,41,12,114,105,0,0,0, - 114,104,0,0,0,114,106,0,0,0,114,179,0,0,0,114, - 177,0,0,0,114,242,0,0,0,114,153,0,0,0,114,196, - 0,0,0,114,181,0,0,0,114,180,0,0,0,114,185,0, - 0,0,114,187,0,0,0,114,4,0,0,0,114,4,0,0, - 0,114,4,0,0,0,114,5,0,0,0,114,241,0,0,0, - 218,3,0,0,115,16,0,0,0,12,1,12,3,18,9,12, - 3,12,3,12,3,12,3,12,3,114,241,0,0,0,99,0, - 0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,64, - 0,0,0,115,160,0,0,0,101,0,0,90,1,0,100,0, - 0,90,2,0,100,1,0,90,3,0,101,4,0,100,2,0, - 100,3,0,132,0,0,131,1,0,90,5,0,101,4,0,100, - 4,0,100,5,0,132,0,0,131,1,0,90,6,0,101,4, - 0,100,6,0,100,7,0,132,0,0,131,1,0,90,7,0, - 101,4,0,100,8,0,100,9,0,132,0,0,131,1,0,90, - 8,0,101,4,0,100,10,0,100,11,0,100,12,0,132,1, - 0,131,1,0,90,9,0,101,4,0,100,10,0,100,10,0, - 100,13,0,100,14,0,132,2,0,131,1,0,90,10,0,101, - 4,0,100,10,0,100,15,0,100,16,0,132,1,0,131,1, - 0,90,11,0,100,10,0,83,41,17,218,10,80,97,116,104, - 70,105,110,100,101,114,122,62,77,101,116,97,32,112,97,116, - 104,32,102,105,110,100,101,114,32,102,111,114,32,115,121,115, - 46,112,97,116,104,32,97,110,100,32,112,97,99,107,97,103, - 101,32,95,95,112,97,116,104,95,95,32,97,116,116,114,105, - 98,117,116,101,115,46,99,1,0,0,0,0,0,0,0,2, - 0,0,0,4,0,0,0,67,0,0,0,115,55,0,0,0, - 120,48,0,116,0,0,106,1,0,106,2,0,131,0,0,68, - 93,31,0,125,1,0,116,3,0,124,1,0,100,1,0,131, - 2,0,114,16,0,124,1,0,106,4,0,131,0,0,1,113, - 16,0,87,100,2,0,83,41,3,122,125,67,97,108,108,32, - 116,104,101,32,105,110,118,97,108,105,100,97,116,101,95,99, - 97,99,104,101,115,40,41,32,109,101,116,104,111,100,32,111, - 110,32,97,108,108,32,112,97,116,104,32,101,110,116,114,121, - 32,102,105,110,100,101,114,115,10,32,32,32,32,32,32,32, - 32,115,116,111,114,101,100,32,105,110,32,115,121,115,46,112, - 97,116,104,95,105,109,112,111,114,116,101,114,95,99,97,99, - 104,101,115,32,40,119,104,101,114,101,32,105,109,112,108,101, - 109,101,110,116,101,100,41,46,218,17,105,110,118,97,108,105, - 100,97,116,101,95,99,97,99,104,101,115,78,41,5,114,7, - 0,0,0,218,19,112,97,116,104,95,105,109,112,111,114,116, - 101,114,95,99,97,99,104,101,218,6,118,97,108,117,101,115, - 114,108,0,0,0,114,244,0,0,0,41,2,114,164,0,0, - 0,218,6,102,105,110,100,101,114,114,4,0,0,0,114,4, - 0,0,0,114,5,0,0,0,114,244,0,0,0,8,4,0, - 0,115,6,0,0,0,0,4,22,1,15,1,122,28,80,97, - 116,104,70,105,110,100,101,114,46,105,110,118,97,108,105,100, - 97,116,101,95,99,97,99,104,101,115,99,2,0,0,0,0, - 0,0,0,3,0,0,0,12,0,0,0,67,0,0,0,115, - 107,0,0,0,116,0,0,106,1,0,100,1,0,107,9,0, - 114,41,0,116,0,0,106,1,0,12,114,41,0,116,2,0, - 106,3,0,100,2,0,116,4,0,131,2,0,1,120,59,0, - 116,0,0,106,1,0,68,93,44,0,125,2,0,121,14,0, - 124,2,0,124,1,0,131,1,0,83,87,113,51,0,4,116, - 5,0,107,10,0,114,94,0,1,1,1,119,51,0,89,113, - 51,0,88,113,51,0,87,100,1,0,83,100,1,0,83,41, - 3,122,113,83,101,97,114,99,104,32,115,101,113,117,101,110, - 99,101,32,111,102,32,104,111,111,107,115,32,102,111,114,32, - 97,32,102,105,110,100,101,114,32,102,111,114,32,39,112,97, - 116,104,39,46,10,10,32,32,32,32,32,32,32,32,73,102, - 32,39,104,111,111,107,115,39,32,105,115,32,102,97,108,115, - 101,32,116,104,101,110,32,117,115,101,32,115,121,115,46,112, - 97,116,104,95,104,111,111,107,115,46,10,10,32,32,32,32, - 32,32,32,32,78,122,23,115,121,115,46,112,97,116,104,95, - 104,111,111,107,115,32,105,115,32,101,109,112,116,121,41,6, - 114,7,0,0,0,218,10,112,97,116,104,95,104,111,111,107, - 115,114,60,0,0,0,114,61,0,0,0,114,118,0,0,0, - 114,99,0,0,0,41,3,114,164,0,0,0,114,35,0,0, - 0,90,4,104,111,111,107,114,4,0,0,0,114,4,0,0, - 0,114,5,0,0,0,218,11,95,112,97,116,104,95,104,111, - 111,107,115,16,4,0,0,115,16,0,0,0,0,7,25,1, - 16,1,16,1,3,1,14,1,13,1,12,2,122,22,80,97, - 116,104,70,105,110,100,101,114,46,95,112,97,116,104,95,104, - 111,111,107,115,99,2,0,0,0,0,0,0,0,3,0,0, - 0,19,0,0,0,67,0,0,0,115,123,0,0,0,124,1, - 0,100,1,0,107,2,0,114,53,0,121,16,0,116,0,0, - 106,1,0,131,0,0,125,1,0,87,110,22,0,4,116,2, - 0,107,10,0,114,52,0,1,1,1,100,2,0,83,89,110, - 1,0,88,121,17,0,116,3,0,106,4,0,124,1,0,25, - 125,2,0,87,110,46,0,4,116,5,0,107,10,0,114,118, - 0,1,1,1,124,0,0,106,6,0,124,1,0,131,1,0, - 125,2,0,124,2,0,116,3,0,106,4,0,124,1,0,60, - 89,110,1,0,88,124,2,0,83,41,3,122,210,71,101,116, - 32,116,104,101,32,102,105,110,100,101,114,32,102,111,114,32, - 116,104,101,32,112,97,116,104,32,101,110,116,114,121,32,102, - 114,111,109,32,115,121,115,46,112,97,116,104,95,105,109,112, - 111,114,116,101,114,95,99,97,99,104,101,46,10,10,32,32, - 32,32,32,32,32,32,73,102,32,116,104,101,32,112,97,116, - 104,32,101,110,116,114,121,32,105,115,32,110,111,116,32,105, - 110,32,116,104,101,32,99,97,99,104,101,44,32,102,105,110, - 100,32,116,104,101,32,97,112,112,114,111,112,114,105,97,116, - 101,32,102,105,110,100,101,114,10,32,32,32,32,32,32,32, - 32,97,110,100,32,99,97,99,104,101,32,105,116,46,32,73, - 102,32,110,111,32,102,105,110,100,101,114,32,105,115,32,97, - 118,97,105,108,97,98,108,101,44,32,115,116,111,114,101,32, - 78,111,110,101,46,10,10,32,32,32,32,32,32,32,32,114, - 30,0,0,0,78,41,7,114,3,0,0,0,114,45,0,0, - 0,218,17,70,105,108,101,78,111,116,70,111,117,110,100,69, - 114,114,111,114,114,7,0,0,0,114,245,0,0,0,114,131, - 0,0,0,114,249,0,0,0,41,3,114,164,0,0,0,114, - 35,0,0,0,114,247,0,0,0,114,4,0,0,0,114,4, - 0,0,0,114,5,0,0,0,218,20,95,112,97,116,104,95, - 105,109,112,111,114,116,101,114,95,99,97,99,104,101,33,4, - 0,0,115,22,0,0,0,0,8,12,1,3,1,16,1,13, - 3,9,1,3,1,17,1,13,1,15,1,18,1,122,31,80, - 97,116,104,70,105,110,100,101,114,46,95,112,97,116,104,95, - 105,109,112,111,114,116,101,114,95,99,97,99,104,101,99,3, - 0,0,0,0,0,0,0,6,0,0,0,3,0,0,0,67, - 0,0,0,115,119,0,0,0,116,0,0,124,2,0,100,1, - 0,131,2,0,114,39,0,124,2,0,106,1,0,124,1,0, - 131,1,0,92,2,0,125,3,0,125,4,0,110,21,0,124, - 2,0,106,2,0,124,1,0,131,1,0,125,3,0,103,0, - 0,125,4,0,124,3,0,100,0,0,107,9,0,114,88,0, - 116,3,0,106,4,0,124,1,0,124,3,0,131,2,0,83, - 116,3,0,106,5,0,124,1,0,100,0,0,131,2,0,125, - 5,0,124,4,0,124,5,0,95,6,0,124,5,0,83,41, - 2,78,114,117,0,0,0,41,7,114,108,0,0,0,114,117, - 0,0,0,114,176,0,0,0,114,114,0,0,0,114,173,0, - 0,0,114,154,0,0,0,114,150,0,0,0,41,6,114,164, - 0,0,0,114,119,0,0,0,114,247,0,0,0,114,120,0, - 0,0,114,121,0,0,0,114,158,0,0,0,114,4,0,0, - 0,114,4,0,0,0,114,5,0,0,0,218,16,95,108,101, - 103,97,99,121,95,103,101,116,95,115,112,101,99,55,4,0, - 0,115,18,0,0,0,0,4,15,1,24,2,15,1,6,1, - 12,1,16,1,18,1,9,1,122,27,80,97,116,104,70,105, - 110,100,101,114,46,95,108,101,103,97,99,121,95,103,101,116, - 95,115,112,101,99,78,99,4,0,0,0,0,0,0,0,9, - 0,0,0,5,0,0,0,67,0,0,0,115,243,0,0,0, - 103,0,0,125,4,0,120,230,0,124,2,0,68,93,191,0, - 125,5,0,116,0,0,124,5,0,116,1,0,116,2,0,102, - 2,0,131,2,0,115,43,0,113,13,0,124,0,0,106,3, - 0,124,5,0,131,1,0,125,6,0,124,6,0,100,1,0, - 107,9,0,114,13,0,116,4,0,124,6,0,100,2,0,131, - 2,0,114,106,0,124,6,0,106,5,0,124,1,0,124,3, - 0,131,2,0,125,7,0,110,18,0,124,0,0,106,6,0, - 124,1,0,124,6,0,131,2,0,125,7,0,124,7,0,100, - 1,0,107,8,0,114,139,0,113,13,0,124,7,0,106,7, - 0,100,1,0,107,9,0,114,158,0,124,7,0,83,124,7, - 0,106,8,0,125,8,0,124,8,0,100,1,0,107,8,0, - 114,191,0,116,9,0,100,3,0,131,1,0,130,1,0,124, - 4,0,106,10,0,124,8,0,131,1,0,1,113,13,0,87, - 116,11,0,106,12,0,124,1,0,100,1,0,131,2,0,125, - 7,0,124,4,0,124,7,0,95,8,0,124,7,0,83,100, - 1,0,83,41,4,122,63,70,105,110,100,32,116,104,101,32, - 108,111,97,100,101,114,32,111,114,32,110,97,109,101,115,112, - 97,99,101,95,112,97,116,104,32,102,111,114,32,116,104,105, - 115,32,109,111,100,117,108,101,47,112,97,99,107,97,103,101, - 32,110,97,109,101,46,78,114,175,0,0,0,122,19,115,112, - 101,99,32,109,105,115,115,105,110,103,32,108,111,97,100,101, - 114,41,13,114,137,0,0,0,114,69,0,0,0,218,5,98, - 121,116,101,115,114,251,0,0,0,114,108,0,0,0,114,175, - 0,0,0,114,252,0,0,0,114,120,0,0,0,114,150,0, - 0,0,114,99,0,0,0,114,143,0,0,0,114,114,0,0, - 0,114,154,0,0,0,41,9,114,164,0,0,0,114,119,0, - 0,0,114,35,0,0,0,114,174,0,0,0,218,14,110,97, - 109,101,115,112,97,99,101,95,112,97,116,104,90,5,101,110, - 116,114,121,114,247,0,0,0,114,158,0,0,0,114,121,0, - 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0, - 0,218,9,95,103,101,116,95,115,112,101,99,70,4,0,0, - 115,40,0,0,0,0,5,6,1,13,1,21,1,3,1,15, - 1,12,1,15,1,21,2,18,1,12,1,3,1,15,1,4, - 1,9,1,12,1,12,5,17,2,18,1,9,1,122,20,80, - 97,116,104,70,105,110,100,101,114,46,95,103,101,116,95,115, - 112,101,99,99,4,0,0,0,0,0,0,0,6,0,0,0, - 4,0,0,0,67,0,0,0,115,140,0,0,0,124,2,0, - 100,1,0,107,8,0,114,21,0,116,0,0,106,1,0,125, - 2,0,124,0,0,106,2,0,124,1,0,124,2,0,124,3, - 0,131,3,0,125,4,0,124,4,0,100,1,0,107,8,0, - 114,58,0,100,1,0,83,124,4,0,106,3,0,100,1,0, - 107,8,0,114,132,0,124,4,0,106,4,0,125,5,0,124, - 5,0,114,125,0,100,2,0,124,4,0,95,5,0,116,6, - 0,124,1,0,124,5,0,124,0,0,106,2,0,131,3,0, - 124,4,0,95,4,0,124,4,0,83,100,1,0,83,110,4, - 0,124,4,0,83,100,1,0,83,41,3,122,98,102,105,110, - 100,32,116,104,101,32,109,111,100,117,108,101,32,111,110,32, - 115,121,115,46,112,97,116,104,32,111,114,32,39,112,97,116, - 104,39,32,98,97,115,101,100,32,111,110,32,115,121,115,46, - 112,97,116,104,95,104,111,111,107,115,32,97,110,100,10,32, - 32,32,32,32,32,32,32,115,121,115,46,112,97,116,104,95, - 105,109,112,111,114,116,101,114,95,99,97,99,104,101,46,78, - 90,9,110,97,109,101,115,112,97,99,101,41,7,114,7,0, - 0,0,114,35,0,0,0,114,255,0,0,0,114,120,0,0, - 0,114,150,0,0,0,114,152,0,0,0,114,224,0,0,0, - 41,6,114,164,0,0,0,114,119,0,0,0,114,35,0,0, - 0,114,174,0,0,0,114,158,0,0,0,114,254,0,0,0, - 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, - 175,0,0,0,102,4,0,0,115,26,0,0,0,0,4,12, - 1,9,1,21,1,12,1,4,1,15,1,9,1,6,3,9, - 1,24,1,4,2,7,2,122,20,80,97,116,104,70,105,110, - 100,101,114,46,102,105,110,100,95,115,112,101,99,99,3,0, - 0,0,0,0,0,0,4,0,0,0,3,0,0,0,67,0, - 0,0,115,41,0,0,0,124,0,0,106,0,0,124,1,0, - 124,2,0,131,2,0,125,3,0,124,3,0,100,1,0,107, - 8,0,114,34,0,100,1,0,83,124,3,0,106,1,0,83, - 41,2,122,170,102,105,110,100,32,116,104,101,32,109,111,100, - 117,108,101,32,111,110,32,115,121,115,46,112,97,116,104,32, - 111,114,32,39,112,97,116,104,39,32,98,97,115,101,100,32, - 111,110,32,115,121,115,46,112,97,116,104,95,104,111,111,107, - 115,32,97,110,100,10,32,32,32,32,32,32,32,32,115,121, - 115,46,112,97,116,104,95,105,109,112,111,114,116,101,114,95, - 99,97,99,104,101,46,10,10,32,32,32,32,32,32,32,32, - 84,104,105,115,32,109,101,116,104,111,100,32,105,115,32,100, - 101,112,114,101,99,97,116,101,100,46,32,32,85,115,101,32, - 102,105,110,100,95,115,112,101,99,40,41,32,105,110,115,116, - 101,97,100,46,10,10,32,32,32,32,32,32,32,32,78,41, - 2,114,175,0,0,0,114,120,0,0,0,41,4,114,164,0, - 0,0,114,119,0,0,0,114,35,0,0,0,114,158,0,0, - 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,176,0,0,0,124,4,0,0,115,8,0,0,0,0,8, - 18,1,12,1,4,1,122,22,80,97,116,104,70,105,110,100, - 101,114,46,102,105,110,100,95,109,111,100,117,108,101,41,12, - 114,105,0,0,0,114,104,0,0,0,114,106,0,0,0,114, - 107,0,0,0,114,177,0,0,0,114,244,0,0,0,114,249, - 0,0,0,114,251,0,0,0,114,252,0,0,0,114,255,0, - 0,0,114,175,0,0,0,114,176,0,0,0,114,4,0,0, - 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,243,0,0,0,4,4,0,0,115,22,0,0,0,12,2, - 6,2,18,8,18,17,18,22,18,15,3,1,18,31,3,1, - 21,21,3,1,114,243,0,0,0,99,0,0,0,0,0,0, - 0,0,0,0,0,0,3,0,0,0,64,0,0,0,115,133, + 0,114,192,0,0,0,59,3,0,0,115,42,0,0,0,0, + 2,18,1,6,2,22,1,18,1,17,2,19,1,15,1,3, + 1,17,1,13,2,7,1,18,3,9,1,10,1,27,1,3, + 1,16,1,20,1,18,2,12,1,122,25,83,111,117,114,99, + 101,70,105,108,101,76,111,97,100,101,114,46,115,101,116,95, + 100,97,116,97,78,41,7,114,105,0,0,0,114,104,0,0, + 0,114,106,0,0,0,114,107,0,0,0,114,191,0,0,0, + 114,193,0,0,0,114,192,0,0,0,114,4,0,0,0,114, + 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,212, + 0,0,0,45,3,0,0,115,8,0,0,0,12,2,6,2, + 12,5,12,5,114,212,0,0,0,99,0,0,0,0,0,0, + 0,0,0,0,0,0,2,0,0,0,64,0,0,0,115,46, 0,0,0,101,0,0,90,1,0,100,0,0,90,2,0,100, 1,0,90,3,0,100,2,0,100,3,0,132,0,0,90,4, - 0,100,4,0,100,5,0,132,0,0,90,5,0,101,6,0, - 90,7,0,100,6,0,100,7,0,132,0,0,90,8,0,100, - 8,0,100,9,0,132,0,0,90,9,0,100,10,0,100,11, - 0,100,12,0,132,1,0,90,10,0,100,13,0,100,14,0, - 132,0,0,90,11,0,101,12,0,100,15,0,100,16,0,132, - 0,0,131,1,0,90,13,0,100,17,0,100,18,0,132,0, - 0,90,14,0,100,10,0,83,41,19,218,10,70,105,108,101, - 70,105,110,100,101,114,122,172,70,105,108,101,45,98,97,115, - 101,100,32,102,105,110,100,101,114,46,10,10,32,32,32,32, - 73,110,116,101,114,97,99,116,105,111,110,115,32,119,105,116, - 104,32,116,104,101,32,102,105,108,101,32,115,121,115,116,101, - 109,32,97,114,101,32,99,97,99,104,101,100,32,102,111,114, - 32,112,101,114,102,111,114,109,97,110,99,101,44,32,98,101, - 105,110,103,10,32,32,32,32,114,101,102,114,101,115,104,101, - 100,32,119,104,101,110,32,116,104,101,32,100,105,114,101,99, - 116,111,114,121,32,116,104,101,32,102,105,110,100,101,114,32, - 105,115,32,104,97,110,100,108,105,110,103,32,104,97,115,32, - 98,101,101,110,32,109,111,100,105,102,105,101,100,46,10,10, - 32,32,32,32,99,2,0,0,0,0,0,0,0,5,0,0, - 0,5,0,0,0,7,0,0,0,115,122,0,0,0,103,0, - 0,125,3,0,120,52,0,124,2,0,68,93,44,0,92,2, - 0,137,0,0,125,4,0,124,3,0,106,0,0,135,0,0, - 102,1,0,100,1,0,100,2,0,134,0,0,124,4,0,68, - 131,1,0,131,1,0,1,113,13,0,87,124,3,0,124,0, - 0,95,1,0,124,1,0,112,79,0,100,3,0,124,0,0, - 95,2,0,100,6,0,124,0,0,95,3,0,116,4,0,131, - 0,0,124,0,0,95,5,0,116,4,0,131,0,0,124,0, - 0,95,6,0,100,5,0,83,41,7,122,154,73,110,105,116, - 105,97,108,105,122,101,32,119,105,116,104,32,116,104,101,32, - 112,97,116,104,32,116,111,32,115,101,97,114,99,104,32,111, - 110,32,97,110,100,32,97,32,118,97,114,105,97,98,108,101, - 32,110,117,109,98,101,114,32,111,102,10,32,32,32,32,32, - 32,32,32,50,45,116,117,112,108,101,115,32,99,111,110,116, - 97,105,110,105,110,103,32,116,104,101,32,108,111,97,100,101, - 114,32,97,110,100,32,116,104,101,32,102,105,108,101,32,115, - 117,102,102,105,120,101,115,32,116,104,101,32,108,111,97,100, - 101,114,10,32,32,32,32,32,32,32,32,114,101,99,111,103, - 110,105,122,101,115,46,99,1,0,0,0,0,0,0,0,2, - 0,0,0,3,0,0,0,51,0,0,0,115,27,0,0,0, - 124,0,0,93,17,0,125,1,0,124,1,0,136,0,0,102, - 2,0,86,1,113,3,0,100,0,0,83,41,1,78,114,4, - 0,0,0,41,2,114,22,0,0,0,114,219,0,0,0,41, - 1,114,120,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,221,0,0,0,153,4,0,0,115,2,0,0,0,6,0, - 122,38,70,105,108,101,70,105,110,100,101,114,46,95,95,105, - 110,105,116,95,95,46,60,108,111,99,97,108,115,62,46,60, - 103,101,110,101,120,112,114,62,114,58,0,0,0,114,29,0, - 0,0,78,114,87,0,0,0,41,7,114,143,0,0,0,218, - 8,95,108,111,97,100,101,114,115,114,35,0,0,0,218,11, - 95,112,97,116,104,95,109,116,105,109,101,218,3,115,101,116, - 218,11,95,112,97,116,104,95,99,97,99,104,101,218,19,95, - 114,101,108,97,120,101,100,95,112,97,116,104,95,99,97,99, - 104,101,41,5,114,100,0,0,0,114,35,0,0,0,218,14, - 108,111,97,100,101,114,95,100,101,116,97,105,108,115,90,7, - 108,111,97,100,101,114,115,114,160,0,0,0,114,4,0,0, - 0,41,1,114,120,0,0,0,114,5,0,0,0,114,179,0, - 0,0,147,4,0,0,115,16,0,0,0,0,4,6,1,19, - 1,36,1,9,2,15,1,9,1,12,1,122,19,70,105,108, + 0,100,4,0,100,5,0,132,0,0,90,5,0,100,6,0, + 83,41,7,218,20,83,111,117,114,99,101,108,101,115,115,70, + 105,108,101,76,111,97,100,101,114,122,45,76,111,97,100,101, + 114,32,119,104,105,99,104,32,104,97,110,100,108,101,115,32, + 115,111,117,114,99,101,108,101,115,115,32,102,105,108,101,32, + 105,109,112,111,114,116,115,46,99,2,0,0,0,0,0,0, + 0,5,0,0,0,6,0,0,0,67,0,0,0,115,76,0, + 0,0,124,0,0,106,0,0,124,1,0,131,1,0,125,2, + 0,124,0,0,106,1,0,124,2,0,131,1,0,125,3,0, + 116,2,0,124,3,0,100,1,0,124,1,0,100,2,0,124, + 2,0,131,1,2,125,4,0,116,3,0,124,4,0,100,1, + 0,124,1,0,100,3,0,124,2,0,131,1,2,83,41,4, + 78,114,98,0,0,0,114,35,0,0,0,114,89,0,0,0, + 41,4,114,151,0,0,0,114,194,0,0,0,114,135,0,0, + 0,114,141,0,0,0,41,5,114,100,0,0,0,114,119,0, + 0,0,114,35,0,0,0,114,53,0,0,0,114,203,0,0, + 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, + 114,181,0,0,0,94,3,0,0,115,8,0,0,0,0,1, + 15,1,15,1,24,1,122,29,83,111,117,114,99,101,108,101, + 115,115,70,105,108,101,76,111,97,100,101,114,46,103,101,116, + 95,99,111,100,101,99,2,0,0,0,0,0,0,0,2,0, + 0,0,1,0,0,0,67,0,0,0,115,4,0,0,0,100, + 1,0,83,41,2,122,39,82,101,116,117,114,110,32,78,111, + 110,101,32,97,115,32,116,104,101,114,101,32,105,115,32,110, + 111,32,115,111,117,114,99,101,32,99,111,100,101,46,78,114, + 4,0,0,0,41,2,114,100,0,0,0,114,119,0,0,0, + 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114, + 196,0,0,0,100,3,0,0,115,2,0,0,0,0,2,122, + 31,83,111,117,114,99,101,108,101,115,115,70,105,108,101,76, + 111,97,100,101,114,46,103,101,116,95,115,111,117,114,99,101, + 78,41,6,114,105,0,0,0,114,104,0,0,0,114,106,0, + 0,0,114,107,0,0,0,114,181,0,0,0,114,196,0,0, + 0,114,4,0,0,0,114,4,0,0,0,114,4,0,0,0, + 114,5,0,0,0,114,217,0,0,0,90,3,0,0,115,6, + 0,0,0,12,2,6,2,12,6,114,217,0,0,0,99,0, + 0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,64, + 0,0,0,115,136,0,0,0,101,0,0,90,1,0,100,0, + 0,90,2,0,100,1,0,90,3,0,100,2,0,100,3,0, + 132,0,0,90,4,0,100,4,0,100,5,0,132,0,0,90, + 5,0,100,6,0,100,7,0,132,0,0,90,6,0,100,8, + 0,100,9,0,132,0,0,90,7,0,100,10,0,100,11,0, + 132,0,0,90,8,0,100,12,0,100,13,0,132,0,0,90, + 9,0,100,14,0,100,15,0,132,0,0,90,10,0,100,16, + 0,100,17,0,132,0,0,90,11,0,101,12,0,100,18,0, + 100,19,0,132,0,0,131,1,0,90,13,0,100,20,0,83, + 41,21,218,19,69,120,116,101,110,115,105,111,110,70,105,108, + 101,76,111,97,100,101,114,122,93,76,111,97,100,101,114,32, + 102,111,114,32,101,120,116,101,110,115,105,111,110,32,109,111, + 100,117,108,101,115,46,10,10,32,32,32,32,84,104,101,32, + 99,111,110,115,116,114,117,99,116,111,114,32,105,115,32,100, + 101,115,105,103,110,101,100,32,116,111,32,119,111,114,107,32, + 119,105,116,104,32,70,105,108,101,70,105,110,100,101,114,46, + 10,10,32,32,32,32,99,3,0,0,0,0,0,0,0,3, + 0,0,0,2,0,0,0,67,0,0,0,115,22,0,0,0, + 124,1,0,124,0,0,95,0,0,124,2,0,124,0,0,95, + 1,0,100,0,0,83,41,1,78,41,2,114,98,0,0,0, + 114,35,0,0,0,41,3,114,100,0,0,0,114,98,0,0, + 0,114,35,0,0,0,114,4,0,0,0,114,4,0,0,0, + 114,5,0,0,0,114,179,0,0,0,117,3,0,0,115,4, + 0,0,0,0,1,9,1,122,28,69,120,116,101,110,115,105, + 111,110,70,105,108,101,76,111,97,100,101,114,46,95,95,105, + 110,105,116,95,95,99,2,0,0,0,0,0,0,0,2,0, + 0,0,2,0,0,0,67,0,0,0,115,34,0,0,0,124, + 0,0,106,0,0,124,1,0,106,0,0,107,2,0,111,33, + 0,124,0,0,106,1,0,124,1,0,106,1,0,107,2,0, + 83,41,1,78,41,2,114,205,0,0,0,114,111,0,0,0, + 41,2,114,100,0,0,0,114,206,0,0,0,114,4,0,0, + 0,114,4,0,0,0,114,5,0,0,0,114,207,0,0,0, + 121,3,0,0,115,4,0,0,0,0,1,18,1,122,26,69, + 120,116,101,110,115,105,111,110,70,105,108,101,76,111,97,100, + 101,114,46,95,95,101,113,95,95,99,1,0,0,0,0,0, + 0,0,1,0,0,0,3,0,0,0,67,0,0,0,115,26, + 0,0,0,116,0,0,124,0,0,106,1,0,131,1,0,116, + 0,0,124,0,0,106,2,0,131,1,0,65,83,41,1,78, + 41,3,114,208,0,0,0,114,98,0,0,0,114,35,0,0, + 0,41,1,114,100,0,0,0,114,4,0,0,0,114,4,0, + 0,0,114,5,0,0,0,114,209,0,0,0,125,3,0,0, + 115,2,0,0,0,0,1,122,28,69,120,116,101,110,115,105, + 111,110,70,105,108,101,76,111,97,100,101,114,46,95,95,104, + 97,115,104,95,95,99,2,0,0,0,0,0,0,0,3,0, + 0,0,4,0,0,0,67,0,0,0,115,50,0,0,0,116, + 0,0,106,1,0,116,2,0,106,3,0,124,1,0,131,2, + 0,125,2,0,116,0,0,106,4,0,100,1,0,124,1,0, + 106,5,0,124,0,0,106,6,0,131,3,0,1,124,2,0, + 83,41,2,122,38,67,114,101,97,116,101,32,97,110,32,117, + 110,105,116,105,97,108,105,122,101,100,32,101,120,116,101,110, + 115,105,111,110,32,109,111,100,117,108,101,122,38,101,120,116, + 101,110,115,105,111,110,32,109,111,100,117,108,101,32,123,33, + 114,125,32,108,111,97,100,101,100,32,102,114,111,109,32,123, + 33,114,125,41,7,114,114,0,0,0,114,182,0,0,0,114, + 139,0,0,0,90,14,99,114,101,97,116,101,95,100,121,110, + 97,109,105,99,114,129,0,0,0,114,98,0,0,0,114,35, + 0,0,0,41,3,114,100,0,0,0,114,158,0,0,0,114, + 184,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, + 0,0,0,114,180,0,0,0,128,3,0,0,115,10,0,0, + 0,0,2,6,1,15,1,9,1,16,1,122,33,69,120,116, + 101,110,115,105,111,110,70,105,108,101,76,111,97,100,101,114, + 46,99,114,101,97,116,101,95,109,111,100,117,108,101,99,2, + 0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,67, + 0,0,0,115,48,0,0,0,116,0,0,106,1,0,116,2, + 0,106,3,0,124,1,0,131,2,0,1,116,0,0,106,4, + 0,100,1,0,124,0,0,106,5,0,124,0,0,106,6,0, + 131,3,0,1,100,2,0,83,41,3,122,30,73,110,105,116, + 105,97,108,105,122,101,32,97,110,32,101,120,116,101,110,115, + 105,111,110,32,109,111,100,117,108,101,122,40,101,120,116,101, + 110,115,105,111,110,32,109,111,100,117,108,101,32,123,33,114, + 125,32,101,120,101,99,117,116,101,100,32,102,114,111,109,32, + 123,33,114,125,78,41,7,114,114,0,0,0,114,182,0,0, + 0,114,139,0,0,0,90,12,101,120,101,99,95,100,121,110, + 97,109,105,99,114,129,0,0,0,114,98,0,0,0,114,35, + 0,0,0,41,2,114,100,0,0,0,114,184,0,0,0,114, + 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,185, + 0,0,0,136,3,0,0,115,6,0,0,0,0,2,19,1, + 9,1,122,31,69,120,116,101,110,115,105,111,110,70,105,108, + 101,76,111,97,100,101,114,46,101,120,101,99,95,109,111,100, + 117,108,101,99,2,0,0,0,0,0,0,0,2,0,0,0, + 4,0,0,0,3,0,0,0,115,48,0,0,0,116,0,0, + 124,0,0,106,1,0,131,1,0,100,1,0,25,137,0,0, + 116,2,0,135,0,0,102,1,0,100,2,0,100,3,0,134, + 0,0,116,3,0,68,131,1,0,131,1,0,83,41,4,122, + 49,82,101,116,117,114,110,32,84,114,117,101,32,105,102,32, + 116,104,101,32,101,120,116,101,110,115,105,111,110,32,109,111, + 100,117,108,101,32,105,115,32,97,32,112,97,99,107,97,103, + 101,46,114,29,0,0,0,99,1,0,0,0,0,0,0,0, + 2,0,0,0,4,0,0,0,51,0,0,0,115,31,0,0, + 0,124,0,0,93,21,0,125,1,0,136,0,0,100,0,0, + 124,1,0,23,107,2,0,86,1,113,3,0,100,1,0,83, + 41,2,114,179,0,0,0,78,114,4,0,0,0,41,2,114, + 22,0,0,0,218,6,115,117,102,102,105,120,41,1,218,9, + 102,105,108,101,95,110,97,109,101,114,4,0,0,0,114,5, + 0,0,0,250,9,60,103,101,110,101,120,112,114,62,145,3, + 0,0,115,2,0,0,0,6,1,122,49,69,120,116,101,110, + 115,105,111,110,70,105,108,101,76,111,97,100,101,114,46,105, + 115,95,112,97,99,107,97,103,101,46,60,108,111,99,97,108, + 115,62,46,60,103,101,110,101,120,112,114,62,41,4,114,38, + 0,0,0,114,35,0,0,0,218,3,97,110,121,218,18,69, + 88,84,69,78,83,73,79,78,95,83,85,70,70,73,88,69, + 83,41,2,114,100,0,0,0,114,119,0,0,0,114,4,0, + 0,0,41,1,114,220,0,0,0,114,5,0,0,0,114,153, + 0,0,0,142,3,0,0,115,6,0,0,0,0,2,19,1, + 18,1,122,30,69,120,116,101,110,115,105,111,110,70,105,108, + 101,76,111,97,100,101,114,46,105,115,95,112,97,99,107,97, + 103,101,99,2,0,0,0,0,0,0,0,2,0,0,0,1, + 0,0,0,67,0,0,0,115,4,0,0,0,100,1,0,83, + 41,2,122,63,82,101,116,117,114,110,32,78,111,110,101,32, + 97,115,32,97,110,32,101,120,116,101,110,115,105,111,110,32, + 109,111,100,117,108,101,32,99,97,110,110,111,116,32,99,114, + 101,97,116,101,32,97,32,99,111,100,101,32,111,98,106,101, + 99,116,46,78,114,4,0,0,0,41,2,114,100,0,0,0, + 114,119,0,0,0,114,4,0,0,0,114,4,0,0,0,114, + 5,0,0,0,114,181,0,0,0,148,3,0,0,115,2,0, + 0,0,0,2,122,28,69,120,116,101,110,115,105,111,110,70, + 105,108,101,76,111,97,100,101,114,46,103,101,116,95,99,111, + 100,101,99,2,0,0,0,0,0,0,0,2,0,0,0,1, + 0,0,0,67,0,0,0,115,4,0,0,0,100,1,0,83, + 41,2,122,53,82,101,116,117,114,110,32,78,111,110,101,32, + 97,115,32,101,120,116,101,110,115,105,111,110,32,109,111,100, + 117,108,101,115,32,104,97,118,101,32,110,111,32,115,111,117, + 114,99,101,32,99,111,100,101,46,78,114,4,0,0,0,41, + 2,114,100,0,0,0,114,119,0,0,0,114,4,0,0,0, + 114,4,0,0,0,114,5,0,0,0,114,196,0,0,0,152, + 3,0,0,115,2,0,0,0,0,2,122,30,69,120,116,101, + 110,115,105,111,110,70,105,108,101,76,111,97,100,101,114,46, + 103,101,116,95,115,111,117,114,99,101,99,2,0,0,0,0, + 0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,115, + 7,0,0,0,124,0,0,106,0,0,83,41,1,122,58,82, + 101,116,117,114,110,32,116,104,101,32,112,97,116,104,32,116, + 111,32,116,104,101,32,115,111,117,114,99,101,32,102,105,108, + 101,32,97,115,32,102,111,117,110,100,32,98,121,32,116,104, + 101,32,102,105,110,100,101,114,46,41,1,114,35,0,0,0, + 41,2,114,100,0,0,0,114,119,0,0,0,114,4,0,0, + 0,114,4,0,0,0,114,5,0,0,0,114,151,0,0,0, + 156,3,0,0,115,2,0,0,0,0,3,122,32,69,120,116, + 101,110,115,105,111,110,70,105,108,101,76,111,97,100,101,114, + 46,103,101,116,95,102,105,108,101,110,97,109,101,78,41,14, + 114,105,0,0,0,114,104,0,0,0,114,106,0,0,0,114, + 107,0,0,0,114,179,0,0,0,114,207,0,0,0,114,209, + 0,0,0,114,180,0,0,0,114,185,0,0,0,114,153,0, + 0,0,114,181,0,0,0,114,196,0,0,0,114,116,0,0, + 0,114,151,0,0,0,114,4,0,0,0,114,4,0,0,0, + 114,4,0,0,0,114,5,0,0,0,114,218,0,0,0,109, + 3,0,0,115,20,0,0,0,12,6,6,2,12,4,12,4, + 12,3,12,8,12,6,12,6,12,4,12,4,114,218,0,0, + 0,99,0,0,0,0,0,0,0,0,0,0,0,0,2,0, + 0,0,64,0,0,0,115,130,0,0,0,101,0,0,90,1, + 0,100,0,0,90,2,0,100,1,0,90,3,0,100,2,0, + 100,3,0,132,0,0,90,4,0,100,4,0,100,5,0,132, + 0,0,90,5,0,100,6,0,100,7,0,132,0,0,90,6, + 0,100,8,0,100,9,0,132,0,0,90,7,0,100,10,0, + 100,11,0,132,0,0,90,8,0,100,12,0,100,13,0,132, + 0,0,90,9,0,100,14,0,100,15,0,132,0,0,90,10, + 0,100,16,0,100,17,0,132,0,0,90,11,0,100,18,0, + 100,19,0,132,0,0,90,12,0,100,20,0,83,41,21,218, + 14,95,78,97,109,101,115,112,97,99,101,80,97,116,104,97, + 38,1,0,0,82,101,112,114,101,115,101,110,116,115,32,97, + 32,110,97,109,101,115,112,97,99,101,32,112,97,99,107,97, + 103,101,39,115,32,112,97,116,104,46,32,32,73,116,32,117, + 115,101,115,32,116,104,101,32,109,111,100,117,108,101,32,110, + 97,109,101,10,32,32,32,32,116,111,32,102,105,110,100,32, + 105,116,115,32,112,97,114,101,110,116,32,109,111,100,117,108, + 101,44,32,97,110,100,32,102,114,111,109,32,116,104,101,114, + 101,32,105,116,32,108,111,111,107,115,32,117,112,32,116,104, + 101,32,112,97,114,101,110,116,39,115,10,32,32,32,32,95, + 95,112,97,116,104,95,95,46,32,32,87,104,101,110,32,116, + 104,105,115,32,99,104,97,110,103,101,115,44,32,116,104,101, + 32,109,111,100,117,108,101,39,115,32,111,119,110,32,112,97, + 116,104,32,105,115,32,114,101,99,111,109,112,117,116,101,100, + 44,10,32,32,32,32,117,115,105,110,103,32,112,97,116,104, + 95,102,105,110,100,101,114,46,32,32,70,111,114,32,116,111, + 112,45,108,101,118,101,108,32,109,111,100,117,108,101,115,44, + 32,116,104,101,32,112,97,114,101,110,116,32,109,111,100,117, + 108,101,39,115,32,112,97,116,104,10,32,32,32,32,105,115, + 32,115,121,115,46,112,97,116,104,46,99,4,0,0,0,0, + 0,0,0,4,0,0,0,2,0,0,0,67,0,0,0,115, + 52,0,0,0,124,1,0,124,0,0,95,0,0,124,2,0, + 124,0,0,95,1,0,116,2,0,124,0,0,106,3,0,131, + 0,0,131,1,0,124,0,0,95,4,0,124,3,0,124,0, + 0,95,5,0,100,0,0,83,41,1,78,41,6,218,5,95, + 110,97,109,101,218,5,95,112,97,116,104,114,93,0,0,0, + 218,16,95,103,101,116,95,112,97,114,101,110,116,95,112,97, + 116,104,218,17,95,108,97,115,116,95,112,97,114,101,110,116, + 95,112,97,116,104,218,12,95,112,97,116,104,95,102,105,110, + 100,101,114,41,4,114,100,0,0,0,114,98,0,0,0,114, + 35,0,0,0,218,11,112,97,116,104,95,102,105,110,100,101, + 114,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, + 114,179,0,0,0,169,3,0,0,115,8,0,0,0,0,1, + 9,1,9,1,21,1,122,23,95,78,97,109,101,115,112,97, + 99,101,80,97,116,104,46,95,95,105,110,105,116,95,95,99, + 1,0,0,0,0,0,0,0,4,0,0,0,3,0,0,0, + 67,0,0,0,115,53,0,0,0,124,0,0,106,0,0,106, + 1,0,100,1,0,131,1,0,92,3,0,125,1,0,125,2, + 0,125,3,0,124,2,0,100,2,0,107,2,0,114,43,0, + 100,6,0,83,124,1,0,100,5,0,102,2,0,83,41,7, + 122,62,82,101,116,117,114,110,115,32,97,32,116,117,112,108, + 101,32,111,102,32,40,112,97,114,101,110,116,45,109,111,100, + 117,108,101,45,110,97,109,101,44,32,112,97,114,101,110,116, + 45,112,97,116,104,45,97,116,116,114,45,110,97,109,101,41, + 114,58,0,0,0,114,30,0,0,0,114,7,0,0,0,114, + 35,0,0,0,90,8,95,95,112,97,116,104,95,95,41,2, + 122,3,115,121,115,122,4,112,97,116,104,41,2,114,225,0, + 0,0,114,32,0,0,0,41,4,114,100,0,0,0,114,216, + 0,0,0,218,3,100,111,116,90,2,109,101,114,4,0,0, + 0,114,4,0,0,0,114,5,0,0,0,218,23,95,102,105, + 110,100,95,112,97,114,101,110,116,95,112,97,116,104,95,110, + 97,109,101,115,175,3,0,0,115,8,0,0,0,0,2,27, + 1,12,2,4,3,122,38,95,78,97,109,101,115,112,97,99, + 101,80,97,116,104,46,95,102,105,110,100,95,112,97,114,101, + 110,116,95,112,97,116,104,95,110,97,109,101,115,99,1,0, + 0,0,0,0,0,0,3,0,0,0,3,0,0,0,67,0, + 0,0,115,38,0,0,0,124,0,0,106,0,0,131,0,0, + 92,2,0,125,1,0,125,2,0,116,1,0,116,2,0,106, + 3,0,124,1,0,25,124,2,0,131,2,0,83,41,1,78, + 41,4,114,232,0,0,0,114,110,0,0,0,114,7,0,0, + 0,218,7,109,111,100,117,108,101,115,41,3,114,100,0,0, + 0,90,18,112,97,114,101,110,116,95,109,111,100,117,108,101, + 95,110,97,109,101,90,14,112,97,116,104,95,97,116,116,114, + 95,110,97,109,101,114,4,0,0,0,114,4,0,0,0,114, + 5,0,0,0,114,227,0,0,0,185,3,0,0,115,4,0, + 0,0,0,1,18,1,122,31,95,78,97,109,101,115,112,97, + 99,101,80,97,116,104,46,95,103,101,116,95,112,97,114,101, + 110,116,95,112,97,116,104,99,1,0,0,0,0,0,0,0, + 3,0,0,0,3,0,0,0,67,0,0,0,115,118,0,0, + 0,116,0,0,124,0,0,106,1,0,131,0,0,131,1,0, + 125,1,0,124,1,0,124,0,0,106,2,0,107,3,0,114, + 111,0,124,0,0,106,3,0,124,0,0,106,4,0,124,1, + 0,131,2,0,125,2,0,124,2,0,100,0,0,107,9,0, + 114,102,0,124,2,0,106,5,0,100,0,0,107,8,0,114, + 102,0,124,2,0,106,6,0,114,102,0,124,2,0,106,6, + 0,124,0,0,95,7,0,124,1,0,124,0,0,95,2,0, + 124,0,0,106,7,0,83,41,1,78,41,8,114,93,0,0, + 0,114,227,0,0,0,114,228,0,0,0,114,229,0,0,0, + 114,225,0,0,0,114,120,0,0,0,114,150,0,0,0,114, + 226,0,0,0,41,3,114,100,0,0,0,90,11,112,97,114, + 101,110,116,95,112,97,116,104,114,158,0,0,0,114,4,0, + 0,0,114,4,0,0,0,114,5,0,0,0,218,12,95,114, + 101,99,97,108,99,117,108,97,116,101,189,3,0,0,115,16, + 0,0,0,0,2,18,1,15,1,21,3,27,1,9,1,12, + 1,9,1,122,27,95,78,97,109,101,115,112,97,99,101,80, + 97,116,104,46,95,114,101,99,97,108,99,117,108,97,116,101, + 99,1,0,0,0,0,0,0,0,1,0,0,0,2,0,0, + 0,67,0,0,0,115,16,0,0,0,116,0,0,124,0,0, + 106,1,0,131,0,0,131,1,0,83,41,1,78,41,2,218, + 4,105,116,101,114,114,234,0,0,0,41,1,114,100,0,0, + 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, + 218,8,95,95,105,116,101,114,95,95,202,3,0,0,115,2, + 0,0,0,0,1,122,23,95,78,97,109,101,115,112,97,99, + 101,80,97,116,104,46,95,95,105,116,101,114,95,95,99,1, + 0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,67, + 0,0,0,115,16,0,0,0,116,0,0,124,0,0,106,1, + 0,131,0,0,131,1,0,83,41,1,78,41,2,114,31,0, + 0,0,114,234,0,0,0,41,1,114,100,0,0,0,114,4, + 0,0,0,114,4,0,0,0,114,5,0,0,0,218,7,95, + 95,108,101,110,95,95,205,3,0,0,115,2,0,0,0,0, + 1,122,22,95,78,97,109,101,115,112,97,99,101,80,97,116, + 104,46,95,95,108,101,110,95,95,99,1,0,0,0,0,0, + 0,0,1,0,0,0,2,0,0,0,67,0,0,0,115,16, + 0,0,0,100,1,0,106,0,0,124,0,0,106,1,0,131, + 1,0,83,41,2,78,122,20,95,78,97,109,101,115,112,97, + 99,101,80,97,116,104,40,123,33,114,125,41,41,2,114,47, + 0,0,0,114,226,0,0,0,41,1,114,100,0,0,0,114, + 4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,8, + 95,95,114,101,112,114,95,95,208,3,0,0,115,2,0,0, + 0,0,1,122,23,95,78,97,109,101,115,112,97,99,101,80, + 97,116,104,46,95,95,114,101,112,114,95,95,99,2,0,0, + 0,0,0,0,0,2,0,0,0,2,0,0,0,67,0,0, + 0,115,16,0,0,0,124,1,0,124,0,0,106,0,0,131, + 0,0,107,6,0,83,41,1,78,41,1,114,234,0,0,0, + 41,2,114,100,0,0,0,218,4,105,116,101,109,114,4,0, + 0,0,114,4,0,0,0,114,5,0,0,0,218,12,95,95, + 99,111,110,116,97,105,110,115,95,95,211,3,0,0,115,2, + 0,0,0,0,1,122,27,95,78,97,109,101,115,112,97,99, + 101,80,97,116,104,46,95,95,99,111,110,116,97,105,110,115, + 95,95,99,2,0,0,0,0,0,0,0,2,0,0,0,2, + 0,0,0,67,0,0,0,115,20,0,0,0,124,0,0,106, + 0,0,106,1,0,124,1,0,131,1,0,1,100,0,0,83, + 41,1,78,41,2,114,226,0,0,0,114,157,0,0,0,41, + 2,114,100,0,0,0,114,239,0,0,0,114,4,0,0,0, + 114,4,0,0,0,114,5,0,0,0,114,157,0,0,0,214, + 3,0,0,115,2,0,0,0,0,1,122,21,95,78,97,109, + 101,115,112,97,99,101,80,97,116,104,46,97,112,112,101,110, + 100,78,41,13,114,105,0,0,0,114,104,0,0,0,114,106, + 0,0,0,114,107,0,0,0,114,179,0,0,0,114,232,0, + 0,0,114,227,0,0,0,114,234,0,0,0,114,236,0,0, + 0,114,237,0,0,0,114,238,0,0,0,114,240,0,0,0, + 114,157,0,0,0,114,4,0,0,0,114,4,0,0,0,114, + 4,0,0,0,114,5,0,0,0,114,224,0,0,0,162,3, + 0,0,115,20,0,0,0,12,5,6,2,12,6,12,10,12, + 4,12,13,12,3,12,3,12,3,12,3,114,224,0,0,0, + 99,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0, + 0,64,0,0,0,115,118,0,0,0,101,0,0,90,1,0, + 100,0,0,90,2,0,100,1,0,100,2,0,132,0,0,90, + 3,0,101,4,0,100,3,0,100,4,0,132,0,0,131,1, + 0,90,5,0,100,5,0,100,6,0,132,0,0,90,6,0, + 100,7,0,100,8,0,132,0,0,90,7,0,100,9,0,100, + 10,0,132,0,0,90,8,0,100,11,0,100,12,0,132,0, + 0,90,9,0,100,13,0,100,14,0,132,0,0,90,10,0, + 100,15,0,100,16,0,132,0,0,90,11,0,100,17,0,83, + 41,18,218,16,95,78,97,109,101,115,112,97,99,101,76,111, + 97,100,101,114,99,4,0,0,0,0,0,0,0,4,0,0, + 0,4,0,0,0,67,0,0,0,115,25,0,0,0,116,0, + 0,124,1,0,124,2,0,124,3,0,131,3,0,124,0,0, + 95,1,0,100,0,0,83,41,1,78,41,2,114,224,0,0, + 0,114,226,0,0,0,41,4,114,100,0,0,0,114,98,0, + 0,0,114,35,0,0,0,114,230,0,0,0,114,4,0,0, + 0,114,4,0,0,0,114,5,0,0,0,114,179,0,0,0, + 220,3,0,0,115,2,0,0,0,0,1,122,25,95,78,97, + 109,101,115,112,97,99,101,76,111,97,100,101,114,46,95,95, + 105,110,105,116,95,95,99,2,0,0,0,0,0,0,0,2, + 0,0,0,2,0,0,0,67,0,0,0,115,16,0,0,0, + 100,1,0,106,0,0,124,1,0,106,1,0,131,1,0,83, + 41,2,122,115,82,101,116,117,114,110,32,114,101,112,114,32, + 102,111,114,32,116,104,101,32,109,111,100,117,108,101,46,10, + 10,32,32,32,32,32,32,32,32,84,104,101,32,109,101,116, + 104,111,100,32,105,115,32,100,101,112,114,101,99,97,116,101, + 100,46,32,32,84,104,101,32,105,109,112,111,114,116,32,109, + 97,99,104,105,110,101,114,121,32,100,111,101,115,32,116,104, + 101,32,106,111,98,32,105,116,115,101,108,102,46,10,10,32, + 32,32,32,32,32,32,32,122,25,60,109,111,100,117,108,101, + 32,123,33,114,125,32,40,110,97,109,101,115,112,97,99,101, + 41,62,41,2,114,47,0,0,0,114,105,0,0,0,41,2, + 114,164,0,0,0,114,184,0,0,0,114,4,0,0,0,114, + 4,0,0,0,114,5,0,0,0,218,11,109,111,100,117,108, + 101,95,114,101,112,114,223,3,0,0,115,2,0,0,0,0, + 7,122,28,95,78,97,109,101,115,112,97,99,101,76,111,97, + 100,101,114,46,109,111,100,117,108,101,95,114,101,112,114,99, + 2,0,0,0,0,0,0,0,2,0,0,0,1,0,0,0, + 67,0,0,0,115,4,0,0,0,100,1,0,83,41,2,78, + 84,114,4,0,0,0,41,2,114,100,0,0,0,114,119,0, + 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0, + 0,114,153,0,0,0,232,3,0,0,115,2,0,0,0,0, + 1,122,27,95,78,97,109,101,115,112,97,99,101,76,111,97, + 100,101,114,46,105,115,95,112,97,99,107,97,103,101,99,2, + 0,0,0,0,0,0,0,2,0,0,0,1,0,0,0,67, + 0,0,0,115,4,0,0,0,100,1,0,83,41,2,78,114, + 30,0,0,0,114,4,0,0,0,41,2,114,100,0,0,0, + 114,119,0,0,0,114,4,0,0,0,114,4,0,0,0,114, + 5,0,0,0,114,196,0,0,0,235,3,0,0,115,2,0, + 0,0,0,1,122,27,95,78,97,109,101,115,112,97,99,101, + 76,111,97,100,101,114,46,103,101,116,95,115,111,117,114,99, + 101,99,2,0,0,0,0,0,0,0,2,0,0,0,6,0, + 0,0,67,0,0,0,115,22,0,0,0,116,0,0,100,1, + 0,100,2,0,100,3,0,100,4,0,100,5,0,131,3,1, + 83,41,6,78,114,30,0,0,0,122,8,60,115,116,114,105, + 110,103,62,114,183,0,0,0,114,198,0,0,0,84,41,1, + 114,199,0,0,0,41,2,114,100,0,0,0,114,119,0,0, + 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, + 114,181,0,0,0,238,3,0,0,115,2,0,0,0,0,1, + 122,25,95,78,97,109,101,115,112,97,99,101,76,111,97,100, + 101,114,46,103,101,116,95,99,111,100,101,99,2,0,0,0, + 0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,0, + 115,4,0,0,0,100,1,0,83,41,2,122,42,85,115,101, + 32,100,101,102,97,117,108,116,32,115,101,109,97,110,116,105, + 99,115,32,102,111,114,32,109,111,100,117,108,101,32,99,114, + 101,97,116,105,111,110,46,78,114,4,0,0,0,41,2,114, + 100,0,0,0,114,158,0,0,0,114,4,0,0,0,114,4, + 0,0,0,114,5,0,0,0,114,180,0,0,0,241,3,0, + 0,115,0,0,0,0,122,30,95,78,97,109,101,115,112,97, + 99,101,76,111,97,100,101,114,46,99,114,101,97,116,101,95, + 109,111,100,117,108,101,99,2,0,0,0,0,0,0,0,2, + 0,0,0,1,0,0,0,67,0,0,0,115,4,0,0,0, + 100,0,0,83,41,1,78,114,4,0,0,0,41,2,114,100, + 0,0,0,114,184,0,0,0,114,4,0,0,0,114,4,0, + 0,0,114,5,0,0,0,114,185,0,0,0,244,3,0,0, + 115,2,0,0,0,0,1,122,28,95,78,97,109,101,115,112, + 97,99,101,76,111,97,100,101,114,46,101,120,101,99,95,109, + 111,100,117,108,101,99,2,0,0,0,0,0,0,0,2,0, + 0,0,3,0,0,0,67,0,0,0,115,35,0,0,0,116, + 0,0,106,1,0,100,1,0,124,0,0,106,2,0,131,2, + 0,1,116,0,0,106,3,0,124,0,0,124,1,0,131,2, + 0,83,41,2,122,98,76,111,97,100,32,97,32,110,97,109, + 101,115,112,97,99,101,32,109,111,100,117,108,101,46,10,10, + 32,32,32,32,32,32,32,32,84,104,105,115,32,109,101,116, + 104,111,100,32,105,115,32,100,101,112,114,101,99,97,116,101, + 100,46,32,32,85,115,101,32,101,120,101,99,95,109,111,100, + 117,108,101,40,41,32,105,110,115,116,101,97,100,46,10,10, + 32,32,32,32,32,32,32,32,122,38,110,97,109,101,115,112, + 97,99,101,32,109,111,100,117,108,101,32,108,111,97,100,101, + 100,32,119,105,116,104,32,112,97,116,104,32,123,33,114,125, + 41,4,114,114,0,0,0,114,129,0,0,0,114,226,0,0, + 0,114,186,0,0,0,41,2,114,100,0,0,0,114,119,0, + 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0, + 0,114,187,0,0,0,247,3,0,0,115,6,0,0,0,0, + 7,9,1,10,1,122,28,95,78,97,109,101,115,112,97,99, + 101,76,111,97,100,101,114,46,108,111,97,100,95,109,111,100, + 117,108,101,78,41,12,114,105,0,0,0,114,104,0,0,0, + 114,106,0,0,0,114,179,0,0,0,114,177,0,0,0,114, + 242,0,0,0,114,153,0,0,0,114,196,0,0,0,114,181, + 0,0,0,114,180,0,0,0,114,185,0,0,0,114,187,0, + 0,0,114,4,0,0,0,114,4,0,0,0,114,4,0,0, + 0,114,5,0,0,0,114,241,0,0,0,219,3,0,0,115, + 16,0,0,0,12,1,12,3,18,9,12,3,12,3,12,3, + 12,3,12,3,114,241,0,0,0,99,0,0,0,0,0,0, + 0,0,0,0,0,0,5,0,0,0,64,0,0,0,115,160, + 0,0,0,101,0,0,90,1,0,100,0,0,90,2,0,100, + 1,0,90,3,0,101,4,0,100,2,0,100,3,0,132,0, + 0,131,1,0,90,5,0,101,4,0,100,4,0,100,5,0, + 132,0,0,131,1,0,90,6,0,101,4,0,100,6,0,100, + 7,0,132,0,0,131,1,0,90,7,0,101,4,0,100,8, + 0,100,9,0,132,0,0,131,1,0,90,8,0,101,4,0, + 100,10,0,100,11,0,100,12,0,132,1,0,131,1,0,90, + 9,0,101,4,0,100,10,0,100,10,0,100,13,0,100,14, + 0,132,2,0,131,1,0,90,10,0,101,4,0,100,10,0, + 100,15,0,100,16,0,132,1,0,131,1,0,90,11,0,100, + 10,0,83,41,17,218,10,80,97,116,104,70,105,110,100,101, + 114,122,62,77,101,116,97,32,112,97,116,104,32,102,105,110, + 100,101,114,32,102,111,114,32,115,121,115,46,112,97,116,104, + 32,97,110,100,32,112,97,99,107,97,103,101,32,95,95,112, + 97,116,104,95,95,32,97,116,116,114,105,98,117,116,101,115, + 46,99,1,0,0,0,0,0,0,0,2,0,0,0,4,0, + 0,0,67,0,0,0,115,55,0,0,0,120,48,0,116,0, + 0,106,1,0,106,2,0,131,0,0,68,93,31,0,125,1, + 0,116,3,0,124,1,0,100,1,0,131,2,0,114,16,0, + 124,1,0,106,4,0,131,0,0,1,113,16,0,87,100,2, + 0,83,41,3,122,125,67,97,108,108,32,116,104,101,32,105, + 110,118,97,108,105,100,97,116,101,95,99,97,99,104,101,115, + 40,41,32,109,101,116,104,111,100,32,111,110,32,97,108,108, + 32,112,97,116,104,32,101,110,116,114,121,32,102,105,110,100, + 101,114,115,10,32,32,32,32,32,32,32,32,115,116,111,114, + 101,100,32,105,110,32,115,121,115,46,112,97,116,104,95,105, + 109,112,111,114,116,101,114,95,99,97,99,104,101,115,32,40, + 119,104,101,114,101,32,105,109,112,108,101,109,101,110,116,101, + 100,41,46,218,17,105,110,118,97,108,105,100,97,116,101,95, + 99,97,99,104,101,115,78,41,5,114,7,0,0,0,218,19, + 112,97,116,104,95,105,109,112,111,114,116,101,114,95,99,97, + 99,104,101,218,6,118,97,108,117,101,115,114,108,0,0,0, + 114,244,0,0,0,41,2,114,164,0,0,0,218,6,102,105, + 110,100,101,114,114,4,0,0,0,114,4,0,0,0,114,5, + 0,0,0,114,244,0,0,0,9,4,0,0,115,6,0,0, + 0,0,4,22,1,15,1,122,28,80,97,116,104,70,105,110, + 100,101,114,46,105,110,118,97,108,105,100,97,116,101,95,99, + 97,99,104,101,115,99,2,0,0,0,0,0,0,0,3,0, + 0,0,12,0,0,0,67,0,0,0,115,107,0,0,0,116, + 0,0,106,1,0,100,1,0,107,9,0,114,41,0,116,0, + 0,106,1,0,12,114,41,0,116,2,0,106,3,0,100,2, + 0,116,4,0,131,2,0,1,120,59,0,116,0,0,106,1, + 0,68,93,44,0,125,2,0,121,14,0,124,2,0,124,1, + 0,131,1,0,83,87,113,51,0,4,116,5,0,107,10,0, + 114,94,0,1,1,1,119,51,0,89,113,51,0,88,113,51, + 0,87,100,1,0,83,100,1,0,83,41,3,122,113,83,101, + 97,114,99,104,32,115,101,113,117,101,110,99,101,32,111,102, + 32,104,111,111,107,115,32,102,111,114,32,97,32,102,105,110, + 100,101,114,32,102,111,114,32,39,112,97,116,104,39,46,10, + 10,32,32,32,32,32,32,32,32,73,102,32,39,104,111,111, + 107,115,39,32,105,115,32,102,97,108,115,101,32,116,104,101, + 110,32,117,115,101,32,115,121,115,46,112,97,116,104,95,104, + 111,111,107,115,46,10,10,32,32,32,32,32,32,32,32,78, + 122,23,115,121,115,46,112,97,116,104,95,104,111,111,107,115, + 32,105,115,32,101,109,112,116,121,41,6,114,7,0,0,0, + 218,10,112,97,116,104,95,104,111,111,107,115,114,60,0,0, + 0,114,61,0,0,0,114,118,0,0,0,114,99,0,0,0, + 41,3,114,164,0,0,0,114,35,0,0,0,90,4,104,111, + 111,107,114,4,0,0,0,114,4,0,0,0,114,5,0,0, + 0,218,11,95,112,97,116,104,95,104,111,111,107,115,17,4, + 0,0,115,16,0,0,0,0,7,25,1,16,1,16,1,3, + 1,14,1,13,1,12,2,122,22,80,97,116,104,70,105,110, + 100,101,114,46,95,112,97,116,104,95,104,111,111,107,115,99, + 2,0,0,0,0,0,0,0,3,0,0,0,19,0,0,0, + 67,0,0,0,115,123,0,0,0,124,1,0,100,1,0,107, + 2,0,114,53,0,121,16,0,116,0,0,106,1,0,131,0, + 0,125,1,0,87,110,22,0,4,116,2,0,107,10,0,114, + 52,0,1,1,1,100,2,0,83,89,110,1,0,88,121,17, + 0,116,3,0,106,4,0,124,1,0,25,125,2,0,87,110, + 46,0,4,116,5,0,107,10,0,114,118,0,1,1,1,124, + 0,0,106,6,0,124,1,0,131,1,0,125,2,0,124,2, + 0,116,3,0,106,4,0,124,1,0,60,89,110,1,0,88, + 124,2,0,83,41,3,122,210,71,101,116,32,116,104,101,32, + 102,105,110,100,101,114,32,102,111,114,32,116,104,101,32,112, + 97,116,104,32,101,110,116,114,121,32,102,114,111,109,32,115, + 121,115,46,112,97,116,104,95,105,109,112,111,114,116,101,114, + 95,99,97,99,104,101,46,10,10,32,32,32,32,32,32,32, + 32,73,102,32,116,104,101,32,112,97,116,104,32,101,110,116, + 114,121,32,105,115,32,110,111,116,32,105,110,32,116,104,101, + 32,99,97,99,104,101,44,32,102,105,110,100,32,116,104,101, + 32,97,112,112,114,111,112,114,105,97,116,101,32,102,105,110, + 100,101,114,10,32,32,32,32,32,32,32,32,97,110,100,32, + 99,97,99,104,101,32,105,116,46,32,73,102,32,110,111,32, + 102,105,110,100,101,114,32,105,115,32,97,118,97,105,108,97, + 98,108,101,44,32,115,116,111,114,101,32,78,111,110,101,46, + 10,10,32,32,32,32,32,32,32,32,114,30,0,0,0,78, + 41,7,114,3,0,0,0,114,45,0,0,0,218,17,70,105, + 108,101,78,111,116,70,111,117,110,100,69,114,114,111,114,114, + 7,0,0,0,114,245,0,0,0,114,131,0,0,0,114,249, + 0,0,0,41,3,114,164,0,0,0,114,35,0,0,0,114, + 247,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5, + 0,0,0,218,20,95,112,97,116,104,95,105,109,112,111,114, + 116,101,114,95,99,97,99,104,101,34,4,0,0,115,22,0, + 0,0,0,8,12,1,3,1,16,1,13,3,9,1,3,1, + 17,1,13,1,15,1,18,1,122,31,80,97,116,104,70,105, + 110,100,101,114,46,95,112,97,116,104,95,105,109,112,111,114, + 116,101,114,95,99,97,99,104,101,99,3,0,0,0,0,0, + 0,0,6,0,0,0,3,0,0,0,67,0,0,0,115,119, + 0,0,0,116,0,0,124,2,0,100,1,0,131,2,0,114, + 39,0,124,2,0,106,1,0,124,1,0,131,1,0,92,2, + 0,125,3,0,125,4,0,110,21,0,124,2,0,106,2,0, + 124,1,0,131,1,0,125,3,0,103,0,0,125,4,0,124, + 3,0,100,0,0,107,9,0,114,88,0,116,3,0,106,4, + 0,124,1,0,124,3,0,131,2,0,83,116,3,0,106,5, + 0,124,1,0,100,0,0,131,2,0,125,5,0,124,4,0, + 124,5,0,95,6,0,124,5,0,83,41,2,78,114,117,0, + 0,0,41,7,114,108,0,0,0,114,117,0,0,0,114,176, + 0,0,0,114,114,0,0,0,114,173,0,0,0,114,154,0, + 0,0,114,150,0,0,0,41,6,114,164,0,0,0,114,119, + 0,0,0,114,247,0,0,0,114,120,0,0,0,114,121,0, + 0,0,114,158,0,0,0,114,4,0,0,0,114,4,0,0, + 0,114,5,0,0,0,218,16,95,108,101,103,97,99,121,95, + 103,101,116,95,115,112,101,99,56,4,0,0,115,18,0,0, + 0,0,4,15,1,24,2,15,1,6,1,12,1,16,1,18, + 1,9,1,122,27,80,97,116,104,70,105,110,100,101,114,46, + 95,108,101,103,97,99,121,95,103,101,116,95,115,112,101,99, + 78,99,4,0,0,0,0,0,0,0,9,0,0,0,5,0, + 0,0,67,0,0,0,115,243,0,0,0,103,0,0,125,4, + 0,120,230,0,124,2,0,68,93,191,0,125,5,0,116,0, + 0,124,5,0,116,1,0,116,2,0,102,2,0,131,2,0, + 115,43,0,113,13,0,124,0,0,106,3,0,124,5,0,131, + 1,0,125,6,0,124,6,0,100,1,0,107,9,0,114,13, + 0,116,4,0,124,6,0,100,2,0,131,2,0,114,106,0, + 124,6,0,106,5,0,124,1,0,124,3,0,131,2,0,125, + 7,0,110,18,0,124,0,0,106,6,0,124,1,0,124,6, + 0,131,2,0,125,7,0,124,7,0,100,1,0,107,8,0, + 114,139,0,113,13,0,124,7,0,106,7,0,100,1,0,107, + 9,0,114,158,0,124,7,0,83,124,7,0,106,8,0,125, + 8,0,124,8,0,100,1,0,107,8,0,114,191,0,116,9, + 0,100,3,0,131,1,0,130,1,0,124,4,0,106,10,0, + 124,8,0,131,1,0,1,113,13,0,87,116,11,0,106,12, + 0,124,1,0,100,1,0,131,2,0,125,7,0,124,4,0, + 124,7,0,95,8,0,124,7,0,83,100,1,0,83,41,4, + 122,63,70,105,110,100,32,116,104,101,32,108,111,97,100,101, + 114,32,111,114,32,110,97,109,101,115,112,97,99,101,95,112, + 97,116,104,32,102,111,114,32,116,104,105,115,32,109,111,100, + 117,108,101,47,112,97,99,107,97,103,101,32,110,97,109,101, + 46,78,114,175,0,0,0,122,19,115,112,101,99,32,109,105, + 115,115,105,110,103,32,108,111,97,100,101,114,41,13,114,137, + 0,0,0,114,69,0,0,0,218,5,98,121,116,101,115,114, + 251,0,0,0,114,108,0,0,0,114,175,0,0,0,114,252, + 0,0,0,114,120,0,0,0,114,150,0,0,0,114,99,0, + 0,0,114,143,0,0,0,114,114,0,0,0,114,154,0,0, + 0,41,9,114,164,0,0,0,114,119,0,0,0,114,35,0, + 0,0,114,174,0,0,0,218,14,110,97,109,101,115,112,97, + 99,101,95,112,97,116,104,90,5,101,110,116,114,121,114,247, + 0,0,0,114,158,0,0,0,114,121,0,0,0,114,4,0, + 0,0,114,4,0,0,0,114,5,0,0,0,218,9,95,103, + 101,116,95,115,112,101,99,71,4,0,0,115,40,0,0,0, + 0,5,6,1,13,1,21,1,3,1,15,1,12,1,15,1, + 21,2,18,1,12,1,3,1,15,1,4,1,9,1,12,1, + 12,5,17,2,18,1,9,1,122,20,80,97,116,104,70,105, + 110,100,101,114,46,95,103,101,116,95,115,112,101,99,99,4, + 0,0,0,0,0,0,0,6,0,0,0,4,0,0,0,67, + 0,0,0,115,140,0,0,0,124,2,0,100,1,0,107,8, + 0,114,21,0,116,0,0,106,1,0,125,2,0,124,0,0, + 106,2,0,124,1,0,124,2,0,124,3,0,131,3,0,125, + 4,0,124,4,0,100,1,0,107,8,0,114,58,0,100,1, + 0,83,124,4,0,106,3,0,100,1,0,107,8,0,114,132, + 0,124,4,0,106,4,0,125,5,0,124,5,0,114,125,0, + 100,2,0,124,4,0,95,5,0,116,6,0,124,1,0,124, + 5,0,124,0,0,106,2,0,131,3,0,124,4,0,95,4, + 0,124,4,0,83,100,1,0,83,110,4,0,124,4,0,83, + 100,1,0,83,41,3,122,98,102,105,110,100,32,116,104,101, + 32,109,111,100,117,108,101,32,111,110,32,115,121,115,46,112, + 97,116,104,32,111,114,32,39,112,97,116,104,39,32,98,97, + 115,101,100,32,111,110,32,115,121,115,46,112,97,116,104,95, + 104,111,111,107,115,32,97,110,100,10,32,32,32,32,32,32, + 32,32,115,121,115,46,112,97,116,104,95,105,109,112,111,114, + 116,101,114,95,99,97,99,104,101,46,78,90,9,110,97,109, + 101,115,112,97,99,101,41,7,114,7,0,0,0,114,35,0, + 0,0,114,255,0,0,0,114,120,0,0,0,114,150,0,0, + 0,114,152,0,0,0,114,224,0,0,0,41,6,114,164,0, + 0,0,114,119,0,0,0,114,35,0,0,0,114,174,0,0, + 0,114,158,0,0,0,114,254,0,0,0,114,4,0,0,0, + 114,4,0,0,0,114,5,0,0,0,114,175,0,0,0,103, + 4,0,0,115,26,0,0,0,0,4,12,1,9,1,21,1, + 12,1,4,1,15,1,9,1,6,3,9,1,24,1,4,2, + 7,2,122,20,80,97,116,104,70,105,110,100,101,114,46,102, + 105,110,100,95,115,112,101,99,99,3,0,0,0,0,0,0, + 0,4,0,0,0,3,0,0,0,67,0,0,0,115,41,0, + 0,0,124,0,0,106,0,0,124,1,0,124,2,0,131,2, + 0,125,3,0,124,3,0,100,1,0,107,8,0,114,34,0, + 100,1,0,83,124,3,0,106,1,0,83,41,2,122,170,102, + 105,110,100,32,116,104,101,32,109,111,100,117,108,101,32,111, + 110,32,115,121,115,46,112,97,116,104,32,111,114,32,39,112, + 97,116,104,39,32,98,97,115,101,100,32,111,110,32,115,121, + 115,46,112,97,116,104,95,104,111,111,107,115,32,97,110,100, + 10,32,32,32,32,32,32,32,32,115,121,115,46,112,97,116, + 104,95,105,109,112,111,114,116,101,114,95,99,97,99,104,101, + 46,10,10,32,32,32,32,32,32,32,32,84,104,105,115,32, + 109,101,116,104,111,100,32,105,115,32,100,101,112,114,101,99, + 97,116,101,100,46,32,32,85,115,101,32,102,105,110,100,95, + 115,112,101,99,40,41,32,105,110,115,116,101,97,100,46,10, + 10,32,32,32,32,32,32,32,32,78,41,2,114,175,0,0, + 0,114,120,0,0,0,41,4,114,164,0,0,0,114,119,0, + 0,0,114,35,0,0,0,114,158,0,0,0,114,4,0,0, + 0,114,4,0,0,0,114,5,0,0,0,114,176,0,0,0, + 125,4,0,0,115,8,0,0,0,0,8,18,1,12,1,4, + 1,122,22,80,97,116,104,70,105,110,100,101,114,46,102,105, + 110,100,95,109,111,100,117,108,101,41,12,114,105,0,0,0, + 114,104,0,0,0,114,106,0,0,0,114,107,0,0,0,114, + 177,0,0,0,114,244,0,0,0,114,249,0,0,0,114,251, + 0,0,0,114,252,0,0,0,114,255,0,0,0,114,175,0, + 0,0,114,176,0,0,0,114,4,0,0,0,114,4,0,0, + 0,114,4,0,0,0,114,5,0,0,0,114,243,0,0,0, + 5,4,0,0,115,22,0,0,0,12,2,6,2,18,8,18, + 17,18,22,18,15,3,1,18,31,3,1,21,21,3,1,114, + 243,0,0,0,99,0,0,0,0,0,0,0,0,0,0,0, + 0,3,0,0,0,64,0,0,0,115,133,0,0,0,101,0, + 0,90,1,0,100,0,0,90,2,0,100,1,0,90,3,0, + 100,2,0,100,3,0,132,0,0,90,4,0,100,4,0,100, + 5,0,132,0,0,90,5,0,101,6,0,90,7,0,100,6, + 0,100,7,0,132,0,0,90,8,0,100,8,0,100,9,0, + 132,0,0,90,9,0,100,10,0,100,11,0,100,12,0,132, + 1,0,90,10,0,100,13,0,100,14,0,132,0,0,90,11, + 0,101,12,0,100,15,0,100,16,0,132,0,0,131,1,0, + 90,13,0,100,17,0,100,18,0,132,0,0,90,14,0,100, + 10,0,83,41,19,218,10,70,105,108,101,70,105,110,100,101, + 114,122,172,70,105,108,101,45,98,97,115,101,100,32,102,105, + 110,100,101,114,46,10,10,32,32,32,32,73,110,116,101,114, + 97,99,116,105,111,110,115,32,119,105,116,104,32,116,104,101, + 32,102,105,108,101,32,115,121,115,116,101,109,32,97,114,101, + 32,99,97,99,104,101,100,32,102,111,114,32,112,101,114,102, + 111,114,109,97,110,99,101,44,32,98,101,105,110,103,10,32, + 32,32,32,114,101,102,114,101,115,104,101,100,32,119,104,101, + 110,32,116,104,101,32,100,105,114,101,99,116,111,114,121,32, + 116,104,101,32,102,105,110,100,101,114,32,105,115,32,104,97, + 110,100,108,105,110,103,32,104,97,115,32,98,101,101,110,32, + 109,111,100,105,102,105,101,100,46,10,10,32,32,32,32,99, + 2,0,0,0,0,0,0,0,5,0,0,0,5,0,0,0, + 7,0,0,0,115,122,0,0,0,103,0,0,125,3,0,120, + 52,0,124,2,0,68,93,44,0,92,2,0,137,0,0,125, + 4,0,124,3,0,106,0,0,135,0,0,102,1,0,100,1, + 0,100,2,0,134,0,0,124,4,0,68,131,1,0,131,1, + 0,1,113,13,0,87,124,3,0,124,0,0,95,1,0,124, + 1,0,112,79,0,100,3,0,124,0,0,95,2,0,100,6, + 0,124,0,0,95,3,0,116,4,0,131,0,0,124,0,0, + 95,5,0,116,4,0,131,0,0,124,0,0,95,6,0,100, + 5,0,83,41,7,122,154,73,110,105,116,105,97,108,105,122, + 101,32,119,105,116,104,32,116,104,101,32,112,97,116,104,32, + 116,111,32,115,101,97,114,99,104,32,111,110,32,97,110,100, + 32,97,32,118,97,114,105,97,98,108,101,32,110,117,109,98, + 101,114,32,111,102,10,32,32,32,32,32,32,32,32,50,45, + 116,117,112,108,101,115,32,99,111,110,116,97,105,110,105,110, + 103,32,116,104,101,32,108,111,97,100,101,114,32,97,110,100, + 32,116,104,101,32,102,105,108,101,32,115,117,102,102,105,120, + 101,115,32,116,104,101,32,108,111,97,100,101,114,10,32,32, + 32,32,32,32,32,32,114,101,99,111,103,110,105,122,101,115, + 46,99,1,0,0,0,0,0,0,0,2,0,0,0,3,0, + 0,0,51,0,0,0,115,27,0,0,0,124,0,0,93,17, + 0,125,1,0,124,1,0,136,0,0,102,2,0,86,1,113, + 3,0,100,0,0,83,41,1,78,114,4,0,0,0,41,2, + 114,22,0,0,0,114,219,0,0,0,41,1,114,120,0,0, + 0,114,4,0,0,0,114,5,0,0,0,114,221,0,0,0, + 154,4,0,0,115,2,0,0,0,6,0,122,38,70,105,108, 101,70,105,110,100,101,114,46,95,95,105,110,105,116,95,95, - 99,1,0,0,0,0,0,0,0,1,0,0,0,2,0,0, - 0,67,0,0,0,115,13,0,0,0,100,3,0,124,0,0, - 95,0,0,100,2,0,83,41,4,122,31,73,110,118,97,108, - 105,100,97,116,101,32,116,104,101,32,100,105,114,101,99,116, - 111,114,121,32,109,116,105,109,101,46,114,29,0,0,0,78, - 114,87,0,0,0,41,1,114,2,1,0,0,41,1,114,100, + 46,60,108,111,99,97,108,115,62,46,60,103,101,110,101,120, + 112,114,62,114,58,0,0,0,114,29,0,0,0,78,114,87, + 0,0,0,41,7,114,143,0,0,0,218,8,95,108,111,97, + 100,101,114,115,114,35,0,0,0,218,11,95,112,97,116,104, + 95,109,116,105,109,101,218,3,115,101,116,218,11,95,112,97, + 116,104,95,99,97,99,104,101,218,19,95,114,101,108,97,120, + 101,100,95,112,97,116,104,95,99,97,99,104,101,41,5,114, + 100,0,0,0,114,35,0,0,0,218,14,108,111,97,100,101, + 114,95,100,101,116,97,105,108,115,90,7,108,111,97,100,101, + 114,115,114,160,0,0,0,114,4,0,0,0,41,1,114,120, + 0,0,0,114,5,0,0,0,114,179,0,0,0,148,4,0, + 0,115,16,0,0,0,0,4,6,1,19,1,36,1,9,2, + 15,1,9,1,12,1,122,19,70,105,108,101,70,105,110,100, + 101,114,46,95,95,105,110,105,116,95,95,99,1,0,0,0, + 0,0,0,0,1,0,0,0,2,0,0,0,67,0,0,0, + 115,13,0,0,0,100,3,0,124,0,0,95,0,0,100,2, + 0,83,41,4,122,31,73,110,118,97,108,105,100,97,116,101, + 32,116,104,101,32,100,105,114,101,99,116,111,114,121,32,109, + 116,105,109,101,46,114,29,0,0,0,78,114,87,0,0,0, + 41,1,114,2,1,0,0,41,1,114,100,0,0,0,114,4, + 0,0,0,114,4,0,0,0,114,5,0,0,0,114,244,0, + 0,0,162,4,0,0,115,2,0,0,0,0,2,122,28,70, + 105,108,101,70,105,110,100,101,114,46,105,110,118,97,108,105, + 100,97,116,101,95,99,97,99,104,101,115,99,2,0,0,0, + 0,0,0,0,3,0,0,0,2,0,0,0,67,0,0,0, + 115,59,0,0,0,124,0,0,106,0,0,124,1,0,131,1, + 0,125,2,0,124,2,0,100,1,0,107,8,0,114,37,0, + 100,1,0,103,0,0,102,2,0,83,124,2,0,106,1,0, + 124,2,0,106,2,0,112,55,0,103,0,0,102,2,0,83, + 41,2,122,197,84,114,121,32,116,111,32,102,105,110,100,32, + 97,32,108,111,97,100,101,114,32,102,111,114,32,116,104,101, + 32,115,112,101,99,105,102,105,101,100,32,109,111,100,117,108, + 101,44,32,111,114,32,116,104,101,32,110,97,109,101,115,112, + 97,99,101,10,32,32,32,32,32,32,32,32,112,97,99,107, + 97,103,101,32,112,111,114,116,105,111,110,115,46,32,82,101, + 116,117,114,110,115,32,40,108,111,97,100,101,114,44,32,108, + 105,115,116,45,111,102,45,112,111,114,116,105,111,110,115,41, + 46,10,10,32,32,32,32,32,32,32,32,84,104,105,115,32, + 109,101,116,104,111,100,32,105,115,32,100,101,112,114,101,99, + 97,116,101,100,46,32,32,85,115,101,32,102,105,110,100,95, + 115,112,101,99,40,41,32,105,110,115,116,101,97,100,46,10, + 10,32,32,32,32,32,32,32,32,78,41,3,114,175,0,0, + 0,114,120,0,0,0,114,150,0,0,0,41,3,114,100,0, + 0,0,114,119,0,0,0,114,158,0,0,0,114,4,0,0, + 0,114,4,0,0,0,114,5,0,0,0,114,117,0,0,0, + 168,4,0,0,115,8,0,0,0,0,7,15,1,12,1,10, + 1,122,22,70,105,108,101,70,105,110,100,101,114,46,102,105, + 110,100,95,108,111,97,100,101,114,99,6,0,0,0,0,0, + 0,0,7,0,0,0,7,0,0,0,67,0,0,0,115,40, + 0,0,0,124,1,0,124,2,0,124,3,0,131,2,0,125, + 6,0,116,0,0,124,2,0,124,3,0,100,1,0,124,6, + 0,100,2,0,124,4,0,131,2,2,83,41,3,78,114,120, + 0,0,0,114,150,0,0,0,41,1,114,161,0,0,0,41, + 7,114,100,0,0,0,114,159,0,0,0,114,119,0,0,0, + 114,35,0,0,0,90,4,115,109,115,108,114,174,0,0,0, + 114,120,0,0,0,114,4,0,0,0,114,4,0,0,0,114, + 5,0,0,0,114,255,0,0,0,180,4,0,0,115,6,0, + 0,0,0,1,15,1,18,1,122,20,70,105,108,101,70,105, + 110,100,101,114,46,95,103,101,116,95,115,112,101,99,78,99, + 3,0,0,0,0,0,0,0,14,0,0,0,15,0,0,0, + 67,0,0,0,115,228,1,0,0,100,1,0,125,3,0,124, + 1,0,106,0,0,100,2,0,131,1,0,100,3,0,25,125, + 4,0,121,34,0,116,1,0,124,0,0,106,2,0,112,49, + 0,116,3,0,106,4,0,131,0,0,131,1,0,106,5,0, + 125,5,0,87,110,24,0,4,116,6,0,107,10,0,114,85, + 0,1,1,1,100,10,0,125,5,0,89,110,1,0,88,124, + 5,0,124,0,0,106,7,0,107,3,0,114,120,0,124,0, + 0,106,8,0,131,0,0,1,124,5,0,124,0,0,95,7, + 0,116,9,0,131,0,0,114,153,0,124,0,0,106,10,0, + 125,6,0,124,4,0,106,11,0,131,0,0,125,7,0,110, + 15,0,124,0,0,106,12,0,125,6,0,124,4,0,125,7, + 0,124,7,0,124,6,0,107,6,0,114,45,1,116,13,0, + 124,0,0,106,2,0,124,4,0,131,2,0,125,8,0,120, + 100,0,124,0,0,106,14,0,68,93,77,0,92,2,0,125, + 9,0,125,10,0,100,5,0,124,9,0,23,125,11,0,116, + 13,0,124,8,0,124,11,0,131,2,0,125,12,0,116,15, + 0,124,12,0,131,1,0,114,208,0,124,0,0,106,16,0, + 124,10,0,124,1,0,124,12,0,124,8,0,103,1,0,124, + 2,0,131,5,0,83,113,208,0,87,116,17,0,124,8,0, + 131,1,0,125,3,0,120,120,0,124,0,0,106,14,0,68, + 93,109,0,92,2,0,125,9,0,125,10,0,116,13,0,124, + 0,0,106,2,0,124,4,0,124,9,0,23,131,2,0,125, + 12,0,116,18,0,106,19,0,100,6,0,124,12,0,100,7, + 0,100,3,0,131,2,1,1,124,7,0,124,9,0,23,124, + 6,0,107,6,0,114,55,1,116,15,0,124,12,0,131,1, + 0,114,55,1,124,0,0,106,16,0,124,10,0,124,1,0, + 124,12,0,100,8,0,124,2,0,131,5,0,83,113,55,1, + 87,124,3,0,114,224,1,116,18,0,106,19,0,100,9,0, + 124,8,0,131,2,0,1,116,18,0,106,20,0,124,1,0, + 100,8,0,131,2,0,125,13,0,124,8,0,103,1,0,124, + 13,0,95,21,0,124,13,0,83,100,8,0,83,41,11,122, + 125,84,114,121,32,116,111,32,102,105,110,100,32,97,32,108, + 111,97,100,101,114,32,102,111,114,32,116,104,101,32,115,112, + 101,99,105,102,105,101,100,32,109,111,100,117,108,101,44,32, + 111,114,32,116,104,101,32,110,97,109,101,115,112,97,99,101, + 10,32,32,32,32,32,32,32,32,112,97,99,107,97,103,101, + 32,112,111,114,116,105,111,110,115,46,32,82,101,116,117,114, + 110,115,32,40,108,111,97,100,101,114,44,32,108,105,115,116, + 45,111,102,45,112,111,114,116,105,111,110,115,41,46,70,114, + 58,0,0,0,114,56,0,0,0,114,29,0,0,0,114,179, + 0,0,0,122,9,116,114,121,105,110,103,32,123,125,90,9, + 118,101,114,98,111,115,105,116,121,78,122,25,112,111,115,115, + 105,98,108,101,32,110,97,109,101,115,112,97,99,101,32,102, + 111,114,32,123,125,114,87,0,0,0,41,22,114,32,0,0, + 0,114,39,0,0,0,114,35,0,0,0,114,3,0,0,0, + 114,45,0,0,0,114,213,0,0,0,114,40,0,0,0,114, + 2,1,0,0,218,11,95,102,105,108,108,95,99,97,99,104, + 101,114,6,0,0,0,114,5,1,0,0,114,88,0,0,0, + 114,4,1,0,0,114,28,0,0,0,114,1,1,0,0,114, + 44,0,0,0,114,255,0,0,0,114,46,0,0,0,114,114, + 0,0,0,114,129,0,0,0,114,154,0,0,0,114,150,0, + 0,0,41,14,114,100,0,0,0,114,119,0,0,0,114,174, + 0,0,0,90,12,105,115,95,110,97,109,101,115,112,97,99, + 101,90,11,116,97,105,108,95,109,111,100,117,108,101,114,126, + 0,0,0,90,5,99,97,99,104,101,90,12,99,97,99,104, + 101,95,109,111,100,117,108,101,90,9,98,97,115,101,95,112, + 97,116,104,114,219,0,0,0,114,159,0,0,0,90,13,105, + 110,105,116,95,102,105,108,101,110,97,109,101,90,9,102,117, + 108,108,95,112,97,116,104,114,158,0,0,0,114,4,0,0, + 0,114,4,0,0,0,114,5,0,0,0,114,175,0,0,0, + 185,4,0,0,115,70,0,0,0,0,3,6,1,19,1,3, + 1,34,1,13,1,11,1,15,1,10,1,9,2,9,1,9, + 1,15,2,9,1,6,2,12,1,18,1,22,1,10,1,15, + 1,12,1,32,4,12,2,22,1,22,1,22,1,16,1,12, + 1,15,1,14,1,6,1,16,1,18,1,12,1,4,1,122, + 20,70,105,108,101,70,105,110,100,101,114,46,102,105,110,100, + 95,115,112,101,99,99,1,0,0,0,0,0,0,0,9,0, + 0,0,13,0,0,0,67,0,0,0,115,11,1,0,0,124, + 0,0,106,0,0,125,1,0,121,31,0,116,1,0,106,2, + 0,124,1,0,112,33,0,116,1,0,106,3,0,131,0,0, + 131,1,0,125,2,0,87,110,33,0,4,116,4,0,116,5, + 0,116,6,0,102,3,0,107,10,0,114,75,0,1,1,1, + 103,0,0,125,2,0,89,110,1,0,88,116,7,0,106,8, + 0,106,9,0,100,1,0,131,1,0,115,112,0,116,10,0, + 124,2,0,131,1,0,124,0,0,95,11,0,110,111,0,116, + 10,0,131,0,0,125,3,0,120,90,0,124,2,0,68,93, + 82,0,125,4,0,124,4,0,106,12,0,100,2,0,131,1, + 0,92,3,0,125,5,0,125,6,0,125,7,0,124,6,0, + 114,191,0,100,3,0,106,13,0,124,5,0,124,7,0,106, + 14,0,131,0,0,131,2,0,125,8,0,110,6,0,124,5, + 0,125,8,0,124,3,0,106,15,0,124,8,0,131,1,0, + 1,113,128,0,87,124,3,0,124,0,0,95,11,0,116,7, + 0,106,8,0,106,9,0,116,16,0,131,1,0,114,7,1, + 100,4,0,100,5,0,132,0,0,124,2,0,68,131,1,0, + 124,0,0,95,17,0,100,6,0,83,41,7,122,68,70,105, + 108,108,32,116,104,101,32,99,97,99,104,101,32,111,102,32, + 112,111,116,101,110,116,105,97,108,32,109,111,100,117,108,101, + 115,32,97,110,100,32,112,97,99,107,97,103,101,115,32,102, + 111,114,32,116,104,105,115,32,100,105,114,101,99,116,111,114, + 121,46,114,0,0,0,0,114,58,0,0,0,122,5,123,125, + 46,123,125,99,1,0,0,0,0,0,0,0,2,0,0,0, + 3,0,0,0,83,0,0,0,115,28,0,0,0,104,0,0, + 124,0,0,93,18,0,125,1,0,124,1,0,106,0,0,131, + 0,0,146,2,0,113,6,0,83,114,4,0,0,0,41,1, + 114,88,0,0,0,41,2,114,22,0,0,0,90,2,102,110, + 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,250, + 9,60,115,101,116,99,111,109,112,62,4,5,0,0,115,2, + 0,0,0,9,0,122,41,70,105,108,101,70,105,110,100,101, + 114,46,95,102,105,108,108,95,99,97,99,104,101,46,60,108, + 111,99,97,108,115,62,46,60,115,101,116,99,111,109,112,62, + 78,41,18,114,35,0,0,0,114,3,0,0,0,90,7,108, + 105,115,116,100,105,114,114,45,0,0,0,114,250,0,0,0, + 218,15,80,101,114,109,105,115,115,105,111,110,69,114,114,111, + 114,218,18,78,111,116,65,68,105,114,101,99,116,111,114,121, + 69,114,114,111,114,114,7,0,0,0,114,8,0,0,0,114, + 9,0,0,0,114,3,1,0,0,114,4,1,0,0,114,83, + 0,0,0,114,47,0,0,0,114,88,0,0,0,218,3,97, + 100,100,114,10,0,0,0,114,5,1,0,0,41,9,114,100, + 0,0,0,114,35,0,0,0,90,8,99,111,110,116,101,110, + 116,115,90,21,108,111,119,101,114,95,115,117,102,102,105,120, + 95,99,111,110,116,101,110,116,115,114,239,0,0,0,114,98, + 0,0,0,114,231,0,0,0,114,219,0,0,0,90,8,110, + 101,119,95,110,97,109,101,114,4,0,0,0,114,4,0,0, + 0,114,5,0,0,0,114,7,1,0,0,231,4,0,0,115, + 34,0,0,0,0,2,9,1,3,1,31,1,22,3,11,3, + 18,1,18,7,9,1,13,1,24,1,6,1,27,2,6,1, + 17,1,9,1,18,1,122,22,70,105,108,101,70,105,110,100, + 101,114,46,95,102,105,108,108,95,99,97,99,104,101,99,1, + 0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,7, + 0,0,0,115,25,0,0,0,135,0,0,135,1,0,102,2, + 0,100,1,0,100,2,0,134,0,0,125,2,0,124,2,0, + 83,41,3,97,20,1,0,0,65,32,99,108,97,115,115,32, + 109,101,116,104,111,100,32,119,104,105,99,104,32,114,101,116, + 117,114,110,115,32,97,32,99,108,111,115,117,114,101,32,116, + 111,32,117,115,101,32,111,110,32,115,121,115,46,112,97,116, + 104,95,104,111,111,107,10,32,32,32,32,32,32,32,32,119, + 104,105,99,104,32,119,105,108,108,32,114,101,116,117,114,110, + 32,97,110,32,105,110,115,116,97,110,99,101,32,117,115,105, + 110,103,32,116,104,101,32,115,112,101,99,105,102,105,101,100, + 32,108,111,97,100,101,114,115,32,97,110,100,32,116,104,101, + 32,112,97,116,104,10,32,32,32,32,32,32,32,32,99,97, + 108,108,101,100,32,111,110,32,116,104,101,32,99,108,111,115, + 117,114,101,46,10,10,32,32,32,32,32,32,32,32,73,102, + 32,116,104,101,32,112,97,116,104,32,99,97,108,108,101,100, + 32,111,110,32,116,104,101,32,99,108,111,115,117,114,101,32, + 105,115,32,110,111,116,32,97,32,100,105,114,101,99,116,111, + 114,121,44,32,73,109,112,111,114,116,69,114,114,111,114,32, + 105,115,10,32,32,32,32,32,32,32,32,114,97,105,115,101, + 100,46,10,10,32,32,32,32,32,32,32,32,99,1,0,0, + 0,0,0,0,0,1,0,0,0,4,0,0,0,19,0,0, + 0,115,43,0,0,0,116,0,0,124,0,0,131,1,0,115, + 30,0,116,1,0,100,1,0,100,2,0,124,0,0,131,1, + 1,130,1,0,136,0,0,124,0,0,136,1,0,140,1,0, + 83,41,3,122,45,80,97,116,104,32,104,111,111,107,32,102, + 111,114,32,105,109,112,111,114,116,108,105,98,46,109,97,99, + 104,105,110,101,114,121,46,70,105,108,101,70,105,110,100,101, + 114,46,122,30,111,110,108,121,32,100,105,114,101,99,116,111, + 114,105,101,115,32,97,114,101,32,115,117,112,112,111,114,116, + 101,100,114,35,0,0,0,41,2,114,46,0,0,0,114,99, + 0,0,0,41,1,114,35,0,0,0,41,2,114,164,0,0, + 0,114,6,1,0,0,114,4,0,0,0,114,5,0,0,0, + 218,24,112,97,116,104,95,104,111,111,107,95,102,111,114,95, + 70,105,108,101,70,105,110,100,101,114,16,5,0,0,115,6, + 0,0,0,0,2,12,1,18,1,122,54,70,105,108,101,70, + 105,110,100,101,114,46,112,97,116,104,95,104,111,111,107,46, + 60,108,111,99,97,108,115,62,46,112,97,116,104,95,104,111, + 111,107,95,102,111,114,95,70,105,108,101,70,105,110,100,101, + 114,114,4,0,0,0,41,3,114,164,0,0,0,114,6,1, + 0,0,114,12,1,0,0,114,4,0,0,0,41,2,114,164, + 0,0,0,114,6,1,0,0,114,5,0,0,0,218,9,112, + 97,116,104,95,104,111,111,107,6,5,0,0,115,4,0,0, + 0,0,10,21,6,122,20,70,105,108,101,70,105,110,100,101, + 114,46,112,97,116,104,95,104,111,111,107,99,1,0,0,0, + 0,0,0,0,1,0,0,0,2,0,0,0,67,0,0,0, + 115,16,0,0,0,100,1,0,106,0,0,124,0,0,106,1, + 0,131,1,0,83,41,2,78,122,16,70,105,108,101,70,105, + 110,100,101,114,40,123,33,114,125,41,41,2,114,47,0,0, + 0,114,35,0,0,0,41,1,114,100,0,0,0,114,4,0, + 0,0,114,4,0,0,0,114,5,0,0,0,114,238,0,0, + 0,24,5,0,0,115,2,0,0,0,0,1,122,19,70,105, + 108,101,70,105,110,100,101,114,46,95,95,114,101,112,114,95, + 95,41,15,114,105,0,0,0,114,104,0,0,0,114,106,0, + 0,0,114,107,0,0,0,114,179,0,0,0,114,244,0,0, + 0,114,123,0,0,0,114,176,0,0,0,114,117,0,0,0, + 114,255,0,0,0,114,175,0,0,0,114,7,1,0,0,114, + 177,0,0,0,114,13,1,0,0,114,238,0,0,0,114,4, 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0, - 0,0,114,244,0,0,0,161,4,0,0,115,2,0,0,0, - 0,2,122,28,70,105,108,101,70,105,110,100,101,114,46,105, - 110,118,97,108,105,100,97,116,101,95,99,97,99,104,101,115, - 99,2,0,0,0,0,0,0,0,3,0,0,0,2,0,0, - 0,67,0,0,0,115,59,0,0,0,124,0,0,106,0,0, - 124,1,0,131,1,0,125,2,0,124,2,0,100,1,0,107, - 8,0,114,37,0,100,1,0,103,0,0,102,2,0,83,124, - 2,0,106,1,0,124,2,0,106,2,0,112,55,0,103,0, - 0,102,2,0,83,41,2,122,197,84,114,121,32,116,111,32, - 102,105,110,100,32,97,32,108,111,97,100,101,114,32,102,111, - 114,32,116,104,101,32,115,112,101,99,105,102,105,101,100,32, - 109,111,100,117,108,101,44,32,111,114,32,116,104,101,32,110, - 97,109,101,115,112,97,99,101,10,32,32,32,32,32,32,32, - 32,112,97,99,107,97,103,101,32,112,111,114,116,105,111,110, - 115,46,32,82,101,116,117,114,110,115,32,40,108,111,97,100, - 101,114,44,32,108,105,115,116,45,111,102,45,112,111,114,116, - 105,111,110,115,41,46,10,10,32,32,32,32,32,32,32,32, - 84,104,105,115,32,109,101,116,104,111,100,32,105,115,32,100, - 101,112,114,101,99,97,116,101,100,46,32,32,85,115,101,32, - 102,105,110,100,95,115,112,101,99,40,41,32,105,110,115,116, - 101,97,100,46,10,10,32,32,32,32,32,32,32,32,78,41, - 3,114,175,0,0,0,114,120,0,0,0,114,150,0,0,0, - 41,3,114,100,0,0,0,114,119,0,0,0,114,158,0,0, - 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,117,0,0,0,167,4,0,0,115,8,0,0,0,0,7, - 15,1,12,1,10,1,122,22,70,105,108,101,70,105,110,100, - 101,114,46,102,105,110,100,95,108,111,97,100,101,114,99,6, - 0,0,0,0,0,0,0,7,0,0,0,7,0,0,0,67, - 0,0,0,115,40,0,0,0,124,1,0,124,2,0,124,3, - 0,131,2,0,125,6,0,116,0,0,124,2,0,124,3,0, - 100,1,0,124,6,0,100,2,0,124,4,0,131,2,2,83, - 41,3,78,114,120,0,0,0,114,150,0,0,0,41,1,114, - 161,0,0,0,41,7,114,100,0,0,0,114,159,0,0,0, - 114,119,0,0,0,114,35,0,0,0,90,4,115,109,115,108, - 114,174,0,0,0,114,120,0,0,0,114,4,0,0,0,114, - 4,0,0,0,114,5,0,0,0,114,255,0,0,0,179,4, - 0,0,115,6,0,0,0,0,1,15,1,18,1,122,20,70, - 105,108,101,70,105,110,100,101,114,46,95,103,101,116,95,115, - 112,101,99,78,99,3,0,0,0,0,0,0,0,14,0,0, - 0,15,0,0,0,67,0,0,0,115,228,1,0,0,100,1, - 0,125,3,0,124,1,0,106,0,0,100,2,0,131,1,0, - 100,3,0,25,125,4,0,121,34,0,116,1,0,124,0,0, - 106,2,0,112,49,0,116,3,0,106,4,0,131,0,0,131, - 1,0,106,5,0,125,5,0,87,110,24,0,4,116,6,0, - 107,10,0,114,85,0,1,1,1,100,10,0,125,5,0,89, - 110,1,0,88,124,5,0,124,0,0,106,7,0,107,3,0, - 114,120,0,124,0,0,106,8,0,131,0,0,1,124,5,0, - 124,0,0,95,7,0,116,9,0,131,0,0,114,153,0,124, - 0,0,106,10,0,125,6,0,124,4,0,106,11,0,131,0, - 0,125,7,0,110,15,0,124,0,0,106,12,0,125,6,0, - 124,4,0,125,7,0,124,7,0,124,6,0,107,6,0,114, - 45,1,116,13,0,124,0,0,106,2,0,124,4,0,131,2, - 0,125,8,0,120,100,0,124,0,0,106,14,0,68,93,77, - 0,92,2,0,125,9,0,125,10,0,100,5,0,124,9,0, - 23,125,11,0,116,13,0,124,8,0,124,11,0,131,2,0, - 125,12,0,116,15,0,124,12,0,131,1,0,114,208,0,124, - 0,0,106,16,0,124,10,0,124,1,0,124,12,0,124,8, - 0,103,1,0,124,2,0,131,5,0,83,113,208,0,87,116, - 17,0,124,8,0,131,1,0,125,3,0,120,120,0,124,0, - 0,106,14,0,68,93,109,0,92,2,0,125,9,0,125,10, - 0,116,13,0,124,0,0,106,2,0,124,4,0,124,9,0, - 23,131,2,0,125,12,0,116,18,0,106,19,0,100,6,0, - 124,12,0,100,7,0,100,3,0,131,2,1,1,124,7,0, - 124,9,0,23,124,6,0,107,6,0,114,55,1,116,15,0, - 124,12,0,131,1,0,114,55,1,124,0,0,106,16,0,124, - 10,0,124,1,0,124,12,0,100,8,0,124,2,0,131,5, - 0,83,113,55,1,87,124,3,0,114,224,1,116,18,0,106, - 19,0,100,9,0,124,8,0,131,2,0,1,116,18,0,106, - 20,0,124,1,0,100,8,0,131,2,0,125,13,0,124,8, - 0,103,1,0,124,13,0,95,21,0,124,13,0,83,100,8, - 0,83,41,11,122,125,84,114,121,32,116,111,32,102,105,110, - 100,32,97,32,108,111,97,100,101,114,32,102,111,114,32,116, - 104,101,32,115,112,101,99,105,102,105,101,100,32,109,111,100, - 117,108,101,44,32,111,114,32,116,104,101,32,110,97,109,101, - 115,112,97,99,101,10,32,32,32,32,32,32,32,32,112,97, - 99,107,97,103,101,32,112,111,114,116,105,111,110,115,46,32, - 82,101,116,117,114,110,115,32,40,108,111,97,100,101,114,44, - 32,108,105,115,116,45,111,102,45,112,111,114,116,105,111,110, - 115,41,46,70,114,58,0,0,0,114,56,0,0,0,114,29, - 0,0,0,114,179,0,0,0,122,9,116,114,121,105,110,103, - 32,123,125,90,9,118,101,114,98,111,115,105,116,121,78,122, - 25,112,111,115,115,105,98,108,101,32,110,97,109,101,115,112, - 97,99,101,32,102,111,114,32,123,125,114,87,0,0,0,41, - 22,114,32,0,0,0,114,39,0,0,0,114,35,0,0,0, - 114,3,0,0,0,114,45,0,0,0,114,213,0,0,0,114, - 40,0,0,0,114,2,1,0,0,218,11,95,102,105,108,108, - 95,99,97,99,104,101,114,6,0,0,0,114,5,1,0,0, - 114,88,0,0,0,114,4,1,0,0,114,28,0,0,0,114, - 1,1,0,0,114,44,0,0,0,114,255,0,0,0,114,46, - 0,0,0,114,114,0,0,0,114,129,0,0,0,114,154,0, - 0,0,114,150,0,0,0,41,14,114,100,0,0,0,114,119, - 0,0,0,114,174,0,0,0,90,12,105,115,95,110,97,109, - 101,115,112,97,99,101,90,11,116,97,105,108,95,109,111,100, - 117,108,101,114,126,0,0,0,90,5,99,97,99,104,101,90, - 12,99,97,99,104,101,95,109,111,100,117,108,101,90,9,98, - 97,115,101,95,112,97,116,104,114,219,0,0,0,114,159,0, - 0,0,90,13,105,110,105,116,95,102,105,108,101,110,97,109, - 101,90,9,102,117,108,108,95,112,97,116,104,114,158,0,0, - 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,175,0,0,0,184,4,0,0,115,70,0,0,0,0,3, - 6,1,19,1,3,1,34,1,13,1,11,1,15,1,10,1, - 9,2,9,1,9,1,15,2,9,1,6,2,12,1,18,1, - 22,1,10,1,15,1,12,1,32,4,12,2,22,1,22,1, - 22,1,16,1,12,1,15,1,14,1,6,1,16,1,18,1, - 12,1,4,1,122,20,70,105,108,101,70,105,110,100,101,114, - 46,102,105,110,100,95,115,112,101,99,99,1,0,0,0,0, - 0,0,0,9,0,0,0,13,0,0,0,67,0,0,0,115, - 11,1,0,0,124,0,0,106,0,0,125,1,0,121,31,0, - 116,1,0,106,2,0,124,1,0,112,33,0,116,1,0,106, - 3,0,131,0,0,131,1,0,125,2,0,87,110,33,0,4, - 116,4,0,116,5,0,116,6,0,102,3,0,107,10,0,114, - 75,0,1,1,1,103,0,0,125,2,0,89,110,1,0,88, - 116,7,0,106,8,0,106,9,0,100,1,0,131,1,0,115, - 112,0,116,10,0,124,2,0,131,1,0,124,0,0,95,11, - 0,110,111,0,116,10,0,131,0,0,125,3,0,120,90,0, - 124,2,0,68,93,82,0,125,4,0,124,4,0,106,12,0, - 100,2,0,131,1,0,92,3,0,125,5,0,125,6,0,125, - 7,0,124,6,0,114,191,0,100,3,0,106,13,0,124,5, - 0,124,7,0,106,14,0,131,0,0,131,2,0,125,8,0, - 110,6,0,124,5,0,125,8,0,124,3,0,106,15,0,124, - 8,0,131,1,0,1,113,128,0,87,124,3,0,124,0,0, - 95,11,0,116,7,0,106,8,0,106,9,0,116,16,0,131, - 1,0,114,7,1,100,4,0,100,5,0,132,0,0,124,2, - 0,68,131,1,0,124,0,0,95,17,0,100,6,0,83,41, - 7,122,68,70,105,108,108,32,116,104,101,32,99,97,99,104, - 101,32,111,102,32,112,111,116,101,110,116,105,97,108,32,109, - 111,100,117,108,101,115,32,97,110,100,32,112,97,99,107,97, - 103,101,115,32,102,111,114,32,116,104,105,115,32,100,105,114, - 101,99,116,111,114,121,46,114,0,0,0,0,114,58,0,0, - 0,122,5,123,125,46,123,125,99,1,0,0,0,0,0,0, - 0,2,0,0,0,3,0,0,0,83,0,0,0,115,28,0, - 0,0,104,0,0,124,0,0,93,18,0,125,1,0,124,1, - 0,106,0,0,131,0,0,146,2,0,113,6,0,83,114,4, - 0,0,0,41,1,114,88,0,0,0,41,2,114,22,0,0, - 0,90,2,102,110,114,4,0,0,0,114,4,0,0,0,114, - 5,0,0,0,250,9,60,115,101,116,99,111,109,112,62,3, - 5,0,0,115,2,0,0,0,9,0,122,41,70,105,108,101, - 70,105,110,100,101,114,46,95,102,105,108,108,95,99,97,99, - 104,101,46,60,108,111,99,97,108,115,62,46,60,115,101,116, - 99,111,109,112,62,78,41,18,114,35,0,0,0,114,3,0, - 0,0,90,7,108,105,115,116,100,105,114,114,45,0,0,0, - 114,250,0,0,0,218,15,80,101,114,109,105,115,115,105,111, - 110,69,114,114,111,114,218,18,78,111,116,65,68,105,114,101, - 99,116,111,114,121,69,114,114,111,114,114,7,0,0,0,114, - 8,0,0,0,114,9,0,0,0,114,3,1,0,0,114,4, - 1,0,0,114,83,0,0,0,114,47,0,0,0,114,88,0, - 0,0,218,3,97,100,100,114,10,0,0,0,114,5,1,0, - 0,41,9,114,100,0,0,0,114,35,0,0,0,90,8,99, - 111,110,116,101,110,116,115,90,21,108,111,119,101,114,95,115, - 117,102,102,105,120,95,99,111,110,116,101,110,116,115,114,239, - 0,0,0,114,98,0,0,0,114,231,0,0,0,114,219,0, - 0,0,90,8,110,101,119,95,110,97,109,101,114,4,0,0, - 0,114,4,0,0,0,114,5,0,0,0,114,7,1,0,0, - 230,4,0,0,115,34,0,0,0,0,2,9,1,3,1,31, - 1,22,3,11,3,18,1,18,7,9,1,13,1,24,1,6, - 1,27,2,6,1,17,1,9,1,18,1,122,22,70,105,108, - 101,70,105,110,100,101,114,46,95,102,105,108,108,95,99,97, - 99,104,101,99,1,0,0,0,0,0,0,0,3,0,0,0, - 3,0,0,0,7,0,0,0,115,25,0,0,0,135,0,0, - 135,1,0,102,2,0,100,1,0,100,2,0,134,0,0,125, - 2,0,124,2,0,83,41,3,97,20,1,0,0,65,32,99, - 108,97,115,115,32,109,101,116,104,111,100,32,119,104,105,99, - 104,32,114,101,116,117,114,110,115,32,97,32,99,108,111,115, - 117,114,101,32,116,111,32,117,115,101,32,111,110,32,115,121, - 115,46,112,97,116,104,95,104,111,111,107,10,32,32,32,32, - 32,32,32,32,119,104,105,99,104,32,119,105,108,108,32,114, - 101,116,117,114,110,32,97,110,32,105,110,115,116,97,110,99, - 101,32,117,115,105,110,103,32,116,104,101,32,115,112,101,99, - 105,102,105,101,100,32,108,111,97,100,101,114,115,32,97,110, - 100,32,116,104,101,32,112,97,116,104,10,32,32,32,32,32, - 32,32,32,99,97,108,108,101,100,32,111,110,32,116,104,101, - 32,99,108,111,115,117,114,101,46,10,10,32,32,32,32,32, - 32,32,32,73,102,32,116,104,101,32,112,97,116,104,32,99, - 97,108,108,101,100,32,111,110,32,116,104,101,32,99,108,111, - 115,117,114,101,32,105,115,32,110,111,116,32,97,32,100,105, - 114,101,99,116,111,114,121,44,32,73,109,112,111,114,116,69, - 114,114,111,114,32,105,115,10,32,32,32,32,32,32,32,32, - 114,97,105,115,101,100,46,10,10,32,32,32,32,32,32,32, - 32,99,1,0,0,0,0,0,0,0,1,0,0,0,4,0, - 0,0,19,0,0,0,115,43,0,0,0,116,0,0,124,0, - 0,131,1,0,115,30,0,116,1,0,100,1,0,100,2,0, - 124,0,0,131,1,1,130,1,0,136,0,0,124,0,0,136, - 1,0,140,1,0,83,41,3,122,45,80,97,116,104,32,104, - 111,111,107,32,102,111,114,32,105,109,112,111,114,116,108,105, - 98,46,109,97,99,104,105,110,101,114,121,46,70,105,108,101, - 70,105,110,100,101,114,46,122,30,111,110,108,121,32,100,105, - 114,101,99,116,111,114,105,101,115,32,97,114,101,32,115,117, - 112,112,111,114,116,101,100,114,35,0,0,0,41,2,114,46, - 0,0,0,114,99,0,0,0,41,1,114,35,0,0,0,41, - 2,114,164,0,0,0,114,6,1,0,0,114,4,0,0,0, - 114,5,0,0,0,218,24,112,97,116,104,95,104,111,111,107, - 95,102,111,114,95,70,105,108,101,70,105,110,100,101,114,15, - 5,0,0,115,6,0,0,0,0,2,12,1,18,1,122,54, - 70,105,108,101,70,105,110,100,101,114,46,112,97,116,104,95, - 104,111,111,107,46,60,108,111,99,97,108,115,62,46,112,97, - 116,104,95,104,111,111,107,95,102,111,114,95,70,105,108,101, - 70,105,110,100,101,114,114,4,0,0,0,41,3,114,164,0, - 0,0,114,6,1,0,0,114,12,1,0,0,114,4,0,0, - 0,41,2,114,164,0,0,0,114,6,1,0,0,114,5,0, - 0,0,218,9,112,97,116,104,95,104,111,111,107,5,5,0, - 0,115,4,0,0,0,0,10,21,6,122,20,70,105,108,101, - 70,105,110,100,101,114,46,112,97,116,104,95,104,111,111,107, - 99,1,0,0,0,0,0,0,0,1,0,0,0,2,0,0, - 0,67,0,0,0,115,16,0,0,0,100,1,0,106,0,0, - 124,0,0,106,1,0,131,1,0,83,41,2,78,122,16,70, - 105,108,101,70,105,110,100,101,114,40,123,33,114,125,41,41, - 2,114,47,0,0,0,114,35,0,0,0,41,1,114,100,0, - 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0, - 0,114,238,0,0,0,23,5,0,0,115,2,0,0,0,0, - 1,122,19,70,105,108,101,70,105,110,100,101,114,46,95,95, - 114,101,112,114,95,95,41,15,114,105,0,0,0,114,104,0, - 0,0,114,106,0,0,0,114,107,0,0,0,114,179,0,0, - 0,114,244,0,0,0,114,123,0,0,0,114,176,0,0,0, - 114,117,0,0,0,114,255,0,0,0,114,175,0,0,0,114, - 7,1,0,0,114,177,0,0,0,114,13,1,0,0,114,238, - 0,0,0,114,4,0,0,0,114,4,0,0,0,114,4,0, - 0,0,114,5,0,0,0,114,0,1,0,0,138,4,0,0, - 115,20,0,0,0,12,7,6,2,12,14,12,4,6,2,12, - 12,12,5,15,46,12,31,18,18,114,0,1,0,0,99,4, - 0,0,0,0,0,0,0,6,0,0,0,11,0,0,0,67, - 0,0,0,115,195,0,0,0,124,0,0,106,0,0,100,1, - 0,131,1,0,125,4,0,124,0,0,106,0,0,100,2,0, - 131,1,0,125,5,0,124,4,0,115,99,0,124,5,0,114, - 54,0,124,5,0,106,1,0,125,4,0,110,45,0,124,2, - 0,124,3,0,107,2,0,114,84,0,116,2,0,124,1,0, - 124,2,0,131,2,0,125,4,0,110,15,0,116,3,0,124, - 1,0,124,2,0,131,2,0,125,4,0,124,5,0,115,126, - 0,116,4,0,124,1,0,124,2,0,100,3,0,124,4,0, - 131,2,1,125,5,0,121,44,0,124,5,0,124,0,0,100, - 2,0,60,124,4,0,124,0,0,100,1,0,60,124,2,0, - 124,0,0,100,4,0,60,124,3,0,124,0,0,100,5,0, - 60,87,110,18,0,4,116,5,0,107,10,0,114,190,0,1, - 1,1,89,110,1,0,88,100,0,0,83,41,6,78,218,10, - 95,95,108,111,97,100,101,114,95,95,218,8,95,95,115,112, - 101,99,95,95,114,120,0,0,0,90,8,95,95,102,105,108, - 101,95,95,90,10,95,95,99,97,99,104,101,100,95,95,41, - 6,218,3,103,101,116,114,120,0,0,0,114,217,0,0,0, - 114,212,0,0,0,114,161,0,0,0,218,9,69,120,99,101, - 112,116,105,111,110,41,6,90,2,110,115,114,98,0,0,0, - 90,8,112,97,116,104,110,97,109,101,90,9,99,112,97,116, - 104,110,97,109,101,114,120,0,0,0,114,158,0,0,0,114, - 4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,14, - 95,102,105,120,95,117,112,95,109,111,100,117,108,101,29,5, - 0,0,115,34,0,0,0,0,2,15,1,15,1,6,1,6, - 1,12,1,12,1,18,2,15,1,6,1,21,1,3,1,10, - 1,10,1,10,1,14,1,13,2,114,18,1,0,0,99,0, - 0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,67, - 0,0,0,115,55,0,0,0,116,0,0,116,1,0,106,2, - 0,131,0,0,102,2,0,125,0,0,116,3,0,116,4,0, - 102,2,0,125,1,0,116,5,0,116,6,0,102,2,0,125, - 2,0,124,0,0,124,1,0,124,2,0,103,3,0,83,41, - 1,122,95,82,101,116,117,114,110,115,32,97,32,108,105,115, - 116,32,111,102,32,102,105,108,101,45,98,97,115,101,100,32, - 109,111,100,117,108,101,32,108,111,97,100,101,114,115,46,10, - 10,32,32,32,32,69,97,99,104,32,105,116,101,109,32,105, - 115,32,97,32,116,117,112,108,101,32,40,108,111,97,100,101, - 114,44,32,115,117,102,102,105,120,101,115,41,46,10,32,32, - 32,32,41,7,114,218,0,0,0,114,139,0,0,0,218,18, - 101,120,116,101,110,115,105,111,110,95,115,117,102,102,105,120, - 101,115,114,212,0,0,0,114,84,0,0,0,114,217,0,0, - 0,114,74,0,0,0,41,3,90,10,101,120,116,101,110,115, - 105,111,110,115,90,6,115,111,117,114,99,101,90,8,98,121, - 116,101,99,111,100,101,114,4,0,0,0,114,4,0,0,0, - 114,5,0,0,0,114,155,0,0,0,52,5,0,0,115,8, - 0,0,0,0,5,18,1,12,1,12,1,114,155,0,0,0, - 99,1,0,0,0,0,0,0,0,12,0,0,0,12,0,0, - 0,67,0,0,0,115,70,2,0,0,124,0,0,97,0,0, - 116,0,0,106,1,0,97,1,0,116,0,0,106,2,0,97, - 2,0,116,1,0,106,3,0,116,4,0,25,125,1,0,120, - 76,0,100,26,0,68,93,68,0,125,2,0,124,2,0,116, - 1,0,106,3,0,107,7,0,114,83,0,116,0,0,106,5, - 0,124,2,0,131,1,0,125,3,0,110,13,0,116,1,0, - 106,3,0,124,2,0,25,125,3,0,116,6,0,124,1,0, - 124,2,0,124,3,0,131,3,0,1,113,44,0,87,100,5, - 0,100,6,0,103,1,0,102,2,0,100,7,0,100,8,0, - 100,6,0,103,2,0,102,2,0,102,2,0,125,4,0,120, - 149,0,124,4,0,68,93,129,0,92,2,0,125,5,0,125, - 6,0,116,7,0,100,9,0,100,10,0,132,0,0,124,6, - 0,68,131,1,0,131,1,0,115,199,0,116,8,0,130,1, - 0,124,6,0,100,11,0,25,125,7,0,124,5,0,116,1, - 0,106,3,0,107,6,0,114,241,0,116,1,0,106,3,0, - 124,5,0,25,125,8,0,80,113,156,0,121,20,0,116,0, - 0,106,5,0,124,5,0,131,1,0,125,8,0,80,87,113, - 156,0,4,116,9,0,107,10,0,114,28,1,1,1,1,119, - 156,0,89,113,156,0,88,113,156,0,87,116,9,0,100,12, - 0,131,1,0,130,1,0,116,6,0,124,1,0,100,13,0, - 124,8,0,131,3,0,1,116,6,0,124,1,0,100,14,0, - 124,7,0,131,3,0,1,116,6,0,124,1,0,100,15,0, - 100,16,0,106,10,0,124,6,0,131,1,0,131,3,0,1, - 121,19,0,116,0,0,106,5,0,100,17,0,131,1,0,125, - 9,0,87,110,24,0,4,116,9,0,107,10,0,114,147,1, - 1,1,1,100,18,0,125,9,0,89,110,1,0,88,116,6, - 0,124,1,0,100,17,0,124,9,0,131,3,0,1,116,0, - 0,106,5,0,100,19,0,131,1,0,125,10,0,116,6,0, - 124,1,0,100,19,0,124,10,0,131,3,0,1,124,5,0, - 100,7,0,107,2,0,114,238,1,116,0,0,106,5,0,100, - 20,0,131,1,0,125,11,0,116,6,0,124,1,0,100,21, - 0,124,11,0,131,3,0,1,116,6,0,124,1,0,100,22, - 0,116,11,0,131,0,0,131,3,0,1,116,12,0,106,13, - 0,116,2,0,106,14,0,131,0,0,131,1,0,1,124,5, - 0,100,7,0,107,2,0,114,66,2,116,15,0,106,16,0, - 100,23,0,131,1,0,1,100,24,0,116,12,0,107,6,0, - 114,66,2,100,25,0,116,17,0,95,18,0,100,18,0,83, - 41,27,122,205,83,101,116,117,112,32,116,104,101,32,112,97, - 116,104,45,98,97,115,101,100,32,105,109,112,111,114,116,101, - 114,115,32,102,111,114,32,105,109,112,111,114,116,108,105,98, - 32,98,121,32,105,109,112,111,114,116,105,110,103,32,110,101, - 101,100,101,100,10,32,32,32,32,98,117,105,108,116,45,105, - 110,32,109,111,100,117,108,101,115,32,97,110,100,32,105,110, - 106,101,99,116,105,110,103,32,116,104,101,109,32,105,110,116, - 111,32,116,104,101,32,103,108,111,98,97,108,32,110,97,109, - 101,115,112,97,99,101,46,10,10,32,32,32,32,79,116,104, - 101,114,32,99,111,109,112,111,110,101,110,116,115,32,97,114, - 101,32,101,120,116,114,97,99,116,101,100,32,102,114,111,109, - 32,116,104,101,32,99,111,114,101,32,98,111,111,116,115,116, - 114,97,112,32,109,111,100,117,108,101,46,10,10,32,32,32, - 32,114,49,0,0,0,114,60,0,0,0,218,8,98,117,105, - 108,116,105,110,115,114,136,0,0,0,90,5,112,111,115,105, - 120,250,1,47,218,2,110,116,250,1,92,99,1,0,0,0, - 0,0,0,0,2,0,0,0,3,0,0,0,115,0,0,0, - 115,33,0,0,0,124,0,0,93,23,0,125,1,0,116,0, - 0,124,1,0,131,1,0,100,0,0,107,2,0,86,1,113, - 3,0,100,1,0,83,41,2,114,29,0,0,0,78,41,1, - 114,31,0,0,0,41,2,114,22,0,0,0,114,77,0,0, - 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, - 114,221,0,0,0,88,5,0,0,115,2,0,0,0,6,0, - 122,25,95,115,101,116,117,112,46,60,108,111,99,97,108,115, - 62,46,60,103,101,110,101,120,112,114,62,114,59,0,0,0, - 122,30,105,109,112,111,114,116,108,105,98,32,114,101,113,117, - 105,114,101,115,32,112,111,115,105,120,32,111,114,32,110,116, - 114,3,0,0,0,114,25,0,0,0,114,21,0,0,0,114, - 30,0,0,0,90,7,95,116,104,114,101,97,100,78,90,8, - 95,119,101,97,107,114,101,102,90,6,119,105,110,114,101,103, - 114,163,0,0,0,114,6,0,0,0,122,4,46,112,121,119, - 122,6,95,100,46,112,121,100,84,41,4,122,3,95,105,111, - 122,9,95,119,97,114,110,105,110,103,115,122,8,98,117,105, - 108,116,105,110,115,122,7,109,97,114,115,104,97,108,41,19, - 114,114,0,0,0,114,7,0,0,0,114,139,0,0,0,114, - 233,0,0,0,114,105,0,0,0,90,18,95,98,117,105,108, - 116,105,110,95,102,114,111,109,95,110,97,109,101,114,109,0, - 0,0,218,3,97,108,108,218,14,65,115,115,101,114,116,105, - 111,110,69,114,114,111,114,114,99,0,0,0,114,26,0,0, - 0,114,11,0,0,0,114,223,0,0,0,114,143,0,0,0, - 114,19,1,0,0,114,84,0,0,0,114,157,0,0,0,114, - 162,0,0,0,114,167,0,0,0,41,12,218,17,95,98,111, - 111,116,115,116,114,97,112,95,109,111,100,117,108,101,90,11, - 115,101,108,102,95,109,111,100,117,108,101,90,12,98,117,105, - 108,116,105,110,95,110,97,109,101,90,14,98,117,105,108,116, - 105,110,95,109,111,100,117,108,101,90,10,111,115,95,100,101, - 116,97,105,108,115,90,10,98,117,105,108,116,105,110,95,111, - 115,114,21,0,0,0,114,25,0,0,0,90,9,111,115,95, - 109,111,100,117,108,101,90,13,116,104,114,101,97,100,95,109, - 111,100,117,108,101,90,14,119,101,97,107,114,101,102,95,109, - 111,100,117,108,101,90,13,119,105,110,114,101,103,95,109,111, - 100,117,108,101,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,218,6,95,115,101,116,117,112,63,5,0,0,115, - 82,0,0,0,0,8,6,1,9,1,9,3,13,1,13,1, - 15,1,18,2,13,1,20,3,33,1,19,2,31,1,10,1, - 15,1,13,1,4,2,3,1,15,1,5,1,13,1,12,2, - 12,1,16,1,16,1,25,3,3,1,19,1,13,2,11,1, - 16,3,15,1,16,3,12,1,15,1,16,3,19,1,19,1, - 12,1,13,1,12,1,114,27,1,0,0,99,1,0,0,0, - 0,0,0,0,2,0,0,0,3,0,0,0,67,0,0,0, - 115,116,0,0,0,116,0,0,124,0,0,131,1,0,1,116, - 1,0,131,0,0,125,1,0,116,2,0,106,3,0,106,4, - 0,116,5,0,106,6,0,124,1,0,140,0,0,103,1,0, - 131,1,0,1,116,7,0,106,8,0,100,1,0,107,2,0, - 114,78,0,116,2,0,106,9,0,106,10,0,116,11,0,131, - 1,0,1,116,2,0,106,9,0,106,10,0,116,12,0,131, - 1,0,1,116,5,0,124,0,0,95,5,0,116,13,0,124, - 0,0,95,13,0,100,2,0,83,41,3,122,41,73,110,115, - 116,97,108,108,32,116,104,101,32,112,97,116,104,45,98,97, - 115,101,100,32,105,109,112,111,114,116,32,99,111,109,112,111, - 110,101,110,116,115,46,114,22,1,0,0,78,41,14,114,27, - 1,0,0,114,155,0,0,0,114,7,0,0,0,114,248,0, - 0,0,114,143,0,0,0,114,0,1,0,0,114,13,1,0, - 0,114,3,0,0,0,114,105,0,0,0,218,9,109,101,116, - 97,95,112,97,116,104,114,157,0,0,0,114,162,0,0,0, - 114,243,0,0,0,114,212,0,0,0,41,2,114,26,1,0, - 0,90,17,115,117,112,112,111,114,116,101,100,95,108,111,97, - 100,101,114,115,114,4,0,0,0,114,4,0,0,0,114,5, - 0,0,0,218,8,95,105,110,115,116,97,108,108,131,5,0, - 0,115,16,0,0,0,0,2,10,1,9,1,28,1,15,1, - 16,1,16,4,9,1,114,29,1,0,0,41,3,122,3,119, - 105,110,114,1,0,0,0,114,2,0,0,0,41,56,114,107, - 0,0,0,114,10,0,0,0,114,11,0,0,0,114,17,0, - 0,0,114,19,0,0,0,114,28,0,0,0,114,38,0,0, - 0,114,39,0,0,0,114,43,0,0,0,114,44,0,0,0, - 114,46,0,0,0,114,55,0,0,0,218,4,116,121,112,101, - 218,8,95,95,99,111,100,101,95,95,114,138,0,0,0,114, - 15,0,0,0,114,128,0,0,0,114,14,0,0,0,114,18, - 0,0,0,90,17,95,82,65,87,95,77,65,71,73,67,95, - 78,85,77,66,69,82,114,73,0,0,0,114,72,0,0,0, - 114,84,0,0,0,114,74,0,0,0,90,23,68,69,66,85, - 71,95,66,89,84,69,67,79,68,69,95,83,85,70,70,73, - 88,69,83,90,27,79,80,84,73,77,73,90,69,68,95,66, - 89,84,69,67,79,68,69,95,83,85,70,70,73,88,69,83, - 114,79,0,0,0,114,85,0,0,0,114,91,0,0,0,114, - 95,0,0,0,114,97,0,0,0,114,116,0,0,0,114,123, - 0,0,0,114,135,0,0,0,114,141,0,0,0,114,144,0, - 0,0,114,149,0,0,0,218,6,111,98,106,101,99,116,114, - 156,0,0,0,114,161,0,0,0,114,162,0,0,0,114,178, - 0,0,0,114,188,0,0,0,114,204,0,0,0,114,212,0, - 0,0,114,217,0,0,0,114,223,0,0,0,114,218,0,0, - 0,114,224,0,0,0,114,241,0,0,0,114,243,0,0,0, - 114,0,1,0,0,114,18,1,0,0,114,155,0,0,0,114, - 27,1,0,0,114,29,1,0,0,114,4,0,0,0,114,4, - 0,0,0,114,4,0,0,0,114,5,0,0,0,218,8,60, - 109,111,100,117,108,101,62,8,0,0,0,115,98,0,0,0, - 6,17,6,3,12,12,12,5,12,5,12,6,12,12,12,10, - 12,9,12,5,12,7,15,22,15,111,22,1,18,2,6,1, - 6,2,9,2,9,2,10,2,21,44,12,33,12,19,12,12, - 12,12,12,28,12,17,21,55,21,12,18,10,12,14,9,3, - 12,1,15,65,19,64,19,28,22,110,19,41,25,45,25,16, - 6,3,25,53,19,57,19,42,19,134,19,147,15,23,12,11, - 12,68, + 0,0,114,0,1,0,0,139,4,0,0,115,20,0,0,0, + 12,7,6,2,12,14,12,4,6,2,12,12,12,5,15,46, + 12,31,18,18,114,0,1,0,0,99,4,0,0,0,0,0, + 0,0,6,0,0,0,11,0,0,0,67,0,0,0,115,195, + 0,0,0,124,0,0,106,0,0,100,1,0,131,1,0,125, + 4,0,124,0,0,106,0,0,100,2,0,131,1,0,125,5, + 0,124,4,0,115,99,0,124,5,0,114,54,0,124,5,0, + 106,1,0,125,4,0,110,45,0,124,2,0,124,3,0,107, + 2,0,114,84,0,116,2,0,124,1,0,124,2,0,131,2, + 0,125,4,0,110,15,0,116,3,0,124,1,0,124,2,0, + 131,2,0,125,4,0,124,5,0,115,126,0,116,4,0,124, + 1,0,124,2,0,100,3,0,124,4,0,131,2,1,125,5, + 0,121,44,0,124,5,0,124,0,0,100,2,0,60,124,4, + 0,124,0,0,100,1,0,60,124,2,0,124,0,0,100,4, + 0,60,124,3,0,124,0,0,100,5,0,60,87,110,18,0, + 4,116,5,0,107,10,0,114,190,0,1,1,1,89,110,1, + 0,88,100,0,0,83,41,6,78,218,10,95,95,108,111,97, + 100,101,114,95,95,218,8,95,95,115,112,101,99,95,95,114, + 120,0,0,0,90,8,95,95,102,105,108,101,95,95,90,10, + 95,95,99,97,99,104,101,100,95,95,41,6,218,3,103,101, + 116,114,120,0,0,0,114,217,0,0,0,114,212,0,0,0, + 114,161,0,0,0,218,9,69,120,99,101,112,116,105,111,110, + 41,6,90,2,110,115,114,98,0,0,0,90,8,112,97,116, + 104,110,97,109,101,90,9,99,112,97,116,104,110,97,109,101, + 114,120,0,0,0,114,158,0,0,0,114,4,0,0,0,114, + 4,0,0,0,114,5,0,0,0,218,14,95,102,105,120,95, + 117,112,95,109,111,100,117,108,101,30,5,0,0,115,34,0, + 0,0,0,2,15,1,15,1,6,1,6,1,12,1,12,1, + 18,2,15,1,6,1,21,1,3,1,10,1,10,1,10,1, + 14,1,13,2,114,18,1,0,0,99,0,0,0,0,0,0, + 0,0,3,0,0,0,3,0,0,0,67,0,0,0,115,55, + 0,0,0,116,0,0,116,1,0,106,2,0,131,0,0,102, + 2,0,125,0,0,116,3,0,116,4,0,102,2,0,125,1, + 0,116,5,0,116,6,0,102,2,0,125,2,0,124,0,0, + 124,1,0,124,2,0,103,3,0,83,41,1,122,95,82,101, + 116,117,114,110,115,32,97,32,108,105,115,116,32,111,102,32, + 102,105,108,101,45,98,97,115,101,100,32,109,111,100,117,108, + 101,32,108,111,97,100,101,114,115,46,10,10,32,32,32,32, + 69,97,99,104,32,105,116,101,109,32,105,115,32,97,32,116, + 117,112,108,101,32,40,108,111,97,100,101,114,44,32,115,117, + 102,102,105,120,101,115,41,46,10,32,32,32,32,41,7,114, + 218,0,0,0,114,139,0,0,0,218,18,101,120,116,101,110, + 115,105,111,110,95,115,117,102,102,105,120,101,115,114,212,0, + 0,0,114,84,0,0,0,114,217,0,0,0,114,74,0,0, + 0,41,3,90,10,101,120,116,101,110,115,105,111,110,115,90, + 6,115,111,117,114,99,101,90,8,98,121,116,101,99,111,100, + 101,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0, + 114,155,0,0,0,53,5,0,0,115,8,0,0,0,0,5, + 18,1,12,1,12,1,114,155,0,0,0,99,1,0,0,0, + 0,0,0,0,12,0,0,0,12,0,0,0,67,0,0,0, + 115,70,2,0,0,124,0,0,97,0,0,116,0,0,106,1, + 0,97,1,0,116,0,0,106,2,0,97,2,0,116,1,0, + 106,3,0,116,4,0,25,125,1,0,120,76,0,100,26,0, + 68,93,68,0,125,2,0,124,2,0,116,1,0,106,3,0, + 107,7,0,114,83,0,116,0,0,106,5,0,124,2,0,131, + 1,0,125,3,0,110,13,0,116,1,0,106,3,0,124,2, + 0,25,125,3,0,116,6,0,124,1,0,124,2,0,124,3, + 0,131,3,0,1,113,44,0,87,100,5,0,100,6,0,103, + 1,0,102,2,0,100,7,0,100,8,0,100,6,0,103,2, + 0,102,2,0,102,2,0,125,4,0,120,149,0,124,4,0, + 68,93,129,0,92,2,0,125,5,0,125,6,0,116,7,0, + 100,9,0,100,10,0,132,0,0,124,6,0,68,131,1,0, + 131,1,0,115,199,0,116,8,0,130,1,0,124,6,0,100, + 11,0,25,125,7,0,124,5,0,116,1,0,106,3,0,107, + 6,0,114,241,0,116,1,0,106,3,0,124,5,0,25,125, + 8,0,80,113,156,0,121,20,0,116,0,0,106,5,0,124, + 5,0,131,1,0,125,8,0,80,87,113,156,0,4,116,9, + 0,107,10,0,114,28,1,1,1,1,119,156,0,89,113,156, + 0,88,113,156,0,87,116,9,0,100,12,0,131,1,0,130, + 1,0,116,6,0,124,1,0,100,13,0,124,8,0,131,3, + 0,1,116,6,0,124,1,0,100,14,0,124,7,0,131,3, + 0,1,116,6,0,124,1,0,100,15,0,100,16,0,106,10, + 0,124,6,0,131,1,0,131,3,0,1,121,19,0,116,0, + 0,106,5,0,100,17,0,131,1,0,125,9,0,87,110,24, + 0,4,116,9,0,107,10,0,114,147,1,1,1,1,100,18, + 0,125,9,0,89,110,1,0,88,116,6,0,124,1,0,100, + 17,0,124,9,0,131,3,0,1,116,0,0,106,5,0,100, + 19,0,131,1,0,125,10,0,116,6,0,124,1,0,100,19, + 0,124,10,0,131,3,0,1,124,5,0,100,7,0,107,2, + 0,114,238,1,116,0,0,106,5,0,100,20,0,131,1,0, + 125,11,0,116,6,0,124,1,0,100,21,0,124,11,0,131, + 3,0,1,116,6,0,124,1,0,100,22,0,116,11,0,131, + 0,0,131,3,0,1,116,12,0,106,13,0,116,2,0,106, + 14,0,131,0,0,131,1,0,1,124,5,0,100,7,0,107, + 2,0,114,66,2,116,15,0,106,16,0,100,23,0,131,1, + 0,1,100,24,0,116,12,0,107,6,0,114,66,2,100,25, + 0,116,17,0,95,18,0,100,18,0,83,41,27,122,205,83, + 101,116,117,112,32,116,104,101,32,112,97,116,104,45,98,97, + 115,101,100,32,105,109,112,111,114,116,101,114,115,32,102,111, + 114,32,105,109,112,111,114,116,108,105,98,32,98,121,32,105, + 109,112,111,114,116,105,110,103,32,110,101,101,100,101,100,10, + 32,32,32,32,98,117,105,108,116,45,105,110,32,109,111,100, + 117,108,101,115,32,97,110,100,32,105,110,106,101,99,116,105, + 110,103,32,116,104,101,109,32,105,110,116,111,32,116,104,101, + 32,103,108,111,98,97,108,32,110,97,109,101,115,112,97,99, + 101,46,10,10,32,32,32,32,79,116,104,101,114,32,99,111, + 109,112,111,110,101,110,116,115,32,97,114,101,32,101,120,116, + 114,97,99,116,101,100,32,102,114,111,109,32,116,104,101,32, + 99,111,114,101,32,98,111,111,116,115,116,114,97,112,32,109, + 111,100,117,108,101,46,10,10,32,32,32,32,114,49,0,0, + 0,114,60,0,0,0,218,8,98,117,105,108,116,105,110,115, + 114,136,0,0,0,90,5,112,111,115,105,120,250,1,47,218, + 2,110,116,250,1,92,99,1,0,0,0,0,0,0,0,2, + 0,0,0,3,0,0,0,115,0,0,0,115,33,0,0,0, + 124,0,0,93,23,0,125,1,0,116,0,0,124,1,0,131, + 1,0,100,0,0,107,2,0,86,1,113,3,0,100,1,0, + 83,41,2,114,29,0,0,0,78,41,1,114,31,0,0,0, + 41,2,114,22,0,0,0,114,77,0,0,0,114,4,0,0, + 0,114,4,0,0,0,114,5,0,0,0,114,221,0,0,0, + 89,5,0,0,115,2,0,0,0,6,0,122,25,95,115,101, + 116,117,112,46,60,108,111,99,97,108,115,62,46,60,103,101, + 110,101,120,112,114,62,114,59,0,0,0,122,30,105,109,112, + 111,114,116,108,105,98,32,114,101,113,117,105,114,101,115,32, + 112,111,115,105,120,32,111,114,32,110,116,114,3,0,0,0, + 114,25,0,0,0,114,21,0,0,0,114,30,0,0,0,90, + 7,95,116,104,114,101,97,100,78,90,8,95,119,101,97,107, + 114,101,102,90,6,119,105,110,114,101,103,114,163,0,0,0, + 114,6,0,0,0,122,4,46,112,121,119,122,6,95,100,46, + 112,121,100,84,41,4,122,3,95,105,111,122,9,95,119,97, + 114,110,105,110,103,115,122,8,98,117,105,108,116,105,110,115, + 122,7,109,97,114,115,104,97,108,41,19,114,114,0,0,0, + 114,7,0,0,0,114,139,0,0,0,114,233,0,0,0,114, + 105,0,0,0,90,18,95,98,117,105,108,116,105,110,95,102, + 114,111,109,95,110,97,109,101,114,109,0,0,0,218,3,97, + 108,108,218,14,65,115,115,101,114,116,105,111,110,69,114,114, + 111,114,114,99,0,0,0,114,26,0,0,0,114,11,0,0, + 0,114,223,0,0,0,114,143,0,0,0,114,19,1,0,0, + 114,84,0,0,0,114,157,0,0,0,114,162,0,0,0,114, + 167,0,0,0,41,12,218,17,95,98,111,111,116,115,116,114, + 97,112,95,109,111,100,117,108,101,90,11,115,101,108,102,95, + 109,111,100,117,108,101,90,12,98,117,105,108,116,105,110,95, + 110,97,109,101,90,14,98,117,105,108,116,105,110,95,109,111, + 100,117,108,101,90,10,111,115,95,100,101,116,97,105,108,115, + 90,10,98,117,105,108,116,105,110,95,111,115,114,21,0,0, + 0,114,25,0,0,0,90,9,111,115,95,109,111,100,117,108, + 101,90,13,116,104,114,101,97,100,95,109,111,100,117,108,101, + 90,14,119,101,97,107,114,101,102,95,109,111,100,117,108,101, + 90,13,119,105,110,114,101,103,95,109,111,100,117,108,101,114, + 4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,6, + 95,115,101,116,117,112,64,5,0,0,115,82,0,0,0,0, + 8,6,1,9,1,9,3,13,1,13,1,15,1,18,2,13, + 1,20,3,33,1,19,2,31,1,10,1,15,1,13,1,4, + 2,3,1,15,1,5,1,13,1,12,2,12,1,16,1,16, + 1,25,3,3,1,19,1,13,2,11,1,16,3,15,1,16, + 3,12,1,15,1,16,3,19,1,19,1,12,1,13,1,12, + 1,114,27,1,0,0,99,1,0,0,0,0,0,0,0,2, + 0,0,0,3,0,0,0,67,0,0,0,115,116,0,0,0, + 116,0,0,124,0,0,131,1,0,1,116,1,0,131,0,0, + 125,1,0,116,2,0,106,3,0,106,4,0,116,5,0,106, + 6,0,124,1,0,140,0,0,103,1,0,131,1,0,1,116, + 7,0,106,8,0,100,1,0,107,2,0,114,78,0,116,2, + 0,106,9,0,106,10,0,116,11,0,131,1,0,1,116,2, + 0,106,9,0,106,10,0,116,12,0,131,1,0,1,116,5, + 0,124,0,0,95,5,0,116,13,0,124,0,0,95,13,0, + 100,2,0,83,41,3,122,41,73,110,115,116,97,108,108,32, + 116,104,101,32,112,97,116,104,45,98,97,115,101,100,32,105, + 109,112,111,114,116,32,99,111,109,112,111,110,101,110,116,115, + 46,114,22,1,0,0,78,41,14,114,27,1,0,0,114,155, + 0,0,0,114,7,0,0,0,114,248,0,0,0,114,143,0, + 0,0,114,0,1,0,0,114,13,1,0,0,114,3,0,0, + 0,114,105,0,0,0,218,9,109,101,116,97,95,112,97,116, + 104,114,157,0,0,0,114,162,0,0,0,114,243,0,0,0, + 114,212,0,0,0,41,2,114,26,1,0,0,90,17,115,117, + 112,112,111,114,116,101,100,95,108,111,97,100,101,114,115,114, + 4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,8, + 95,105,110,115,116,97,108,108,132,5,0,0,115,16,0,0, + 0,0,2,10,1,9,1,28,1,15,1,16,1,16,4,9, + 1,114,29,1,0,0,41,3,122,3,119,105,110,114,1,0, + 0,0,114,2,0,0,0,41,56,114,107,0,0,0,114,10, + 0,0,0,114,11,0,0,0,114,17,0,0,0,114,19,0, + 0,0,114,28,0,0,0,114,38,0,0,0,114,39,0,0, + 0,114,43,0,0,0,114,44,0,0,0,114,46,0,0,0, + 114,55,0,0,0,218,4,116,121,112,101,218,8,95,95,99, + 111,100,101,95,95,114,138,0,0,0,114,15,0,0,0,114, + 128,0,0,0,114,14,0,0,0,114,18,0,0,0,90,17, + 95,82,65,87,95,77,65,71,73,67,95,78,85,77,66,69, + 82,114,73,0,0,0,114,72,0,0,0,114,84,0,0,0, + 114,74,0,0,0,90,23,68,69,66,85,71,95,66,89,84, + 69,67,79,68,69,95,83,85,70,70,73,88,69,83,90,27, + 79,80,84,73,77,73,90,69,68,95,66,89,84,69,67,79, + 68,69,95,83,85,70,70,73,88,69,83,114,79,0,0,0, + 114,85,0,0,0,114,91,0,0,0,114,95,0,0,0,114, + 97,0,0,0,114,116,0,0,0,114,123,0,0,0,114,135, + 0,0,0,114,141,0,0,0,114,144,0,0,0,114,149,0, + 0,0,218,6,111,98,106,101,99,116,114,156,0,0,0,114, + 161,0,0,0,114,162,0,0,0,114,178,0,0,0,114,188, + 0,0,0,114,204,0,0,0,114,212,0,0,0,114,217,0, + 0,0,114,223,0,0,0,114,218,0,0,0,114,224,0,0, + 0,114,241,0,0,0,114,243,0,0,0,114,0,1,0,0, + 114,18,1,0,0,114,155,0,0,0,114,27,1,0,0,114, + 29,1,0,0,114,4,0,0,0,114,4,0,0,0,114,4, + 0,0,0,114,5,0,0,0,218,8,60,109,111,100,117,108, + 101,62,8,0,0,0,115,98,0,0,0,6,17,6,3,12, + 12,12,5,12,5,12,6,12,12,12,10,12,9,12,5,12, + 7,15,22,15,111,22,1,18,2,6,1,6,2,9,2,9, + 2,10,2,21,44,12,33,12,19,12,12,12,12,12,28,12, + 17,21,55,21,12,18,10,12,14,9,3,12,1,15,65,19, + 64,19,29,22,110,19,41,25,45,25,16,6,3,25,53,19, + 57,19,42,19,134,19,147,15,23,12,11,12,68, }; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 29 01:01:38 2015 From: python-checkins at python.org (zach.ware) Date: Tue, 29 Dec 2015 06:01:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325972=2C_=2320440?= =?utf-8?q?=3A_Fix_compilation_on_Windows?= Message-ID: <20151229055119.70445.6090@psf.io> https://hg.python.org/cpython/rev/e04cd497aa41 changeset: 99713:e04cd497aa41 user: Zachary Ware date: Mon Dec 28 21:51:02 2015 -0800 summary: Issue #25972, #20440: Fix compilation on Windows files: Modules/_ctypes/_ctypes.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -5150,7 +5150,7 @@ return -1; Py_INCREF(args); - Py_SETREF((PyBaseExceptionObject *)self->args, args); + Py_SETREF(((PyBaseExceptionObject *)self)->args, args); return 0; } -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Tue Dec 29 03:43:13 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 29 Dec 2015 08:43:13 +0000 Subject: [Python-checkins] Daily reference leaks (ab0e60a36368): sum=4 Message-ID: <20151229084312.70439.56858@psf.io> results for ab0e60a36368 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflog66RpPO', '--timeout', '7200'] From lp_benchmark_robot at intel.com Tue Dec 29 08:48:49 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 29 Dec 2015 13:48:49 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-29 Message-ID: Results for project Python default, build date 2015-12-29 03:06:56 +0000 commit: ab0e60a3636881dc9ffaba761c44e941cfd96477 previous commit: 92760d2edc9ec8407f844320bfe4988e8ca8e1de revision date: 2015-12-29 01:55:27 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.26% 0.35% 10.84% 14.58% :-( pybench 0.10% -0.55% -1.81% 6.30% :-( regex_v8 2.73% -1.90% -5.00% 5.58% :-) nbody 0.23% 0.46% -0.32% 8.11% :-( json_dump_v2 0.21% -0.27% -1.98% 11.42% :-( normal_startup 0.80% -1.04% -1.53% 5.00% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) Note: Benchmark results are measured in seconds. Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Tue Dec 29 08:49:53 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 29 Dec 2015 13:49:53 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-29 Message-ID: <3cfc7ccc-92e7-4307-9a8b-67c79aa5c608@irsmsx102.ger.corp.intel.com> Results for project Python 2.7, build date 2015-12-29 03:58:12 +0000 commit: 11670e4be1a92d0a36ea6d8d2039a500f2f577ec previous commit: d7b5c2f99a99414eb8698f38444de4b6f5463eb2 revision date: 2015-12-27 13:41:58 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.38% 0.06% 3.92% 3.85% :-) pybench 0.14% 0.03% 6.28% 4.59% :-( regex_v8 1.14% -0.47% -2.46% 10.65% :-( nbody 0.12% -0.80% 8.28% 1.00% :-( json_dump_v2 0.25% -0.05% 5.56% 8.42% :-( normal_startup 2.00% -0.20% -6.05% 3.20% :-( ssbench 0.16% -0.19% 1.14% 1.66% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Tue Dec 29 11:08:58 2015 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 29 Dec 2015 16:08:58 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy41ICgjMjU5NzMp?= Message-ID: <20151229160857.3373.90451@psf.io> https://hg.python.org/cpython/rev/c64e68d703cf changeset: 99715:c64e68d703cf parent: 99713:e04cd497aa41 parent: 99714:4fa8c0c69ee9 user: Benjamin Peterson date: Tue Dec 29 10:08:51 2015 -0600 summary: merge 3.5 (#25973) files: Lib/test/test_syntax.py | 8 ++++++++ Misc/NEWS | 3 +++ Python/symtable.c | 24 ++++++++++++++++-------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -416,6 +416,14 @@ ## ... ## SyntaxWarning: name 'x' is assigned to before nonlocal declaration + From https://bugs.python.org/issue25973 + >>> class A: + ... def f(self): + ... nonlocal __x + Traceback (most recent call last): + ... + SyntaxError: no binding for nonlocal '_A__x' found + This tests assignment-context; there was a bug in Python 2.5 where compiling a complex 'if' (one with 'elif') would fail to notice an invalid suite, diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #25973: Fix segfault when an invalid nonlocal statement binds a name + starting with two underscores. + - Issue #22995: Instances of extension types with a state that aren't subclasses of list or dict and haven't implemented any pickle-related methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__, diff --git a/Python/symtable.c b/Python/symtable.c --- a/Python/symtable.c +++ b/Python/symtable.c @@ -368,15 +368,20 @@ Py_ssize_t i; PyObject *data; assert(ste->ste_directives); - for (i = 0; ; i++) { + for (i = 0; i < PyList_GET_SIZE(ste->ste_directives); i++) { data = PyList_GET_ITEM(ste->ste_directives, i); assert(PyTuple_CheckExact(data)); - if (PyTuple_GET_ITEM(data, 0) == name) - break; + assert(PyUnicode_CheckExact(PyTuple_GET_ITEM(data, 0))); + if (PyUnicode_Compare(PyTuple_GET_ITEM(data, 0), name) == 0) { + PyErr_SyntaxLocationObject(ste->ste_table->st_filename, + PyLong_AsLong(PyTuple_GET_ITEM(data, 1)), + PyLong_AsLong(PyTuple_GET_ITEM(data, 2))); + + return 0; + } } - PyErr_SyntaxLocationObject(ste->ste_table->st_filename, - PyLong_AsLong(PyTuple_GET_ITEM(data, 1)), - PyLong_AsLong(PyTuple_GET_ITEM(data, 2))); + PyErr_SetString(PyExc_RuntimeError, + "BUG: internal directive bookkeeping broken"); return 0; } @@ -1115,14 +1120,17 @@ static int symtable_record_directive(struct symtable *st, identifier name, stmt_ty s) { - PyObject *data; + PyObject *data, *mangled; int res; if (!st->st_cur->ste_directives) { st->st_cur->ste_directives = PyList_New(0); if (!st->st_cur->ste_directives) return 0; } - data = Py_BuildValue("(Oii)", name, s->lineno, s->col_offset); + mangled = _Py_Mangle(st->st_private, name); + if (!mangled) + return 0; + data = Py_BuildValue("(Nii)", mangled, s->lineno, s->col_offset); if (!data) return 0; res = PyList_Append(st->st_cur->ste_directives, data); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 29 11:08:58 2015 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 29 Dec 2015 16:08:58 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_make_recording?= =?utf-8?q?_and_reporting_errors_and_nonlocal_and_global_directives_more?= Message-ID: <20151229160857.21233.73087@psf.io> https://hg.python.org/cpython/rev/4fa8c0c69ee9 changeset: 99714:4fa8c0c69ee9 branch: 3.5 parent: 99710:9f13322eba8e user: Benjamin Peterson date: Tue Dec 29 10:08:34 2015 -0600 summary: make recording and reporting errors and nonlocal and global directives more robust (closes #25973) files: Lib/test/test_syntax.py | 8 ++++++++ Misc/NEWS | 3 +++ Python/symtable.c | 24 ++++++++++++++++-------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -416,6 +416,14 @@ ## ... ## SyntaxWarning: name 'x' is assigned to before nonlocal declaration + From https://bugs.python.org/issue25973 + >>> class A: + ... def f(self): + ... nonlocal __x + Traceback (most recent call last): + ... + SyntaxError: no binding for nonlocal '_A__x' found + This tests assignment-context; there was a bug in Python 2.5 where compiling a complex 'if' (one with 'elif') would fail to notice an invalid suite, diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #25973: Fix segfault when an invalid nonlocal statement binds a name + starting with two underscores. + - Issue #22995: Instances of extension types with a state that aren't subclasses of list or dict and haven't implemented any pickle-related methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__, diff --git a/Python/symtable.c b/Python/symtable.c --- a/Python/symtable.c +++ b/Python/symtable.c @@ -368,15 +368,20 @@ Py_ssize_t i; PyObject *data; assert(ste->ste_directives); - for (i = 0; ; i++) { + for (i = 0; i < PyList_GET_SIZE(ste->ste_directives); i++) { data = PyList_GET_ITEM(ste->ste_directives, i); assert(PyTuple_CheckExact(data)); - if (PyTuple_GET_ITEM(data, 0) == name) - break; + assert(PyUnicode_CheckExact(PyTuple_GET_ITEM(data, 0))); + if (PyUnicode_Compare(PyTuple_GET_ITEM(data, 0), name) == 0) { + PyErr_SyntaxLocationObject(ste->ste_table->st_filename, + PyLong_AsLong(PyTuple_GET_ITEM(data, 1)), + PyLong_AsLong(PyTuple_GET_ITEM(data, 2))); + + return 0; + } } - PyErr_SyntaxLocationObject(ste->ste_table->st_filename, - PyLong_AsLong(PyTuple_GET_ITEM(data, 1)), - PyLong_AsLong(PyTuple_GET_ITEM(data, 2))); + PyErr_SetString(PyExc_RuntimeError, + "BUG: internal directive bookkeeping broken"); return 0; } @@ -1115,14 +1120,17 @@ static int symtable_record_directive(struct symtable *st, identifier name, stmt_ty s) { - PyObject *data; + PyObject *data, *mangled; int res; if (!st->st_cur->ste_directives) { st->st_cur->ste_directives = PyList_New(0); if (!st->st_cur->ste_directives) return 0; } - data = Py_BuildValue("(Oii)", name, s->lineno, s->col_offset); + mangled = _Py_Mangle(st->st_private, name); + if (!mangled) + return 0; + data = Py_BuildValue("(Nii)", mangled, s->lineno, s->col_offset); if (!data) return 0; res = PyList_Append(st->st_cur->ste_directives, data); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 29 15:34:44 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Dec 2015 20:34:44 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325971=3A_Optimize?= =?utf-8?q?d_creating_Fractions_from_floats_by_2_times_and_from?= Message-ID: <20151229203444.21237.76838@psf.io> https://hg.python.org/cpython/rev/284026a8af9e changeset: 99716:284026a8af9e user: Serhiy Storchaka date: Tue Dec 29 22:34:23 2015 +0200 summary: Issue #25971: Optimized creating Fractions from floats by 2 times and from Decimals by 3 times. Unified error messages in float.as_integer_ratio(), Decimal.as_integer_ratio(), and Fraction constructors. files: Lib/_pydecimal.py | 6 +--- Lib/fractions.py | 32 +++---------------------- Lib/test/test_fractions.py | 14 +++++----- Misc/NEWS | 3 ++ Objects/floatobject.c | 12 ++++---- 5 files changed, 22 insertions(+), 45 deletions(-) diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -1026,11 +1026,9 @@ """ if self._is_special: if self.is_nan(): - raise ValueError("Cannot pass NaN " - "to decimal.as_integer_ratio.") + raise ValueError("cannot convert NaN to integer ratio") else: - raise OverflowError("Cannot pass infinity " - "to decimal.as_integer_ratio.") + raise OverflowError("cannot convert Infinity to integer ratio") if not self: return 0, 1 diff --git a/Lib/fractions.py b/Lib/fractions.py --- a/Lib/fractions.py +++ b/Lib/fractions.py @@ -125,17 +125,9 @@ self._denominator = numerator.denominator return self - elif isinstance(numerator, float): - # Exact conversion from float - value = Fraction.from_float(numerator) - self._numerator = value._numerator - self._denominator = value._denominator - return self - - elif isinstance(numerator, Decimal): - value = Fraction.from_decimal(numerator) - self._numerator = value._numerator - self._denominator = value._denominator + elif isinstance(numerator, (float, Decimal)): + # Exact conversion + self._numerator, self._denominator = numerator.as_integer_ratio() return self elif isinstance(numerator, str): @@ -210,10 +202,6 @@ elif not isinstance(f, float): raise TypeError("%s.from_float() only takes floats, not %r (%s)" % (cls.__name__, f, type(f).__name__)) - if math.isnan(f): - raise ValueError("Cannot convert %r to %s." % (f, cls.__name__)) - if math.isinf(f): - raise OverflowError("Cannot convert %r to %s." % (f, cls.__name__)) return cls(*f.as_integer_ratio()) @classmethod @@ -226,19 +214,7 @@ raise TypeError( "%s.from_decimal() only takes Decimals, not %r (%s)" % (cls.__name__, dec, type(dec).__name__)) - if dec.is_infinite(): - raise OverflowError( - "Cannot convert %s to %s." % (dec, cls.__name__)) - if dec.is_nan(): - raise ValueError("Cannot convert %s to %s." % (dec, cls.__name__)) - sign, digits, exp = dec.as_tuple() - digits = int(''.join(map(str, digits))) - if sign: - digits = -digits - if exp >= 0: - return cls(digits * 10 ** exp) - else: - return cls(digits, 10 ** -exp) + return cls(*dec.as_integer_ratio()) def limit_denominator(self, max_denominator=1000000): """Closest Fraction to self with denominator at most max_denominator. diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py --- a/Lib/test/test_fractions.py +++ b/Lib/test/test_fractions.py @@ -263,13 +263,13 @@ nan = inf - inf # bug 16469: error types should be consistent with float -> int self.assertRaisesMessage( - OverflowError, "Cannot convert inf to Fraction.", + OverflowError, "cannot convert Infinity to integer ratio", F.from_float, inf) self.assertRaisesMessage( - OverflowError, "Cannot convert -inf to Fraction.", + OverflowError, "cannot convert Infinity to integer ratio", F.from_float, -inf) self.assertRaisesMessage( - ValueError, "Cannot convert nan to Fraction.", + ValueError, "cannot convert NaN to integer ratio", F.from_float, nan) def testFromDecimal(self): @@ -284,16 +284,16 @@ # bug 16469: error types should be consistent with decimal -> int self.assertRaisesMessage( - OverflowError, "Cannot convert Infinity to Fraction.", + OverflowError, "cannot convert Infinity to integer ratio", F.from_decimal, Decimal("inf")) self.assertRaisesMessage( - OverflowError, "Cannot convert -Infinity to Fraction.", + OverflowError, "cannot convert Infinity to integer ratio", F.from_decimal, Decimal("-inf")) self.assertRaisesMessage( - ValueError, "Cannot convert NaN to Fraction.", + ValueError, "cannot convert NaN to integer ratio", F.from_decimal, Decimal("nan")) self.assertRaisesMessage( - ValueError, "Cannot convert sNaN to Fraction.", + ValueError, "cannot convert NaN to integer ratio", F.from_decimal, Decimal("snan")) def testLimitDenominator(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -126,6 +126,9 @@ Library ------- +- Issue #25971: Optimized creating Fractions from floats by 2 times and from + Decimals by 3 times. + - Issue #25802: Document as deprecated the remaining implementations of importlib.abc.Loader.load_module(). diff --git a/Objects/floatobject.c b/Objects/floatobject.c --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1466,14 +1466,14 @@ CONVERT_TO_DOUBLE(v, self); if (Py_IS_INFINITY(self)) { - PyErr_SetString(PyExc_OverflowError, - "Cannot pass infinity to float.as_integer_ratio."); - return NULL; + PyErr_SetString(PyExc_OverflowError, + "cannot convert Infinity to integer ratio"); + return NULL; } if (Py_IS_NAN(self)) { - PyErr_SetString(PyExc_ValueError, - "Cannot pass NaN to float.as_integer_ratio."); - return NULL; + PyErr_SetString(PyExc_ValueError, + "cannot convert NaN to integer ratio"); + return NULL; } PyFPE_START_PROTECT("as_integer_ratio", goto error); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 29 16:39:00 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 29 Dec 2015 21:39:00 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Clean_up_float=2Eas=5Finte?= =?utf-8?b?Z2VyX3JhdGlvKCku?= Message-ID: <20151229213859.8285.34676@psf.io> https://hg.python.org/cpython/rev/3292b4862627 changeset: 99717:3292b4862627 user: Serhiy Storchaka date: Tue Dec 29 22:55:48 2015 +0200 summary: Clean up float.as_integer_ratio(). files: Objects/floatobject.c | 36 +++++++++++++----------------- 1 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Objects/floatobject.c b/Objects/floatobject.c --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1451,18 +1451,12 @@ int exponent; int i; - PyObject *prev; PyObject *py_exponent = NULL; PyObject *numerator = NULL; PyObject *denominator = NULL; PyObject *result_pair = NULL; PyNumberMethods *long_methods = PyLong_Type.tp_as_number; -#define INPLACE_UPDATE(obj, call) \ - prev = obj; \ - obj = call; \ - Py_DECREF(prev); \ - CONVERT_TO_DOUBLE(v, self); if (Py_IS_INFINITY(self)) { @@ -1489,29 +1483,31 @@ to be truncated by PyLong_FromDouble(). */ numerator = PyLong_FromDouble(float_part); - if (numerator == NULL) goto error; + if (numerator == NULL) + goto error; + denominator = PyLong_FromLong(1); + if (denominator == NULL) + goto error; + py_exponent = PyLong_FromLong(Py_ABS(exponent)); + if (py_exponent == NULL) + goto error; /* fold in 2**exponent */ - denominator = PyLong_FromLong(1); - py_exponent = PyLong_FromLong(labs((long)exponent)); - if (py_exponent == NULL) goto error; - INPLACE_UPDATE(py_exponent, - long_methods->nb_lshift(denominator, py_exponent)); - if (py_exponent == NULL) goto error; if (exponent > 0) { - INPLACE_UPDATE(numerator, - long_methods->nb_multiply(numerator, py_exponent)); - if (numerator == NULL) goto error; + Py_SETREF(numerator, + long_methods->nb_lshift(numerator, py_exponent)); + if (numerator == NULL) + goto error; } else { - Py_DECREF(denominator); - denominator = py_exponent; - py_exponent = NULL; + Py_SETREF(denominator, + long_methods->nb_lshift(denominator, py_exponent)); + if (denominator == NULL) + goto error; } result_pair = PyTuple_Pack(2, numerator, denominator); -#undef INPLACE_UPDATE error: Py_XDECREF(py_exponent); Py_XDECREF(denominator); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 29 18:42:47 2015 From: python-checkins at python.org (berker.peksag) Date: Tue, 29 Dec 2015 23:42:47 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1OTc3?= =?utf-8?q?=3A_Fix_typos_in_Lib/tokenize=2Epy?= Message-ID: <20151229234247.105580.36854@psf.io> https://hg.python.org/cpython/rev/9057e3857119 changeset: 99718:9057e3857119 branch: 3.5 parent: 99714:4fa8c0c69ee9 user: Berker Peksag date: Wed Dec 30 01:41:58 2015 +0200 summary: Issue #25977: Fix typos in Lib/tokenize.py Patch by John Walker. files: Lib/tokenize.py | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/tokenize.py b/Lib/tokenize.py --- a/Lib/tokenize.py +++ b/Lib/tokenize.py @@ -328,8 +328,8 @@ Round-trip invariant for full input: Untokenized source will match input source exactly - Round-trip invariant for limited intput: - # Output bytes will tokenize the back to the input + Round-trip invariant for limited input: + # Output bytes will tokenize back to the input t1 = [tok[:2] for tok in tokenize(f.readline)] newcode = untokenize(t1) readline = BytesIO(newcode).readline @@ -465,10 +465,10 @@ def tokenize(readline): """ - The tokenize() generator requires one argment, readline, which + The tokenize() generator requires one argument, readline, which must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function - should return one line of input as bytes. Alternately, readline + should return one line of input as bytes. Alternatively, readline can be a callable function terminating with StopIteration: readline = open(myfile, 'rb').__next__ # Example of alternate readline -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Dec 29 18:42:47 2015 From: python-checkins at python.org (berker.peksag) Date: Tue, 29 Dec 2015 23:42:47 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325977=3A_Fix_typos_in_Lib/tokenize=2Epy?= Message-ID: <20151229234247.21244.46549@psf.io> https://hg.python.org/cpython/rev/5b43d7984a63 changeset: 99719:5b43d7984a63 parent: 99717:3292b4862627 parent: 99718:9057e3857119 user: Berker Peksag date: Wed Dec 30 01:42:43 2015 +0200 summary: Issue #25977: Fix typos in Lib/tokenize.py Patch by John Walker. files: Lib/tokenize.py | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/tokenize.py b/Lib/tokenize.py --- a/Lib/tokenize.py +++ b/Lib/tokenize.py @@ -325,8 +325,8 @@ Round-trip invariant for full input: Untokenized source will match input source exactly - Round-trip invariant for limited intput: - # Output bytes will tokenize the back to the input + Round-trip invariant for limited input: + # Output bytes will tokenize back to the input t1 = [tok[:2] for tok in tokenize(f.readline)] newcode = untokenize(t1) readline = BytesIO(newcode).readline @@ -462,10 +462,10 @@ def tokenize(readline): """ - The tokenize() generator requires one argment, readline, which + The tokenize() generator requires one argument, readline, which must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function - should return one line of input as bytes. Alternately, readline + should return one line of input as bytes. Alternatively, readline can be a callable function terminating with StopIteration: readline = open(myfile, 'rb').__next__ # Example of alternate readline @@ -645,7 +645,7 @@ # we switch to longer prefixes, this needs to be # adjusted. # Note that initial == token[:1]. - # Also note that single quote checking must come afer + # Also note that single quote checking must come after # triple quote checking (above). elif (initial in single_quoted or token[:2] in single_quoted or -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 30 02:29:32 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 30 Dec 2015 07:29:32 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Fixed_formatting_comman-line_usage_message=2E?= Message-ID: <20151230072932.21394.17564@psf.io> https://hg.python.org/cpython/rev/0155eefa8162 changeset: 99721:0155eefa8162 parent: 99719:5b43d7984a63 parent: 99720:4679b841e5ef user: Serhiy Storchaka date: Wed Dec 30 09:28:48 2015 +0200 summary: Fixed formatting comman-line usage message. files: Modules/main.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/main.c b/Modules/main.c --- a/Modules/main.c +++ b/Modules/main.c @@ -85,11 +85,11 @@ arg ...: arguments passed to program in sys.argv[1:]\n\n\ Other environment variables:\n\ PYTHONSTARTUP: file executed on interactive startup (no default)\n\ -PYTHONPATH : '%c'-separated list of directories prefixed to the\n\ +PYTHONPATH : '%lc'-separated list of directories prefixed to the\n\ default module search path. The result is sys.path.\n\ "; static const char usage_5[] = -"PYTHONHOME : alternate directory (or %c).\n" +"PYTHONHOME : alternate directory (or %lc).\n" " The default module search path uses %s.\n" "PYTHONCASEOK : ignore case in 'import' statements (Windows).\n" "PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n" @@ -114,8 +114,8 @@ fputs(usage_1, f); fputs(usage_2, f); fputs(usage_3, f); - fprintf(f, usage_4, DELIM); - fprintf(f, usage_5, DELIM, PYTHONHOMEHELP); + fprintf(f, usage_4, (wint_t)DELIM); + fprintf(f, usage_5, (wint_t)DELIM, PYTHONHOMEHELP); fputs(usage_6, f); } return exitcode; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 30 02:29:32 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 30 Dec 2015 07:29:32 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fixed_formatti?= =?utf-8?q?ng_comman-line_usage_message=2E?= Message-ID: <20151230072932.126325.10196@psf.io> https://hg.python.org/cpython/rev/4679b841e5ef changeset: 99720:4679b841e5ef branch: 3.5 parent: 99718:9057e3857119 user: Serhiy Storchaka date: Wed Dec 30 09:28:19 2015 +0200 summary: Fixed formatting comman-line usage message. files: Modules/main.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/main.c b/Modules/main.c --- a/Modules/main.c +++ b/Modules/main.c @@ -85,11 +85,11 @@ arg ...: arguments passed to program in sys.argv[1:]\n\n\ Other environment variables:\n\ PYTHONSTARTUP: file executed on interactive startup (no default)\n\ -PYTHONPATH : '%c'-separated list of directories prefixed to the\n\ +PYTHONPATH : '%lc'-separated list of directories prefixed to the\n\ default module search path. The result is sys.path.\n\ "; static char *usage_5 = -"PYTHONHOME : alternate directory (or %c).\n" +"PYTHONHOME : alternate directory (or %lc).\n" " The default module search path uses %s.\n" "PYTHONCASEOK : ignore case in 'import' statements (Windows).\n" "PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n" @@ -114,8 +114,8 @@ fputs(usage_1, f); fputs(usage_2, f); fputs(usage_3, f); - fprintf(f, usage_4, DELIM); - fprintf(f, usage_5, DELIM, PYTHONHOMEHELP); + fprintf(f, usage_4, (wint_t)DELIM); + fprintf(f, usage_5, (wint_t)DELIM, PYTHONHOMEHELP); fputs(usage_6, f); } return exitcode; -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Wed Dec 30 03:44:22 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 30 Dec 2015 08:44:22 +0000 Subject: [Python-checkins] Daily reference leaks (5b43d7984a63): sum=4 Message-ID: <20151230084422.9638.80659@psf.io> results for 5b43d7984a63 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/refloge6mSqW', '--timeout', '7200'] From lp_benchmark_robot at intel.com Wed Dec 30 09:04:21 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 30 Dec 2015 14:04:21 +0000 Subject: [Python-checkins] Benchmark Results for Python Default 2015-12-30 Message-ID: <47ddd9f7-f246-4ce3-8ed5-4c59eef9bf70@irsmsx153.ger.corp.intel.com> Results for project Python default, build date 2015-12-30 03:06:04 +0000 commit: 5b43d7984a63a5b3eb6139187bc7da3a3dc1b011 previous commit: ab0e60a3636881dc9ffaba761c44e941cfd96477 revision date: 2015-12-29 23:42:43 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781e89a309d03b60a1f75f8499250e6 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.27% 0.37% 11.16% 15.17% :-| pybench 0.06% 0.38% -1.42% 5.24% :-( regex_v8 2.65% -0.15% -5.15% 5.60% :-| nbody 0.07% 0.17% -0.15% 9.00% :-| json_dump_v2 0.13% 0.41% -1.56% 11.65% :-( normal_startup 0.96% -0.46% -2.09% 5.26% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) Note: Benchmark results are measured in seconds. Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Wed Dec 30 09:05:27 2015 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 30 Dec 2015 14:05:27 +0000 Subject: [Python-checkins] Benchmark Results for Python 2.7 2015-12-30 Message-ID: No new revisions. Here are the previous results: Results for project Python 2.7, build date 2015-12-30 03:57:04 +0000 commit: 11670e4be1a92d0a36ea6d8d2039a500f2f577ec previous commit: deda5b5160d264b4ed74d03bf57396410df3b780 revision date: 2015-12-27 13:41:58 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dcf821daade360741e00714667653f from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.38% -0.37% 3.92% 3.85% :-) pybench 0.14% 0.26% 6.28% 4.59% :-( regex_v8 1.14% -0.30% -2.46% 10.65% :-) nbody 0.12% -0.32% 8.28% 1.00% :-) json_dump_v2 0.25% 1.02% 5.56% 8.42% :-( normal_startup 2.00% -0.31% -6.05% 3.20% :-| ssbench 0.16% 0.18% 1.14% 1.66% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Wed Dec 30 13:45:29 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 30 Dec 2015 18:45:29 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzIyOTk1?= =?utf-8?q?=3A_Instances_of_extension_types_with_a_state_that_aren=27t?= Message-ID: <20151230184527.70443.67419@psf.io> https://hg.python.org/cpython/rev/92172d7372dd changeset: 99722:92172d7372dd branch: 2.7 parent: 99688:11670e4be1a9 user: Serhiy Storchaka date: Wed Dec 30 20:43:29 2015 +0200 summary: Issue #22995: Instances of extension types with a state that aren't subclasses of list or dict and haven't implemented any pickle-related methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__, or __getstate__), can no longer be pickled. Including memoryview. files: Lib/test/test_buffer.py | 13 +++++++ Lib/test/test_csv.py | 13 +++++++ Lib/test/test_memoryview.py | 15 +++++++++ Misc/NEWS | 5 +++ Objects/typeobject.c | 41 ++++++++++++++++++++---- 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -4,6 +4,8 @@ """ +import copy +import pickle import sys import unittest from test import test_support @@ -35,6 +37,17 @@ buf = buffer(data, sys.maxsize, sys.maxsize) self.assertEqual(buf[:4096], "") + def test_copy(self): + buf = buffer(b'abc') + with self.assertRaises(TypeError): + copy.copy(buf) + + def test_pickle(self): + buf = buffer(b'abc') + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + with self.assertRaises(TypeError): + pickle.dumps(buf, proto) + def test_main(): with test_support.check_py3k_warnings(("buffer.. not supported", diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -2,6 +2,7 @@ # Copyright (C) 2001,2002 Python Software Foundation # csv package unit tests +import copy import sys import os import unittest @@ -10,6 +11,7 @@ import csv import gc import io +import pickle from test import test_support class Test_Csv(unittest.TestCase): @@ -466,6 +468,17 @@ self.assertRaises(TypeError, csv.reader, [], quoting = -1) self.assertRaises(TypeError, csv.reader, [], quoting = 100) + def test_copy(self): + for name in csv.list_dialects(): + dialect = csv.get_dialect(name) + self.assertRaises(TypeError, copy.copy, dialect) + + def test_pickle(self): + for name in csv.list_dialects(): + dialect = csv.get_dialect(name) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + self.assertRaises(TypeError, pickle.dumps, dialect, proto) + class TestCsvBase(unittest.TestCase): def readerAssertEqual(self, input, expected_result): fd, name = tempfile.mkstemp() diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py --- a/Lib/test/test_memoryview.py +++ b/Lib/test/test_memoryview.py @@ -10,6 +10,8 @@ import array from test import test_support import io +import copy +import pickle class AbstractMemoryTests: @@ -354,6 +356,19 @@ #pass +class OtherTest(unittest.TestCase): + def test_copy(self): + m = memoryview(b'abc') + with self.assertRaises(TypeError): + copy.copy(m) + + def test_pickle(self): + m = memoryview(b'abc') + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + with self.assertRaises(TypeError): + pickle.dumps(m, proto) + + def test_main(): test_support.run_unittest(__name__) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,11 @@ Core and Builtins ----------------- +- Issue #22995: Instances of extension types with a state that aren't + subclasses of list or dict and haven't implemented any pickle-related + methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__, + or __getstate__), can no longer be pickled. Including memoryview. + - Issue #20440: Massive replacing unsafe attribute setting code with special macro Py_SETREF. diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3207,6 +3207,7 @@ PyObject *slots = NULL, *listitems = NULL, *dictitems = NULL; PyObject *copyreg = NULL, *newobj = NULL, *res = NULL; Py_ssize_t i, n; + int required_state = 0; cls = PyObject_GetAttrString(obj, "__class__"); if (cls == NULL) @@ -3214,7 +3215,7 @@ if (PyType_Check(cls) && ((PyTypeObject *)cls)->tp_new == NULL) { PyErr_Format(PyExc_TypeError, - "can't pickle %s objects", + "can't pickle %.200s objects", ((PyTypeObject *)cls)->tp_name); return NULL; } @@ -3223,7 +3224,9 @@ if (getnewargs != NULL) { args = PyObject_CallObject(getnewargs, NULL); Py_DECREF(getnewargs); - if (args != NULL && !PyTuple_Check(args)) { + if (args == NULL) + goto end; + if (!PyTuple_Check(args)) { PyErr_Format(PyExc_TypeError, "__getnewargs__ should return a tuple, " "not '%.200s'", Py_TYPE(args)->tp_name); @@ -3232,10 +3235,8 @@ } else { PyErr_Clear(); - args = PyTuple_New(0); - } - if (args == NULL) - goto end; + required_state = !PyList_Check(obj) && !PyDict_Check(obj); + } getstate = PyObject_GetAttrString(obj, "__getstate__"); if (getstate != NULL) { @@ -3246,6 +3247,14 @@ } else { PyErr_Clear(); + + if (required_state && obj->ob_type->tp_itemsize) { + PyErr_Format(PyExc_TypeError, + "can't pickle %.200s objects", + Py_TYPE(obj)->tp_name); + goto end; + } + state = PyObject_GetAttrString(obj, "__dict__"); if (state == NULL) { PyErr_Clear(); @@ -3255,8 +3264,24 @@ names = slotnames(cls); if (names == NULL) goto end; + assert(names == Py_None || PyList_Check(names)); + if (required_state) { + Py_ssize_t basicsize = PyBaseObject_Type.tp_basicsize; + if (obj->ob_type->tp_dictoffset) + basicsize += sizeof(PyObject *); + if (obj->ob_type->tp_weaklistoffset) + basicsize += sizeof(PyObject *); + if (names != Py_None) + basicsize += sizeof(PyObject *) * Py_SIZE(names); + if (obj->ob_type->tp_basicsize > basicsize) { + PyErr_Format(PyExc_TypeError, + "can't pickle %.200s objects", + Py_TYPE(obj)->tp_name); + goto end; + } + } + if (names != Py_None) { - assert(PyList_Check(names)); slots = PyDict_New(); if (slots == NULL) goto end; @@ -3318,7 +3343,7 @@ if (newobj == NULL) goto end; - n = PyTuple_GET_SIZE(args); + n = args ? PyTuple_GET_SIZE(args) : 0; args2 = PyTuple_New(n+1); if (args2 == NULL) goto end; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 30 14:00:58 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 30 Dec 2015 19:00:58 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Make_catched_e?= =?utf-8?q?xceptions_more_specific_and_correct_a_comment=2E?= Message-ID: <20151230190057.70431.93293@psf.io> https://hg.python.org/cpython/rev/32806d3f9bd2 changeset: 99723:32806d3f9bd2 branch: 2.7 user: Serhiy Storchaka date: Wed Dec 30 20:59:32 2015 +0200 summary: Make catched exceptions more specific and correct a comment. files: Lib/test/pickletester.py | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -1373,15 +1373,16 @@ # 5th item is not an iterator return dict, (), None, None, [] - # Protocol 0 is less strict and also accept iterables. + # Protocol 0 in Python implementation is less strict and also accepts + # iterables. for proto in protocols: try: self.dumps(C(), proto) - except (AttributeError, pickle.PickleError, cPickle.PickleError): + except (AttributeError, pickle.PicklingError, cPickle.PicklingError): pass try: self.dumps(D(), proto) - except (AttributeError, pickle.PickleError, cPickle.PickleError): + except (AttributeError, pickle.PicklingError, cPickle.PicklingError): pass def test_many_puts_and_gets(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 30 14:00:58 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 30 Dec 2015 19:00:58 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Make_catched_e?= =?utf-8?q?xception_more_specific_and_correct_a_comment=2E?= Message-ID: <20151230190058.105560.9260@psf.io> https://hg.python.org/cpython/rev/b35212d6d4ce changeset: 99724:b35212d6d4ce branch: 3.5 parent: 99720:4679b841e5ef user: Serhiy Storchaka date: Wed Dec 30 21:00:08 2015 +0200 summary: Make catched exception more specific and correct a comment. files: Lib/test/pickletester.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -1944,15 +1944,15 @@ # 5th item is not an iterator return dict, (), None, None, [] - # Protocol 0 is less strict and also accept iterables. + # Python implementation is less strict and also accepts iterables. for proto in protocols: try: self.dumps(C(), proto) - except (pickle.PickleError): + except pickle.PicklingError: pass try: self.dumps(D(), proto) - except (pickle.PickleError): + except pickle.PicklingError: pass def test_many_puts_and_gets(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 30 14:00:58 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 30 Dec 2015 19:00:58 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Make_catched_exception_more_specific_and_correct_a_comme?= =?utf-8?b?bnQu?= Message-ID: <20151230190058.21239.32969@psf.io> https://hg.python.org/cpython/rev/965f0bddac6d changeset: 99725:965f0bddac6d parent: 99721:0155eefa8162 parent: 99724:b35212d6d4ce user: Serhiy Storchaka date: Wed Dec 30 21:00:29 2015 +0200 summary: Make catched exception more specific and correct a comment. files: Lib/test/pickletester.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -1942,15 +1942,15 @@ # 5th item is not an iterator return dict, (), None, None, [] - # Protocol 0 is less strict and also accept iterables. + # Python implementation is less strict and also accepts iterables. for proto in protocols: try: self.dumps(C(), proto) - except (pickle.PickleError): + except pickle.PicklingError: pass try: self.dumps(D(), proto) - except (pickle.PickleError): + except pickle.PicklingError: pass def test_many_puts_and_gets(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 30 14:42:15 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 30 Dec 2015 19:42:15 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1OTYx?= =?utf-8?q?=3A_Disallowed_null_characters_in_the_type_name=2E?= Message-ID: <20151230194215.8275.55907@psf.io> https://hg.python.org/cpython/rev/29cc6b2f9d28 changeset: 99726:29cc6b2f9d28 branch: 2.7 parent: 99723:32806d3f9bd2 user: Serhiy Storchaka date: Wed Dec 30 21:39:21 2015 +0200 summary: Issue #25961: Disallowed null characters in the type name. files: Misc/NEWS | 2 ++ Objects/typeobject.c | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #25961: Disallowed null characters in the type name. + - Issue #22995: Instances of extension types with a state that aren't subclasses of list or dict and haven't implemented any pickle-related methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__, diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -244,8 +244,8 @@ } if (strlen(PyString_AS_STRING(value)) != (size_t)PyString_GET_SIZE(value)) { - PyErr_Format(PyExc_ValueError, - "__name__ must not contain null bytes"); + PyErr_SetString(PyExc_ValueError, + "type name must not contain null characters"); return -1; } @@ -2071,8 +2071,8 @@ PyTypeObject *type, *base, *tmptype, *winner; PyHeapTypeObject *et; PyMemberDef *mp; - Py_ssize_t i, nbases, nslots, slotoffset, add_dict, add_weak; - int j, may_add_dict, may_add_weak; + Py_ssize_t i, nbases, nslots, slotoffset; + int j, may_add_dict, may_add_weak, add_dict, add_weak; assert(args != NULL && PyTuple_Check(args)); assert(kwds == NULL || PyDict_Check(kwds)); @@ -2342,6 +2342,13 @@ type->tp_as_mapping = &et->as_mapping; type->tp_as_buffer = &et->as_buffer; type->tp_name = PyString_AS_STRING(name); + if (!type->tp_name) + goto error; + if (strlen(type->tp_name) != (size_t)PyString_GET_SIZE(name)) { + PyErr_SetString(PyExc_ValueError, + "type name must not contain null characters"); + goto error; + } /* Set tp_base and tp_bases */ type->tp_bases = bases; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 30 14:42:15 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 30 Dec 2015 19:42:15 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1OTYx?= =?utf-8?q?=3A_Disallowed_null_characters_in_the_type_name=2E?= Message-ID: <20151230194215.77237.962@psf.io> https://hg.python.org/cpython/rev/d2417971c934 changeset: 99727:d2417971c934 branch: 3.5 parent: 99724:b35212d6d4ce user: Serhiy Storchaka date: Wed Dec 30 21:40:49 2015 +0200 summary: Issue #25961: Disallowed null characters in the type name. Simplified testing for null characters in __name__ setter. files: Misc/NEWS | 2 + Objects/typeobject.c | 49 ++++++++++++------------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #25961: Disallowed null characters in the type name. + - Issue #25973: Fix segfault when an invalid nonlocal statement binds a name starting with two underscores. diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -401,9 +401,8 @@ static int type_set_name(PyTypeObject *type, PyObject *value, void *context) { - PyHeapTypeObject* et; - char *tp_name; - PyObject *tmp; + const char *tp_name; + Py_ssize_t name_size; if (!check_set_special_type_attr(type, value, "__name__")) return -1; @@ -414,33 +413,18 @@ return -1; } - /* Check absence of null characters */ - tmp = PyUnicode_FromStringAndSize("\0", 1); - if (tmp == NULL) - return -1; - if (PyUnicode_Contains(value, tmp) != 0) { - Py_DECREF(tmp); - PyErr_Format(PyExc_ValueError, - "__name__ must not contain null bytes"); - return -1; - } - Py_DECREF(tmp); - - tp_name = _PyUnicode_AsString(value); + tp_name = PyUnicode_AsUTF8AndSize(value, &name_size); if (tp_name == NULL) return -1; - - et = (PyHeapTypeObject*)type; - + if (strlen(tp_name) != (size_t)name_size) { + PyErr_SetString(PyExc_ValueError, + "type name must not contain null characters"); + return -1; + } + + type->tp_name = tp_name; Py_INCREF(value); - - /* Wait until et is a sane state before Py_DECREF'ing the old et->ht_name - value. (Bug #16447.) */ - tmp = et->ht_name; - et->ht_name = value; - - type->tp_name = tp_name; - Py_DECREF(tmp); + Py_SETREF(((PyHeapTypeObject*)type)->ht_name, value); return 0; } @@ -2285,8 +2269,8 @@ PyTypeObject *type = NULL, *base, *tmptype, *winner; PyHeapTypeObject *et; PyMemberDef *mp; - Py_ssize_t i, nbases, nslots, slotoffset, add_dict, add_weak; - int j, may_add_dict, may_add_weak; + Py_ssize_t i, nbases, nslots, slotoffset, name_size; + int j, may_add_dict, may_add_weak, add_dict, add_weak; _Py_IDENTIFIER(__qualname__); _Py_IDENTIFIER(__slots__); @@ -2509,9 +2493,14 @@ type->tp_as_sequence = &et->as_sequence; type->tp_as_mapping = &et->as_mapping; type->tp_as_buffer = &et->as_buffer; - type->tp_name = _PyUnicode_AsString(name); + type->tp_name = PyUnicode_AsUTF8AndSize(name, &name_size); if (!type->tp_name) goto error; + if (strlen(type->tp_name) != (size_t)name_size) { + PyErr_SetString(PyExc_ValueError, + "type name must not contain null characters"); + goto error; + } /* Set tp_base and tp_bases */ type->tp_bases = bases; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Dec 30 14:42:16 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 30 Dec 2015 19:42:16 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325961=3A_Disallowed_null_characters_in_the_type?= =?utf-8?q?_name=2E?= Message-ID: <20151230194215.126315.44118@psf.io> https://hg.python.org/cpython/rev/1ab7bcd4e176 changeset: 99728:1ab7bcd4e176 parent: 99725:965f0bddac6d parent: 99727:d2417971c934 user: Serhiy Storchaka date: Wed Dec 30 21:41:53 2015 +0200 summary: Issue #25961: Disallowed null characters in the type name. Simplified testing for null characters in __name__ setter. files: Misc/NEWS | 2 + Objects/typeobject.c | 34 +++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #25961: Disallowed null characters in the type name. + - Issue #25973: Fix segfault when an invalid nonlocal statement binds a name starting with two underscores. diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -401,8 +401,8 @@ static int type_set_name(PyTypeObject *type, PyObject *value, void *context) { - char *tp_name; - PyObject *tmp; + const char *tp_name; + Py_ssize_t name_size; if (!check_set_special_type_attr(type, value, "__name__")) return -1; @@ -413,21 +413,14 @@ return -1; } - /* Check absence of null characters */ - tmp = PyUnicode_FromStringAndSize("\0", 1); - if (tmp == NULL) - return -1; - if (PyUnicode_Contains(value, tmp) != 0) { - Py_DECREF(tmp); - PyErr_Format(PyExc_ValueError, - "__name__ must not contain null bytes"); - return -1; - } - Py_DECREF(tmp); - - tp_name = _PyUnicode_AsString(value); + tp_name = PyUnicode_AsUTF8AndSize(value, &name_size); if (tp_name == NULL) return -1; + if (strlen(tp_name) != (size_t)name_size) { + PyErr_SetString(PyExc_ValueError, + "type name must not contain null characters"); + return -1; + } type->tp_name = tp_name; Py_INCREF(value); @@ -2284,8 +2277,8 @@ PyTypeObject *type = NULL, *base, *tmptype, *winner; PyHeapTypeObject *et; PyMemberDef *mp; - Py_ssize_t i, nbases, nslots, slotoffset, add_dict, add_weak; - int j, may_add_dict, may_add_weak; + Py_ssize_t i, nbases, nslots, slotoffset, name_size; + int j, may_add_dict, may_add_weak, add_dict, add_weak; _Py_IDENTIFIER(__qualname__); _Py_IDENTIFIER(__slots__); @@ -2508,9 +2501,14 @@ type->tp_as_sequence = &et->as_sequence; type->tp_as_mapping = &et->as_mapping; type->tp_as_buffer = &et->as_buffer; - type->tp_name = _PyUnicode_AsString(name); + type->tp_name = PyUnicode_AsUTF8AndSize(name, &name_size); if (!type->tp_name) goto error; + if (strlen(type->tp_name) != (size_t)name_size) { + PyErr_SetString(PyExc_ValueError, + "type name must not contain null characters"); + goto error; + } /* Set tp_base and tp_bases */ type->tp_bases = bases; -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Thu Dec 31 03:46:39 2015 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 31 Dec 2015 08:46:39 +0000 Subject: [Python-checkins] Daily reference leaks (1ab7bcd4e176): sum=2 Message-ID: <20151231084639.21227.17181@psf.io> results for 1ab7bcd4e176 on branch "default" -------------------------------------------- test_collections leaked [0, 0, -2] references, sum=-2 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogexQhcM', '--timeout', '7200'] From python-checkins at python.org Thu Dec 31 05:08:13 2015 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 31 Dec 2015 10:08:13 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1OTYx?= =?utf-8?q?=3A_Fixed_compilation_error_and_a_leak_in_type_constructor=2E?= Message-ID: <20151231100813.21227.29879@psf.io> https://hg.python.org/cpython/rev/57fea6f75ac2 changeset: 99729:57fea6f75ac2 branch: 2.7 parent: 99726:29cc6b2f9d28 user: Serhiy Storchaka date: Thu Dec 31 12:03:14 2015 +0200 summary: Issue #25961: Fixed compilation error and a leak in type constructor. files: Objects/typeobject.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2342,12 +2342,17 @@ type->tp_as_mapping = &et->as_mapping; type->tp_as_buffer = &et->as_buffer; type->tp_name = PyString_AS_STRING(name); - if (!type->tp_name) - goto error; + if (!type->tp_name) { + Py_DECREF(bases); + Py_DECREF(type); + return NULL; + } if (strlen(type->tp_name) != (size_t)PyString_GET_SIZE(name)) { PyErr_SetString(PyExc_ValueError, "type name must not contain null characters"); - goto error; + Py_DECREF(bases); + Py_DECREF(type); + return NULL; } /* Set tp_base and tp_bases */ @@ -2369,8 +2374,10 @@ tmp = PyDict_GetItemString(tmp, "__name__"); if (tmp != NULL) { if (PyDict_SetItemString(dict, "__module__", - tmp) < 0) + tmp) < 0) { + Py_DECREF(type); return NULL; + } } } } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Dec 31 10:03:29 2015 From: python-checkins at python.org (senthil.kumaran) Date: Thu, 31 Dec 2015 15:03:29 +0000 Subject: [Python-checkins] =?utf-8?q?test=3A_test_commit_to_hgtest_repo=2E?= Message-ID: <20151231150324.124854.74446@psf.io> https://hg.python.org/test/rev/09a6bd753c5d changeset: 228:09a6bd753c5d user: Senthil Kumaran date: Thu Dec 31 07:03:18 2015 -0800 summary: test commit to hgtest repo. testing old rsa key. files: quote | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/quote b/quote --- a/quote +++ b/quote @@ -9,3 +9,7 @@ "Little else matters than to write good code." -- Karl Lehenbauer + +There are only two kinds of languages: the ones people complain about and the ones nobody uses +? Bjarne Stroustrup + -- Repository URL: https://hg.python.org/test